OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
34 #include "core/dom/StyleEngine.h" | 34 #include "core/dom/StyleEngine.h" |
35 #include "core/dom/Text.h" | 35 #include "core/dom/Text.h" |
36 #include "core/dom/shadow/ElementShadow.h" | 36 #include "core/dom/shadow/ElementShadow.h" |
37 #include "core/dom/shadow/InsertionPoint.h" | 37 #include "core/dom/shadow/InsertionPoint.h" |
38 #include "core/dom/shadow/ShadowRootRareDataV0.h" | 38 #include "core/dom/shadow/ShadowRootRareDataV0.h" |
39 #include "core/dom/shadow/SlotAssignment.h" | 39 #include "core/dom/shadow/SlotAssignment.h" |
40 #include "core/editing/serializers/Serialization.h" | 40 #include "core/editing/serializers/Serialization.h" |
41 #include "core/html/HTMLShadowElement.h" | 41 #include "core/html/HTMLShadowElement.h" |
42 #include "core/html/HTMLSlotElement.h" | 42 #include "core/html/HTMLSlotElement.h" |
43 #include "core/layout/LayoutObject.h" | |
43 #include "public/platform/Platform.h" | 44 #include "public/platform/Platform.h" |
44 | 45 |
45 namespace blink { | 46 namespace blink { |
46 | 47 |
47 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { | 48 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { |
48 char emptyClassFieldsDueToGCMixinMarker[1]; | 49 char emptyClassFieldsDueToGCMixinMarker[1]; |
49 Member<void*> willbeMember[3]; | 50 Member<void*> willbeMember[3]; |
50 unsigned countersAndFlags[1]; | 51 unsigned countersAndFlags[1]; |
51 }; | 52 }; |
52 | 53 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 setNeedsReattachLayoutTree(); | 149 setNeedsReattachLayoutTree(); |
149 } | 150 } |
150 | 151 |
151 // There's no style to update so just calling recalcStyle means we're updated. | 152 // There's no style to update so just calling recalcStyle means we're updated. |
152 clearNeedsStyleRecalc(); | 153 clearNeedsStyleRecalc(); |
153 | 154 |
154 recalcDescendantStyles(change); | 155 recalcDescendantStyles(change); |
155 clearChildNeedsStyleRecalc(); | 156 clearChildNeedsStyleRecalc(); |
156 } | 157 } |
157 | 158 |
158 void ShadowRoot::rebuildLayoutTree() { | 159 void ShadowRoot::rebuildLayoutTree(Text*& nextTextSibling) { |
159 // ShadowRoot doesn't support custom callbacks. | 160 // ShadowRoot doesn't support custom callbacks. |
160 DCHECK(!hasCustomStyleCallbacks()); | 161 DCHECK(!hasCustomStyleCallbacks()); |
161 | 162 |
163 if (!needsReattachLayoutTree() && !childNeedsReattachLayoutTree()) { | |
164 skipRebuildLayoutTree(nextTextSibling); | |
165 return; | |
166 } | |
167 | |
162 StyleSharingDepthScope sharingScope(*this); | 168 StyleSharingDepthScope sharingScope(*this); |
163 | 169 |
164 clearNeedsReattachLayoutTree(); | 170 clearNeedsReattachLayoutTree(); |
165 rebuildChildrenLayoutTrees(); | 171 rebuildChildrenLayoutTrees(nextTextSibling); |
166 clearChildNeedsReattachLayoutTree(); | 172 clearChildNeedsReattachLayoutTree(); |
167 } | 173 } |
168 | 174 |
175 void ShadowRoot::skipRebuildLayoutTree(Text*& nextTextSibling) const { | |
176 // We call this method when neither this, nor our child nodes are marked | |
177 // for re-attachment, but the host has been marked with | |
178 // childNeedsReattachLayoutTree. That happens when ::before or ::after needs | |
179 // re-attachment. In that case, we find update nextTextSibling with the first | |
esprehn
2017/03/30 09:30:33
Find is weird grammar?
rune
2017/03/30 09:49:48
Done.
| |
180 // text node sibling not preceeded by any in-flow children to allow for | |
181 // correct whitespace re-attachment if the ::before element display changes. | |
182 DCHECK(document().inStyleRecalc()); | |
183 DCHECK(!document().childNeedsDistributionRecalc()); | |
184 DCHECK(!needsStyleRecalc()); | |
185 DCHECK(!childNeedsStyleRecalc()); | |
186 DCHECK(!needsReattachLayoutTree()); | |
187 DCHECK(!childNeedsReattachLayoutTree()); | |
188 | |
189 for (Node* sibling = firstChild(); sibling; | |
190 sibling = sibling->nextSibling()) { | |
191 if (sibling->isTextNode()) { | |
192 nextTextSibling = toText(sibling); | |
193 return; | |
194 } | |
195 LayoutObject* layoutObject = sibling->layoutObject(); | |
196 if (layoutObject && !layoutObject->isFloatingOrOutOfFlowPositioned()) { | |
197 nextTextSibling = nullptr; | |
198 return; | |
199 } | |
200 } | |
201 } | |
202 | |
169 void ShadowRoot::attachLayoutTree(const AttachContext& context) { | 203 void ShadowRoot::attachLayoutTree(const AttachContext& context) { |
170 StyleSharingDepthScope sharingScope(*this); | 204 StyleSharingDepthScope sharingScope(*this); |
171 DocumentFragment::attachLayoutTree(context); | 205 DocumentFragment::attachLayoutTree(context); |
172 } | 206 } |
173 | 207 |
174 void ShadowRoot::detachLayoutTree(const AttachContext& context) { | 208 void ShadowRoot::detachLayoutTree(const AttachContext& context) { |
175 if (context.clearInvalidation) | 209 if (context.clearInvalidation) |
176 document().styleEngine().styleInvalidator().clearInvalidation(*this); | 210 document().styleEngine().styleInvalidator().clearInvalidation(*this); |
177 DocumentFragment::detachLayoutTree(context); | 211 DocumentFragment::detachLayoutTree(context); |
178 } | 212 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 ostream << "ShadowRootType::Open"; | 380 ostream << "ShadowRootType::Open"; |
347 break; | 381 break; |
348 case ShadowRootType::Closed: | 382 case ShadowRootType::Closed: |
349 ostream << "ShadowRootType::Closed"; | 383 ostream << "ShadowRootType::Closed"; |
350 break; | 384 break; |
351 } | 385 } |
352 return ostream; | 386 return ostream; |
353 } | 387 } |
354 | 388 |
355 } // namespace blink | 389 } // namespace blink |
OLD | NEW |