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

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

Issue 2058823002: Implement callback reactions for Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@stack-ce
Patch Set: Minor cleanup Created 4 years, 6 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CustomElement_h 5 #ifndef CustomElement_h
6 #define CustomElement_h 6 #define CustomElement_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/HTMLNames.h" 9 #include "core/HTMLNames.h"
10 #include "core/dom/Element.h" 10 #include "core/dom/Element.h"
11 #include "wtf/Allocator.h" 11 #include "wtf/Allocator.h"
12 #include "wtf/text/AtomicString.h" 12 #include "wtf/text/AtomicString.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 class Document; 16 class Document;
17 class Element; 17 class Element;
18 class HTMLElement; 18 class HTMLElement;
19 class QualifiedName; 19 class QualifiedName;
20 class CustomElementDefinition; 20 class CustomElementDefinition;
21 class CustomElementReaction;
21 class CustomElementRegistry; 22 class CustomElementRegistry;
22 23
23 class CORE_EXPORT CustomElement { 24 class CORE_EXPORT CustomElement {
24 STATIC_ONLY(CustomElement); 25 STATIC_ONLY(CustomElement);
25 public: 26 public:
26 // Retrieves the CustomElementsRegistry for Element, if any. This 27 // Retrieves the CustomElementsRegistry for Element, if any. This
27 // may be a different object for a given element over its lifetime 28 // may be a different object for a given element over its lifetime
28 // as it moves between documents. 29 // as it moves between documents.
29 static CustomElementsRegistry* registry(const Element&); 30 static CustomElementsRegistry* registry(const Element&);
30 static CustomElementsRegistry* registry(const Document&); 31 static CustomElementsRegistry* registry(const Document&);
31 32
32 // Returns true if element could possibly match a custom element 33 static CustomElementDefinition* definitionForElement(const Element&);
33 // descriptor *now*. See CustomElementDescriptor::matches for the
34 // meaning of "match". Custom element processing which depends on
35 // matching a descriptor, such as upgrade, can be skipped for
36 // elements that fail this test.
37 //
38 // Although this result is currently constant for a given element,
39 // when customized built-in elements are implemented the result
40 // will depend on the value of the 'is' attribute. In addition,
41 // these elements may stop matching descriptors after being
42 // upgraded, so use Node::getCustomElementState to detect
43 // customized elements.
44 static bool descriptorMayMatch(const Element& element)
kojii 2016/06/13 02:31:10 Should "getCustomElementState() == CustomElementSt
dominicc (has gone to gerrit) 2016/06/13 07:59:01 Yep, sounds good! We don't need this any more. Yay
45 {
46 // TODO(dominicc): Broaden this check when customized built-in
47 // elements are implemented.
48 return isValidName(element.localName())
49 && element.namespaceURI() == HTMLNames::xhtmlNamespaceURI;
50 }
51 34
52 static bool isValidName(const AtomicString& name); 35 static bool isValidName(const AtomicString& name);
53 36
54 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me); 37 static bool shouldCreateCustomElement(Document&, const AtomicString& localNa me);
55 static bool shouldCreateCustomElement(Document&, const QualifiedName&); 38 static bool shouldCreateCustomElement(Document&, const QualifiedName&);
56 39
57 static HTMLElement* createCustomElement(Document&, const AtomicString& local Name, CreateElementFlags); 40 static HTMLElement* createCustomElement(Document&, const AtomicString& local Name, CreateElementFlags);
58 static HTMLElement* createCustomElement(Document&, const QualifiedName&, Cre ateElementFlags); 41 static HTMLElement* createCustomElement(Document&, const QualifiedName&, Cre ateElementFlags);
59 42
60 static void enqueueUpgradeReaction(Element*, CustomElementDefinition*); 43 static void enqueueConnectedCallback(Element*);
44 static void enqueueDisconnectedCallback(Element*);
45 static void enqueueAttributeChangedCallback(Element*, const QualifiedName&,
46 const AtomicString& oldValue, const AtomicString& newValue);
61 47
62 private: 48 private:
63 static HTMLElement* createCustomElementAsync(Document&, CustomElementDefinit ion&, const QualifiedName&); 49 static HTMLElement* createCustomElementAsync(Document&, CustomElementDefinit ion&, const QualifiedName&);
50
dominicc (has gone to gerrit) 2016/06/13 07:59:01 Nit: Delete?
kojii 2016/06/13 14:56:42 This is to be deleted in another CL ;)
64 }; 51 };
65 52
66 } // namespace blink 53 } // namespace blink
67 54
68 #endif // CustomElement_h 55 #endif // CustomElement_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698