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

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

Issue 2740823005: Track lastTextNode during rebuildLayoutTree. (Closed)
Patch Set: Missing reset of lastTextNode for elements. 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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 isInTopLayer()); 1841 isInTopLayer());
1842 1842
1843 return style.release(); 1843 return style.release();
1844 } 1844 }
1845 1845
1846 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() { 1846 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() {
1847 DCHECK(document().inStyleRecalc()); 1847 DCHECK(document().inStyleRecalc());
1848 return document().ensureStyleResolver().styleForElement(this); 1848 return document().ensureStyleResolver().styleForElement(this);
1849 } 1849 }
1850 1850
1851 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) { 1851 void Element::recalcStyle(StyleRecalcChange change) {
1852 DCHECK(document().inStyleRecalc()); 1852 DCHECK(document().inStyleRecalc());
1853 DCHECK(!document().lifecycle().inDetach()); 1853 DCHECK(!document().lifecycle().inDetach());
1854 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); 1854 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1855 DCHECK(inActiveDocument()); 1855 DCHECK(inActiveDocument());
1856 1856
1857 if (hasCustomStyleCallbacks()) 1857 if (hasCustomStyleCallbacks())
1858 willRecalcStyle(change); 1858 willRecalcStyle(change);
1859 1859
1860 if (change >= IndependentInherit || needsStyleRecalc()) { 1860 if (change >= IndependentInherit || needsStyleRecalc()) {
1861 if (hasRareData()) { 1861 if (hasRareData()) {
(...skipping 20 matching lines...) Expand all
1882 data->clearComputedStyle(); 1882 data->clearComputedStyle();
1883 } 1883 }
1884 } 1884 }
1885 1885
1886 if (change >= IndependentInherit) { 1886 if (change >= IndependentInherit) {
1887 if (ElementAnimations* elementAnimations = data->elementAnimations()) 1887 if (ElementAnimations* elementAnimations = data->elementAnimations())
1888 elementAnimations->setAnimationStyleChange(false); 1888 elementAnimations->setAnimationStyleChange(false);
1889 } 1889 }
1890 } 1890 }
1891 if (parentComputedStyle()) 1891 if (parentComputedStyle())
1892 change = recalcOwnStyle(change, nextTextSibling); 1892 change = recalcOwnStyle(change);
1893 // Needed because the rebuildLayoutTree code needs to see what the 1893 // Needed because the rebuildLayoutTree code needs to see what the
1894 // styleChangeType() was on reattach roots. See Node::reattachLayoutTree() 1894 // styleChangeType() was on reattach roots. See Node::reattachLayoutTree()
1895 // for an example. 1895 // for an example.
1896 if (change != Reattach) 1896 if (change != Reattach)
1897 clearNeedsStyleRecalc(); 1897 clearNeedsStyleRecalc();
1898 } 1898 }
1899 1899
1900 // If we are going to reattach we don't need to recalc the style of 1900 // If we are going to reattach we don't need to recalc the style of
1901 // our descendants anymore. 1901 // our descendants anymore.
1902 if (change < Reattach && 1902 if (change < Reattach &&
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 const ComputedStyle* style = computedStyle(); 1947 const ComputedStyle* style = computedStyle();
1948 if (!style || style->animations() || style->transitions()) 1948 if (!style || style->animations() || style->transitions())
1949 return nullptr; 1949 return nullptr;
1950 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); 1950 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style);
1951 newStyle->propagateIndependentInheritedProperties(*parentStyle); 1951 newStyle->propagateIndependentInheritedProperties(*parentStyle);
1952 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), 1952 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(),
1953 independentInheritedStylesPropagated, 1); 1953 independentInheritedStylesPropagated, 1);
1954 return newStyle; 1954 return newStyle;
1955 } 1955 }
1956 1956
1957 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change, 1957 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) {
1958 Text* nextTextSibling) {
1959 DCHECK(document().inStyleRecalc()); 1958 DCHECK(document().inStyleRecalc());
1960 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); 1959 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc());
1961 DCHECK(change >= IndependentInherit || needsStyleRecalc()); 1960 DCHECK(change >= IndependentInherit || needsStyleRecalc());
1962 DCHECK(parentComputedStyle()); 1961 DCHECK(parentComputedStyle());
1963 1962
1964 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); 1963 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle();
1965 1964
1966 // When propagating inherited changes, we don't need to do a full style recalc 1965 // When propagating inherited changes, we don't need to do a full style recalc
1967 // if the only changed properties are independent. In this case, we can simply 1966 // if the only changed properties are independent. In this case, we can simply
1968 // set these directly on the ComputedStyle object. 1967 // set these directly on the ComputedStyle object.
1969 RefPtr<ComputedStyle> newStyle = propagateInheritedProperties(change); 1968 RefPtr<ComputedStyle> newStyle = propagateInheritedProperties(change);
1970 if (!newStyle) 1969 if (!newStyle)
1971 newStyle = styleForLayoutObject(); 1970 newStyle = styleForLayoutObject();
1972 DCHECK(newStyle); 1971 DCHECK(newStyle);
1973 1972
1974 StyleRecalcChange localChange = 1973 StyleRecalcChange localChange =
1975 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); 1974 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get());
1976 if (localChange == NoChange) { 1975 if (localChange == NoChange) {
1977 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); 1976 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1);
1978 } else { 1977 } else {
1979 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); 1978 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1);
1980 } 1979 }
1981 1980
1982 if (localChange == Reattach) { 1981 if (localChange == Reattach) {
1983 StyleReattachData styleReattachData; 1982 document().addNonAttachedStyle(*this, std::move(newStyle));
1984 styleReattachData.computedStyle = std::move(newStyle);
1985 styleReattachData.nextTextSibling = nextTextSibling;
1986 document().addStyleReattachData(*this, styleReattachData);
1987 setNeedsReattachLayoutTree(); 1983 setNeedsReattachLayoutTree();
1988 return Reattach; 1984 return Reattach;
1989 } 1985 }
1990 1986
1991 DCHECK(oldStyle); 1987 DCHECK(oldStyle);
1992 1988
1993 if (localChange != NoChange) 1989 if (localChange != NoChange)
1994 updateCallbackSelectors(oldStyle.get(), newStyle.get()); 1990 updateCallbackSelectors(oldStyle.get(), newStyle.get());
1995 1991
1996 if (LayoutObject* layoutObject = this->layoutObject()) { 1992 if (LayoutObject* layoutObject = this->layoutObject()) {
(...skipping 24 matching lines...) Expand all
2021 return Inherit; 2017 return Inherit;
2022 newStyle->copyChildDependentFlagsFrom(*oldStyle); 2018 newStyle->copyChildDependentFlagsFrom(*oldStyle);
2023 } 2019 }
2024 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) 2020 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle())
2025 return UpdatePseudoElements; 2021 return UpdatePseudoElements;
2026 } 2022 }
2027 2023
2028 return localChange; 2024 return localChange;
2029 } 2025 }
2030 2026
2031 void Element::rebuildLayoutTree() { 2027 void Element::rebuildLayoutTree(Text* nextTextSibling) {
2032 DCHECK(inActiveDocument()); 2028 DCHECK(inActiveDocument());
2033 DCHECK(parentNode()); 2029 DCHECK(parentNode());
2034 2030
2035 if (needsReattachLayoutTree()) { 2031 if (needsReattachLayoutTree()) {
2036 StyleReattachData styleReattachData =
2037 document().getStyleReattachData(*this);
2038 AttachContext reattachContext; 2032 AttachContext reattachContext;
2039 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); 2033 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this);
2040 bool layoutObjectWillChange = needsAttach() || layoutObject(); 2034 bool layoutObjectWillChange = needsAttach() || layoutObject();
2041 reattachLayoutTree(reattachContext); 2035 reattachLayoutTree(reattachContext);
2042 if (layoutObjectWillChange || layoutObject()) { 2036 if (layoutObjectWillChange || layoutObject())
2043 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles 2037 reattachWhitespaceSiblingsIfNeeded(nextTextSibling);
2044 // we can either traverse the current subtree from this node onwards
2045 // or store it.
2046 // The choice is between increased time and increased memory complexity.
2047 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling);
2048 }
2049 } else if (childNeedsReattachLayoutTree()) { 2038 } else if (childNeedsReattachLayoutTree()) {
2050 DCHECK(!needsReattachLayoutTree()); 2039 DCHECK(!needsReattachLayoutTree());
2051 SelectorFilterParentScope filterScope(*this); 2040 SelectorFilterParentScope filterScope(*this);
2052 StyleSharingDepthScope sharingScope(*this); 2041 StyleSharingDepthScope sharingScope(*this);
2053 reattachPseudoElementLayoutTree(PseudoIdBefore); 2042 reattachPseudoElementLayoutTree(PseudoIdBefore);
2054 rebuildShadowRootLayoutTree(); 2043 rebuildShadowRootLayoutTree();
2055 rebuildChildrenLayoutTrees(); 2044 rebuildChildrenLayoutTrees();
2056 reattachPseudoElementLayoutTree(PseudoIdAfter); 2045 reattachPseudoElementLayoutTree(PseudoIdAfter);
2057 reattachPseudoElementLayoutTree(PseudoIdBackdrop); 2046 reattachPseudoElementLayoutTree(PseudoIdBackdrop);
2058 reattachPseudoElementLayoutTree(PseudoIdFirstLetter); 2047 reattachPseudoElementLayoutTree(PseudoIdFirstLetter);
(...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after
4185 } 4174 }
4186 4175
4187 DEFINE_TRACE_WRAPPERS(Element) { 4176 DEFINE_TRACE_WRAPPERS(Element) {
4188 if (hasRareData()) { 4177 if (hasRareData()) {
4189 visitor->traceWrappers(elementRareData()); 4178 visitor->traceWrappers(elementRareData());
4190 } 4179 }
4191 ContainerNode::traceWrappers(visitor); 4180 ContainerNode::traceWrappers(visitor);
4192 } 4181 }
4193 4182
4194 } // namespace blink 4183 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.h ('k') | third_party/WebKit/Source/core/dom/StyleReattachData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698