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

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

Issue 2630293003: Do not allocate SlotAssignment unless a shadowroot has a slot (Closed)
Patch Set: renamed Created 3 years, 11 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) 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 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * 10 *
(...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 break; 2314 break;
2315 filteredInsertionPoints.push_back(insertionPoint); 2315 filteredInsertionPoints.push_back(insertionPoint);
2316 } 2316 }
2317 return StaticNodeList::adopt(filteredInsertionPoints); 2317 return StaticNodeList::adopt(filteredInsertionPoints);
2318 } 2318 }
2319 2319
2320 HTMLSlotElement* Node::assignedSlot() const { 2320 HTMLSlotElement* Node::assignedSlot() const {
2321 // assignedSlot doesn't need to call updateDistribution(). 2321 // assignedSlot doesn't need to call updateDistribution().
2322 DCHECK(!isPseudoElement()); 2322 DCHECK(!isPseudoElement());
2323 if (ShadowRoot* root = v1ShadowRootOfParent()) 2323 if (ShadowRoot* root = v1ShadowRootOfParent())
2324 return root->ensureSlotAssignment().findSlot(*this); 2324 return root->assignedSlotFor(*this);
2325 return nullptr; 2325 return nullptr;
2326 } 2326 }
2327 2327
2328 HTMLSlotElement* Node::assignedSlotForBinding() { 2328 HTMLSlotElement* Node::assignedSlotForBinding() {
2329 // assignedSlot doesn't need to call updateDistribution(). 2329 // assignedSlot doesn't need to call updateDistribution().
2330 if (ShadowRoot* root = v1ShadowRootOfParent()) { 2330 if (ShadowRoot* root = v1ShadowRootOfParent()) {
2331 if (root->type() == ShadowRootType::Open) 2331 if (root->type() == ShadowRootType::Open)
2332 return root->ensureSlotAssignment().findSlot(*this); 2332 return root->assignedSlotFor(*this);
2333 } 2333 }
2334 return nullptr; 2334 return nullptr;
2335 } 2335 }
2336 2336
2337 void Node::setFocused(bool flag) { 2337 void Node::setFocused(bool flag) {
2338 document().userActionElements().setFocused(this, flag); 2338 document().userActionElements().setFocused(this, flag);
2339 } 2339 }
2340 2340
2341 void Node::setActive(bool flag) { 2341 void Node::setActive(bool flag) {
2342 document().userActionElements().setActive(this, flag); 2342 document().userActionElements().setActive(this, flag);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2445 // Relevant DOM Standard: 2445 // Relevant DOM Standard:
2446 // https://dom.spec.whatwg.org/#concept-node-insert 2446 // https://dom.spec.whatwg.org/#concept-node-insert
2447 // - 6.1.2: If parent is a shadow host and node is a slotable, then assign a 2447 // - 6.1.2: If parent is a shadow host and node is a slotable, then assign a
2448 // slot for node. 2448 // slot for node.
2449 // https://dom.spec.whatwg.org/#concept-node-remove 2449 // https://dom.spec.whatwg.org/#concept-node-remove
2450 // - 10. If node is assigned, then run assign slotables for node’s assigned 2450 // - 10. If node is assigned, then run assign slotables for node’s assigned
2451 // slot. 2451 // slot.
2452 2452
2453 // Although DOM Standard requires "assign a slot for node / run assign 2453 // Although DOM Standard requires "assign a slot for node / run assign
2454 // slotables" at this timing, we skip it as an optimization. 2454 // slotables" at this timing, we skip it as an optimization.
2455 if (HTMLSlotElement* slot = root->ensureSlotAssignment().findSlot(*this)) 2455 if (HTMLSlotElement* slot = root->assignedSlotFor(*this))
2456 slot->didSlotChange(slotChangeType); 2456 slot->didSlotChange(slotChangeType);
2457 } else { 2457 } else {
2458 // Relevant DOM Standard: 2458 // Relevant DOM Standard:
2459 // https://dom.spec.whatwg.org/#concept-node-insert 2459 // https://dom.spec.whatwg.org/#concept-node-insert
2460 // - 6.1.3: If parent is a slot whose assigned nodes is the empty list, then 2460 // - 6.1.3: If parent is a slot whose assigned nodes is the empty list, then
2461 // run signal a slot change for parent. 2461 // run signal a slot change for parent.
2462 // https://dom.spec.whatwg.org/#concept-node-remove 2462 // https://dom.spec.whatwg.org/#concept-node-remove
2463 // - 11. If parent is a slot whose assigned nodes is the empty list, then 2463 // - 11. If parent is a slot whose assigned nodes is the empty list, then
2464 // run signal a slot change for parent. 2464 // run signal a slot change for parent.
2465 Element* parent = parentElement(); 2465 Element* parent = parentElement();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 if (node) { 2560 if (node) {
2561 std::stringstream stream; 2561 std::stringstream stream;
2562 node->printNodePathTo(stream); 2562 node->printNodePathTo(stream);
2563 LOG(INFO) << stream.str(); 2563 LOG(INFO) << stream.str();
2564 } else { 2564 } else {
2565 LOG(INFO) << "Cannot showNodePath for <null>"; 2565 LOG(INFO) << "Cannot showNodePath for <null>";
2566 } 2566 }
2567 } 2567 }
2568 2568
2569 #endif 2569 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Element.cpp ('k') | third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698