| 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) { | 1838 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) { |
| 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(); | |
| 1862 } | 1861 } |
| 1863 | 1862 |
| 1864 // If we reattached we don't need to recalc the style of our descendants | 1863 // If we reattached we don't need to recalc the style of our descendants |
| 1865 // anymore. | 1864 // anymore. |
| 1866 if ((change >= UpdatePseudoElements && change < Reattach) || | 1865 if ((change >= UpdatePseudoElements && change < Reattach) || |
| 1867 childNeedsStyleRecalc()) { | 1866 childNeedsStyleRecalc()) { |
| 1868 SelectorFilterParentScope filterScope(*this); | 1867 SelectorFilterParentScope filterScope(*this); |
| 1869 StyleSharingDepthScope sharingScope(*this); | 1868 StyleSharingDepthScope sharingScope(*this); |
| 1870 | 1869 |
| 1871 updatePseudoElement(PseudoIdBefore, change); | 1870 updatePseudoElement(PseudoIdBefore, change); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1883 updatePseudoElement(PseudoIdBackdrop, change); | 1882 updatePseudoElement(PseudoIdBackdrop, change); |
| 1884 | 1883 |
| 1885 // 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 |
| 1886 // 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. |
| 1887 // This can be seen when a child transitions from floating to | 1886 // This can be seen when a child transitions from floating to |
| 1888 // 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. |
| 1889 updatePseudoElement(PseudoIdFirstLetter, | 1888 updatePseudoElement(PseudoIdFirstLetter, |
| 1890 childNeedsStyleRecalc() ? Force : change); | 1889 childNeedsStyleRecalc() ? Force : change); |
| 1891 | 1890 |
| 1892 clearChildNeedsStyleRecalc(); | 1891 clearChildNeedsStyleRecalc(); |
| 1893 clearChildNeedsReattachLayoutTree(); | |
| 1894 } | 1892 } |
| 1895 | 1893 |
| 1896 if (hasCustomStyleCallbacks()) | 1894 if (hasCustomStyleCallbacks()) |
| 1897 didRecalcStyle(change); | 1895 didRecalcStyle(change); |
| 1896 |
| 1897 if (change == Reattach) |
| 1898 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
| 1898 } | 1899 } |
| 1899 | 1900 |
| 1900 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1901 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
| 1901 StyleRecalcChange change) { | 1902 StyleRecalcChange change) { |
| 1902 if (change != IndependentInherit) | 1903 if (change != IndependentInherit) |
| 1903 return nullptr; | 1904 return nullptr; |
| 1904 if (needsStyleRecalc()) | 1905 if (needsStyleRecalc()) |
| 1905 return nullptr; | 1906 return nullptr; |
| 1906 if (hasAnimations()) | 1907 if (hasAnimations()) |
| 1907 return nullptr; | 1908 return nullptr; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1936 StyleRecalcChange localChange = | 1937 StyleRecalcChange localChange = |
| 1937 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); | 1938 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
| 1938 if (localChange == NoChange) { | 1939 if (localChange == NoChange) { |
| 1939 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); | 1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); |
| 1940 } else { | 1941 } else { |
| 1941 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1942 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
| 1942 } | 1943 } |
| 1943 | 1944 |
| 1944 if (localChange == Reattach) { | 1945 if (localChange == Reattach) { |
| 1945 document().addNonAttachedStyle(*this, std::move(newStyle)); | 1946 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()); | |
| 1991 AttachContext reattachContext; | 1990 AttachContext reattachContext; |
| 1992 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 1991 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); |
| 1993 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 1992 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()); | |
| 2001 reattachLayoutTree(reattachContext); | 1993 reattachLayoutTree(reattachContext); |
| 2002 // Since needsReattachLayoutTree() is always true we go into | 1994 if (layoutObjectWillChange || layoutObject()) |
| 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()); | |
| 2013 return Reattach; | 1995 return Reattach; |
| 2014 } | |
| 2015 return ReattachNoLayoutObject; | 1996 return ReattachNoLayoutObject; |
| 2016 } | 1997 } |
| 2017 | 1998 |
| 2018 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 1999 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
| 2019 const ComputedStyle* newStyle) { | 2000 const ComputedStyle* newStyle) { |
| 2020 Vector<String> emptyVector; | 2001 Vector<String> emptyVector; |
| 2021 const Vector<String>& oldCallbackSelectors = | 2002 const Vector<String>& oldCallbackSelectors = |
| 2022 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2003 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
| 2023 const Vector<String>& newCallbackSelectors = | 2004 const Vector<String>& newCallbackSelectors = |
| 2024 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2005 newStyle ? newStyle->callbackSelectors() : emptyVector; |
| (...skipping 2070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 } | 4076 } |
| 4096 | 4077 |
| 4097 DEFINE_TRACE_WRAPPERS(Element) { | 4078 DEFINE_TRACE_WRAPPERS(Element) { |
| 4098 if (hasRareData()) { | 4079 if (hasRareData()) { |
| 4099 visitor->traceWrappers(elementRareData()); | 4080 visitor->traceWrappers(elementRareData()); |
| 4100 } | 4081 } |
| 4101 ContainerNode::traceWrappers(visitor); | 4082 ContainerNode::traceWrappers(visitor); |
| 4102 } | 4083 } |
| 4103 | 4084 |
| 4104 } // namespace blink | 4085 } // namespace blink |
| OLD | NEW |