changeset 1048:52ca66a9a69c

comments
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 23 Apr 2009 10:37:05 +0200
parents 5de270a9a02b
children a913df1621ac
files src/css.cc src/css.hh
diffstat 2 files changed, 56 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.cc	Wed Apr 22 13:23:56 2009 -0400
+++ b/src/css.cc	Thu Apr 23 10:37:05 2009 +0200
@@ -30,6 +30,9 @@
          getRef (i)->free ();
 }
 
+/**
+ * \brief Set property to a given name and type.
+ */
 void CssPropertyList::set (CssPropertyName name, CssValueType type,
                            CssPropertyValue value) {
    CssProperty *prop;
@@ -53,6 +56,9 @@
    prop->value = value;
 }
 
+/**
+ * \brief Merge properties into argument property list.
+ */
 void CssPropertyList::apply (CssPropertyList *props) {
    for (int i = 0; i < size (); i++)
       props->set ((CssPropertyName) getRef (i)->name,
@@ -84,6 +90,9 @@
    delete selectorList;
 }
 
+/**
+ * \brief Return whether selector matches at a given node in the document tree.
+ */
 bool CssSelector::match (Doctree *docTree, const DoctreeNode *node) {
    CssSimpleSelector *sel;
    Combinator comb = CHILD;
@@ -141,6 +150,12 @@
    cs->selector = new CssSimpleSelector ();
 }
 
+/**
+ * \brief Return the specificity of the selector.
+ *
+ * The specificity of a CSS selector is defined in
+ * http://www.w3.org/TR/CSS21/cascade.html#specificity
+ */
 int CssSelector::specificity () {
    int spec = 0;
 
@@ -185,6 +200,10 @@
    dFree (pseudo);
 }
 
+/**
+ * \brief Return whether simple selector matches at a given node of
+ *        the document tree.
+ */
 bool CssSimpleSelector::match (const DoctreeNode *n) {
    if (element != ELEMENT_ANY && element != n->element)
       return false;
@@ -200,6 +219,11 @@
    return true;
 }
 
+/**
+ * \brief Return the specificity of the simple selector.
+ *
+ * The result is used in CssSelector::specificity ().
+ */
 int CssSimpleSelector::specificity () {
    int spec = 0;
 
@@ -247,7 +271,8 @@
 }
 
 /*
- * \brief insert rule with increasing specificity
+ * \brief Insert rule with increasing specificity.
+ *
  * If two rules have the same specificity, the one that was added later
  * will be added behind the others.
  * This gives later added rules more weight.
@@ -281,6 +306,12 @@
    delete anyTable;
 }
 
+/**
+ * \brief Insert a rule into CssStyleSheet.
+ *
+ * To improve matching performance the rules are organized into
+ * rule lists based on the topmost simple selector of their selector.
+ */
 void CssStyleSheet::addRule (CssRule *rule) {
    CssSimpleSelector *top = rule->selector->top ();
    RuleList *ruleList = NULL;
@@ -318,6 +349,12 @@
    }
 }
 
+/**
+ * \brief Apply a stylesheet to a property list.
+ *
+ * The properties are set as defined by the rules in the stylesheet that
+ * match at the given node in the document tree.
+ */ 
 void CssStyleSheet::apply (CssPropertyList *props,
                            Doctree *docTree, const DoctreeNode *node) {
    RuleList *ruleList[4];
@@ -405,6 +442,15 @@
          delete sheet[o];
 }
 
+/**
+ * \brief Apply a CSS context to a property list.
+ *
+ * The stylesheets in the context are applied one after the other
+ * in the ordering defined by CSS 2.1.
+ * Stylesheets that are applied later can overwrite properties set
+ * by previous stylesheets.
+ * This allows e.g. user styles to overwrite author styles.
+ */
 void CssContext::apply (CssPropertyList *props, Doctree *docTree,
          CssPropertyList *tagStyle, CssPropertyList *nonCssHints) {
    const DoctreeNode *node = docTree->top ();
@@ -444,6 +490,12 @@
    }
 }
 
+/**
+ * \brief Create the user agent style.
+ *
+ * The user agent style defines how dillo renders HTML in the absence of 
+ * author or user styles.
+ */
 void CssContext::buildUserAgentStyle () {
    const char *cssBuf =
      "body  {background-color: #dcd1ba; font-family: sans-serif; color: black;"
--- a/src/css.hh	Wed Apr 22 13:23:56 2009 -0400
+++ b/src/css.hh	Thu Apr 23 10:37:05 2009 +0200
@@ -283,6 +283,7 @@
 
 /**
  * \brief CSS selector class.
+ *
  * \todo Implement missing selector options.
  */
 class CssSelector {
@@ -320,6 +321,7 @@
 
 /**
  * \brief A CssSelector CssPropertyList pair.
+ *
  *  The CssPropertyList is applied if the CssSelector matches.
  */
 class CssRule {
@@ -341,6 +343,7 @@
 
 /**
  * \brief A list of CssRules.
+ *
  * In apply () all matching rules are applied.
  */
 class CssStyleSheet {