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

Side by Side Diff: third_party/WebKit/Source/core/dom/Element.cpp

Issue 2727233005: Remove calls to styleForLayoutObject() in LayoutTreeBuilder::style() (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Peter Kelly (pmk@post.com) 4 * (C) 2001 Peter Kelly (pmk@post.com)
5 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * (C) 2001 Dirk Mueller (mueller@kde.org)
6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 * (C) 2007 David Smith (catfish.man@gmail.com)
7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. 7 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * (C) 2007 Eric Seidel (eric@webkit.org) 9 * (C) 2007 Eric Seidel (eric@webkit.org)
10 * 10 *
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 if (ElementAnimations* elementAnimations = 1732 if (ElementAnimations* elementAnimations =
1733 elementRareData()->elementAnimations()) { 1733 elementRareData()->elementAnimations()) {
1734 elementAnimations->cssAnimations().cancel(); 1734 elementAnimations->cssAnimations().cancel();
1735 elementAnimations->setAnimationStyleChange(false); 1735 elementAnimations->setAnimationStyleChange(false);
1736 } 1736 }
1737 } 1737 }
1738 1738
1739 SelectorFilterParentScope filterScope(*this); 1739 SelectorFilterParentScope filterScope(*this);
1740 StyleSharingDepthScope sharingScope(*this); 1740 StyleSharingDepthScope sharingScope(*this);
1741 1741
1742 clearNeedsReattachLayoutTree();
1742 createPseudoElementIfNeeded(PseudoIdBefore); 1743 createPseudoElementIfNeeded(PseudoIdBefore);
1743 1744
1744 // When a shadow root exists, it does the work of attaching the children. 1745 // When a shadow root exists, it does the work of attaching the children.
1745 if (ElementShadow* shadow = this->shadow()) 1746 if (ElementShadow* shadow = this->shadow())
1746 shadow->attach(context); 1747 shadow->attach(context);
1747 1748
1748 ContainerNode::attachLayoutTree(context); 1749 ContainerNode::attachLayoutTree(context);
1749 1750
1750 createPseudoElementIfNeeded(PseudoIdAfter); 1751 createPseudoElementIfNeeded(PseudoIdAfter);
1751 createPseudoElementIfNeeded(PseudoIdBackdrop); 1752 createPseudoElementIfNeeded(PseudoIdBackdrop);
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2014 2015
2015 StyleRecalcChange localChange = 2016 StyleRecalcChange localChange =
2016 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); 2017 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get());
2017 if (localChange == NoChange) { 2018 if (localChange == NoChange) {
2018 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 2019 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
2019 } else { 2020 } else {
2020 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); 2021 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1);
2021 } 2022 }
2022 2023
2023 if (localChange == Reattach) { 2024 if (localChange == Reattach) {
2025 // This mimicks Element::recalcStyleForReattach except it also stores the
2026 // nextTextSibling information.
2024 StyleReattachData styleReattachData; 2027 StyleReattachData styleReattachData;
2025 styleReattachData.computedStyle = std::move(newStyle); 2028 styleReattachData.computedStyle = std::move(newStyle);
2026 styleReattachData.nextTextSibling = nextTextSibling; 2029 styleReattachData.nextTextSibling = nextTextSibling;
2027 document().addStyleReattachData(*this, styleReattachData); 2030 document().addStyleReattachData(*this, styleReattachData);
2028 setNeedsReattachLayoutTree(); 2031 setNeedsReattachLayoutTree();
2032 if (layoutObjectIsNeeded(*styleReattachData.computedStyle)) {
2033 recalcContainedStyleForReattach();
2034 }
2029 return Reattach; 2035 return Reattach;
2030 } 2036 }
2031 2037
2032 DCHECK(oldStyle); 2038 DCHECK(oldStyle);
2033 2039
2034 if (localChange != NoChange) 2040 if (localChange != NoChange)
2035 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 2041 updateCallbackSelectors(oldStyle.get(), newStyle.get());
2036 2042
2037 if (LayoutObject* layoutObject = this->layoutObject()) { 2043 if (LayoutObject* layoutObject = this->layoutObject()) {
2038 if (localChange != NoChange) { 2044 if (localChange != NoChange) {
(...skipping 24 matching lines...) Expand all
2063 return Inherit; 2069 return Inherit;
2064 newStyle->copyChildDependentFlagsFrom(*oldStyle); 2070 newStyle->copyChildDependentFlagsFrom(*oldStyle);
2065 } 2071 }
2066 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) 2072 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle())
2067 return UpdatePseudoElements; 2073 return UpdatePseudoElements;
2068 } 2074 }
2069 2075
2070 return localChange; 2076 return localChange;
2071 } 2077 }
2072 2078
2079 void Element::recalcStyleForReattach() {
2080 StyleReattachData styleReattachData;
2081 styleReattachData.computedStyle = styleForLayoutObject();
2082 document().addStyleReattachData(*this, styleReattachData);
2083 setNeedsReattachLayoutTree();
2084 if (layoutObjectIsNeeded(*styleReattachData.computedStyle.get())) {
2085 recalcContainedStyleForReattach();
2086 }
2087 }
2088
2089 void Element::recalcContainedStyleForReattach() {
2090 if (!childrenCanHaveStyle())
2091 return;
2092 if (hasCustomStyleCallbacks())
2093 return;
2094
2095 SelectorFilterParentScope filterScope(*this);
2096 StyleSharingDepthScope sharingScope(*this);
2097 recalcShadowRootStylesForReattach();
2098 recalcDescendantStylesForReattach();
2099 }
2100
2101 void Element::recalcShadowRootStylesForReattach() {
2102 for (ShadowRoot* root = youngestShadowRoot(); root;
2103 root = root->olderShadowRoot()) {
2104 root->recalcDescendantStylesForReattach();
2105 }
2106 }
2107
2073 void Element::rebuildLayoutTree() { 2108 void Element::rebuildLayoutTree() {
2074 DCHECK(inActiveDocument()); 2109 DCHECK(inActiveDocument());
2075 DCHECK(parentNode()); 2110 DCHECK(parentNode());
2076 2111
2077 if (needsReattachLayoutTree()) { 2112 if (needsReattachLayoutTree()) {
2078 StyleReattachData styleReattachData = 2113 StyleReattachData styleReattachData =
2079 document().getStyleReattachData(*this); 2114 document().getStyleReattachData(*this);
2080 AttachContext reattachContext; 2115 AttachContext reattachContext;
2081 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); 2116 reattachContext.resolvedStyle = styleReattachData.computedStyle.get();
2082 bool layoutObjectWillChange = needsAttach() || layoutObject(); 2117 bool layoutObjectWillChange = needsAttach() || layoutObject();
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 RefPtr<ComputedStyle> result = 3268 RefPtr<ComputedStyle> result =
3234 document().ensureStyleResolver().pseudoStyleForElement( 3269 document().ensureStyleResolver().pseudoStyleForElement(
3235 this, PseudoStyleRequest(pseudoElementSpecifier, 3270 this, PseudoStyleRequest(pseudoElementSpecifier,
3236 PseudoStyleRequest::ForComputedStyle), 3271 PseudoStyleRequest::ForComputedStyle),
3237 elementStyle, elementStyle); 3272 elementStyle, elementStyle);
3238 DCHECK(result); 3273 DCHECK(result);
3239 return elementStyle->addCachedPseudoStyle(result.release()); 3274 return elementStyle->addCachedPseudoStyle(result.release());
3240 } 3275 }
3241 3276
3242 const ComputedStyle* Element::nonLayoutObjectComputedStyle() const { 3277 const ComputedStyle* Element::nonLayoutObjectComputedStyle() const {
3278 if (needsReattachLayoutTree())
3279 return document().getStyleReattachData(*this).computedStyle.get();
3280
3243 if (layoutObject() || !hasRareData()) 3281 if (layoutObject() || !hasRareData())
3244 return nullptr; 3282 return nullptr;
3245 3283
3246 return elementRareData()->computedStyle(); 3284 return elementRareData()->computedStyle();
3247 } 3285 }
3248 3286
3249 bool Element::hasDisplayContentsStyle() const { 3287 bool Element::hasDisplayContentsStyle() const {
3250 if (const ComputedStyle* style = nonLayoutObjectComputedStyle()) 3288 if (const ComputedStyle* style = nonLayoutObjectComputedStyle())
3251 return style->display() == EDisplay::Contents; 3289 return style->display() == EDisplay::Contents;
3252 return false; 3290 return false;
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
4227 } 4265 }
4228 4266
4229 DEFINE_TRACE_WRAPPERS(Element) { 4267 DEFINE_TRACE_WRAPPERS(Element) {
4230 if (hasRareData()) { 4268 if (hasRareData()) {
4231 visitor->traceWrappers(elementRareData()); 4269 visitor->traceWrappers(elementRareData());
4232 } 4270 }
4233 ContainerNode::traceWrappers(visitor); 4271 ContainerNode::traceWrappers(visitor);
4234 } 4272 }
4235 4273
4236 } // namespace blink 4274 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/LayoutTreeBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698