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

Unified Diff: Source/core/css/resolver/StyleResolver.cpp

Issue 16629006: Revert 151996 "Avoid N^2 walk placing renderers when building th..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Update to head Created 7 years, 6 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/core/css/resolver/StyleResolver.h ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/resolver/StyleResolver.cpp
diff --git a/Source/core/css/resolver/StyleResolver.cpp b/Source/core/css/resolver/StyleResolver.cpp
index e312bb2ad25a14d6f7e56d1118f0c6429b164c2d..ad1f061161689da39ec088da606e557dba8c8d3f 100644
--- a/Source/core/css/resolver/StyleResolver.cpp
+++ b/Source/core/css/resolver/StyleResolver.cpp
@@ -560,10 +560,10 @@ void StyleResolver::matchAllRules(ElementRuleCollector& collector, bool matchAut
collector.matchedResult().isCacheable = false;
}
-inline void StyleResolver::initElement(Element* e, int childIndex)
+inline void StyleResolver::initElement(Element* e)
{
if (m_state.element() != e) {
- m_state.initElement(e, childIndex);
+ m_state.initElement(e);
if (e && e == e->document()->documentElement()) {
e->document()->setDirectionSetOnDocumentElement(false);
e->document()->setWritingModeSetOnDocumentElement(false);
@@ -600,7 +600,7 @@ Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCoun
RenderStyle* parentStyle = p->renderStyle();
unsigned subcount = 0;
Node* thisCousin = p;
- Node* currentNode = p->nextSibling();
+ Node* currentNode = p->previousSibling();
// Reserve the tries for this level. This effectively makes sure that the algorithm
// will never go deeper than cStyleSearchLevelThreshold levels into recursion.
@@ -618,7 +618,7 @@ Node* StyleResolver::locateCousinList(Element* parent, unsigned& visitedNodeCoun
}
if (subcount >= cStyleSearchThreshold)
return 0;
- currentNode = currentNode->nextSibling();
+ currentNode = currentNode->previousSibling();
}
currentNode = locateCousinList(thisCousin->parentElement(), visitedNodeCount);
thisCousin = currentNode;
@@ -814,7 +814,7 @@ bool StyleResolver::canShareStyleWithElement(StyledElement* element) const
inline StyledElement* StyleResolver::findSiblingForStyleSharing(Node* node, unsigned& count) const
{
- for (; node; node = node->nextSibling()) {
+ for (; node; node = node->previousSibling()) {
if (!node->isStyledElement())
continue;
if (canShareStyleWithElement(static_cast<StyledElement*>(node)))
@@ -859,11 +859,11 @@ RenderStyle* StyleResolver::locateSharedStyle()
// FIXME: This shouldn't be a member variable. The style sharing code could be factored out of StyleResolver.
state.setElementAffectedByClassRules(state.element() && state.element()->hasClass() && classNamesAffectedByRules(state.element()->classNames()));
- // Check next siblings and their cousins.
+ // Check previous siblings and their cousins.
unsigned count = 0;
unsigned visitedNodeCount = 0;
StyledElement* shareElement = 0;
- Node* cousinList = state.styledElement()->nextSibling();
+ Node* cousinList = state.styledElement()->previousSibling();
while (cousinList) {
shareElement = findSiblingForStyleSharing(cousinList, count);
if (shareElement)
@@ -1078,8 +1078,8 @@ static inline bool isAtShadowBoundary(const Element* element)
return parentNode && parentNode->isShadowRoot();
}
-PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent, StyleSharingBehavior sharingBehavior,
- RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling, int childIndex)
+PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent,
+ StyleSharingBehavior sharingBehavior, RuleMatchingBehavior matchingBehavior, RenderRegion* regionForStyling)
{
// Once an element has a renderer, we don't try to destroy it, since otherwise the renderer
// will vanish if a style recalc happens during loading.
@@ -1094,7 +1094,7 @@ PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS
}
StyleResolverState& state = m_state;
- initElement(element, childIndex);
+ initElement(element);
state.initForStyleResolve(document(), element, defaultParent, regionForStyling);
if (sharingBehavior == AllowStyleSharing && !state.distributedToInsertionPoint()) {
RenderStyle* sharedStyle = locateSharedStyle();
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | Source/core/css/resolver/StyleResolverState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698