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

Unified Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 1982973002: Add CustomElementState for Custom Elements v1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix and UNREACHABLE -> NOTREACHED Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/NodeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7018a3bc473fb3124ca0479161f0bceaf3d82b9b..578f245ab2c871bb4709946013f4d0294a50117a 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -2303,6 +2303,55 @@ 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();
+
+ switch (newState) {
+ case CustomElementState::Uncustomized:
+ NOTREACHED(); // Everything starts in this state
+ return;
+
+ case CustomElementState::Undefined:
+ DCHECK_EQ(CustomElementState::Uncustomized, oldState);
+ break;
+
+ case CustomElementState::Custom:
+ DCHECK_EQ(CustomElementState::Undefined, oldState);
+ break;
+ }
+
+ DCHECK(isHTMLElement());
+ DCHECK_NE(V0Upgraded, getV0CustomElementState());
+
+ setFlag(CustomElementFlag);
+ if (newState == CustomElementState::Custom)
+ setFlag(CustomElementCustomFlag);
+ DCHECK(newState == getCustomElementState());
+
+ // TODO(kojii): Should fire pseudoStateChanged() when :defined selector is
+ // ready.
+ // toElement(this)->pseudoStateChanged(CSSSelector::PseudoDefined);
+}
+
void Node::setV0CustomElementState(V0CustomElementState newState)
{
V0CustomElementState oldState = getV0CustomElementState();
@@ -2322,6 +2371,7 @@ void Node::setV0CustomElementState(V0CustomElementState newState)
}
DCHECK(isHTMLElement() || isSVGElement());
+ DCHECK(CustomElementState::Custom != getCustomElementState());
setFlag(V0CustomElementFlag);
setFlag(newState == V0Upgraded, V0CustomElementUpgradedFlag);
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/core/dom/NodeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698