Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Unified Diff: Source/WebCore/dom/Element.cpp

Issue 8390051: Merge 98492 - REGRESSION (r94887): Scrolling the HTML spec is more jerky now than it was (regress... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/912/
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebCore/css/SelectorChecker.cpp ('k') | Source/WebCore/rendering/style/RenderStyle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebCore/dom/Element.cpp
===================================================================
--- Source/WebCore/dom/Element.cpp (revision 98492)
+++ Source/WebCore/dom/Element.cpp (working copy)
@@ -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
« no previous file with comments | « Source/WebCore/css/SelectorChecker.cpp ('k') | Source/WebCore/rendering/style/RenderStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698