OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 10 matching lines...) Expand all Loading... |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/dom/custom/CustomElement.h" | 31 #include "core/dom/custom/V0CustomElement.h" |
32 | 32 |
33 #include "core/HTMLNames.h" | 33 #include "core/HTMLNames.h" |
34 #include "core/MathMLNames.h" | 34 #include "core/MathMLNames.h" |
35 #include "core/SVGNames.h" | 35 #include "core/SVGNames.h" |
36 #include "core/dom/Document.h" | 36 #include "core/dom/Document.h" |
37 #include "core/dom/Element.h" | 37 #include "core/dom/Element.h" |
38 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" | 38 #include "core/dom/custom/V0CustomElementMicrotaskRunQueue.h" |
39 #include "core/dom/custom/CustomElementObserver.h" | 39 #include "core/dom/custom/V0CustomElementObserver.h" |
40 #include "core/dom/custom/CustomElementScheduler.h" | 40 #include "core/dom/custom/V0CustomElementScheduler.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 CustomElementMicrotaskImportStep* CustomElement::didCreateImport(HTMLImportChild
* import) | 44 V0CustomElementMicrotaskImportStep* V0CustomElement::didCreateImport(HTMLImportC
hild* import) |
45 { | 45 { |
46 return CustomElementScheduler::scheduleImport(import); | 46 return V0CustomElementScheduler::scheduleImport(import); |
47 } | 47 } |
48 | 48 |
49 void CustomElement::didFinishLoadingImport(Document& master) | 49 void V0CustomElement::didFinishLoadingImport(Document& master) |
50 { | 50 { |
51 master.customElementMicrotaskRunQueue()->requestDispatchIfNeeded(); | 51 master.customElementMicrotaskRunQueue()->requestDispatchIfNeeded(); |
52 } | 52 } |
53 | 53 |
54 Vector<AtomicString>& CustomElement::embedderCustomElementNames() | 54 Vector<AtomicString>& V0CustomElement::embedderCustomElementNames() |
55 { | 55 { |
56 DEFINE_STATIC_LOCAL(Vector<AtomicString>, names, ()); | 56 DEFINE_STATIC_LOCAL(Vector<AtomicString>, names, ()); |
57 return names; | 57 return names; |
58 } | 58 } |
59 | 59 |
60 void CustomElement::addEmbedderCustomElementName(const AtomicString& name) | 60 void V0CustomElement::addEmbedderCustomElementName(const AtomicString& name) |
61 { | 61 { |
62 AtomicString lower = name.lower(); | 62 AtomicString lower = name.lower(); |
63 if (isValidName(lower, EmbedderNames)) | 63 if (isValidName(lower, EmbedderNames)) |
64 return; | 64 return; |
65 embedderCustomElementNames().append(lower); | 65 embedderCustomElementNames().append(lower); |
66 } | 66 } |
67 | 67 |
68 static inline bool isValidNCName(const AtomicString& name) | 68 static inline bool isValidNCName(const AtomicString& name) |
69 { | 69 { |
70 if (kNotFound != name.find(':')) | 70 if (kNotFound != name.find(':')) |
71 return false; | 71 return false; |
72 | 72 |
73 if (!name.getString().is8Bit()) { | 73 if (!name.getString().is8Bit()) { |
74 const UChar32 c = name.characters16()[0]; | 74 const UChar32 c = name.characters16()[0]; |
75 // These characters comes under CombiningChar in NCName and according to | 75 // These characters comes under CombiningChar in NCName and according to |
76 // NCName only BaseChar and Ideodgraphic can come as first chars. | 76 // NCName only BaseChar and Ideodgraphic can come as first chars. |
77 // Also these characters come under Letter_Other in UnicodeData, thats | 77 // Also these characters come under Letter_Other in UnicodeData, thats |
78 // why they pass as valid document name. | 78 // why they pass as valid document name. |
79 if (c == 0x0B83 || c == 0x0F88 || c == 0x0F89 || c == 0x0F8A || c == 0x0
F8B) | 79 if (c == 0x0B83 || c == 0x0F88 || c == 0x0F89 || c == 0x0F8A || c == 0x0
F8B) |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 return Document::isValidName(name.getString()); | 83 return Document::isValidName(name.getString()); |
84 } | 84 } |
85 | 85 |
86 bool CustomElement::isValidName(const AtomicString& name, NameSet validNames) | 86 bool V0CustomElement::isValidName(const AtomicString& name, NameSet validNames) |
87 { | 87 { |
88 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames(
).find(name)) | 88 if ((validNames & EmbedderNames) && kNotFound != embedderCustomElementNames(
).find(name)) |
89 return Document::isValidName(name); | 89 return Document::isValidName(name); |
90 | 90 |
91 if ((validNames & StandardNames) && kNotFound != name.find('-')) { | 91 if ((validNames & StandardNames) && kNotFound != name.find('-')) { |
92 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ()); | 92 DEFINE_STATIC_LOCAL(Vector<AtomicString>, reservedNames, ()); |
93 if (reservedNames.isEmpty()) { | 93 if (reservedNames.isEmpty()) { |
94 // FIXME(crbug.com/426605): We should be able to remove this. | 94 // FIXME(crbug.com/426605): We should be able to remove this. |
95 reservedNames.append(MathMLNames::annotation_xmlTag.localName()); | 95 reservedNames.append(MathMLNames::annotation_xmlTag.localName()); |
96 } | 96 } |
97 | 97 |
98 if (kNotFound == reservedNames.find(name)) | 98 if (kNotFound == reservedNames.find(name)) |
99 return isValidNCName(name); | 99 return isValidNCName(name); |
100 } | 100 } |
101 | 101 |
102 return false; | 102 return false; |
103 } | 103 } |
104 | 104 |
105 void CustomElement::define(Element* element, CustomElementDefinition* definition
) | 105 void V0CustomElement::define(Element* element, V0CustomElementDefinition* defini
tion) |
106 { | 106 { |
107 switch (element->getCustomElementState()) { | 107 switch (element->getCustomElementState()) { |
108 case Element::NotCustomElement: | 108 case Element::NotCustomElement: |
109 case Element::Upgraded: | 109 case Element::Upgraded: |
110 ASSERT_NOT_REACHED(); | 110 ASSERT_NOT_REACHED(); |
111 break; | 111 break; |
112 | 112 |
113 case Element::WaitingForUpgrade: | 113 case Element::WaitingForUpgrade: |
114 element->setCustomElementDefinition(definition); | 114 element->setCustomElementDefinition(definition); |
115 CustomElementScheduler::scheduleCallback(definition->callbacks(), elemen
t, CustomElementLifecycleCallbacks::CreatedCallback); | 115 V0CustomElementScheduler::scheduleCallback(definition->callbacks(), elem
ent, V0CustomElementLifecycleCallbacks::CreatedCallback); |
116 break; | 116 break; |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void CustomElement::attributeDidChange(Element* element, const AtomicString& nam
e, const AtomicString& oldValue, const AtomicString& newValue) | 120 void V0CustomElement::attributeDidChange(Element* element, const AtomicString& n
ame, const AtomicString& oldValue, const AtomicString& newValue) |
121 { | 121 { |
122 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); | 122 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); |
123 CustomElementScheduler::scheduleAttributeChangedCallback(element->customElem
entDefinition()->callbacks(), element, name, oldValue, newValue); | 123 V0CustomElementScheduler::scheduleAttributeChangedCallback(element->customEl
ementDefinition()->callbacks(), element, name, oldValue, newValue); |
124 } | 124 } |
125 | 125 |
126 void CustomElement::didAttach(Element* element, const Document& document) | 126 void V0CustomElement::didAttach(Element* element, const Document& document) |
127 { | 127 { |
128 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); | 128 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); |
129 if (!document.domWindow()) | 129 if (!document.domWindow()) |
130 return; | 130 return; |
131 CustomElementScheduler::scheduleCallback(element->customElementDefinition()-
>callbacks(), element, CustomElementLifecycleCallbacks::AttachedCallback); | 131 V0CustomElementScheduler::scheduleCallback(element->customElementDefinition(
)->callbacks(), element, V0CustomElementLifecycleCallbacks::AttachedCallback); |
132 } | 132 } |
133 | 133 |
134 void CustomElement::didDetach(Element* element, const Document& document) | 134 void V0CustomElement::didDetach(Element* element, const Document& document) |
135 { | 135 { |
136 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); | 136 DCHECK_EQ(element->getCustomElementState(), Element::Upgraded); |
137 if (!document.domWindow()) | 137 if (!document.domWindow()) |
138 return; | 138 return; |
139 CustomElementScheduler::scheduleCallback(element->customElementDefinition()-
>callbacks(), element, CustomElementLifecycleCallbacks::DetachedCallback); | 139 V0CustomElementScheduler::scheduleCallback(element->customElementDefinition(
)->callbacks(), element, V0CustomElementLifecycleCallbacks::DetachedCallback); |
140 } | 140 } |
141 | 141 |
142 void CustomElement::wasDestroyed(Element* element) | 142 void V0CustomElement::wasDestroyed(Element* element) |
143 { | 143 { |
144 switch (element->getCustomElementState()) { | 144 switch (element->getCustomElementState()) { |
145 case Element::NotCustomElement: | 145 case Element::NotCustomElement: |
146 ASSERT_NOT_REACHED(); | 146 ASSERT_NOT_REACHED(); |
147 break; | 147 break; |
148 | 148 |
149 case Element::WaitingForUpgrade: | 149 case Element::WaitingForUpgrade: |
150 case Element::Upgraded: | 150 case Element::Upgraded: |
151 CustomElementObserver::notifyElementWasDestroyed(element); | 151 V0CustomElementObserver::notifyElementWasDestroyed(element); |
152 break; | 152 break; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 } // namespace blink | 156 } // namespace blink |
OLD | NEW |