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 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 isInTopLayer()); | 1828 isInTopLayer()); |
1829 | 1829 |
1830 return style.release(); | 1830 return style.release(); |
1831 } | 1831 } |
1832 | 1832 |
1833 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() { | 1833 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() { |
1834 DCHECK(document().inStyleRecalc()); | 1834 DCHECK(document().inStyleRecalc()); |
1835 return document().ensureStyleResolver().styleForElement(this); | 1835 return document().ensureStyleResolver().styleForElement(this); |
1836 } | 1836 } |
1837 | 1837 |
1838 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) { | 1838 void Element::recalcStyle(StyleRecalcChange change) { |
1839 DCHECK(document().inStyleRecalc()); | 1839 DCHECK(document().inStyleRecalc()); |
1840 DCHECK(!document().lifecycle().inDetach()); | 1840 DCHECK(!document().lifecycle().inDetach()); |
1841 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1841 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
1842 DCHECK(inActiveDocument()); | 1842 DCHECK(inActiveDocument()); |
1843 | 1843 |
1844 if (hasCustomStyleCallbacks()) | 1844 if (hasCustomStyleCallbacks()) |
1845 willRecalcStyle(change); | 1845 willRecalcStyle(change); |
1846 | 1846 |
1847 if (change >= IndependentInherit || needsStyleRecalc()) { | 1847 if (change >= IndependentInherit || needsStyleRecalc()) { |
1848 if (hasRareData()) { | 1848 if (hasRareData()) { |
1849 ElementRareData* data = elementRareData(); | 1849 ElementRareData* data = elementRareData(); |
1850 if (change != IndependentInherit) | 1850 if (change != IndependentInherit) |
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(); |
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 DCHECK(inActiveDocument()); |
1990 AttachContext reattachContext; | 1991 AttachContext reattachContext; |
1991 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 1992 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); |
1992 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 1993 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
| 1994 |
| 1995 // We are calling Element::rebuildLayoutTree() from inside |
| 1996 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree |
| 1997 // flag - so needsReattachLayoutTree() should always be true. |
| 1998 DCHECK(parentNode()); |
| 1999 DCHECK(parentNode()->childNeedsReattachLayoutTree()); |
| 2000 DCHECK(needsReattachLayoutTree()); |
1993 reattachLayoutTree(reattachContext); | 2001 reattachLayoutTree(reattachContext); |
1994 if (layoutObjectWillChange || layoutObject()) | 2002 // Since needsReattachLayoutTree() is always true we go into |
| 2003 // reattachLayoutTree() which reattaches all the descendant |
| 2004 // sub-trees. At this point no child should need reattaching. |
| 2005 DCHECK(!childNeedsReattachLayoutTree()); |
| 2006 |
| 2007 if (layoutObjectWillChange || layoutObject()) { |
| 2008 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
| 2009 // we can either traverse the current subtree from this node onwards |
| 2010 // or store it. |
| 2011 // The choice is between increased time and increased memory complexity. |
| 2012 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); |
1995 return Reattach; | 2013 return Reattach; |
| 2014 } |
1996 return ReattachNoLayoutObject; | 2015 return ReattachNoLayoutObject; |
1997 } | 2016 } |
1998 | 2017 |
1999 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2018 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
2000 const ComputedStyle* newStyle) { | 2019 const ComputedStyle* newStyle) { |
2001 Vector<String> emptyVector; | 2020 Vector<String> emptyVector; |
2002 const Vector<String>& oldCallbackSelectors = | 2021 const Vector<String>& oldCallbackSelectors = |
2003 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2022 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
2004 const Vector<String>& newCallbackSelectors = | 2023 const Vector<String>& newCallbackSelectors = |
2005 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2024 newStyle ? newStyle->callbackSelectors() : emptyVector; |
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4080 } | 4099 } |
4081 | 4100 |
4082 DEFINE_TRACE_WRAPPERS(Element) { | 4101 DEFINE_TRACE_WRAPPERS(Element) { |
4083 if (hasRareData()) { | 4102 if (hasRareData()) { |
4084 visitor->traceWrappers(elementRareData()); | 4103 visitor->traceWrappers(elementRareData()); |
4085 } | 4104 } |
4086 ContainerNode::traceWrappers(visitor); | 4105 ContainerNode::traceWrappers(visitor); |
4087 } | 4106 } |
4088 | 4107 |
4089 } // namespace blink | 4108 } // namespace blink |
OLD | NEW |