Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: third_party/WebKit/Source/core/dom/shadow/InsertionPoint.cpp

Issue 2322213002: Refactor ElementShadow by separating v0 related features as ElementShadowV0 (Closed)
Patch Set: addressed Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/dom/shadow/InsertionPoint.h" 31 #include "core/dom/shadow/InsertionPoint.h"
32 32
33 #include "core/HTMLNames.h" 33 #include "core/HTMLNames.h"
34 #include "core/dom/Document.h"
35 #include "core/dom/ElementTraversal.h" 34 #include "core/dom/ElementTraversal.h"
36 #include "core/dom/QualifiedName.h" 35 #include "core/dom/QualifiedName.h"
37 #include "core/dom/StaticNodeList.h" 36 #include "core/dom/StaticNodeList.h"
38 #include "core/dom/StyleChangeReason.h" 37 #include "core/dom/StyleChangeReason.h"
39 #include "core/dom/shadow/ElementShadow.h" 38 #include "core/dom/shadow/ElementShadow.h"
39 #include "core/dom/shadow/ElementShadowV0.h"
40 40
41 namespace blink { 41 namespace blink {
42 42
43 using namespace HTMLNames; 43 using namespace HTMLNames;
44 44
45 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document) 45 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document& document)
46 : HTMLElement(tagName, document, CreateInsertionPoint) 46 : HTMLElement(tagName, document, CreateInsertionPoint)
47 , m_registeredWithShadowRoot(false) 47 , m_registeredWithShadowRoot(false)
48 { 48 {
49 setHasCustomStyleCallbacks(); 49 setHasCustomStyleCallbacks();
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (ShadowRoot* root = containingShadowRoot()) { 197 if (ShadowRoot* root = containingShadowRoot()) {
198 if (ElementShadow* rootOwner = root->owner()) 198 if (ElementShadow* rootOwner = root->owner())
199 rootOwner->setNeedsDistributionRecalc(); 199 rootOwner->setNeedsDistributionRecalc();
200 } 200 }
201 } 201 }
202 202
203 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint) 203 Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode* i nsertionPoint)
204 { 204 {
205 HTMLElement::insertedInto(insertionPoint); 205 HTMLElement::insertedInto(insertionPoint);
206 if (ShadowRoot* root = containingShadowRoot()) { 206 if (ShadowRoot* root = containingShadowRoot()) {
207 if (ElementShadow* rootOwner = root->owner()) { 207 if (!root->isV1()) {
208 rootOwner->setNeedsDistributionRecalc(); 208 if (ElementShadow* rootOwner = root->owner()) {
209 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoint-> treeScope().rootNode() == root) { 209 rootOwner->setNeedsDistributionRecalc();
210 m_registeredWithShadowRoot = true; 210 if (canBeActive() && !m_registeredWithShadowRoot && insertionPoi nt->treeScope().rootNode() == root) {
211 root->didAddInsertionPoint(this); 211 m_registeredWithShadowRoot = true;
212 if (canAffectSelector()) 212 root->didAddInsertionPoint(this);
213 rootOwner->willAffectSelector(); 213 if (canAffectSelector())
214 rootOwner->v0().willAffectSelector();
215 }
214 } 216 }
215 } 217 }
216 } 218 }
217 219
218 // We could have been distributed into in a detached subtree, make sure to 220 // We could have been distributed into in a detached subtree, make sure to
219 // clear the distribution when inserted again to avoid cycles. 221 // clear the distribution when inserted again to avoid cycles.
220 clearDistribution(); 222 clearDistribution();
221 223
222 return InsertionDone; 224 return InsertionDone;
223 } 225 }
(...skipping 12 matching lines...) Expand all
236 // host can be null when removedFrom() is called from ElementShadow destruct or. 238 // host can be null when removedFrom() is called from ElementShadow destruct or.
237 ElementShadow* rootOwner = root ? root->owner() : 0; 239 ElementShadow* rootOwner = root ? root->owner() : 0;
238 240
239 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. 241 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
240 clearDistribution(); 242 clearDistribution();
241 243
242 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) { 244 if (m_registeredWithShadowRoot && insertionPoint->treeScope().rootNode() == root) {
243 DCHECK(root); 245 DCHECK(root);
244 m_registeredWithShadowRoot = false; 246 m_registeredWithShadowRoot = false;
245 root->didRemoveInsertionPoint(this); 247 root->didRemoveInsertionPoint(this);
246 if (rootOwner) { 248 if (!root->isV1() && rootOwner) {
247 if (canAffectSelector()) 249 if (canAffectSelector())
248 rootOwner->willAffectSelector(); 250 rootOwner->v0().willAffectSelector();
249 } 251 }
250 } 252 }
251 253
252 HTMLElement::removedFrom(insertionPoint); 254 HTMLElement::removedFrom(insertionPoint);
253 } 255 }
254 256
255 DEFINE_TRACE(InsertionPoint) 257 DEFINE_TRACE(InsertionPoint)
256 { 258 {
257 visitor->trace(m_distributedNodes); 259 visitor->trace(m_distributedNodes);
258 HTMLElement::trace(visitor); 260 HTMLElement::trace(visitor);
259 } 261 }
260 262
261 const InsertionPoint* resolveReprojection(const Node* projectedNode) 263 const InsertionPoint* resolveReprojection(const Node* projectedNode)
262 { 264 {
263 DCHECK(projectedNode); 265 DCHECK(projectedNode);
264 const InsertionPoint* insertionPoint = 0; 266 const InsertionPoint* insertionPoint = 0;
265 const Node* current = projectedNode; 267 const Node* current = projectedNode;
266 ElementShadow* lastElementShadow = 0; 268 ElementShadow* lastElementShadow = 0;
267 while (true) { 269 while (true) {
268 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); 270 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current);
269 if (!shadow || shadow->isV1() || shadow == lastElementShadow) 271 if (!shadow || shadow->isV1() || shadow == lastElementShadow)
270 break; 272 break;
271 lastElementShadow = shadow; 273 lastElementShadow = shadow;
272 const InsertionPoint* insertedTo = shadow->finalDestinationInsertionPoin tFor(projectedNode); 274 const InsertionPoint* insertedTo = shadow->v0().finalDestinationInsertio nPointFor(projectedNode);
273 if (!insertedTo) 275 if (!insertedTo)
274 break; 276 break;
275 DCHECK_NE(current, insertedTo); 277 DCHECK_NE(current, insertedTo);
276 current = insertedTo; 278 current = insertedTo;
277 insertionPoint = insertedTo; 279 insertionPoint = insertedTo;
278 } 280 }
279 return insertionPoint; 281 return insertionPoint;
280 } 282 }
281 283
282 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results) 284 void collectDestinationInsertionPoints(const Node& node, HeapVector<Member<Inser tionPoint>, 8>& results)
283 { 285 {
284 const Node* current = &node; 286 const Node* current = &node;
285 ElementShadow* lastElementShadow = 0; 287 ElementShadow* lastElementShadow = 0;
286 while (true) { 288 while (true) {
287 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current); 289 ElementShadow* shadow = shadowWhereNodeCanBeDistributedForV0(*current);
288 if (!shadow || shadow->isV1() || shadow == lastElementShadow) 290 if (!shadow || shadow->isV1() || shadow == lastElementShadow)
289 return; 291 return;
290 lastElementShadow = shadow; 292 lastElementShadow = shadow;
291 const DestinationInsertionPoints* insertionPoints = shadow->destinationI nsertionPointsFor(&node); 293 const DestinationInsertionPoints* insertionPoints = shadow->v0().destina tionInsertionPointsFor(&node);
292 if (!insertionPoints) 294 if (!insertionPoints)
293 return; 295 return;
294 for (size_t i = 0; i < insertionPoints->size(); ++i) 296 for (size_t i = 0; i < insertionPoints->size(); ++i)
295 results.append(insertionPoints->at(i).get()); 297 results.append(insertionPoints->at(i).get());
296 DCHECK_NE(current, insertionPoints->last().get()); 298 DCHECK_NE(current, insertionPoints->last().get());
297 current = insertionPoints->last().get(); 299 current = insertionPoints->last().get();
298 } 300 }
299 } 301 }
300 302
301 } // namespace blink 303 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698