| 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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1862 if (hasRareData()) { | 1862 if (hasRareData()) { |
| 1863 ElementRareData* data = elementRareData(); | 1863 ElementRareData* data = elementRareData(); |
| 1864 if (change != IndependentInherit) | 1864 if (change != IndependentInherit) |
| 1865 data->clearComputedStyle(); | 1865 data->clearComputedStyle(); |
| 1866 | 1866 |
| 1867 if (change >= IndependentInherit) { | 1867 if (change >= IndependentInherit) { |
| 1868 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1868 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
| 1869 elementAnimations->setAnimationStyleChange(false); | 1869 elementAnimations->setAnimationStyleChange(false); |
| 1870 } | 1870 } |
| 1871 } | 1871 } |
| 1872 if (parentComputedStyle()) | 1872 if (parentComputedStyle()) { |
| 1873 change = recalcOwnStyle(change, nextTextSibling); | 1873 change = recalcOwnStyle(change, nextTextSibling); |
| 1874 } else { |
| 1875 // In case we don't perform recalcOwnStyle we will never clear the |
| 1876 // NeedsReattachLayoutTree flag which is set on the creation of each |
| 1877 // Node. Clear that here. |
| 1878 clearNeedsReattachLayoutTree(); |
| 1879 } |
| 1874 clearNeedsStyleRecalc(); | 1880 clearNeedsStyleRecalc(); |
| 1875 clearNeedsReattachLayoutTree(); | |
| 1876 } | 1881 } |
| 1877 | 1882 |
| 1878 // If we reattached we don't need to recalc the style of our descendants | 1883 // If we reattached we don't need to recalc the style of our descendants |
| 1879 // anymore. | 1884 // anymore. |
| 1880 if ((change >= UpdatePseudoElements && change < Reattach) || | 1885 if (change < Reattach && |
| 1881 childNeedsStyleRecalc()) { | 1886 (change >= UpdatePseudoElements || childNeedsStyleRecalc())) { |
| 1882 SelectorFilterParentScope filterScope(*this); | 1887 SelectorFilterParentScope filterScope(*this); |
| 1883 StyleSharingDepthScope sharingScope(*this); | 1888 StyleSharingDepthScope sharingScope(*this); |
| 1884 | 1889 |
| 1885 updatePseudoElement(PseudoIdBefore, change); | 1890 updatePseudoElement(PseudoIdBefore, change); |
| 1886 | 1891 |
| 1887 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1892 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
| 1888 for (ShadowRoot* root = youngestShadowRoot(); root; | 1893 for (ShadowRoot* root = youngestShadowRoot(); root; |
| 1889 root = root->olderShadowRoot()) { | 1894 root = root->olderShadowRoot()) { |
| 1890 if (root->shouldCallRecalcStyle(change)) | 1895 if (root->shouldCallRecalcStyle(change)) |
| 1891 root->recalcStyle(change); | 1896 root->recalcStyle(change); |
| 1892 } | 1897 } |
| 1893 recalcDescendantStyles(change); | 1898 recalcDescendantStyles(change); |
| 1894 } | 1899 } |
| 1895 | 1900 |
| 1896 updatePseudoElement(PseudoIdAfter, change); | 1901 updatePseudoElement(PseudoIdAfter, change); |
| 1897 updatePseudoElement(PseudoIdBackdrop, change); | 1902 updatePseudoElement(PseudoIdBackdrop, change); |
| 1898 | 1903 |
| 1899 // If our children have changed then we need to force the first-letter | 1904 // If our children have changed then we need to force the first-letter |
| 1900 // checks as we don't know if they effected the first letter or not. | 1905 // checks as we don't know if they effected the first letter or not. |
| 1901 // This can be seen when a child transitions from floating to | 1906 // This can be seen when a child transitions from floating to |
| 1902 // non-floating we have to take it into account for the first letter. | 1907 // non-floating we have to take it into account for the first letter. |
| 1903 updatePseudoElement(PseudoIdFirstLetter, | 1908 updatePseudoElement(PseudoIdFirstLetter, |
| 1904 childNeedsStyleRecalc() ? Force : change); | 1909 childNeedsStyleRecalc() ? Force : change); |
| 1905 | 1910 |
| 1906 clearChildNeedsStyleRecalc(); | 1911 clearChildNeedsStyleRecalc(); |
| 1907 clearChildNeedsReattachLayoutTree(); | |
| 1908 } | 1912 } |
| 1909 | 1913 |
| 1910 if (hasCustomStyleCallbacks()) | 1914 if (hasCustomStyleCallbacks()) |
| 1911 didRecalcStyle(change); | 1915 didRecalcStyle(change); |
| 1912 } | 1916 } |
| 1913 | 1917 |
| 1914 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1918 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
| 1915 StyleRecalcChange change) { | 1919 StyleRecalcChange change) { |
| 1916 if (change != IndependentInherit) | 1920 if (change != IndependentInherit) |
| 1917 return nullptr; | 1921 return nullptr; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1957 } else { | 1961 } else { |
| 1958 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1962 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
| 1959 } | 1963 } |
| 1960 | 1964 |
| 1961 if (localChange == Reattach) { | 1965 if (localChange == Reattach) { |
| 1962 StyleReattachData styleReattachData; | 1966 StyleReattachData styleReattachData; |
| 1963 styleReattachData.computedStyle = std::move(newStyle); | 1967 styleReattachData.computedStyle = std::move(newStyle); |
| 1964 styleReattachData.nextTextSibling = nextTextSibling; | 1968 styleReattachData.nextTextSibling = nextTextSibling; |
| 1965 document().addStyleReattachData(*this, styleReattachData); | 1969 document().addStyleReattachData(*this, styleReattachData); |
| 1966 setNeedsReattachLayoutTree(); | 1970 setNeedsReattachLayoutTree(); |
| 1967 return rebuildLayoutTree(); | 1971 return Reattach; |
| 1968 } | 1972 } |
| 1969 | 1973 |
| 1970 DCHECK(oldStyle); | 1974 DCHECK(oldStyle); |
| 1971 | 1975 |
| 1972 if (localChange != NoChange) | 1976 if (localChange != NoChange) |
| 1973 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1977 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
| 1974 | 1978 |
| 1975 if (LayoutObject* layoutObject = this->layoutObject()) { | 1979 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 1976 if (localChange != NoChange || | 1980 if (localChange != NoChange || |
| 1977 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { | 1981 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1998 return Inherit; | 2002 return Inherit; |
| 1999 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 2003 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
| 2000 } | 2004 } |
| 2001 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 2005 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
| 2002 return UpdatePseudoElements; | 2006 return UpdatePseudoElements; |
| 2003 } | 2007 } |
| 2004 | 2008 |
| 2005 return localChange; | 2009 return localChange; |
| 2006 } | 2010 } |
| 2007 | 2011 |
| 2008 StyleRecalcChange Element::rebuildLayoutTree() { | 2012 void Element::rebuildLayoutTree() { |
| 2009 DCHECK(inActiveDocument()); | 2013 DCHECK(inActiveDocument()); |
| 2014 DCHECK(!needsStyleRecalc()); |
| 2015 DCHECK(parentNode()); |
| 2016 |
| 2010 StyleReattachData styleReattachData = document().getStyleReattachData(*this); | 2017 StyleReattachData styleReattachData = document().getStyleReattachData(*this); |
| 2011 AttachContext reattachContext; | 2018 AttachContext reattachContext; |
| 2012 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); | 2019 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); |
| 2013 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 2020 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
| 2014 | 2021 |
| 2015 // We are calling Element::rebuildLayoutTree() from inside | 2022 if (needsReattachLayoutTree()) { |
| 2016 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | 2023 reattachLayoutTree(reattachContext); |
| 2017 // flag - so needsReattachLayoutTree() should always be true. | 2024 } else if (childNeedsReattachLayoutTree()) { |
| 2018 DCHECK(parentNode()); | 2025 SelectorFilterParentScope filterScope(*this); |
| 2019 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | 2026 StyleSharingDepthScope sharingScope(*this); |
| 2020 DCHECK(needsReattachLayoutTree()); | 2027 reattachPseudoElementLayoutTree(PseudoIdBefore); |
| 2021 reattachLayoutTree(reattachContext); | 2028 rebuildShadowRootLayoutTree(); |
| 2022 // Since needsReattachLayoutTree() is always true we go into | 2029 rebuildChildrenLayoutTrees(); |
| 2023 // reattachLayoutTree() which reattaches all the descendant | 2030 reattachPseudoElementLayoutTree(PseudoIdAfter); |
| 2024 // sub-trees. At this point no child should need reattaching. | 2031 reattachPseudoElementLayoutTree(PseudoIdBackdrop); |
| 2032 reattachPseudoElementLayoutTree(PseudoIdFirstLetter); |
| 2033 } |
| 2034 DCHECK(!needsReattachLayoutTree()); |
| 2025 DCHECK(!childNeedsReattachLayoutTree()); | 2035 DCHECK(!childNeedsReattachLayoutTree()); |
| 2026 | 2036 |
| 2027 if (layoutObjectWillChange || layoutObject()) { | 2037 if (layoutObjectWillChange || layoutObject()) { |
| 2028 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | 2038 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
| 2029 // we can either traverse the current subtree from this node onwards | 2039 // we can either traverse the current subtree from this node onwards |
| 2030 // or store it. | 2040 // or store it. |
| 2031 // The choice is between increased time and increased memory complexity. | 2041 // The choice is between increased time and increased memory complexity. |
| 2032 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); | 2042 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); |
| 2033 return Reattach; | |
| 2034 } | 2043 } |
| 2035 return ReattachNoLayoutObject; | 2044 } |
| 2045 |
| 2046 void Element::rebuildShadowRootLayoutTree() { |
| 2047 DCHECK(!needsStyleRecalc()); |
| 2048 DCHECK(!childNeedsStyleRecalc()); |
| 2049 DCHECK(!needsReattachLayoutTree()); |
| 2050 for (ShadowRoot* root = youngestShadowRoot(); root; |
| 2051 root = root->olderShadowRoot()) { |
| 2052 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) |
| 2053 root->rebuildLayoutTree(); |
| 2054 } |
| 2055 } |
| 2056 |
| 2057 void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { |
| 2058 DCHECK(!needsStyleRecalc()); |
| 2059 DCHECK(!childNeedsStyleRecalc()); |
| 2060 DCHECK(!needsReattachLayoutTree()); |
| 2061 if (PseudoElement* element = pseudoElement(pseudoId)) { |
| 2062 if (element->needsReattachLayoutTree() || |
| 2063 element->childNeedsReattachLayoutTree()) |
| 2064 element->rebuildLayoutTree(); |
| 2065 } else { |
| 2066 createPseudoElementIfNeeded(pseudoId); |
| 2067 } |
| 2036 } | 2068 } |
| 2037 | 2069 |
| 2038 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2070 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
| 2039 const ComputedStyle* newStyle) { | 2071 const ComputedStyle* newStyle) { |
| 2040 Vector<String> emptyVector; | 2072 Vector<String> emptyVector; |
| 2041 const Vector<String>& oldCallbackSelectors = | 2073 const Vector<String>& oldCallbackSelectors = |
| 2042 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2074 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
| 2043 const Vector<String>& newCallbackSelectors = | 2075 const Vector<String>& newCallbackSelectors = |
| 2044 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2076 newStyle ? newStyle->callbackSelectors() : emptyVector; |
| 2045 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) | 2077 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4112 } | 4144 } |
| 4113 | 4145 |
| 4114 DEFINE_TRACE_WRAPPERS(Element) { | 4146 DEFINE_TRACE_WRAPPERS(Element) { |
| 4115 if (hasRareData()) { | 4147 if (hasRareData()) { |
| 4116 visitor->traceWrappers(elementRareData()); | 4148 visitor->traceWrappers(elementRareData()); |
| 4117 } | 4149 } |
| 4118 ContainerNode::traceWrappers(visitor); | 4150 ContainerNode::traceWrappers(visitor); |
| 4119 } | 4151 } |
| 4120 | 4152 |
| 4121 } // namespace blink | 4153 } // namespace blink |
| OLD | NEW |