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

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: remove reattachPseudoElementLayoutTree() since its dead code for now 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())
1997 reattachLayoutTree(reattachContext);
1998 else if (childNeedsReattachLayoutTree())
Bugs Nash 2016/10/14 00:36:47 I think this would be better as a DCHECK
nainar 2016/10/14 03:28:10 Done.
1999 NOTREACHED();
2000
2001 if (layoutObjectWillChange || layoutObject()) {
2002 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles
2003 // we can either traverse the parent's tree to get this node or store it
2004 // (like WebKit does).
Bugs Nash 2016/10/14 00:36:47 I wouldn't include what webkit does in a comment -
nainar 2016/10/14 03:28:10 Done.
2005 // The choice is between increased time and increased memory complexity
2006 Text* nextTextSibling = nullptr;
2007 for (Node* sibling = this->nextSibling(); sibling;
2008 sibling = sibling->nextSibling()) {
2009 if (sibling->isElementNode() && toElement(sibling)->layoutObject()) {
Bugs Nash 2016/10/14 00:36:47 could avoid this branch by adding it to the for lo
nainar 2016/10/14 03:28:10 Done.
2010 break;
2011 }
2012 if (sibling->isTextNode()) {
2013 nextTextSibling = toText(sibling);
2014 break;
2015 }
2016 }
2017 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
1997 return Reattach; 2018 return Reattach;
2019 }
1998 return ReattachNoLayoutObject; 2020 return ReattachNoLayoutObject;
1999 } 2021 }
2000 2022
2001 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, 2023 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle,
2002 const ComputedStyle* newStyle) { 2024 const ComputedStyle* newStyle) {
2003 Vector<String> emptyVector; 2025 Vector<String> emptyVector;
2004 const Vector<String>& oldCallbackSelectors = 2026 const Vector<String>& oldCallbackSelectors =
2005 oldStyle ? oldStyle->callbackSelectors() : emptyVector; 2027 oldStyle ? oldStyle->callbackSelectors() : emptyVector;
2006 const Vector<String>& newCallbackSelectors = 2028 const Vector<String>& newCallbackSelectors =
2007 newStyle ? newStyle->callbackSelectors() : emptyVector; 2029 newStyle ? newStyle->callbackSelectors() : emptyVector;
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after
4082 } 4104 }
4083 4105
4084 DEFINE_TRACE_WRAPPERS(Element) { 4106 DEFINE_TRACE_WRAPPERS(Element) {
4085 if (hasRareData()) { 4107 if (hasRareData()) {
4086 visitor->traceWrappers(elementRareData()); 4108 visitor->traceWrappers(elementRareData());
4087 } 4109 }
4088 ContainerNode::traceWrappers(visitor); 4110 ContainerNode::traceWrappers(visitor);
4089 } 4111 }
4090 4112
4091 } // namespace blink 4113 } // 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