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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2030 AttachContext reattachContext; | 2030 AttachContext reattachContext; |
2031 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); | 2031 reattachContext.resolvedStyle = document().getNonAttachedStyle(*this); |
2032 bool layoutObjectWillChange = needsAttach() || layoutObject(); | 2032 bool layoutObjectWillChange = needsAttach() || layoutObject(); |
2033 reattachLayoutTree(reattachContext); | 2033 reattachLayoutTree(reattachContext); |
2034 if (layoutObjectWillChange || layoutObject()) | 2034 if (layoutObjectWillChange || layoutObject()) |
2035 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); | 2035 reattachWhitespaceSiblingsIfNeeded(nextTextSibling); |
2036 } else if (childNeedsReattachLayoutTree()) { | 2036 } else if (childNeedsReattachLayoutTree()) { |
2037 DCHECK(!needsReattachLayoutTree()); | 2037 DCHECK(!needsReattachLayoutTree()); |
2038 SelectorFilterParentScope filterScope(*this); | 2038 SelectorFilterParentScope filterScope(*this); |
2039 StyleSharingDepthScope sharingScope(*this); | 2039 StyleSharingDepthScope sharingScope(*this); |
2040 reattachPseudoElementLayoutTree(PseudoIdBefore); | 2040 Text* nextTextSibling = nullptr; |
2041 rebuildShadowRootLayoutTree(); | 2041 rebuildPseudoElementLayoutTree(PseudoIdAfter); |
2042 rebuildChildrenLayoutTrees(); | 2042 rebuildShadowRootLayoutTree(nextTextSibling); |
2043 reattachPseudoElementLayoutTree(PseudoIdAfter); | 2043 rebuildChildrenLayoutTrees(nextTextSibling); |
2044 reattachPseudoElementLayoutTree(PseudoIdBackdrop); | 2044 rebuildPseudoElementLayoutTree(PseudoIdBefore, nextTextSibling); |
esprehn
2017/03/28 20:56:51
Why do we only need this for ::before?
rune
2017/03/29 10:39:47
We always evaluate the need for a whitespace layou
| |
2045 reattachPseudoElementLayoutTree(PseudoIdFirstLetter); | 2045 rebuildPseudoElementLayoutTree(PseudoIdBackdrop); |
2046 rebuildPseudoElementLayoutTree(PseudoIdFirstLetter); | |
2046 } | 2047 } |
2047 DCHECK(!needsStyleRecalc()); | 2048 DCHECK(!needsStyleRecalc()); |
2048 DCHECK(!childNeedsStyleRecalc()); | 2049 DCHECK(!childNeedsStyleRecalc()); |
2049 DCHECK(!needsReattachLayoutTree()); | 2050 DCHECK(!needsReattachLayoutTree()); |
2050 DCHECK(!childNeedsReattachLayoutTree()); | 2051 DCHECK(!childNeedsReattachLayoutTree()); |
2051 } | 2052 } |
2052 | 2053 |
2053 void Element::rebuildShadowRootLayoutTree() { | 2054 void Element::rebuildShadowRootLayoutTree(Text*& nextTextSibling) { |
2054 for (ShadowRoot* root = youngestShadowRoot(); root; | 2055 for (ShadowRoot* root = youngestShadowRoot(); root; |
2055 root = root->olderShadowRoot()) { | 2056 root = root->olderShadowRoot()) { |
2057 // TODO(rune@opera.com): nextTextSibling is not set correctly when we have | |
2058 // slotted nodes (crbug.com/648931). Also, it may be incorrect when we have | |
2059 // multiple shadow roots (for V0 shadow hosts). | |
2060 // | |
2061 // When we call this method and neither this, nor our child nodes are marked | |
2062 // for re-attachment, it means one or more pseudo elements needs re- | |
2063 // attachment. In that case, find the first text node sibling not preceeded | |
2064 // by any in-flow children as the nextTextSibling to allow correct | |
2065 // whitespace re-attachment if the ::before element display changes. | |
2056 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) | 2066 if (root->needsReattachLayoutTree() || root->childNeedsReattachLayoutTree()) |
2057 root->rebuildLayoutTree(); | 2067 root->rebuildLayoutTree(nextTextSibling); |
2068 else | |
2069 nextTextSibling = root->findNextTextSibling(); | |
esprehn
2017/03/28 20:56:51
ShadowRoot can't have siblings so this doesn't mak
rune
2017/03/29 10:39:47
Rewrote this for PS2.
| |
2058 } | 2070 } |
2059 } | 2071 } |
2060 | 2072 |
2061 void Element::reattachPseudoElementLayoutTree(PseudoId pseudoId) { | 2073 void Element::rebuildPseudoElementLayoutTree(PseudoId pseudoId, |
2074 Text* nextTextSibling) { | |
2062 if (PseudoElement* element = pseudoElement(pseudoId)) { | 2075 if (PseudoElement* element = pseudoElement(pseudoId)) { |
2063 if (element->needsReattachLayoutTree() || | 2076 if (element->needsReattachLayoutTree() || |
2064 element->childNeedsReattachLayoutTree()) | 2077 element->childNeedsReattachLayoutTree()) |
2065 element->rebuildLayoutTree(); | 2078 element->rebuildLayoutTree(nextTextSibling); |
2066 } else { | 2079 } else { |
2067 createPseudoElementIfNeeded(pseudoId); | 2080 createPseudoElementIfNeeded(pseudoId); |
2068 } | 2081 } |
2069 } | 2082 } |
2070 | 2083 |
2071 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, | 2084 void Element::updateCallbackSelectors(const ComputedStyle* oldStyle, |
2072 const ComputedStyle* newStyle) { | 2085 const ComputedStyle* newStyle) { |
2073 Vector<String> emptyVector; | 2086 Vector<String> emptyVector; |
2074 const Vector<String>& oldCallbackSelectors = | 2087 const Vector<String>& oldCallbackSelectors = |
2075 oldStyle ? oldStyle->callbackSelectors() : emptyVector; | 2088 oldStyle ? oldStyle->callbackSelectors() : emptyVector; |
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4170 } | 4183 } |
4171 | 4184 |
4172 DEFINE_TRACE_WRAPPERS(Element) { | 4185 DEFINE_TRACE_WRAPPERS(Element) { |
4173 if (hasRareData()) { | 4186 if (hasRareData()) { |
4174 visitor->traceWrappers(elementRareData()); | 4187 visitor->traceWrappers(elementRareData()); |
4175 } | 4188 } |
4176 ContainerNode::traceWrappers(visitor); | 4189 ContainerNode::traceWrappers(visitor); |
4177 } | 4190 } |
4178 | 4191 |
4179 } // namespace blink | 4192 } // namespace blink |
OLD | NEW |