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

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

Issue 2420043002: Stop re-signaling a slotchange event (Closed)
Patch Set: New slotchange behavior Created 4 years, 2 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 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 2337
2338 DCHECK(isHTMLElement() || isSVGElement()); 2338 DCHECK(isHTMLElement() || isSVGElement());
2339 DCHECK(CustomElementState::Custom != getCustomElementState()); 2339 DCHECK(CustomElementState::Custom != getCustomElementState());
2340 setFlag(V0CustomElementFlag); 2340 setFlag(V0CustomElementFlag);
2341 setFlag(newState == V0Upgraded, V0CustomElementUpgradedFlag); 2341 setFlag(newState == V0Upgraded, V0CustomElementUpgradedFlag);
2342 2342
2343 if (oldState == V0NotCustomElement || newState == V0Upgraded) 2343 if (oldState == V0NotCustomElement || newState == V0Upgraded)
2344 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved); 2344 toElement(this)->pseudoStateChanged(CSSSelector::PseudoUnresolved);
2345 } 2345 }
2346 2346
2347 void Node::checkSlotChange() { 2347 void Node::checkSlotChange(SlotChangeType slotChangeType) {
2348 // Common check logic is used in both cases, "after inserted" and "before 2348 // Common check logic is used in both cases, "after inserted" and "before
2349 // removed". 2349 // removed".
2350 if (!isSlotable()) 2350 if (!isSlotable())
2351 return; 2351 return;
2352 if (ShadowRoot* root = v1ShadowRootOfParent()) { 2352 if (ShadowRoot* root = v1ShadowRootOfParent()) {
2353 // Relevant DOM Standard: 2353 // Relevant DOM Standard:
2354 // https://dom.spec.whatwg.org/#concept-node-insert 2354 // https://dom.spec.whatwg.org/#concept-node-insert
2355 // - 6.1.2: If parent is a shadow host and node is a slotable, then assign a 2355 // - 6.1.2: If parent is a shadow host and node is a slotable, then assign a
2356 // slot for node. 2356 // slot for node.
2357 // https://dom.spec.whatwg.org/#concept-node-remove 2357 // https://dom.spec.whatwg.org/#concept-node-remove
2358 // - 10. If node is assigned, then run assign slotables for node’s assigned 2358 // - 10. If node is assigned, then run assign slotables for node’s assigned
2359 // slot. 2359 // slot.
2360 2360
2361 // Although DOM Standard requires "assign a slot for node / run assign 2361 // Although DOM Standard requires "assign a slot for node / run assign
2362 // slotables" at this timing, we skip it as an optimization. 2362 // slotables" at this timing, we skip it as an optimization.
2363 if (HTMLSlotElement* slot = root->ensureSlotAssignment().findSlot(*this)) 2363 if (HTMLSlotElement* slot = root->ensureSlotAssignment().findSlot(*this))
2364 slot->enqueueSlotChangeEvent(); 2364 slot->didSlotChange(slotChangeType);
2365 } else { 2365 } else {
2366 // Relevant DOM Standard: 2366 // Relevant DOM Standard:
2367 // https://dom.spec.whatwg.org/#concept-node-insert 2367 // https://dom.spec.whatwg.org/#concept-node-insert
2368 // - 6.1.3: If parent is a slot whose assigned nodes is the empty list, then 2368 // - 6.1.3: If parent is a slot whose assigned nodes is the empty list, then
2369 // run signal a slot change for parent. 2369 // run signal a slot change for parent.
2370 // https://dom.spec.whatwg.org/#concept-node-remove 2370 // https://dom.spec.whatwg.org/#concept-node-remove
2371 // - 11. If parent is a slot whose assigned nodes is the empty list, then 2371 // - 11. If parent is a slot whose assigned nodes is the empty list, then
2372 // run signal a slot change for parent. 2372 // run signal a slot change for parent.
2373 Element* parent = parentElement(); 2373 Element* parent = parentElement();
2374 if (parent && isHTMLSlotElement(parent)) { 2374 if (parent && isHTMLSlotElement(parent)) {
2375 HTMLSlotElement& parentSlot = toHTMLSlotElement(*parent); 2375 HTMLSlotElement& parentSlot = toHTMLSlotElement(*parent);
2376 if (ShadowRoot* root = containingShadowRoot()) { 2376 if (ShadowRoot* root = containingShadowRoot()) {
2377 if (root && root->isV1() && !parentSlot.hasAssignedNodesSlow()) 2377 if (root && root->isV1() && !parentSlot.hasAssignedNodesSlow())
kochi 2016/10/31 08:39:13 BTW (this is not for this review) this |root| is g
2378 parentSlot.enqueueSlotChangeEvent(); 2378 parentSlot.didSlotChange(slotChangeType);
2379 } 2379 }
2380 } 2380 }
2381 } 2381 }
2382 } 2382 }
2383 2383
2384 DEFINE_TRACE(Node) { 2384 DEFINE_TRACE(Node) {
2385 visitor->trace(m_parentOrShadowHostNode); 2385 visitor->trace(m_parentOrShadowHostNode);
2386 visitor->trace(m_previous); 2386 visitor->trace(m_previous);
2387 visitor->trace(m_next); 2387 visitor->trace(m_next);
2388 // rareData() and m_data.m_layoutObject share their storage. We have to trace 2388 // rareData() and m_data.m_layoutObject share their storage. We have to trace
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 if (node) { 2467 if (node) {
2468 std::stringstream stream; 2468 std::stringstream stream;
2469 node->printNodePathTo(stream); 2469 node->printNodePathTo(stream);
2470 LOG(INFO) << stream.str(); 2470 LOG(INFO) << stream.str();
2471 } else { 2471 } else {
2472 LOG(INFO) << "Cannot showNodePath for <null>"; 2472 LOG(INFO) << "Cannot showNodePath for <null>";
2473 } 2473 }
2474 } 2474 }
2475 2475
2476 #endif 2476 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698