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

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

Issue 2173623003: Add "Failed" custom element state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix and cleanup Created 4 years, 5 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 r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/dom/NodeRareData.h" 48 #include "core/dom/NodeRareData.h"
49 #include "core/dom/NodeTraversal.h" 49 #include "core/dom/NodeTraversal.h"
50 #include "core/dom/ProcessingInstruction.h" 50 #include "core/dom/ProcessingInstruction.h"
51 #include "core/dom/Range.h" 51 #include "core/dom/Range.h"
52 #include "core/dom/StaticNodeList.h" 52 #include "core/dom/StaticNodeList.h"
53 #include "core/dom/StyleEngine.h" 53 #include "core/dom/StyleEngine.h"
54 #include "core/dom/TemplateContentDocumentFragment.h" 54 #include "core/dom/TemplateContentDocumentFragment.h"
55 #include "core/dom/Text.h" 55 #include "core/dom/Text.h"
56 #include "core/dom/TreeScopeAdopter.h" 56 #include "core/dom/TreeScopeAdopter.h"
57 #include "core/dom/UserActionElementSet.h" 57 #include "core/dom/UserActionElementSet.h"
58 #include "core/dom/custom/CustomElement.h"
58 #include "core/dom/shadow/ElementShadow.h" 59 #include "core/dom/shadow/ElementShadow.h"
59 #include "core/dom/shadow/FlatTreeTraversal.h" 60 #include "core/dom/shadow/FlatTreeTraversal.h"
60 #include "core/dom/shadow/InsertionPoint.h" 61 #include "core/dom/shadow/InsertionPoint.h"
61 #include "core/dom/shadow/ShadowRoot.h" 62 #include "core/dom/shadow/ShadowRoot.h"
62 #include "core/dom/shadow/SlotAssignment.h" 63 #include "core/dom/shadow/SlotAssignment.h"
63 #include "core/editing/EditingUtilities.h" 64 #include "core/editing/EditingUtilities.h"
64 #include "core/editing/markers/DocumentMarkerController.h" 65 #include "core/editing/markers/DocumentMarkerController.h"
65 #include "core/events/Event.h" 66 #include "core/events/Event.h"
66 #include "core/events/EventDispatchMediator.h" 67 #include "core/events/EventDispatchMediator.h"
67 #include "core/events/EventDispatcher.h" 68 #include "core/events/EventDispatcher.h"
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 DCHECK(isUserActionElement()); 2335 DCHECK(isUserActionElement());
2335 return document().userActionElements().isFocused(this); 2336 return document().userActionElements().isFocused(this);
2336 } 2337 }
2337 2338
2338 std::ostream& operator<<(std::ostream& os, CustomElementState state) 2339 std::ostream& operator<<(std::ostream& os, CustomElementState state)
2339 { 2340 {
2340 switch (state) { 2341 switch (state) {
2341 case CustomElementState::Uncustomized: return os << "Uncustomized"; 2342 case CustomElementState::Uncustomized: return os << "Uncustomized";
2342 case CustomElementState::Undefined: return os << "Undefined"; 2343 case CustomElementState::Undefined: return os << "Undefined";
2343 case CustomElementState::Custom: return os << "Custom"; 2344 case CustomElementState::Custom: return os << "Custom";
2345 case CustomElementState::Failed: return os << "Failed";
2344 default: NOTREACHED(); 2346 default: NOTREACHED();
2345 } 2347 }
2346 return os; 2348 return os;
2347 } 2349 }
2348 2350
2349 CustomElementState Node::getCustomElementState() const
2350 {
2351 return !isCustomElement()
2352 ? CustomElementState::Uncustomized
2353 : (getFlag(CustomElementCustomFlag) ? CustomElementState::Custom : Custo mElementState::Undefined);
2354 }
2355
2356 void Node::setCustomElementState(CustomElementState newState) 2351 void Node::setCustomElementState(CustomElementState newState)
2357 { 2352 {
2358 CustomElementState oldState = getCustomElementState(); 2353 CustomElementState oldState = getCustomElementState();
2359 2354
2355 bool isDefinedChanged = false;
dominicc (has gone to gerrit) 2016/07/26 05:47:42 It might be better to have something that tests "i
2360 switch (newState) { 2356 switch (newState) {
2361 case CustomElementState::Uncustomized: 2357 case CustomElementState::Uncustomized:
2362 NOTREACHED(); // Everything starts in this state 2358 NOTREACHED(); // Everything starts in this state
2363 return; 2359 return;
2364 2360
2365 case CustomElementState::Undefined: 2361 case CustomElementState::Undefined:
2366 DCHECK_EQ(CustomElementState::Uncustomized, oldState); 2362 DCHECK_EQ(CustomElementState::Uncustomized, oldState);
2363 isDefinedChanged = true;
2367 break; 2364 break;
2368 2365
2369 case CustomElementState::Custom: 2366 case CustomElementState::Custom:
2370 DCHECK_EQ(CustomElementState::Undefined, oldState); 2367 DCHECK_EQ(CustomElementState::Undefined, oldState);
2368 isDefinedChanged = true;
2369 break;
2370
2371 case CustomElementState::Failed:
2372 DCHECK_NE(CustomElementState::Failed, oldState);
2373 isDefinedChanged = CustomElement::isDefined(oldState);
2371 break; 2374 break;
2372 } 2375 }
2373 2376
2374 DCHECK(isHTMLElement()); 2377 DCHECK(isHTMLElement());
2375 DCHECK_NE(V0Upgraded, getV0CustomElementState()); 2378 DCHECK_NE(V0Upgraded, getV0CustomElementState());
2376 #if DCHECK_IS_ON() 2379 #if DCHECK_IS_ON()
2377 bool wasDefined = toElement(this)->isDefined(); 2380 bool wasDefined = toElement(this)->isDefined();
2378 #endif 2381 #endif
2379 2382
2380 setFlag(CustomElementFlag); 2383 m_nodeFlags = (m_nodeFlags & ~CustomElementStateMask)
2381 if (newState == CustomElementState::Custom) 2384 | static_cast<NodeFlags>(newState);
2382 setFlag(CustomElementCustomFlag);
2383 DCHECK(newState == getCustomElementState()); 2385 DCHECK(newState == getCustomElementState());
2384 2386
2385 // When the state goes from Uncustomized to Undefined, and then to Custom, 2387 if (isDefinedChanged) {
2386 // isDefined is always flipped.
2387 #if DCHECK_IS_ON() 2388 #if DCHECK_IS_ON()
2388 DCHECK_NE(wasDefined, toElement(this)->isDefined()); 2389 DCHECK_NE(wasDefined, toElement(this)->isDefined());
2389 #endif 2390 #endif
2390 toElement(this)->pseudoStateChanged(CSSSelector::PseudoDefined); 2391 toElement(this)->pseudoStateChanged(CSSSelector::PseudoDefined);
2392 }
2391 } 2393 }
2392 2394
2393 void Node::setV0CustomElementState(V0CustomElementState newState) 2395 void Node::setV0CustomElementState(V0CustomElementState newState)
2394 { 2396 {
2395 V0CustomElementState oldState = getV0CustomElementState(); 2397 V0CustomElementState oldState = getV0CustomElementState();
2396 2398
2397 switch (newState) { 2399 switch (newState) {
2398 case V0NotCustomElement: 2400 case V0NotCustomElement:
2399 ASSERT_NOT_REACHED(); // Everything starts in this state 2401 ASSERT_NOT_REACHED(); // Everything starts in this state
2400 return; 2402 return;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 2538
2537 void showNodePath(const blink::Node* node) 2539 void showNodePath(const blink::Node* node)
2538 { 2540 {
2539 if (node) 2541 if (node)
2540 node->showNodePathForThis(); 2542 node->showNodePathForThis();
2541 else 2543 else
2542 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2544 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2543 } 2545 }
2544 2546
2545 #endif 2547 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698