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

Unified Diff: third_party/WebKit/Source/core/dom/custom/CustomElement.h

Issue 2023093003: Upgrade in-document custom elements when an element is defined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ASAN failure in test helper. 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
Index: third_party/WebKit/Source/core/dom/custom/CustomElement.h
diff --git a/third_party/WebKit/Source/core/dom/custom/CustomElement.h b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
index 7b9dcccc3921ced551871506c108def492927dc4..92e8304a085cdc87b4e9156e272a8d4aeca1443c 100644
--- a/third_party/WebKit/Source/core/dom/custom/CustomElement.h
+++ b/third_party/WebKit/Source/core/dom/custom/CustomElement.h
@@ -6,7 +6,8 @@
#define CustomElement_h
#include "core/CoreExport.h"
-#include "core/dom/Document.h"
+#include "core/HTMLNames.h"
+#include "core/dom/Element.h"
#include "wtf/Allocator.h"
#include "wtf/text/AtomicString.h"
@@ -15,10 +16,36 @@ namespace blink {
class Document;
class HTMLElement;
class QualifiedName;
+class CustomElementRegistry;
class CORE_EXPORT CustomElement {
STATIC_ONLY(CustomElement);
public:
+ // Retrieves the CustomElementsRegistry for Element, if any. This
+ // may be a different object for a given element over its lifetime
+ // as it moves between documents.
+ static CustomElementsRegistry* registry(const Element&);
+
+ // Returns true if element could possibly match a custom element
+ // descriptor *now*. See CustomElementDescriptor::matches for the
+ // meaning of "match". Custom element processing which depends on
+ // matching a descriptor, such as upgrade, can be skipped for
+ // elements that fail this test.
+ //
+ // Although this result is currently constant for a given element,
+ // when customized built-in elements are implemented the result
+ // will depend on the value of the 'is' attribute. In addition,
+ // these elements may stop matching descriptors after being
+ // upgraded, so use Node::getCustomElementState to detect
+ // customized elements.
+ static bool descriptorMayMatch(const Element& element)
+ {
+ // TODO(dominicc): Broaden this check when customized built-in
+ // elements are implemented.
+ return isValidName(element.localName())
+ && element.namespaceURI() == HTMLNames::xhtmlNamespaceURI;
+ }
+
static bool isValidName(const AtomicString& name);
static bool shouldCreateCustomElement(Document&, const AtomicString& localName);

Powered by Google App Engine
This is Rietveld 408576698