Chromium Code Reviews| 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 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1896 if (change != IndependentInherit) | 1896 if (change != IndependentInherit) |
| 1897 data->clearComputedStyle(); | 1897 data->clearComputedStyle(); |
| 1898 | 1898 |
| 1899 if (change >= IndependentInherit) { | 1899 if (change >= IndependentInherit) { |
| 1900 if (ElementAnimations* elementAnimations = data->elementAnimations()) | 1900 if (ElementAnimations* elementAnimations = data->elementAnimations()) |
| 1901 elementAnimations->setAnimationStyleChange(false); | 1901 elementAnimations->setAnimationStyleChange(false); |
| 1902 } | 1902 } |
| 1903 } | 1903 } |
| 1904 if (parentComputedStyle()) | 1904 if (parentComputedStyle()) |
| 1905 change = recalcOwnStyle(change, nextTextSibling); | 1905 change = recalcOwnStyle(change, nextTextSibling); |
| 1906 clearNeedsStyleRecalc(); | 1906 if (change != Reattach) |
|
esprehn
2017/02/22 01:13:17
You could add a comment above this that says this
nainar
2017/02/22 03:12:07
Done.
| |
| 1907 clearNeedsReattachLayoutTree(); | 1907 clearNeedsStyleRecalc(); |
| 1908 } | 1908 } |
| 1909 | 1909 |
| 1910 // If we reattached we don't need to recalc the style of our descendants | 1910 // If we are going to reattach we don't need to recalc the style of |
| 1911 // anymore. | 1911 // our descendants anymore. |
| 1912 if ((change >= UpdatePseudoElements && change < Reattach) || | 1912 if (change < Reattach && |
| 1913 childNeedsStyleRecalc()) { | 1913 (change >= UpdatePseudoElements || childNeedsStyleRecalc())) { |
| 1914 SelectorFilterParentScope filterScope(*this); | 1914 SelectorFilterParentScope filterScope(*this); |
| 1915 StyleSharingDepthScope sharingScope(*this); | 1915 StyleSharingDepthScope sharingScope(*this); |
| 1916 | 1916 |
| 1917 updatePseudoElement(PseudoIdBefore, change); | 1917 updatePseudoElement(PseudoIdBefore, change); |
| 1918 | 1918 |
| 1919 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { | 1919 if (change > UpdatePseudoElements || childNeedsStyleRecalc()) { |
| 1920 for (ShadowRoot* root = youngestShadowRoot(); root; | 1920 for (ShadowRoot* root = youngestShadowRoot(); root; |
| 1921 root = root->olderShadowRoot()) { | 1921 root = root->olderShadowRoot()) { |
| 1922 if (root->shouldCallRecalcStyle(change)) | 1922 if (root->shouldCallRecalcStyle(change)) |
| 1923 root->recalcStyle(change); | 1923 root->recalcStyle(change); |
| 1924 } | 1924 } |
| 1925 recalcDescendantStyles(change); | 1925 recalcDescendantStyles(change); |
| 1926 } | 1926 } |
| 1927 | 1927 |
| 1928 updatePseudoElement(PseudoIdAfter, change); | 1928 updatePseudoElement(PseudoIdAfter, change); |
| 1929 updatePseudoElement(PseudoIdBackdrop, change); | 1929 updatePseudoElement(PseudoIdBackdrop, change); |
| 1930 | 1930 |
| 1931 // If our children have changed then we need to force the first-letter | 1931 // If our children have changed then we need to force the first-letter |
| 1932 // checks as we don't know if they effected the first letter or not. | 1932 // checks as we don't know if they effected the first letter or not. |
| 1933 // This can be seen when a child transitions from floating to | 1933 // This can be seen when a child transitions from floating to |
| 1934 // non-floating we have to take it into account for the first letter. | 1934 // non-floating we have to take it into account for the first letter. |
| 1935 updatePseudoElement(PseudoIdFirstLetter, | 1935 updatePseudoElement(PseudoIdFirstLetter, |
| 1936 childNeedsStyleRecalc() ? Force : change); | 1936 childNeedsStyleRecalc() ? Force : change); |
| 1937 | 1937 |
| 1938 clearChildNeedsStyleRecalc(); | 1938 clearChildNeedsStyleRecalc(); |
| 1939 clearChildNeedsReattachLayoutTree(); | |
| 1940 } | 1939 } |
| 1941 | 1940 |
| 1942 if (hasCustomStyleCallbacks()) | 1941 if (hasCustomStyleCallbacks()) |
| 1943 didRecalcStyle(); | 1942 didRecalcStyle(); |
| 1944 } | 1943 } |
| 1945 | 1944 |
| 1946 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( | 1945 PassRefPtr<ComputedStyle> Element::propagateInheritedProperties( |
| 1947 StyleRecalcChange change) { | 1946 StyleRecalcChange change) { |
| 1948 if (change != IndependentInherit) | 1947 if (change != IndependentInherit) |
| 1949 return nullptr; | 1948 return nullptr; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1989 } else { | 1988 } else { |
| 1990 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); | 1989 INCREMENT_STYLE_STATS_COUNTER(document().styleEngine(), stylesChanged, 1); |
| 1991 } | 1990 } |
| 1992 | 1991 |
| 1993 if (localChange == Reattach) { | 1992 if (localChange == Reattach) { |
| 1994 StyleReattachData styleReattachData; | 1993 StyleReattachData styleReattachData; |
| 1995 styleReattachData.computedStyle = std::move(newStyle); | 1994 styleReattachData.computedStyle = std::move(newStyle); |
| 1996 styleReattachData.nextTextSibling = nextTextSibling; | 1995 styleReattachData.nextTextSibling = nextTextSibling; |
| 1997 document().addStyleReattachData(*this, styleReattachData); | 1996 document().addStyleReattachData(*this, styleReattachData); |
| 1998 setNeedsReattachLayoutTree(); | 1997 setNeedsReattachLayoutTree(); |
| 1999 return rebuildLayoutTree(); | 1998 return Reattach; |
| 2000 } | 1999 } |
| 2001 | 2000 |
| 2002 DCHECK(oldStyle); | 2001 DCHECK(oldStyle); |
| 2003 | 2002 |
| 2004 if (localChange != NoChange) | 2003 if (localChange != NoChange) |
| 2005 updateCallbackSelectors(oldStyle.get(), newStyle.get()); | 2004 updateCallbackSelectors(oldStyle.get(), newStyle.get()); |
| 2006 | 2005 |
| 2007 if (LayoutObject* layoutObject = this->layoutObject()) { | 2006 if (LayoutObject* layoutObject = this->layoutObject()) { |
| 2008 if (localChange != NoChange || | 2007 if (localChange != NoChange || |
| 2009 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { | 2008 pseudoStyleCacheIsInvalid(oldStyle.get(), newStyle.get())) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 2030 return Inherit; | 2029 return Inherit; |
| 2031 newStyle->copyChildDependentFlagsFrom(*oldStyle); | 2030 newStyle->copyChildDependentFlagsFrom(*oldStyle); |
| 2032 } | 2031 } |
| 2033 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) | 2032 if (oldStyle->hasPseudoElementStyle() || newStyle->hasPseudoElementStyle()) |
| 2034 return UpdatePseudoElements; | 2033 return UpdatePseudoElements; |
| 2035 } | 2034 } |
| 2036 | 2035 |
| 2037 return localChange; | 2036 return localChange; |
| 2038 } | 2037 } |
| 2039 | 2038 |
| 2040 StyleRecalcChange Element::rebuildLayoutTree() { | 2039 void Element::rebuildLayoutTree() { |
| 2041 DCHECK(inActiveDocument()); | 2040 DCHECK(inActiveDocument()); |
| 2041 DCHECK(parentNode()); | |
| 2042 | |
| 2042 StyleReattachData styleReattachData = document().getStyleReattachData(*this); | 2043 StyleReattachData styleReattachData = document().getStyleReattachData(*this); |
|
esprehn
2017/02/22 01:13:17
Move this whole block into the needsReattachLayout
nainar
2017/02/22 03:12:07
Done.
| |
| 2043 AttachContext reattachContext; | 2044 AttachContext reattachContext; |
| 2044 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); | 2045 reattachContext.resolvedStyle = styleReattachData.computedStyle.get(); |
| 2045 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 2046 bool layoutObjectWillChange = |
|
nainar
2017/02/22 01:07:58
Changed from last patch
esprehn
2017/02/22 01:13:17
Move this into the needsReattachLayoutTree() case.
nainar
2017/02/22 03:12:07
Done.
| |
| 2047 getStyleChangeType() == NeedsReattachStyleChange || layoutObject(); | |
| 2046 | 2048 |
| 2047 // We are calling Element::rebuildLayoutTree() from inside | 2049 if (needsReattachLayoutTree()) { |
| 2048 // Element::recalcOwnStyle where we set the NeedsReattachLayoutTree | 2050 reattachLayoutTree(reattachContext); |
| 2049 // flag - so needsReattachLayoutTree() should always be true. | 2051 } else if (childNeedsReattachLayoutTree()) { |
| 2050 DCHECK(parentNode()); | 2052 DCHECK(!needsReattachLayoutTree()); |
| 2051 DCHECK(parentNode()->childNeedsReattachLayoutTree()); | 2053 SelectorFilterParentScope filterScope(*this); |
| 2052 DCHECK(needsReattachLayoutTree()); | 2054 StyleSharingDepthScope sharingScope(*this); |
| 2053 reattachLayoutTree(reattachContext); | 2055 reattachPseudoElementLayoutTree(PseudoIdBefore); |
| 2054 // Since needsReattachLayoutTree() is always true we go into | 2056 rebuildShadowRootLayoutTree(); |
| 2055 // reattachLayoutTree() which reattaches all the descendant | 2057 rebuildChildrenLayoutTrees(); |
| 2056 // sub-trees. At this point no child should need reattaching. | 2058 reattachPseudoElementLayoutTree(PseudoIdAfter); |
| 2059 reattachPseudoElementLayoutTree(PseudoIdBackdrop); | |
| 2060 reattachPseudoElementLayoutTree(PseudoIdFirstLetter); | |
| 2061 } | |
| 2062 DCHECK(!needsStyleRecalc()); | |
| 2063 DCHECK(!childNeedsStyleRecalc()); | |
| 2064 DCHECK(!needsReattachLayoutTree()); | |
| 2057 DCHECK(!childNeedsReattachLayoutTree()); | 2065 DCHECK(!childNeedsReattachLayoutTree()); |
| 2058 | 2066 |
| 2059 if (layoutObjectWillChange || layoutObject()) { | 2067 if (layoutObjectWillChange || layoutObject()) { |
|
esprehn
2017/02/22 01:13:17
You want to move this whole block into the needsRe
nainar
2017/02/22 03:12:07
Done.
| |
| 2060 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles | 2068 // nextTextSibling is passed on to recalcStyle from recalcDescendantStyles |
| 2061 // we can either traverse the current subtree from this node onwards | 2069 // we can either traverse the current subtree from this node onwards |
| 2062 // or store it. | 2070 // or store it. |
| 2063 // The choice is between increased time and increased memory complexity. | 2071 // The choice is between increased time and increased memory complexity. |
| 2064 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); | 2072 reattachWhitespaceSiblingsIfNeeded(styleReattachData.nextTextSibling); |
| 2065 return Reattach; | |
| 2066 } | 2073 } |
| 2067 return ReattachNoLayoutObject; | 2074 } |
| 2075 | |
| 2076 void Element::rebuildShadowRootLayoutTree() { | |
| 2077 for (ShadowRoot* root = youngestShadowRoot(); root; | |
| 2078 root = root->olderShadowRoot()) { | |
| 2079 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) | |
| 2080 root->rebuildLayoutTree(); | |
| 2081 } | |
| 2082 } | |
| 2083 | |
| 2084 void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { | |
| 2085 if (PseudoElement* element = pseudoElement(pseudoId)) { | |
| 2086 if (element->needsReattachLayoutTree() || | |
| 2087 element->childNeedsReattachLayoutTree()) | |
| 2088 element->rebuildLayoutTree(); | |
| 2089 } else { | |
| 2090 createPseudoElementIfNeeded(pseudoId); | |
| 2091 } | |
| 2068 } | 2092 } |
| 2069 | 2093 |
| 2070 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2094 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
| 2071 const ComputedStyle* newStyle) { | 2095 const ComputedStyle* newStyle) { |
| 2072 Vector<String> emptyVector; | 2096 Vector<String> emptyVector; |
| 2073 const Vector<String>& oldCallbackSelectors = | 2097 const Vector<String>& oldCallbackSelectors = |
| 2074 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2098 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
| 2075 const Vector<String>& newCallbackSelectors = | 2099 const Vector<String>& newCallbackSelectors = |
| 2076 newStyle ? newStyle->callbackSelectors() : emptyVector; | 2100 newStyle ? newStyle->callbackSelectors() : emptyVector; |
| 2077 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) | 2101 if (oldCallbackSelectors.isEmpty() && newCallbackSelectors.isEmpty()) |
| (...skipping 2064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4142 } | 4166 } |
| 4143 | 4167 |
| 4144 DEFINE_TRACE_WRAPPERS(Element) { | 4168 DEFINE_TRACE_WRAPPERS(Element) { |
| 4145 if (hasRareData()) { | 4169 if (hasRareData()) { |
| 4146 visitor->traceWrappers(elementRareData()); | 4170 visitor->traceWrappers(elementRareData()); |
| 4147 } | 4171 } |
| 4148 ContainerNode::traceWrappers(visitor); | 4172 ContainerNode::traceWrappers(visitor); |
| 4149 } | 4173 } |
| 4150 | 4174 |
| 4151 } // namespace blink | 4175 } // namespace blink |
| OLD | NEW |