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

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

Issue 2398293003: Move Layout Tree Construction code into Element::rebuildLayoutTree() (Closed)
Patch Set: Bugs' comments Created 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1842 matching lines...) Expand 10 before | Expand all | Expand 10 after
1853 data->clearComputedStyle(); 1853 data->clearComputedStyle();
1854 1854
1855 if (change >= IndependentInherit) { 1855 if (change >= IndependentInherit) {
1856 if (ElementAnimations* elementAnimations = data->elementAnimations()) 1856 if (ElementAnimations* elementAnimations = data->elementAnimations())
1857 elementAnimations->setAnimationStyleChange(false); 1857 elementAnimations->setAnimationStyleChange(false);
1858 } 1858 }
1859 } 1859 }
1860 if (parentComputedStyle()) 1860 if (parentComputedStyle())
1861 change = recalcOwnStyle(change); 1861 change = recalcOwnStyle(change);
1862 clearNeedsStyleRecalc(); 1862 clearNeedsStyleRecalc();
1863 clearNeedsReattachLayoutTree();
1863 } 1864 }
1864 1865
1865 // If we reattached we don't need to recalc the style of our descendants 1866 // If we reattached we don't need to recalc the style of our descendants
1866 // anymore. 1867 // anymore.
1867 if ((change >= UpdatePseudoElements && change < Reattach) || 1868 if ((change >= UpdatePseudoElements && change < Reattach) ||
1868 childNeedsStyleRecalc()) { 1869 childNeedsStyleRecalc()) {
1869 SelectorFilterParentScope filterScope(*this); 1870 SelectorFilterParentScope filterScope(*this);
1870 StyleSharingDepthScope sharingScope(*this); 1871 StyleSharingDepthScope sharingScope(*this);
1871 1872
1872 updatePseudoElement(PseudoIdBefore, change); 1873 updatePseudoElement(PseudoIdBefore, change);
(...skipping 11 matching lines...) Expand all
1884 updatePseudoElement(PseudoIdBackdrop, change); 1885 updatePseudoElement(PseudoIdBackdrop, change);
1885 1886
1886 // If our children have changed then we need to force the first-letter 1887 // If our children have changed then we need to force the first-letter
1887 // checks as we don't know if they effected the first letter or not. 1888 // checks as we don't know if they effected the first letter or not.
1888 // This can be seen when a child transitions from floating to 1889 // This can be seen when a child transitions from floating to
1889 // non-floating we have to take it into account for the first letter. 1890 // non-floating we have to take it into account for the first letter.
1890 updatePseudoElement(PseudoIdFirstLetter, 1891 updatePseudoElement(PseudoIdFirstLetter,
1891 childNeedsStyleRecalc() ? Force : change); 1892 childNeedsStyleRecalc() ? Force : change);
1892 1893
1893 clearChildNeedsStyleRecalc(); 1894 clearChildNeedsStyleRecalc();
1895 clearChildNeedsReattachLayoutTree();
1894 } 1896 }
1895 1897
1896 if (hasCustomStyleCallbacks()) 1898 if (hasCustomStyleCallbacks())
1897 didRecalcStyle(change); 1899 didRecalcStyle(change);
1898
1899 if (change == Reattach)
1900 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1901 } 1900 }
1902 1901
1903 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( 1902 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties(
1904 StyleRecalcChange change) { 1903 StyleRecalcChange change) {
1905 if (change != IndependentInherit) 1904 if (change != IndependentInherit)
1906 return nullptr; 1905 return nullptr;
1907 if (needsStyleRecalc()) 1906 if (needsStyleRecalc())
1908 return nullptr; 1907 return nullptr;
1909 if (hasAnimations()) 1908 if (hasAnimations())
1910 return nullptr; 1909 return nullptr;
(...skipping 28 matching lines...) Expand all
1939 StyleRecalcChange localChange = 1938 StyleRecalcChange localChange =
1940 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); 1939 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get());
1941 if (localChange == NoChange) { 1940 if (localChange == NoChange) {
1942 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 1941 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
1943 } else { 1942 } else {
1944 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); 1943 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1);
1945 } 1944 }
1946 1945
1947 if (localChange == Reattach) { 1946 if (localChange == Reattach) {
1948 document().addNonAttachedStyle(*this, std::move(newStyle)); 1947 document().addNonAttachedStyle(*this, std::move(newStyle));
1948 setNeedsReattachLayoutTree();
1949 return rebuildLayoutTree(); 1949 return rebuildLayoutTree();
1950 } 1950 }
1951 1951
1952 DCHECK(oldStyle); 1952 DCHECK(oldStyle);
1953 1953
1954 if (localChange != NoChange) 1954 if (localChange != NoChange)
1955 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1955 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1956 1956
1957 if (LayoutObject* layoutObject = this->layoutObject()) { 1957 if (LayoutObject* layoutObject = this->layoutObject()) {
1958 if (localChange != NoChange || 1958 if (localChange != NoChange ||
(...skipping 26 matching lines...) Expand all
1985 return UpdatePseudoElements; 1985 return UpdatePseudoElements;
1986 } 1986 }
1987 1987
1988 return localChange; 1988 return localChange;
1989 } 1989 }
1990 1990
1991 StyleRecalcChange Element::rebuildLayoutTree() { 1991 StyleRecalcChange Element::rebuildLayoutTree() {
1992 AttachContext reattachContext; 1992 AttachContext reattachContext;
1993 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); 1993 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this);
1994 bool layoutObjectWillChange = needsAttach() || layoutObject(); 1994 bool layoutObjectWillChange = needsAttach() || layoutObject();
1995 reattachLayoutTree(reattachContext); 1995
1996 if (layoutObjectWillChange || layoutObject()) 1996 if (needsReattachLayoutTree())
Bugs Nash 2016/10/17 00:17:05 what is the purpose of this check? it doesn't seem
nainar 2016/10/17 16:29:12 Moved to a DCHECK and added an explainer comment h
1997 reattachLayoutTree(reattachContext);
1998
1999 DCHECK(!childNeedsReattachLayoutTree());
Bugs Nash 2016/10/17 00:17:05 add a comment explaining why we expect this DCHECK
nainar 2016/10/17 16:29:12 Done.
2000
2001 if (layoutObjectWillChange || layoutObject()) {
2002 Text* nextTextSibling = nullptr;
Bugs Nash 2016/10/17 00:17:04 the comment about the trade off between storage an
nainar 2016/10/17 16:29:12 Edited the comment. Moved code to function.
2003 for (Node* sibling = this->nextSibling();
2004 sibling &&
2005 !(sibling->isElementNode() && toElement(sibling)->layoutObject());
2006 sibling = sibling->nextSibling()) {
2007 if (sibling->isTextNode()) {
2008 nextTextSibling = toText(sibling);
2009 break;
2010 }
2011 }
2012 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1997 return Reattach; 2013 return Reattach;
2014 }
1998 return ReattachNoLayoutObject; 2015 return ReattachNoLayoutObject;
1999 } 2016 }
2000 2017
2001 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, 2018 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle,
2002 const ComputedStyle* newStyle) { 2019 const ComputedStyle* newStyle) {
2003 Vector<String> emptyVector; 2020 Vector<String> emptyVector;
2004 const Vector<String>& oldCallbackSelectors = 2021 const Vector<String>& oldCallbackSelectors =
2005 oldStyle ? oldStyle->callbackSelectors() : emptyVector; 2022 oldStyle ? oldStyle->callbackSelectors() : emptyVector;
2006 const Vector<String>& newCallbackSelectors = 2023 const Vector<String>& newCallbackSelectors =
2007 newStyle ? newStyle->callbackSelectors() : emptyVector; 2024 newStyle ? newStyle->callbackSelectors() : emptyVector;
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 } 4099 }
4083 4100
4084 DEFINE_TRACE_WRAPPERS(Element) { 4101 DEFINE_TRACE_WRAPPERS(Element) {
4085 if (hasRareData()) { 4102 if (hasRareData()) {
4086 visitor->traceWrappers(elementRareData()); 4103 visitor->traceWrappers(elementRareData());
4087 } 4104 }
4088 ContainerNode::traceWrappers(visitor); 4105 ContainerNode::traceWrappers(visitor);
4089 } 4106 }
4090 4107
4091 } // namespace blink 4108 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698