Title: [141093] trunk
Revision
141093
Author
[email protected]
Date
2013-01-29 03:36:30 -0800 (Tue, 29 Jan 2013)

Log Message

REGRESSION: ChildrenAffectedBy flags lost between siblings which have child elements sharing style
https://bugs.webkit.org/show_bug.cgi?id=105672

Reviewed by Andreas Kling.

Source/WebCore:

Change in how childrenAffectedBy bits were stored made it easier to trigger an issue where childrenAffectedBy bits
were not set due to sharing of styles between cousin elements.

This patch fixes the issue by not sharing styles from children with parents who prevent sharing.

Tests: fast/selectors/cousin-stylesharing-adjacent-selector.html
       fast/selectors/cousin-stylesharing-last-child-selector.html

* css/StyleResolver.cpp:
(WebCore::parentElementPreventsSharing):
(WebCore::StyleResolver::locateCousinList):
* dom/Element.cpp:
(WebCore::Element::hasFlagsSetDuringStylingOfChildren):
* dom/Element.h:
(Element):

LayoutTests:

Two test cases by Philippe Wittenbergh that triggers the issue.

* fast/selectors/cousin-stylesharing-adjacent-selector-expected.html: Added.
* fast/selectors/cousin-stylesharing-adjacent-selector.html: Added.
* fast/selectors/cousin-stylesharing-last-child-selector-expected.html: Added.
* fast/selectors/cousin-stylesharing-last-child-selector.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141092 => 141093)


--- trunk/LayoutTests/ChangeLog	2013-01-29 11:32:12 UTC (rev 141092)
+++ trunk/LayoutTests/ChangeLog	2013-01-29 11:36:30 UTC (rev 141093)
@@ -1,3 +1,17 @@
+2013-01-29  Allan Sandfeld Jensen  <[email protected]>
+
+        REGRESSION: ChildrenAffectedBy flags lost between siblings which have child elements sharing style
+        https://bugs.webkit.org/show_bug.cgi?id=105672
+
+        Reviewed by Andreas Kling.
+
+        Two test cases by Philippe Wittenbergh that triggers the issue.
+
+        * fast/selectors/cousin-stylesharing-adjacent-selector-expected.html: Added.
+        * fast/selectors/cousin-stylesharing-adjacent-selector.html: Added.
+        * fast/selectors/cousin-stylesharing-last-child-selector-expected.html: Added.
+        * fast/selectors/cousin-stylesharing-last-child-selector.html: Added.
+
 2013-01-29  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: [Regression] Search across all sources is broken.

Added: trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector-expected.html (0 => 141093)


--- trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector-expected.html	2013-01-29 11:36:30 UTC (rev 141093)
@@ -0,0 +1,52 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Bug #105672 - direct adjcent</title>
+<meta name="viewport" content="width=device-width">
+<style type="text/css">
+
+
+table {
+	font-size: 1em;
+	border-collapse: collapse;
+	border: 1px solid #777;
+	margin: 1em 5%;
+}
+th, td {
+	border: 1px solid #777;
+}
+
+td.lastcell { color: red;  background: yellow;}
+</style>
+
+
+</head>
+
+<body>
+
+<table>
+<tbody>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>cell other</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+</tbody>
+</table>
+
+<table>
+<tbody>
+	<tr>
+		<td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>cell other</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td>
+		<td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+</tbody>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector.html (0 => 141093)


--- trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/cousin-stylesharing-adjacent-selector.html	2013-01-29 11:36:30 UTC (rev 141093)
@@ -0,0 +1,52 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Bug #105672 - direct adjcent</title>
+<meta name="viewport" content="width=device-width">
+<style type="text/css">
+
+
+table {
+	font-size: 1em;
+	border-collapse: collapse;
+	border: 1px solid #777;
+	margin: 1em 5%;
+}
+th, td {
+	border: 1px solid #777;
+}
+
+td:first-child+td+td { color: red;  background: yellow;}
+</style>
+
+
+</head>
+
+<body>
+
+<table>
+<tbody>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>cell other</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+</tbody>
+</table>
+
+<table>
+<tbody>
+	<tr>
+		<td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>cell other</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td>
+		<td>other cell</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td>more cell</td></tr>
+</tbody>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector-expected.html (0 => 141093)


--- trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector-expected.html	2013-01-29 11:36:30 UTC (rev 141093)
@@ -0,0 +1,51 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Bug #105672 - last child</title>
+<meta name="viewport" content="width=device-width">
+<style type="text/css">
+
+
+table {
+	font-size: 1em;
+	border-collapse: collapse;
+	border: 1px solid #777;
+	margin: 1em 5%;
+}
+th, td {
+	border: 1px solid #777;
+}
+
+td.lastcell { color: red; }
+</style>
+
+
+</head>
+
+<body>
+
+<table>
+<tbody>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>cell other</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+</tbody>
+</table>
+
+<table>
+<tbody>
+	<tr>
+		<td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>cell other</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td class=lastcell>more cell</td></tr>
+</tbody>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector.html (0 => 141093)


--- trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector.html	                        (rev 0)
+++ trunk/LayoutTests/fast/selectors/cousin-stylesharing-last-child-selector.html	2013-01-29 11:36:30 UTC (rev 141093)
@@ -0,0 +1,51 @@
+<!doctype html>
+<html lang="en">
+<head>
+<meta charset="utf-8">
+<title>Bug #105672 - last child</title>
+<meta name="viewport" content="width=device-width">
+<style type="text/css">
+
+
+table {
+	font-size: 1em;
+	border-collapse: collapse;
+	border: 1px solid #777;
+	margin: 1em 5%;
+}
+th, td {
+	border: 1px solid #777;
+}
+
+td:last-child { color: red; }
+</style>
+
+
+</head>
+
+<body>
+
+<table>
+<tbody>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>cell other</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr><td>cell</td><td>other cell</td><td>more cell</td></tr>
+</tbody>
+</table>
+
+<table>
+<tbody>
+	<tr>
+		<td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>cell other</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td>more cell</td></tr>
+	<tr>
+		<td>cell</td><td>other cell</td><td>more cell</td></tr>
+</tbody>
+</table>
+
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (141092 => 141093)


--- trunk/Source/WebCore/ChangeLog	2013-01-29 11:32:12 UTC (rev 141092)
+++ trunk/Source/WebCore/ChangeLog	2013-01-29 11:36:30 UTC (rev 141093)
@@ -1,3 +1,26 @@
+2013-01-29  Allan Sandfeld Jensen  <[email protected]>
+
+        REGRESSION: ChildrenAffectedBy flags lost between siblings which have child elements sharing style
+        https://bugs.webkit.org/show_bug.cgi?id=105672
+
+        Reviewed by Andreas Kling.
+
+        Change in how childrenAffectedBy bits were stored made it easier to trigger an issue where childrenAffectedBy bits
+        were not set due to sharing of styles between cousin elements.
+
+        This patch fixes the issue by not sharing styles from children with parents who prevent sharing.
+
+        Tests: fast/selectors/cousin-stylesharing-adjacent-selector.html
+               fast/selectors/cousin-stylesharing-last-child-selector.html
+
+        * css/StyleResolver.cpp:
+        (WebCore::parentElementPreventsSharing):
+        (WebCore::StyleResolver::locateCousinList):
+        * dom/Element.cpp:
+        (WebCore::Element::hasFlagsSetDuringStylingOfChildren):
+        * dom/Element.h:
+        (Element):
+
 2013-01-29  Vsevolod Vlasov  <[email protected]>
 
         Web Inspector: [Regression] Search across all sources is broken.

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (141092 => 141093)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-29 11:32:12 UTC (rev 141092)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2013-01-29 11:36:30 UTC (rev 141093)
@@ -1024,6 +1024,13 @@
 static const unsigned cStyleSearchThreshold = 10;
 static const unsigned cStyleSearchLevelThreshold = 10;
 
+static inline bool parentElementPreventsSharing(const Element* parentElement)
+{
+    if (!parentElement)
+        return false;
+    return parentElement->hasFlagsSetDuringStylingOfChildren();
+}
+
 Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCount) const
 {
     if (visitedNodeCount >= cStyleSearchThreshold * cStyleSearchLevelThreshold)
@@ -1053,7 +1060,8 @@
     while (thisCousin) {
         while (currentNode) {
             ++subcount;
-            if (currentNode->renderStyle() == parentStyle && currentNode->lastChild()) {
+            if (currentNode->renderStyle() == parentStyle && currentNode->lastChild()
+                && currentNode->isElementNode() && !parentElementPreventsSharing(toElement(currentNode))) {
                 // Adjust for unused reserved tries.
                 visitedNodeCount -= cStyleSearchThreshold - subcount;
                 return currentNode->lastChild();
@@ -1286,16 +1294,6 @@
     return static_cast<StyledElement*>(node);
 }
 
-static inline bool parentElementPreventsSharing(const Element* parentElement)
-{
-    if (!parentElement)
-        return false;
-    return parentElement->childrenAffectedByPositionalRules()
-        || parentElement->childrenAffectedByFirstChildRules()
-        || parentElement->childrenAffectedByLastChildRules()
-        || parentElement->childrenAffectedByDirectAdjacentRules();
-}
-
 RenderStyle* StyleResolver::locateSharedStyle()
 {
     if (!m_styledElement || !m_parentStyle)

Modified: trunk/Source/WebCore/dom/Element.cpp (141092 => 141093)


--- trunk/Source/WebCore/dom/Element.cpp	2013-01-29 11:32:12 UTC (rev 141092)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-01-29 11:36:30 UTC (rev 141093)
@@ -2066,6 +2066,20 @@
     rareData->setChildIndex(index);
 }
 
+bool Element::hasFlagsSetDuringStylingOfChildren() const
+{
+    if (!hasRareData())
+        return false;
+    return rareDataChildrenAffectedByHover()
+        || rareDataChildrenAffectedByActive()
+        || rareDataChildrenAffectedByDrag()
+        || rareDataChildrenAffectedByFirstChildRules()
+        || rareDataChildrenAffectedByLastChildRules()
+        || rareDataChildrenAffectedByDirectAdjacentRules()
+        || rareDataChildrenAffectedByForwardPositionalRules()
+        || rareDataChildrenAffectedByBackwardPositionalRules();
+}
+
 bool Element::rareDataStyleAffectedByEmpty() const
 {
     ASSERT(hasRareData());

Modified: trunk/Source/WebCore/dom/Element.h (141092 => 141093)


--- trunk/Source/WebCore/dom/Element.h	2013-01-29 11:32:12 UTC (rev 141092)
+++ trunk/Source/WebCore/dom/Element.h	2013-01-29 11:36:30 UTC (rev 141093)
@@ -317,6 +317,8 @@
     bool childrenAffectedByBackwardPositionalRules() const { return hasRareData() && rareDataChildrenAffectedByBackwardPositionalRules(); }
     unsigned childIndex() const { return hasRareData() ? rareDataChildIndex() : 0; }
 
+    bool hasFlagsSetDuringStylingOfChildren() const;
+
     void setStyleAffectedByEmpty();
     void setChildrenAffectedByHover(bool);
     void setChildrenAffectedByActive(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to