Fix a bug in the iteration of locateCousinList and clean up the style sharing stats...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Oct 2004 01:43:59 +0000 (01:43 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Oct 2004 01:43:59 +0000 (01:43 +0000)
        Reviewed by NOBODY (OOPS!).

        * khtml/css/cssstyleselector.cpp:
        (khtml::CSSStyleSelector::locateCousinList):
        (khtml::CSSStyleSelector::elementsCanShareStyle):
        (khtml::CSSStyleSelector::locateSharedStyle):
        (khtml::CSSStyleSelector::styleForElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7778 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/css/cssstyleselector.cpp

index eef5378f6cb1fb823dd5c526956f3a4516a26d9e..758f7f9a04be02e5aa41517421dc43e8e68eef39 100644 (file)
@@ -1,3 +1,15 @@
+2004-10-05  David Hyatt  <hyatt@apple.com>
+
+       Fix a bug in the iteration of locateCousinList and clean up the style sharing stats code.
+
+        Reviewed by NOBODY (OOPS!).
+
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::locateCousinList):
+        (khtml::CSSStyleSelector::elementsCanShareStyle):
+        (khtml::CSSStyleSelector::locateSharedStyle):
+        (khtml::CSSStyleSelector::styleForElement):
+
 2004-10-05  Ken Kocienda  <kocienda@apple.com>
 
         Reviewed by Hyatt
index 3acc6ed5151df626791646370a61f3cb9507206d..3a27be8c200357b7e7460b55180ce7b40f7e4676 100644 (file)
@@ -529,25 +529,26 @@ const int siblingThreshold = 10;
 
 NodeImpl* CSSStyleSelector::locateCousinList(ElementImpl* parent)
 {
+    // FIXME: Investigate the difference between elementsCanShareStyle and a pointer compare of renderstyles.
     if (parent && parent->renderer() && !parent->inlineStyleDecl() && !parent->hasID()) {
         DOM::NodeImpl* n;
         for (n = parent->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
         int subcount = 0;
         while (n) {
-            if (n->renderer() && n->renderer()->style() == parent->renderer()->style())
+            if (n->renderer() && /*elementsCanShareStyle(static_cast<ElementImpl*>(n), parent)) //*/n->renderer()->style() == parent->renderer()->style())
                 return n->lastChild();
             if (subcount++ == siblingThreshold)
                 return 0;
-            for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
+            n = n->previousSibling(); //for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
         }
         if (!n && parent->parentNode() && parent->parentNode()->isElementNode())
             n = locateCousinList(static_cast<ElementImpl*>(parent->parentNode()));
         while (n) {
-            if (n->renderer() && n->renderer()->style() == parent->renderer()->style())
+            if (n->renderer() && /*elementsCanShareStyle(static_cast<ElementImpl*>(n), parent)) //*/n->renderer()->style() == parent->renderer()->style())
                 return n->lastChild();
             if (subcount++ == siblingThreshold)
                 return 0;
-            for (n = parent->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
+            for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
         }
     }
     return 0;
@@ -587,13 +588,8 @@ bool CSSStyleSelector::elementsCanShareStyle(ElementImpl* e1, ElementImpl* e2)
                     anchorsMatch = (pseudoState == e1->renderer()->style()->pseudoState());
                 }
                 
-                if (anchorsMatch) {
-#ifdef STYLE_SHARING_STATS
-                    fraction++; total++;
-                    printf("Sharing %d out of %d\n", fraction, total);
-#endif
+                if (anchorsMatch)
                     return true;
-                }
             }
         }
     }
@@ -624,10 +620,6 @@ RenderStyle* CSSStyleSelector::locateSharedStyle()
             for (n = n->previousSibling(); n && !n->isElementNode(); n = n->previousSibling());
         }        
     }
-#ifdef STYLE_SHARING_STATS
-    total++;
-    printf("Sharing %d out of %d\n", fraction, total);
-#endif
     return 0;
 }
 
@@ -645,6 +637,11 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     initElementAndPseudoState(e);
     if (allowSharing) {
         style = locateSharedStyle();
+#ifdef STYLE_SHARING_STATS
+        fraction += style != 0;
+        total++;
+        printf("Sharing %d out of %d\n", fraction, total);
+#endif
         if (style)
             return style;
     }