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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, nextTextSibling); | 1859 change = recalcOwnStyle(change, nextTextSibling); |
1860 } else { | |
1861 // In case we don't perform recalcOwnStyle we will never clear the | |
1862 // NeedsReattachLayoutTree flag which is set on the creation of each | |
1863 // Node. Clear that here. | |
1864 clearNeedsReattachLayoutTree(); | |
1865 } | |
1860 clearNeedsStyleRecalc(); | 1866 clearNeedsStyleRecalc(); |
1861 clearNeedsReattachLayoutTree(); | |
1862 } | 1867 } |
1863 | 1868 |
1864 // If we reattached we don't need to recalc the style of our descendants | 1869 // If we reattached we don't need to recalc the style of our descendants |
1865 // anymore. | 1870 // anymore. |
1866 if ((change >= UpdatePseudoElements && change < Reattach) || | 1871 if ((change >= UpdatePseudoElements && change < Reattach) || |
1867 childNeedsStyleRecalc()) { | 1872 childNeedsStyleRecalc()) { |
1868 SelectorFilterParentScope filterScope(*this); | 1873 SelectorFilterParentScope filterScope(*this); |
1869 StyleSharingDepthScope sharingScope(*this); | 1874 StyleSharingDepthScope sharingScope(*this); |
1870 | 1875 |
1871 updatePseudoElement(PseudoIdBefore, change); | 1876 updatePseudoElement(PseudoIdBefore, change); |
1872 | 1877 |
1873 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1878 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
1874 for (ShadowRoot* root = youngestShadowRoot(); root; | 1879 for (ShadowRoot* root = youngestShadowRoot(); root; |
1875 root = root->olderShadowRoot()) { | 1880 root = root->olderShadowRoot()) { |
1876 if (root->shouldCallRecalcStyle(change)) | 1881 if (root->shouldCallRecalcStyle(change)) |
1877 root->recalcStyle(change); | 1882 root->recalcStyle(change); |
1883 else | |
nainar
2016/12/15 01:25:33
In case we don't perform ShadowRoot::recalcStyle w
| |
1884 root->clearNeedsReattachLayoutTree(); | |
1878 } | 1885 } |
1879 recalcDescendantStyles(change); | 1886 recalcDescendantStyles(change); |
1880 } | 1887 } |
1881 | 1888 |
1882 updatePseudoElement(PseudoIdAfter, change); | 1889 updatePseudoElement(PseudoIdAfter, change); |
1883 updatePseudoElement(PseudoIdBackdrop, change); | 1890 updatePseudoElement(PseudoIdBackdrop, change); |
1884 | 1891 |
1885 // If our children have changed then we need to force the first-letter | 1892 // 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. | 1893 // 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 | 1894 // 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. | 1895 // non-floating we have to take it into account for the first letter. |
1889 updatePseudoElement(PseudoIdFirstLetter, | 1896 updatePseudoElement(PseudoIdFirstLetter, |
1890 childNeedsStyleRecalc() ? Force : change); | 1897 childNeedsStyleRecalc() ? Force : change); |
1891 | 1898 |
1892 clearChildNeedsStyleRecalc(); | 1899 clearChildNeedsStyleRecalc(); |
1893 clearChildNeedsReattachLayoutTree(); | |
1894 } | 1900 } |
1895 | 1901 |
1896 if (hasCustomStyleCallbacks()) | 1902 if (hasCustomStyleCallbacks()) |
1897 didRecalcStyle(change); | 1903 didRecalcStyle(change); |
1898 } | 1904 } |
1899 | 1905 |
1900 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1906 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
1901 StyleRecalcChange change) { | 1907 StyleRecalcChange change) { |
1902 if (change != IndependentInherit) | 1908 if (change != IndependentInherit) |
1903 return nullptr; | 1909 return nullptr; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1943 } else { | 1949 } else { |
1944 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1950 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
1945 } | 1951 } |
1946 | 1952 |
1947 if (localChange == Reattach) { | 1953 if (localChange == Reattach) { |
1948 StyleReattachData styleReattachData; | 1954 StyleReattachData styleReattachData; |
1949 styleReattachData.computedStyle = std::move(newStyle); | 1955 styleReattachData.computedStyle = std::move(newStyle); |
1950 styleReattachData.nextTextSibling = nextTextSibling; | 1956 styleReattachData.nextTextSibling = nextTextSibling; |
1951 document().addStyleReattachData(*this, styleReattachData); | 1957 document().addStyleReattachData(*this, styleReattachData); |
1952 setNeedsReattachLayoutTree(); | 1958 setNeedsReattachLayoutTree(); |
1953 return rebuildLayoutTree(); | 1959 return Reattach; |
1954 } | 1960 } |
1955 | 1961 |
1956 DCHECK(oldStyle); | 1962 DCHECK(oldStyle); |
1957 | 1963 |
1958 if (localChange != NoChange) | 1964 if (localChange != NoChange) |
1959 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 1965 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
1960 | 1966 |
1961 if (LayoutObject* layoutObject = this->layoutObject()) { | 1967 if (LayoutObject* layoutObject = this->layoutObject()) { |
1962 if (localChange != NoChange || | 1968 if (localChange != NoChange || |
1963 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { | 1969 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { |
(...skipping 20 matching lines...) Expand all Loading... | |
1984 return Inherit; | 1990 return Inherit; |
1985 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 1991 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
1986 } | 1992 } |
1987 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 1993 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
1988 return UpdatePseudoElements; | 1994 return UpdatePseudoElements; |
1989 } | 1995 } |
1990 | 1996 |
1991 return localChange; | 1997 return localChange; |
1992 } | 1998 } |
1993 | 1999 |
1994 StyleRecalcChange Element::rebuildLayoutTree() { | 2000 void Element::rebuildLayoutTree() { |
1995 DCHECK(inActiveDocument()); | 2001 DCHECK(inActiveDocument()); |
2002 DCHECK(!needsStyleRecalc()); | |
2003 DCHECK(!childNeedsStyleRecalc()); | |
2004 DCHECK(parentNode()); | |
2005 | |
1996 StyleReattachData styleReattachData = document().getStyleReattachData(*this); | 2006 StyleReattachData styleReattachData = document().getStyleReattachData(*this); |
1997 AttachContext reattachContext; | 2007 AttachContext reattachContext; |
1998 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); | 2008 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); |
1999 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 2009 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
2000 | 2010 |
2001 // We are calling Element::rebuildLayoutTree() from inside | 2011 if (needsReattachLayoutTree()) { |
2002 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | 2012 reattachLayoutTree(reattachContext); |
2003 // flag - so needsReattachLayoutTree() should always be true. | 2013 } else if (childNeedsReattachLayoutTree()) { |
2004 DCHECK(parentNode()); | 2014 SelectorFilterParentScope filterScope(*this); |
2005 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | 2015 StyleSharingDepthScope sharingScope(*this); |
2006 DCHECK(needsReattachLayoutTree()); | 2016 reattachPseudoElementLayoutTree(PseudoIdBefore); |
2007 reattachLayoutTree(reattachContext); | 2017 rebuildShadowRootLayoutTree(); |
2008 // Since needsReattachLayoutTree() is always true we go into | 2018 rebuildChildrenLayoutTrees(); |
2009 // reattachLayoutTree() which reattaches all the descendant | 2019 reattachPseudoElementLayoutTree(PseudoIdAfter); |
2010 // sub-trees. At this point no child should need reattaching. | 2020 reattachPseudoElementLayoutTree(PseudoIdBackdrop); |
2021 reattachPseudoElementLayoutTree(PseudoIdFirstLetter); | |
2022 } | |
2023 DCHECK(!needsReattachLayoutTree()); | |
2011 DCHECK(!childNeedsReattachLayoutTree()); | 2024 DCHECK(!childNeedsReattachLayoutTree()); |
2012 | 2025 |
2013 if (layoutObjectWillChange || layoutObject()) { | 2026 if (layoutObjectWillChange || layoutObject()) { |
2014 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | 2027 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
2015 // we can either traverse the current subtree from this node onwards | 2028 // we can either traverse the current subtree from this node onwards |
2016 // or store it. | 2029 // or store it. |
2017 // The choice is between increased time and increased memory complexity. | 2030 // The choice is between increased time and increased memory complexity. |
2018 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); | 2031 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); |
2019 return Reattach; | |
2020 } | 2032 } |
2021 return ReattachNoLayoutObject; | 2033 } |
2034 | |
2035 void Element::rebuildShadowRootLayoutTree() { | |
2036 DCHECK(!needsStyleRecalc()); | |
2037 DCHECK(!childNeedsStyleRecalc()); | |
2038 DCHECK(!needsReattachLayoutTree()); | |
2039 for (ShadowRoot* root = youngestShadowRoot(); root; | |
2040 root = root->olderShadowRoot()) { | |
2041 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) | |
2042 root->rebuildLayoutTree(); | |
2043 } | |
2044 } | |
2045 | |
2046 void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { | |
2047 DCHECK(!needsStyleRecalc()); | |
2048 DCHECK(!childNeedsStyleRecalc()); | |
2049 DCHECK(!needsReattachLayoutTree()); | |
2050 if (PseudoElement* element = pseudoElement(pseudoId)) { | |
2051 if (element->needsReattachLayoutTree() || | |
2052 element->childNeedsReattachLayoutTree()) | |
2053 element->rebuildLayoutTree(); | |
2054 } else { | |
2055 createPseudoElementIfNeeded(pseudoId); | |
2056 } | |
2022 } | 2057 } |
2023 | 2058 |
2024 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2059 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
2025 const ComputedStyle* newStyle) { | 2060 const ComputedStyle* newStyle) { |
2026 Vector<String> emptyVector; | 2061 Vector<String> emptyVector; |
2027 const Vector<String>& oldCallbackSelectors = | 2062 const Vector<String>& oldCallbackSelectors = |
2028 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2063 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
2029 const Vector<String>& newCallbackSelectors = | 2064 const Vector<String>& newCallbackSelectors = |
2030 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2065 newStyle ? newStyle->callbackSelectors() : emptyVector; |
2031 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) | 2066 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4091 } | 4126 } |
4092 | 4127 |
4093 DEFINE_TRACE_WRAPPERS(Element) { | 4128 DEFINE_TRACE_WRAPPERS(Element) { |
4094 if (hasRareData()) { | 4129 if (hasRareData()) { |
4095 visitor->traceWrappers(elementRareData()); | 4130 visitor->traceWrappers(elementRareData()); |
4096 } | 4131 } |
4097 ContainerNode::traceWrappers(visitor); | 4132 ContainerNode::traceWrappers(visitor); |
4098 } | 4133 } |
4099 | 4134 |
4100 } // namespace blink | 4135 } // namespace blink |
OLD | NEW |