| 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 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 isInTopLayer()); | 1829 isInTopLayer()); |
| 1830 | 1830 |
| 1831 return style.release(); | 1831 return style.release(); |
| 1832 } | 1832 } |
| 1833 | 1833 |
| 1834 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() { | 1834 PassRefPtr<ComputedStyle> Element::originalStyleForLayoutObject() { |
| 1835 DCHECK(document().inStyleRecalc()); | 1835 DCHECK(document().inStyleRecalc()); |
| 1836 return document().ensureStyleResolver().styleForElement(this); | 1836 return document().ensureStyleResolver().styleForElement(this); |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 void Element::recalcStyle(StyleRecalcChange change) { | 1839 void Element::recalcStyle(StyleRecalcChange change, Text* nextTextSibling) { |
| 1840 DCHECK(document().inStyleRecalc()); | 1840 DCHECK(document().inStyleRecalc()); |
| 1841 DCHECK(!document().lifecycle().inDetach()); | 1841 DCHECK(!document().lifecycle().inDetach()); |
| 1842 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1842 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1843 DCHECK(inActiveDocument()); | 1843 DCHECK(inActiveDocument()); |
| 1844 | 1844 |
| 1845 if (hasCustomStyleCallbacks()) | 1845 if (hasCustomStyleCallbacks()) |
| 1846 willRecalcStyle(change); | 1846 willRecalcStyle(change); |
| 1847 | 1847 |
| 1848 if (change >= IndependentInherit || needsStyleRecalc()) { | 1848 if (change >= IndependentInherit || needsStyleRecalc()) { |
| 1849 if (hasRareData()) { | 1849 if (hasRareData()) { |
| 1850 ElementRareData* data = elementRareData(); | 1850 ElementRareData* data = elementRareData(); |
| 1851 if (change != IndependentInherit) | 1851 if (change != IndependentInherit) |
| 1852 data->clearComputedStyle(); | 1852 data->clearComputedStyle(); |
| 1853 | 1853 |
| 1854 if (change >= IndependentInherit) { | 1854 if (change >= IndependentInherit) { |
| 1855 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1855 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
| 1856 elementAnimations->setAnimationStyleChange(false); | 1856 elementAnimations->setAnimationStyleChange(false); |
| 1857 } | 1857 } |
| 1858 } | 1858 } |
| 1859 if (parentComputedStyle()) | 1859 if (parentComputedStyle()) |
| 1860 change = recalcOwnStyle(change); | 1860 change = recalcOwnStyle(change, nextTextSibling); |
| 1861 clearNeedsStyleRecalc(); | 1861 clearNeedsStyleRecalc(); |
| 1862 clearNeedsReattachLayoutTree(); | 1862 clearNeedsReattachLayoutTree(); |
| 1863 } | 1863 } |
| 1864 | 1864 |
| 1865 // If we reattached we don't need to recalc the style of our descendants | 1865 // If we reattached we don't need to recalc the style of our descendants |
| 1866 // anymore. | 1866 // anymore. |
| 1867 if ((change >= UpdatePseudoElements && change < Reattach) || | 1867 if ((change >= UpdatePseudoElements && change < Reattach) || |
| 1868 childNeedsStyleRecalc()) { | 1868 childNeedsStyleRecalc()) { |
| 1869 SelectorFilterParentScope filterScope(*this); | 1869 SelectorFilterParentScope filterScope(*this); |
| 1870 StyleSharingDepthScope sharingScope(*this); | 1870 StyleSharingDepthScope sharingScope(*this); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 const ComputedStyle* style = computedStyle(); | 1911 const ComputedStyle* style = computedStyle(); |
| 1912 if (!style || style->animations() || style->transitions()) | 1912 if (!style || style->animations() || style->transitions()) |
| 1913 return nullptr; | 1913 return nullptr; |
| 1914 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); | 1914 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(*style); |
| 1915 newStyle->propagateIndependentInheritedProperties(*parentStyle); | 1915 newStyle->propagateIndependentInheritedProperties(*parentStyle); |
| 1916 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), | 1916 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), |
| 1917 independentInheritedStylesPropagated, 1); | 1917 independentInheritedStylesPropagated, 1); |
| 1918 return newStyle; | 1918 return newStyle; |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change) { | 1921 StyleRecalcChange Element::recalcOwnStyle(StyleRecalcChange change, |
| 1922 Text* nextTextSibling) { |
| 1922 DCHECK(document().inStyleRecalc()); | 1923 DCHECK(document().inStyleRecalc()); |
| 1923 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); | 1924 DCHECK(!parentOrShadowHostNode()->needsStyleRecalc()); |
| 1924 DCHECK(change >= IndependentInherit || needsStyleRecalc()); | 1925 DCHECK(change >= IndependentInherit || needsStyleRecalc()); |
| 1925 DCHECK(parentComputedStyle()); | 1926 DCHECK(parentComputedStyle()); |
| 1926 | 1927 |
| 1927 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); | 1928 RefPtr<ComputedStyle> oldStyle = mutableComputedStyle(); |
| 1928 | 1929 |
| 1929 // When propagating inherited changes, we don't need to do a full style recalc | 1930 // When propagating inherited changes, we don't need to do a full style recalc |
| 1930 // if the only changed properties are independent. In this case, we can simply | 1931 // if the only changed properties are independent. In this case, we can simply |
| 1931 // set these directly on the ComputedStyle object. | 1932 // set these directly on the ComputedStyle object. |
| 1932 RefPtr<ComputedStyle> newStyle = propagateInheritedProperties(change); | 1933 RefPtr<ComputedStyle> newStyle = propagateInheritedProperties(change); |
| 1933 if (!newStyle) | 1934 if (!newStyle) |
| 1934 newStyle = styleForLayoutObject(); | 1935 newStyle = styleForLayoutObject(); |
| 1935 DCHECK(newStyle); | 1936 DCHECK(newStyle); |
| 1936 | 1937 |
| 1937 StyleRecalcChange localChange = | 1938 StyleRecalcChange localChange = |
| 1938 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); | 1939 ComputedStyle::stylePropagationDiff(oldStyle.get(), newStyle.get()); |
| 1939 if (localChange == NoChange) { | 1940 if (localChange == NoChange) { |
| 1940 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); | 1941 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesUnchanged, 1); |
| 1941 } else { | 1942 } else { |
| 1942 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1943 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
| 1943 } | 1944 } |
| 1944 | 1945 |
| 1945 if (localChange == Reattach) { | 1946 if (localChange == Reattach) { |
| 1946 document().addNonAttachedStyle(*this, std::move(newStyle)); | 1947 document().addStyleRecalcData( |
| 1948 *this, new StyleRecalcData(std::move(newStyle), nextTextSibling)); |
| 1947 setNeedsReattachLayoutTree(); | 1949 setNeedsReattachLayoutTree(); |
| 1948 return rebuildLayoutTree(); | 1950 return rebuildLayoutTree(); |
| 1949 } | 1951 } |
| 1950 | 1952 |
| 1951 DCHECK(oldStyle); | 1953 DCHECK(oldStyle); |
| 1952 | 1954 |
| 1953 if (localChange != NoChange) | 1955 if (localChange != NoChange) |
| 1954 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1956 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
| 1955 | 1957 |
| 1956 if (LayoutObject* layoutObject = this->layoutObject()) { | 1958 if (LayoutObject* layoutObject = this->layoutObject()) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1982 } | 1984 } |
| 1983 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 1985 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
| 1984 return UpdatePseudoElements; | 1986 return UpdatePseudoElements; |
| 1985 } | 1987 } |
| 1986 | 1988 |
| 1987 return localChange; | 1989 return localChange; |
| 1988 } | 1990 } |
| 1989 | 1991 |
| 1990 StyleRecalcChange Element::rebuildLayoutTree() { | 1992 StyleRecalcChange Element::rebuildLayoutTree() { |
| 1991 DCHECK(inActiveDocument()); | 1993 DCHECK(inActiveDocument()); |
| 1994 StyleRecalcData* styleRecalcData = document().getStyleRecalcData(*this); |
| 1992 AttachContext reattachContext; | 1995 AttachContext reattachContext; |
| 1993 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 1996 reattachContext.resolvedStyle = styleRecalcData->computedStyle.get(); |
| 1994 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 1997 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
| 1995 | 1998 |
| 1996 // We are calling Element::rebuildLayoutTree() from inside | 1999 // We are calling Element::rebuildLayoutTree() from inside |
| 1997 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | 2000 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree |
| 1998 // flag - so needsReattachLayoutTree() should always be true. | 2001 // flag - so needsReattachLayoutTree() should always be true. |
| 1999 DCHECK(parentNode()); | 2002 DCHECK(parentNode()); |
| 2000 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | 2003 DCHECK(parentNode()->childNeedsReattachLayoutTree()); |
| 2001 DCHECK(needsReattachLayoutTree()); | 2004 DCHECK(needsReattachLayoutTree()); |
| 2002 reattachLayoutTree(reattachContext); | 2005 reattachLayoutTree(reattachContext); |
| 2003 // Since needsReattachLayoutTree() is always true we go into | 2006 // Since needsReattachLayoutTree() is always true we go into |
| 2004 // reattachLayoutTree() which reattaches all the descendant | 2007 // reattachLayoutTree() which reattaches all the descendant |
| 2005 // sub-trees. At this point no child should need reattaching. | 2008 // sub-trees. At this point no child should need reattaching. |
| 2006 DCHECK(!childNeedsReattachLayoutTree()); | 2009 DCHECK(!childNeedsReattachLayoutTree()); |
| 2007 | 2010 |
| 2008 if (layoutObjectWillChange || layoutObject()) { | 2011 if (layoutObjectWillChange || layoutObject()) { |
| 2009 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | 2012 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
| 2010 // we can either traverse the current subtree from this node onwards | 2013 // we can either traverse the current subtree from this node onwards |
| 2011 // or store it. | 2014 // or store it. |
| 2012 // The choice is between increased time and increased memory complexity. | 2015 // The choice is between increased time and increased memory complexity. |
| 2013 reattachWhitespaceSiblingsIfNeeded(nextTextSibling()); | 2016 reattachWhitespaceSiblingsIfNeeded(styleRecalcData->nextTextSibling); |
| 2014 return Reattach; | 2017 return Reattach; |
| 2015 } | 2018 } |
| 2016 return ReattachNoLayoutObject; | 2019 return ReattachNoLayoutObject; |
| 2017 } | 2020 } |
| 2018 | 2021 |
| 2019 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2022 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
| 2020 const ComputedStyle* newStyle) { | 2023 const ComputedStyle* newStyle) { |
| 2021 Vector<String> emptyVector; | 2024 Vector<String> emptyVector; |
| 2022 const Vector<String>& oldCallbackSelectors = | 2025 const Vector<String>& oldCallbackSelectors = |
| 2023 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2026 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
| (...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4088 } | 4091 } |
| 4089 | 4092 |
| 4090 DEFINE_TRACE_WRAPPERS(Element) { | 4093 DEFINE_TRACE_WRAPPERS(Element) { |
| 4091 if (hasRareData()) { | 4094 if (hasRareData()) { |
| 4092 visitor->traceWrappers(elementRareData()); | 4095 visitor->traceWrappers(elementRareData()); |
| 4093 } | 4096 } |
| 4094 ContainerNode::traceWrappers(visitor); | 4097 ContainerNode::traceWrappers(visitor); |
| 4095 } | 4098 } |
| 4096 | 4099 |
| 4097 } // namespace blink | 4100 } // namespace blink |
| OLD | NEW |