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

Side by Side Diff: Source/bindings/dart/DartCustomElementConstructorBuilder.cpp

Issue 24294002: Dartium changes for custom element lifecycle events. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #include "config.h"
32 #include "bindings/dart/DartCustomElementConstructorBuilder.h"
33
34 #include "HTMLNames.h"
35 #include "SVGNames.h"
36 #include "bindings/dart/DartCustomElementBinding.h"
37 #include "bindings/dart/DartCustomElementLifecycleCallbacks.h"
38 #include "bindings/dart/DartDOMData.h"
39 #include "bindings/dart/DartUtilities.h"
40 #include "bindings/v8/V8Binding.h"
41 #include "core/dom/CustomElementException.h"
42 #include "core/dom/Document.h"
43
44 namespace WebCore {
45
46 DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Ha ndle customType, const AtomicString& extendsTagName, ScriptState* state, const D ictionary* options)
47 : CustomElementConstructorBuilder(state, options)
48 , m_customType(customType)
49 , m_extendsTagName(extendsTagName)
50 , m_isolate(Dart_CurrentIsolate())
51 , m_context(state->context())
52 {
53 ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext());
54 }
55
56 bool DartCustomElementConstructorBuilder::isFeatureAllowed() const
57 {
58 // Check that we are in the main world
59 return DartDOMData::current()->isDOMEnabled();
60 }
61
62 bool DartCustomElementConstructorBuilder::validateOptions(const AtomicString& ty pe, ExceptionState& es)
63 {
64 AtomicString namespaceURI;
65
66 if (DartUtilities::isTypeSubclassOf(m_customType, DartUtilities::htmlLibrary Name, "HtmlElement")) {
67 namespaceURI = HTMLNames::xhtmlNamespaceURI;
68 } else if (DartUtilities::isTypeSubclassOf(m_customType, DartUtilities::svgL ibraryName, "SvgElement")) {
69 namespaceURI = SVGNames::svgNamespaceURI;
70 } else {
71 CustomElementException::throwException(CustomElementException::Prototype DoesNotExtendHTMLElementSVGElementPrototype, type, es);
72 return false;
73 }
74
75 AtomicString localName;
76 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) {
77 localName = m_extendsTagName.lower();
78
79 // if (!Document::isValidName(localName)) {
vsm 2013/09/19 23:12:26 Should this be commented out? Looks like reasonab
blois 2013/09/20 00:10:25 Sorry, had added a comment which I forgot to uploa
80 // CustomElementException::throwException(CustomElementException::Ex tendsIsInvalidName, type, es);
81 // return false;
82 // }
83 // if (CustomElement::isValidName(localName)) {
84 // CustomElementException::throwException(CustomElementException::Ex tendsIsCustomElementName, type, es);
85 // return false;
86 // }
87 } else {
88 localName = type;
89 }
90
91 m_localName = localName;
92 m_namespaceURI = namespaceURI;
93 return true;
94 }
95
96 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom ElementType, QualifiedName& tagName)
97 {
98 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) {
99 tagName = QualifiedName(nullAtom, m_extendsTagName, m_namespaceURI);
100 } else {
101 tagName = QualifiedName(nullAtom, m_localName, m_namespaceURI);
102 }
103 return true;
104 }
105
106 PassRefPtr<CustomElementLifecycleCallbacks> DartCustomElementConstructorBuilder: :createCallbacks()
107 {
108 RefPtr<ScriptExecutionContext> scriptExecutionContext(toScriptExecutionConte xt(m_context));
109
110 m_callbacks = DartCustomElementLifecycleCallbacks::create(m_isolate, scriptE xecutionContext.get());
111 return m_callbacks.get();
112 }
113
114 bool DartCustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition, ExceptionState& es)
115 {
116 return true;
117 }
118
119 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef inition* definition) const
120 {
121
122 return m_callbacks->setBinding(definition, DartCustomElementBinding::create( m_customType));
123 }
124
125 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const
126 {
127 return ScriptValue();
128 }
129 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698