Title: [98492] trunk
Revision
98492
Author
dglaz...@chromium.org
Date
2011-10-26 09:58:44 -0700 (Wed, 26 Oct 2011)

Log Message

REGRESSION (r94887): Scrolling the HTML spec is more jerky now than it was (regression)
https://bugs.webkit.org/show_bug.cgi?id=70857

Source/WebCore:

Revert r94887, because it regressed performance.

Rubber-stamped by Antti Koivisto.

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::canShareStyleWithElement):
(WebCore::parentStylePreventsSharing):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkSelector):
* dom/Element.cpp:
(WebCore::Element::recalcStyle):
(WebCore::checkForSiblingStyleChanges):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::RenderStyle):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::childrenAffectedByDirectAdjacentRules):
(WebCore::InheritedFlags::setChildrenAffectedByDirectAdjacentRules):

LayoutTests:

Rubber-stamped by Antti Koivisto.

* fast/css/adjacent-sibling-selector-expected.txt: Removed.
* fast/css/adjacent-sibling-selector.html: Removed.

Modified Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (98491 => 98492)


--- trunk/LayoutTests/ChangeLog	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/LayoutTests/ChangeLog	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1,3 +1,13 @@
+2011-10-26  Dimitri Glazkov  <dglaz...@chromium.org>
+
+        REGRESSION (r94887): Scrolling the HTML spec is more jerky now than it was (regression)
+        https://bugs.webkit.org/show_bug.cgi?id=70857
+
+        Rubber-stamped by Antti Koivisto.
+
+        * fast/css/adjacent-sibling-selector-expected.txt: Removed.
+        * fast/css/adjacent-sibling-selector.html: Removed.
+
 2011-10-26  Balazs Kelemen  <kbal...@webkit.org>
 
         inspector/cookie-parser.html is a flaky crash

Deleted: trunk/LayoutTests/fast/css/adjacent-sibling-selector-expected.txt (98491 => 98492)


--- trunk/LayoutTests/fast/css/adjacent-sibling-selector-expected.txt	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/LayoutTests/fast/css/adjacent-sibling-selector-expected.txt	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1,3 +0,0 @@
-Test for https://bugs.webkit.org/show_bug.cgi?id=66887
-Test Result:
-PASSED

Deleted: trunk/LayoutTests/fast/css/adjacent-sibling-selector.html (98491 => 98492)


--- trunk/LayoutTests/fast/css/adjacent-sibling-selector.html	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/LayoutTests/fast/css/adjacent-sibling-selector.html	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1,46 +0,0 @@
-<!doctype html>
-<html>
-<head>
-    <style type="text/css">
-		div[test=before] + div + span {
-            color: red;
-            display: block;
-        }
-		div[test=before] + div + span + span {
-            display: none;
-        }
-		div[test=after] + div + span {
-            display: none;
-        }
-		div[test=after] + div + span + span {
-            color: green;
-            display: block;
-        }
-    </style>
-</head>
-<body  _onload_="startTest();">
-    <div id="div1" test="before">Test for <a href=""
-    <div id="div2">Test Result:</div>
-    <span>FAILED</span>
-    <span>PASSED</span>
-    <script>
-        function change() {
-            var element = document.getElementById('div1');
-            element.attributes.test.value = "after";
-            if (window.layoutTestController) {
-                layoutTestController.notifyDone();
-            }
-        }
-        function startTest() {
-            if (window.layoutTestController) {
-                layoutTestController.dumpAsText();
-                layoutTestController.waitUntilDone();
-            }
-            // Trigger an attribute change after all load processing is done. Doing the change
-            // here immediately does not exhibit the problem.
-            setTimeout("change();", 0);
-        }
-    </script>
-</body>
-</html>
-

Modified: trunk/Source/WebCore/ChangeLog (98491 => 98492)


--- trunk/Source/WebCore/ChangeLog	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/ChangeLog	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1,3 +1,26 @@
+2011-10-26  Dimitri Glazkov  <dglaz...@chromium.org>
+
+        REGRESSION (r94887): Scrolling the HTML spec is more jerky now than it was (regression)
+        https://bugs.webkit.org/show_bug.cgi?id=70857
+
+        Revert r94887, because it regressed performance.
+
+        Rubber-stamped by Antti Koivisto.
+
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::canShareStyleWithElement):
+        (WebCore::parentStylePreventsSharing):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkSelector):
+        * dom/Element.cpp:
+        (WebCore::Element::recalcStyle):
+        (WebCore::checkForSiblingStyleChanges):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::RenderStyle):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::childrenAffectedByDirectAdjacentRules):
+        (WebCore::InheritedFlags::setChildrenAffectedByDirectAdjacentRules):
+
 2011-10-26  Alexander Pavlov  <apav...@chromium.org>
 
         Web Inspector: Need workaround for the red crossed circle in the status bar not bringing up the console when clicked

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (98491 => 98492)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1018,9 +1018,6 @@
     if (style->transitions() || style->animations())
         return false;
 
-    if (style->affectedByDirectAdjacentRules())
-        return false;
-
 #if USE(ACCELERATED_COMPOSITING)
     // Turn off style sharing for elements that can gain layers for reasons outside of the style system.
     // See comments in RenderObject::setStyle().
@@ -1060,7 +1057,8 @@
 {
     return parentStyle->childrenAffectedByPositionalRules()
         || parentStyle->childrenAffectedByFirstChildRules()
-        || parentStyle->childrenAffectedByLastChildRules();
+        || parentStyle->childrenAffectedByLastChildRules() 
+        || parentStyle->childrenAffectedByDirectAdjacentRules();
 }
 
 RenderStyle* CSSStyleSelector::locateSharedStyle()

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (98491 => 98492)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2011-10-26 16:58:44 UTC (rev 98492)
@@ -483,10 +483,10 @@
         }
     case CSSSelector::DirectAdjacent:
         {
-            if (!m_isCollectingRulesOnly) {
-                RenderStyle* currentStyle = elementStyle ? elementStyle : e->renderStyle();
-                if (currentStyle)
-                    currentStyle->setAffectedByDirectAdjacentRules();
+            if (!m_isCollectingRulesOnly && e->parentNode() && e->parentNode()->isElementNode()) {
+                RenderStyle* parentStyle = elementStyle ? elementParentStyle : e->parentNode()->renderStyle();
+                if (parentStyle)
+                    parentStyle->setChildrenAffectedByDirectAdjacentRules();
             }
             Node* n = e->previousSibling();
             while (n && !n->isElementNode())

Modified: trunk/Source/WebCore/dom/Element.cpp (98491 => 98492)


--- trunk/Source/WebCore/dom/Element.cpp	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/dom/Element.cpp	2011-10-26 16:58:44 UTC (rev 98492)
@@ -1092,6 +1092,7 @@
     // Ref currentStyle in case it would otherwise be deleted when setRenderStyle() is called.
     RefPtr<RenderStyle> currentStyle(renderStyle());
     bool hasParentStyle = parentNodeForRenderingAndStyle() ? static_cast<bool>(parentNodeForRenderingAndStyle()->renderStyle()) : false;
+    bool hasDirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByDirectAdjacentRules();
     bool hasIndirectAdjacentRules = currentStyle && currentStyle->childrenAffectedByForwardPositionalRules();
 
     if ((change > NoChange || needsStyleRecalc())) {
@@ -1133,8 +1134,8 @@
                 newStyle->setChildrenAffectedByFirstChildRules();
             if (currentStyle->childrenAffectedByLastChildRules())
                 newStyle->setChildrenAffectedByLastChildRules();
-            if (currentStyle->affectedByDirectAdjacentRules())
-                newStyle->setAffectedByDirectAdjacentRules();
+            if (currentStyle->childrenAffectedByDirectAdjacentRules())
+                newStyle->setChildrenAffectedByDirectAdjacentRules();
         }
 
         if (ch != NoChange || pseudoStyleCacheIsInvalid(currentStyle.get(), newStyle.get()) || (change == Force && renderer() && renderer()->requiresForcedStyleRecalcPropagation())) {
@@ -1164,7 +1165,7 @@
     // FIXME: This check is good enough for :hover + foo, but it is not good enough for :hover + foo + bar.
     // For now we will just worry about the common case, since it's a lot trickier to get the second case right
     // without doing way too much re-resolution.
-    bool previousSiblingHadDirectAdjacentRules = false;
+    bool forceCheckOfNextElementSibling = false;
     bool forceCheckOfAnyElementSibling = false;
     for (Node *n = firstChild(); n; n = n->nextSibling()) {
         if (n->isTextNode()) {
@@ -1176,14 +1177,13 @@
             continue;
         Element* element = static_cast<Element*>(n);
         bool childRulesChanged = element->needsStyleRecalc() && element->styleChangeType() == FullStyleChange;
-        bool childAffectedByDirectAdjacentRules = element->renderStyle() ? element->renderStyle()->affectedByDirectAdjacentRules() : previousSiblingHadDirectAdjacentRules;
-        if (childAffectedByDirectAdjacentRules || forceCheckOfAnyElementSibling)
+        if ((forceCheckOfNextElementSibling || forceCheckOfAnyElementSibling))
             element->setNeedsStyleRecalc();
         if (change >= Inherit || element->childNeedsStyleRecalc() || element->needsStyleRecalc()) {
             parentPusher.push();
             element->recalcStyle(change);
         }
-        previousSiblingHadDirectAdjacentRules = childAffectedByDirectAdjacentRules;
+        forceCheckOfNextElementSibling = childRulesChanged && hasDirectAdjacentRules;
         forceCheckOfAnyElementSibling = forceCheckOfAnyElementSibling || (childRulesChanged && hasIndirectAdjacentRules);
     }
     // FIXME: This does not care about sibling combinators. Will be necessary in XBL2 world.
@@ -1370,6 +1370,17 @@
             newLastChild->setNeedsStyleRecalc();
     }
 
+    // The + selector.  We need to invalidate the first element following the insertion point.  It is the only possible element
+    // that could be affected by this DOM change.
+    if (style->childrenAffectedByDirectAdjacentRules() && afterChange) {
+        Node* firstElementAfterInsertion = 0;
+        for (firstElementAfterInsertion = afterChange;
+             firstElementAfterInsertion && !firstElementAfterInsertion->isElementNode();
+             firstElementAfterInsertion = firstElementAfterInsertion->nextSibling()) {};
+        if (firstElementAfterInsertion && firstElementAfterInsertion->attached())
+            firstElementAfterInsertion->setNeedsStyleRecalc();
+    }
+
     // Forward positional selectors include the ~ selector, nth-child, nth-of-type, first-of-type and only-of-type.
     // Backward positional selectors include nth-last-child, nth-last-of-type, last-of-type and only-of-type.
     // We have to invalidate everything following the insertion point in the forward case, and everything before the insertion point in the

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (98491 => 98492)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2011-10-26 16:58:44 UTC (rev 98492)
@@ -80,11 +80,11 @@
     , m_emptyState(false)
     , m_childrenAffectedByFirstChildRules(false)
     , m_childrenAffectedByLastChildRules(false)
+    , m_childrenAffectedByDirectAdjacentRules(false)
     , m_childrenAffectedByForwardPositionalRules(false)
     , m_childrenAffectedByBackwardPositionalRules(false)
     , m_firstChildState(false)
     , m_lastChildState(false)
-    , m_affectedByDirectAdjacentRules(false)
     , m_childIndex(0)
     , m_box(defaultStyle()->m_box)
     , visual(defaultStyle()->visual)
@@ -109,11 +109,11 @@
     , m_emptyState(false)
     , m_childrenAffectedByFirstChildRules(false)
     , m_childrenAffectedByLastChildRules(false)
+    , m_childrenAffectedByDirectAdjacentRules(false)
     , m_childrenAffectedByForwardPositionalRules(false)
     , m_childrenAffectedByBackwardPositionalRules(false)
     , m_firstChildState(false)
     , m_lastChildState(false)
-    , m_affectedByDirectAdjacentRules(false)
     , m_childIndex(0)
 {
     setBitDefaults();
@@ -149,11 +149,11 @@
     , m_emptyState(false)
     , m_childrenAffectedByFirstChildRules(false)
     , m_childrenAffectedByLastChildRules(false)
+    , m_childrenAffectedByDirectAdjacentRules(false)
     , m_childrenAffectedByForwardPositionalRules(false)
     , m_childrenAffectedByBackwardPositionalRules(false)
     , m_firstChildState(false)
     , m_lastChildState(false)
-    , m_affectedByDirectAdjacentRules(false)
     , m_childIndex(0)
     , m_box(o.m_box)
     , visual(o.visual)

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (98491 => 98492)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-10-26 16:30:50 UTC (rev 98491)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-10-26 16:58:44 UTC (rev 98492)
@@ -138,11 +138,11 @@
     // *-child-of-type, we will just give up and re-evaluate whenever children change at all.
     bool m_childrenAffectedByFirstChildRules : 1;
     bool m_childrenAffectedByLastChildRules : 1;
+    bool m_childrenAffectedByDirectAdjacentRules : 1;
     bool m_childrenAffectedByForwardPositionalRules : 1;
     bool m_childrenAffectedByBackwardPositionalRules : 1;
     bool m_firstChildState : 1;
     bool m_lastChildState : 1;
-    bool m_affectedByDirectAdjacentRules : 1;
     unsigned m_childIndex : 21; // Plenty of bits to cache an index.
 
     // non-inherited attributes
@@ -1313,9 +1313,6 @@
     bool affectedByUncommonAttributeSelectors() const { return m_affectedByUncommonAttributeSelectors; }
     void setAffectedByUncommonAttributeSelectors() { m_affectedByUncommonAttributeSelectors = true; }
 
-    bool affectedByDirectAdjacentRules() const { return m_affectedByDirectAdjacentRules; }
-    void setAffectedByDirectAdjacentRules() { m_affectedByDirectAdjacentRules = true; }
-
     bool unique() const { return m_unique; }
     void setUnique() { m_unique = true; }
 
@@ -1328,6 +1325,8 @@
     void setChildrenAffectedByFirstChildRules() { m_childrenAffectedByFirstChildRules = true; }
     bool childrenAffectedByLastChildRules() const { return m_childrenAffectedByLastChildRules; }
     void setChildrenAffectedByLastChildRules() { m_childrenAffectedByLastChildRules = true; }
+    bool childrenAffectedByDirectAdjacentRules() const { return m_childrenAffectedByDirectAdjacentRules; }
+    void setChildrenAffectedByDirectAdjacentRules() { m_childrenAffectedByDirectAdjacentRules = true; }
     bool childrenAffectedByForwardPositionalRules() const { return m_childrenAffectedByForwardPositionalRules; }
     void setChildrenAffectedByForwardPositionalRules() { m_childrenAffectedByForwardPositionalRules = true; }
     bool childrenAffectedByBackwardPositionalRules() const { return m_childrenAffectedByBackwardPositionalRules; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to