Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 1882 updatePseudoElement(PseudoIdBackdrop, change); | 1883 updatePseudoElement(PseudoIdBackdrop, change); |
| 1883 | 1884 |
| 1884 // If our children have changed then we need to force the first-letter | 1885 // 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. | 1886 // 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 | 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(); |
| 1893 clearChildNeedsReattachLayoutTree(); | |
|
esprehn
2016/10/17 21:36:26
Note that once you start walking the tree you're n
nainar
2016/10/18 00:04:41
Done.
| |
| 1892 } | 1894 } |
| 1893 | 1895 |
| 1894 if (hasCustomStyleCallbacks()) | 1896 if (hasCustomStyleCallbacks()) |
| 1895 didRecalcStyle(change); | 1897 didRecalcStyle(change); |
| 1896 | |
| 1897 if (change == Reattach) | |
| 1898 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | |
| 1899 } | 1898 } |
| 1900 | 1899 |
| 1901 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1900 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
| 1902 StyleRecalcChange change) { | 1901 StyleRecalcChange change) { |
| 1903 if (change != IndependentInherit) | 1902 if (change != IndependentInherit) |
| 1904 return nullptr; | 1903 return nullptr; |
| 1905 if (needsStyleRecalc()) | 1904 if (needsStyleRecalc()) |
| 1906 return nullptr; | 1905 return nullptr; |
| 1907 if (hasAnimations()) | 1906 if (hasAnimations()) |
| 1908 return nullptr; | 1907 return nullptr; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1937 StyleRecalcChange localChange = | 1936 StyleRecalcChange localChange = |
| 1938 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); | 1937 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
| 1939 if (localChange == NoChange) { | 1938 if (localChange == NoChange) { |
| 1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); | 1939 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); |
| 1941 } else { | 1940 } else { |
| 1942 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1941 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
| 1943 } | 1942 } |
| 1944 | 1943 |
| 1945 if (localChange == Reattach) { | 1944 if (localChange == Reattach) { |
| 1946 document().addNonAttachedStyle(*this, std::move(newStyle)); | 1945 document().addNonAttachedStyle(*this, std::move(newStyle)); |
| 1946 setNeedsReattachLayoutTree(); | |
| 1947 return rebuildLayoutTree(); | 1947 return rebuildLayoutTree(); |
| 1948 } | 1948 } |
| 1949 | 1949 |
| 1950 DCHECK(oldStyle); | 1950 DCHECK(oldStyle); |
| 1951 | 1951 |
| 1952 if (localChange != NoChange) | 1952 if (localChange != NoChange) |
| 1953 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1953 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
| 1954 | 1954 |
| 1955 if (LayoutObject* layoutObject = this->layoutObject()) { | 1955 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 1956 if (localChange != NoChange || | 1956 if (localChange != NoChange || |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1980 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1980 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
| 1981 } | 1981 } |
| 1982 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 1982 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
| 1983 return UpdatePseudoElements; | 1983 return UpdatePseudoElements; |
| 1984 } | 1984 } |
| 1985 | 1985 |
| 1986 return localChange; | 1986 return localChange; |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 StyleRecalcChange Element::rebuildLayoutTree() { | 1989 StyleRecalcChange Element::rebuildLayoutTree() { |
| 1990 AttachContext reattachContext; | 1990 AttachContext reattachContext; |
|
esprehn
2016/10/17 21:36:26
DCHECK(inActiveDocument()) in this function
nainar
2016/10/18 00:04:41
Done.
| |
| 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(needsReattachLayoutTree()); | |
| 1993 reattachLayoutTree(reattachContext); | 1998 reattachLayoutTree(reattachContext); |
| 1994 if (layoutObjectWillChange || layoutObject()) | 1999 // Since needsReattachLayoutTree() is always true we go into |
| 2000 // reattachLayoutTree() which reattaches all the descendant | |
| 2001 // sub-trees. At this point no child should need reattaching. | |
| 2002 DCHECK(!childNeedsReattachLayoutTree()); | |
|
esprehn
2016/10/17 21:36:26
DCHECK(parentNode());
DCHECK(parentNode()->childNe
nainar
2016/10/18 00:04:41
Done.
| |
| 2003 | |
| 2004 if (layoutObjectWillChange || layoutObject()) { | |
| 2005 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | |
| 2006 // we can either traverse the current subtree from this node onwards | |
| 2007 // or store it. | |
| 2008 // The choice is between increased time and increased memory complexity. | |
| 2009 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); | |
| 1995 return Reattach; | 2010 return Reattach; |
| 2011 } | |
| 1996 return ReattachNoLayoutObject; | 2012 return ReattachNoLayoutObject; |
| 1997 } | 2013 } |
| 1998 | 2014 |
| 1999 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2015 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
| 2000 const ComputedStyle* newStyle) { | 2016 const ComputedStyle* newStyle) { |
| 2001 Vector<String> emptyVector; | 2017 Vector<String> emptyVector; |
| 2002 const Vector<String>& oldCallbackSelectors = | 2018 const Vector<String>& oldCallbackSelectors = |
| 2003 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2019 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
| 2004 const Vector<String>& newCallbackSelectors = | 2020 const Vector<String>& newCallbackSelectors = |
| 2005 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2021 newStyle ? newStyle->callbackSelectors() : emptyVector; |
| (...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4080 } | 4096 } |
| 4081 | 4097 |
| 4082 DEFINE_TRACE_WRAPPERS(Element) { | 4098 DEFINE_TRACE_WRAPPERS(Element) { |
| 4083 if (hasRareData()) { | 4099 if (hasRareData()) { |
| 4084 visitor->traceWrappers(elementRareData()); | 4100 visitor->traceWrappers(elementRareData()); |
| 4085 } | 4101 } |
| 4086 ContainerNode::traceWrappers(visitor); | 4102 ContainerNode::traceWrappers(visitor); |
| 4087 } | 4103 } |
| 4088 | 4104 |
| 4089 } // namespace blink | 4105 } // namespace blink |
| OLD | NEW |