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

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

Issue 24677002: Revert "Revert "Dartium changes for custom element lifecycle events."" (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 2 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 // TODO: enable once we pick up Blink version 31
80 // if (!Document::isValidName(localName)) {
81 // CustomElementException::throwException(CustomElementException::Ex tendsIsInvalidName, type, es);
82 // return false;
83 // }
84 // if (CustomElement::isValidName(localName)) {
85 // CustomElementException::throwException(CustomElementException::Ex tendsIsCustomElementName, type, es);
86 // return false;
87 // }
88 } else {
89 localName = type;
90 }
91
92 m_localName = localName;
93 m_namespaceURI = namespaceURI;
94 return true;
95 }
96
97 bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& custom ElementType, QualifiedName& tagName)
98 {
99 if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) {
100 tagName = QualifiedName(nullAtom, m_extendsTagName, m_namespaceURI);
101 } else {
102 tagName = QualifiedName(nullAtom, m_localName, m_namespaceURI);
103 }
104 return true;
105 }
106
107 PassRefPtr<CustomElementLifecycleCallbacks> DartCustomElementConstructorBuilder: :createCallbacks()
108 {
109 RefPtr<ScriptExecutionContext> scriptExecutionContext(toScriptExecutionConte xt(m_context));
110
111 m_callbacks = DartCustomElementLifecycleCallbacks::create(m_isolate, scriptE xecutionContext.get());
112 return m_callbacks.get();
113 }
114
115 bool DartCustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition, ExceptionState& es)
116 {
117 return true;
118 }
119
120 bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDef inition* definition) const
121 {
122 return m_callbacks->setBinding(definition, DartCustomElementBinding::create( m_customType));
123 }
124
125 ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const
126 {
127 // Dart does not return a constructor.
128 return ScriptValue();
129 }
130 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/dart/DartCustomElementConstructorBuilder.h ('k') | Source/bindings/dart/DartCustomElementLifecycleCallbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698