OLD | NEW |
---|---|
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 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1850 data->clearComputedStyle(); | 1850 data->clearComputedStyle(); |
1851 | 1851 |
1852 if (change >= IndependentInherit) { | 1852 if (change >= IndependentInherit) { |
1853 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1853 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
1854 elementAnimations->setAnimationStyleChange(false); | 1854 elementAnimations->setAnimationStyleChange(false); |
1855 } | 1855 } |
1856 } | 1856 } |
1857 if (parentComputedStyle()) | 1857 if (parentComputedStyle()) |
1858 change = recalcOwnStyle(change); | 1858 change = recalcOwnStyle(change); |
1859 clearNeedsStyleRecalc(); | 1859 clearNeedsStyleRecalc(); |
1860 clearNeedsReattachLayoutTree(); | |
1861 } | 1860 } |
1862 | 1861 |
1863 // If we reattached we don't need to recalc the style of our descendants | 1862 // If we reattached we don't need to recalc the style of our descendants |
1864 // anymore. | 1863 // anymore. |
1865 if ((change >= UpdatePseudoElements && change < Reattach) || | 1864 if ((change >= UpdatePseudoElements && change < Reattach) || |
1866 childNeedsStyleRecalc()) { | 1865 childNeedsStyleRecalc()) { |
1867 SelectorFilterParentScope filterScope(*this); | 1866 SelectorFilterParentScope filterScope(*this); |
1868 StyleSharingDepthScope sharingScope(*this); | 1867 StyleSharingDepthScope sharingScope(*this); |
1869 | 1868 |
1870 updatePseudoElement(PseudoIdBefore, change); | 1869 updatePseudoElement(PseudoIdBefore, change); |
1871 | 1870 |
1872 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1871 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
1873 for (ShadowRoot* root = youngestShadowRoot(); root; | 1872 for (ShadowRoot* root = youngestShadowRoot(); root; |
1874 root = root->olderShadowRoot()) { | 1873 root = root->olderShadowRoot()) { |
1875 if (root->shouldCallRecalcStyle(change)) | 1874 if (root->shouldCallRecalcStyle(change)) |
1876 root->recalcStyle(change); | 1875 root->recalcStyle(change); |
1877 } | 1876 } |
1878 recalcDescendantStyles(change); | 1877 recalcDescendantStyles(change); |
1878 clearChildNeedsStyleRecalc(); | |
1879 } | 1879 } |
1880 | 1880 |
1881 updatePseudoElement(PseudoIdAfter, change); | 1881 updatePseudoElement(PseudoIdAfter, change); |
1882 updatePseudoElement(PseudoIdBackdrop, change); | 1882 updatePseudoElement(PseudoIdBackdrop, change); |
1883 | 1883 |
1884 // If our children have changed then we need to force the first-letter | 1884 // If our children have changed then we need to force the first-letter |
1885 // checks as we don't know if they effected the first letter or not. | 1885 // checks as we don't know if they effected the first letter or not. |
1886 // This can be seen when a child transitions from floating to | 1886 // This can be seen when a child transitions from floating to |
1887 // non-floating we have to take it into account for the first letter. | 1887 // non-floating we have to take it into account for the first letter. |
1888 updatePseudoElement(PseudoIdFirstLetter, | 1888 updatePseudoElement(PseudoIdFirstLetter, |
1889 childNeedsStyleRecalc() ? Force : change); | 1889 childNeedsStyleRecalc() ? Force : change); |
1890 | |
1891 clearChildNeedsStyleRecalc(); | |
1892 clearChildNeedsReattachLayoutTree(); | |
1893 } | 1890 } |
1894 | 1891 |
1895 if (hasCustomStyleCallbacks()) | 1892 if (hasCustomStyleCallbacks()) |
1896 didRecalcStyle(change); | 1893 didRecalcStyle(change); |
1897 } | 1894 } |
1898 | 1895 |
1899 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1896 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
1900 StyleRecalcChange change) { | 1897 StyleRecalcChange change) { |
1901 if (change != IndependentInherit) | 1898 if (change != IndependentInherit) |
1902 return nullptr; | 1899 return nullptr; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1936 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); | 1933 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
1937 if (localChange == NoChange) { | 1934 if (localChange == NoChange) { |
1938 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); | 1935 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); |
1939 } else { | 1936 } else { |
1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1937 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
1941 } | 1938 } |
1942 | 1939 |
1943 if (localChange == Reattach) { | 1940 if (localChange == Reattach) { |
1944 document().addNonAttachedStyle(*this, std::move(newStyle)); | 1941 document().addNonAttachedStyle(*this, std::move(newStyle)); |
1945 setNeedsReattachLayoutTree(); | 1942 setNeedsReattachLayoutTree(); |
1946 return rebuildLayoutTree(); | 1943 return Reattach; |
1947 } | 1944 } |
1948 | 1945 |
1949 DCHECK(oldStyle); | 1946 DCHECK(oldStyle); |
1950 | 1947 |
1951 if (localChange != NoChange) | 1948 if (localChange != NoChange) |
1952 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1949 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
1953 | 1950 |
1954 if (LayoutObject* layoutObject = this->layoutObject()) { | 1951 if (LayoutObject* layoutObject = this->layoutObject()) { |
1955 if (localChange != NoChange || | 1952 if (localChange != NoChange || |
1956 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || | 1953 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get()) || |
(...skipping 21 matching lines...) Expand all Loading... | |
1978 return Inherit; | 1975 return Inherit; |
1979 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1976 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
1980 } | 1977 } |
1981 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 1978 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
1982 return UpdatePseudoElements; | 1979 return UpdatePseudoElements; |
1983 } | 1980 } |
1984 | 1981 |
1985 return localChange; | 1982 return localChange; |
1986 } | 1983 } |
1987 | 1984 |
1988 StyleRecalcChange Element::rebuildLayoutTree() { | 1985 void Element::rebuildLayoutTree() { |
1989 DCHECK(inActiveDocument()); | 1986 DCHECK(inActiveDocument()); |
1987 DCHECK(!needsStyleRecalc()); | |
1988 DCHECK(!childNeedsStyleRecalc()); | |
1989 DCHECK(parentNode()); | |
1990 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | |
1991 | |
1990 AttachContext reattachContext; | 1992 AttachContext reattachContext; |
1991 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 1993 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); |
1992 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 1994 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
1993 | 1995 |
1994 // We are calling Element::rebuildLayoutTree() from inside | 1996 if (needsReattachLayoutTree()) { |
1995 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | 1997 reattachLayoutTree(reattachContext); |
1996 // flag - so needsReattachLayoutTree() should always be true. | 1998 } else if (childNeedsReattachLayoutTree()) { |
esprehn
2016/11/07 22:32:08
You're missing:
SelectorFilterParentScope filte
| |
1997 DCHECK(parentNode()); | 1999 rebuildShadowRootLayoutTree(); |
1998 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | 2000 rebuildDescendantLayoutTree(); |
1999 DCHECK(needsReattachLayoutTree()); | 2001 reattachPseudoElementLayoutTree(PseudoIdAfter); |
2000 reattachLayoutTree(reattachContext); | 2002 reattachPseudoElementLayoutTree(PseudoIdBackdrop); |
2001 // Since needsReattachLayoutTree() is always true we go into | 2003 } |
2002 // reattachLayoutTree() which reattaches all the descendant | 2004 DCHECK(!needsReattachLayoutTree()); |
2003 // sub-trees. At this point no child should need reattaching. | |
2004 DCHECK(!childNeedsReattachLayoutTree()); | 2005 DCHECK(!childNeedsReattachLayoutTree()); |
2005 | 2006 |
2006 if (layoutObjectWillChange || layoutObject()) { | 2007 if (layoutObjectWillChange || layoutObject()) { |
2007 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | 2008 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
2008 // we can either traverse the current subtree from this node onwards | 2009 // we can either traverse the current subtree from this node onwards |
2009 // or store it. | 2010 // or store it. |
2010 // The choice is between increased time and increased memory complexity. | 2011 // The choice is between increased time and increased memory complexity |
2012 // (for the duration of Style recalc and Layout Tree Construction). | |
2013 // TODO(bugsnash): This is a performance regression - bugsnash is working on | |
2014 // alleviating this regression. | |
2011 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); | 2015 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); |
2012 return Reattach; | |
2013 } | 2016 } |
2014 return ReattachNoLayoutObject; | 2017 } |
esprehn
2016/11/07 22:32:08
Is ReattachNoLayoutObject dead code now?
| |
2018 | |
2019 void Element::rebuildShadowRootLayoutTree() { | |
2020 for (ShadowRoot* root = youngestShadowRoot(); root; | |
2021 root = root->olderShadowRoot()) { | |
2022 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) | |
2023 root->rebuildLayoutTree(); | |
2024 } | |
2025 } | |
2026 void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { | |
2027 if (PseudoElement* element = pseudoElement(pseudoId)) { | |
2028 if (element->needsReattachLayoutTree()) | |
2029 element->rebuildLayoutTree(); | |
2030 } | |
2015 } | 2031 } |
2016 | 2032 |
2017 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2033 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
2018 const ComputedStyle* newStyle) { | 2034 const ComputedStyle* newStyle) { |
2019 Vector<String> emptyVector; | 2035 Vector<String> emptyVector; |
2020 const Vector<String>& oldCallbackSelectors = | 2036 const Vector<String>& oldCallbackSelectors = |
2021 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2037 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
2022 const Vector<String>& newCallbackSelectors = | 2038 const Vector<String>& newCallbackSelectors = |
2023 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2039 newStyle ? newStyle->callbackSelectors() : emptyVector; |
2024 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) | 2040 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) |
(...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4089 } | 4105 } |
4090 | 4106 |
4091 DEFINE_TRACE_WRAPPERS(Element) { | 4107 DEFINE_TRACE_WRAPPERS(Element) { |
4092 if (hasRareData()) { | 4108 if (hasRareData()) { |
4093 visitor->traceWrappers(elementRareData()); | 4109 visitor->traceWrappers(elementRareData()); |
4094 } | 4110 } |
4095 ContainerNode::traceWrappers(visitor); | 4111 ContainerNode::traceWrappers(visitor); |
4096 } | 4112 } |
4097 | 4113 |
4098 } // namespace blink | 4114 } // namespace blink |
OLD | NEW |