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 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1851 data->clearComputedStyle(); | 1851 data->clearComputedStyle(); |
1852 | 1852 |
1853 if (change >= IndependentInherit) { | 1853 if (change >= IndependentInherit) { |
1854 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1854 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
1855 elementAnimations->setAnimationStyleChange(false); | 1855 elementAnimations->setAnimationStyleChange(false); |
1856 } | 1856 } |
1857 } | 1857 } |
1858 if (parentComputedStyle()) | 1858 if (parentComputedStyle()) |
1859 change = recalcOwnStyle(change); | 1859 change = recalcOwnStyle(change); |
1860 clearNeedsStyleRecalc(); | 1860 clearNeedsStyleRecalc(); |
1861 clearNeedsReattachLayoutTree(); | |
1861 } | 1862 } |
1862 | 1863 |
1863 // If we reattached we don't need to recalc the style of our descendants | 1864 // If we reattached we don't need to recalc the style of our descendants |
1864 // anymore. | 1865 // anymore. |
1865 if ((change >= UpdatePseudoElements && change < Reattach) || | 1866 if ((change >= UpdatePseudoElements && change < Reattach) || |
1866 childNeedsStyleRecalc()) { | 1867 childNeedsStyleRecalc()) { |
1867 SelectorFilterParentScope filterScope(*this); | 1868 SelectorFilterParentScope filterScope(*this); |
1868 StyleSharingDepthScope sharingScope(*this); | 1869 StyleSharingDepthScope sharingScope(*this); |
1869 | 1870 |
1870 updatePseudoElement(PseudoIdBefore, change); | 1871 updatePseudoElement(PseudoIdBefore, change); |
(...skipping 15 matching lines...) Expand all Loading... | |
1886 // This can be seen when a child transitions from floating to | 1887 // 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. | 1888 // non-floating we have to take it into account for the first letter. |
1888 updatePseudoElement(PseudoIdFirstLetter, | 1889 updatePseudoElement(PseudoIdFirstLetter, |
1889 childNeedsStyleRecalc() ? Force : change); | 1890 childNeedsStyleRecalc() ? Force : change); |
1890 | 1891 |
1891 clearChildNeedsStyleRecalc(); | 1892 clearChildNeedsStyleRecalc(); |
1892 } | 1893 } |
1893 | 1894 |
1894 if (hasCustomStyleCallbacks()) | 1895 if (hasCustomStyleCallbacks()) |
1895 didRecalcStyle(change); | 1896 didRecalcStyle(change); |
1896 | |
1897 if (change == Reattach) | |
1898 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | |
esprehn
2016/10/18 02:00:10
We don't need the nextTextSibling here anymore so
| |
1899 } | 1897 } |
1900 | 1898 |
1901 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1899 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
1902 StyleRecalcChange change) { | 1900 StyleRecalcChange change) { |
1903 if (change != IndependentInherit) | 1901 if (change != IndependentInherit) |
1904 return nullptr; | 1902 return nullptr; |
1905 if (needsStyleRecalc()) | 1903 if (needsStyleRecalc()) |
1906 return nullptr; | 1904 return nullptr; |
1907 if (hasAnimations()) | 1905 if (hasAnimations()) |
1908 return nullptr; | 1906 return nullptr; |
(...skipping 28 matching lines...) Expand all Loading... | |
1937 StyleRecalcChange localChange = | 1935 StyleRecalcChange localChange = |
1938 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); | 1936 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
1939 if (localChange == NoChange) { | 1937 if (localChange == NoChange) { |
1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); | 1938 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); |
1941 } else { | 1939 } else { |
1942 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
1943 } | 1941 } |
1944 | 1942 |
1945 if (localChange == Reattach) { | 1943 if (localChange == Reattach) { |
1946 document().addNonAttachedStyle(*this, std::move(newStyle)); | 1944 document().addNonAttachedStyle(*this, std::move(newStyle)); |
1945 setNeedsReattachLayoutTree(); | |
1947 return rebuildLayoutTree(); | 1946 return rebuildLayoutTree(); |
1948 } | 1947 } |
1949 | 1948 |
1950 DCHECK(oldStyle); | 1949 DCHECK(oldStyle); |
1951 | 1950 |
1952 if (localChange != NoChange) | 1951 if (localChange != NoChange) |
1953 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1952 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
1954 | 1953 |
1955 if (LayoutObject* layoutObject = this->layoutObject()) { | 1954 if (LayoutObject* layoutObject = this->layoutObject()) { |
1956 if (localChange != NoChange || | 1955 if (localChange != NoChange || |
(...skipping 23 matching lines...) Expand all Loading... | |
1980 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1979 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
1981 } | 1980 } |
1982 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 1981 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
1983 return UpdatePseudoElements; | 1982 return UpdatePseudoElements; |
1984 } | 1983 } |
1985 | 1984 |
1986 return localChange; | 1985 return localChange; |
1987 } | 1986 } |
1988 | 1987 |
1989 StyleRecalcChange Element::rebuildLayoutTree() { | 1988 StyleRecalcChange Element::rebuildLayoutTree() { |
1989 DCHECK(inActiveDocument()); | |
1990 AttachContext reattachContext; | 1990 AttachContext reattachContext; |
1991 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 1991 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); |
1992 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 1992 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
1993 | |
1994 // We are calling Element::rebuildLayoutTree() from inside | |
1995 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | |
1996 // flag - so needsReattachLayoutTree() should always be true. | |
1997 DCHECK(parentNode()); | |
1998 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | |
1999 DCHECK(needsReattachLayoutTree()); | |
1993 reattachLayoutTree(reattachContext); | 2000 reattachLayoutTree(reattachContext); |
1994 if (layoutObjectWillChange || layoutObject()) | 2001 // Since needsReattachLayoutTree() is always true we go into |
2002 // reattachLayoutTree() which reattaches all the descendant | |
2003 // sub-trees. At this point no child should need reattaching. | |
2004 DCHECK(!childNeedsReattachLayoutTree()); | |
2005 | |
2006 if (layoutObjectWillChange || layoutObject()) { | |
2007 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | |
2008 // we can either traverse the current subtree from this node onwards | |
2009 // or store it. | |
2010 // The choice is between increased time and increased memory complexity. | |
2011 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); | |
1995 return Reattach; | 2012 return Reattach; |
2013 } | |
1996 return ReattachNoLayoutObject; | 2014 return ReattachNoLayoutObject; |
1997 } | 2015 } |
1998 | 2016 |
1999 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2017 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
2000 const ComputedStyle* newStyle) { | 2018 const ComputedStyle* newStyle) { |
2001 Vector<String> emptyVector; | 2019 Vector<String> emptyVector; |
2002 const Vector<String>& oldCallbackSelectors = | 2020 const Vector<String>& oldCallbackSelectors = |
2003 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2021 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
2004 const Vector<String>& newCallbackSelectors = | 2022 const Vector<String>& newCallbackSelectors = |
2005 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2023 newStyle ? newStyle->callbackSelectors() : emptyVector; |
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4080 } | 4098 } |
4081 | 4099 |
4082 DEFINE_TRACE_WRAPPERS(Element) { | 4100 DEFINE_TRACE_WRAPPERS(Element) { |
4083 if (hasRareData()) { | 4101 if (hasRareData()) { |
4084 visitor->traceWrappers(elementRareData()); | 4102 visitor->traceWrappers(elementRareData()); |
4085 } | 4103 } |
4086 ContainerNode::traceWrappers(visitor); | 4104 ContainerNode::traceWrappers(visitor); |
4087 } | 4105 } |
4088 | 4106 |
4089 } // namespace blink | 4107 } // namespace blink |
OLD | NEW |