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

Unified 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: Avoid multiple toElement 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/dom/Node.cpp
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index 6e181387c56f729a8792e4dcd0d6d86f2e011fc2..8760f77e3cf3699b5ef4b37b46e8d8871b0424e5 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -56,6 +56,7 @@
#include "core/dom/Text.h"
#include "core/dom/TreeScopeAdopter.h"
#include "core/dom/UserActionElementSet.h"
+#include "core/dom/custom/CustomElement.h"
#include "core/dom/shadow/ElementShadow.h"
#include "core/dom/shadow/FlatTreeTraversal.h"
#include "core/dom/shadow/InsertionPoint.h"
@@ -2220,24 +2221,6 @@ bool Node::isUserActionElementFocused() const
return document().userActionElements().isFocused(this);
}
-std::ostream& operator<<(std::ostream& os, CustomElementState state)
-{
- switch (state) {
- case CustomElementState::Uncustomized: return os << "Uncustomized";
- case CustomElementState::Undefined: return os << "Undefined";
- case CustomElementState::Custom: return os << "Custom";
- default: NOTREACHED();
- }
- return os;
-}
-
-CustomElementState Node::getCustomElementState() const
-{
- return !isCustomElement()
- ? CustomElementState::Uncustomized
- : (getFlag(CustomElementCustomFlag) ? CustomElementState::Custom : CustomElementState::Undefined);
-}
-
void Node::setCustomElementState(CustomElementState newState)
{
CustomElementState oldState = getCustomElementState();
@@ -2254,25 +2237,24 @@ void Node::setCustomElementState(CustomElementState newState)
case CustomElementState::Custom:
DCHECK_EQ(CustomElementState::Undefined, oldState);
break;
+
+ case CustomElementState::Failed:
+ DCHECK_NE(CustomElementState::Failed, oldState);
+ break;
}
DCHECK(isHTMLElement());
DCHECK_NE(V0Upgraded, getV0CustomElementState());
-#if DCHECK_IS_ON()
- bool wasDefined = toElement(this)->isDefined();
-#endif
- setFlag(CustomElementFlag);
- if (newState == CustomElementState::Custom)
- setFlag(CustomElementCustomFlag);
+ Element* element = toElement(this);
+ bool wasDefined = element->isDefined();
+
+ m_nodeFlags = (m_nodeFlags & ~CustomElementStateMask)
+ | static_cast<NodeFlags>(newState);
DCHECK(newState == getCustomElementState());
- // When the state goes from Uncustomized to Undefined, and then to Custom,
- // isDefined is always flipped.
-#if DCHECK_IS_ON()
- DCHECK_NE(wasDefined, toElement(this)->isDefined());
-#endif
- toElement(this)->pseudoStateChanged(CSSSelector::PseudoDefined);
+ if (element->isDefined() != wasDefined)
+ element->pseudoStateChanged(CSSSelector::PseudoDefined);
}
void Node::setV0CustomElementState(V0CustomElementState newState)
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/custom/CustomElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698