| Index: Source/bindings/dart/DartCustomElementConstructorBuilder.cpp
|
| diff --git a/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp b/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2e79b4e2e514009773d9c706cbb35873659932f5
|
| --- /dev/null
|
| +++ b/Source/bindings/dart/DartCustomElementConstructorBuilder.cpp
|
| @@ -0,0 +1,130 @@
|
| +/*
|
| + * Copyright (C) 2013 Google Inc. All rights reserved.
|
| + *
|
| + * Redistribution and use in source and binary forms, with or without
|
| + * modification, are permitted provided that the following conditions are
|
| + * met:
|
| + *
|
| + * * Redistributions of source code must retain the above copyright
|
| + * notice, this list of conditions and the following disclaimer.
|
| + * * Redistributions in binary form must reproduce the above
|
| + * copyright notice, this list of conditions and the following disclaimer
|
| + * in the documentation and/or other materials provided with the
|
| + * distribution.
|
| + * * Neither the name of Google Inc. nor the names of its
|
| + * contributors may be used to endorse or promote products derived from
|
| + * this software without specific prior written permission.
|
| + *
|
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| + */
|
| +
|
| +#include "config.h"
|
| +#include "bindings/dart/DartCustomElementConstructorBuilder.h"
|
| +
|
| +#include "HTMLNames.h"
|
| +#include "SVGNames.h"
|
| +#include "bindings/dart/DartCustomElementBinding.h"
|
| +#include "bindings/dart/DartCustomElementLifecycleCallbacks.h"
|
| +#include "bindings/dart/DartDOMData.h"
|
| +#include "bindings/dart/DartUtilities.h"
|
| +#include "bindings/v8/V8Binding.h"
|
| +#include "core/dom/CustomElementException.h"
|
| +#include "core/dom/Document.h"
|
| +
|
| +namespace WebCore {
|
| +
|
| +DartCustomElementConstructorBuilder::DartCustomElementConstructorBuilder(Dart_Handle customType, const AtomicString& extendsTagName, ScriptState* state, const Dictionary* options)
|
| + : CustomElementConstructorBuilder(state, options)
|
| + , m_customType(customType)
|
| + , m_extendsTagName(extendsTagName)
|
| + , m_isolate(Dart_CurrentIsolate())
|
| + , m_context(state->context())
|
| +{
|
| + ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext());
|
| +}
|
| +
|
| +bool DartCustomElementConstructorBuilder::isFeatureAllowed() const
|
| +{
|
| + // Check that we are in the main world
|
| + return DartDOMData::current()->isDOMEnabled();
|
| +}
|
| +
|
| +bool DartCustomElementConstructorBuilder::validateOptions(const AtomicString& type, ExceptionState& es)
|
| +{
|
| + AtomicString namespaceURI;
|
| +
|
| + if (DartUtilities::isTypeSubclassOf(m_customType, DartUtilities::htmlLibraryName, "HtmlElement")) {
|
| + namespaceURI = HTMLNames::xhtmlNamespaceURI;
|
| + } else if (DartUtilities::isTypeSubclassOf(m_customType, DartUtilities::svgLibraryName, "SvgElement")) {
|
| + namespaceURI = SVGNames::svgNamespaceURI;
|
| + } else {
|
| + CustomElementException::throwException(CustomElementException::PrototypeDoesNotExtendHTMLElementSVGElementPrototype, type, es);
|
| + return false;
|
| + }
|
| +
|
| + AtomicString localName;
|
| + if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) {
|
| + localName = m_extendsTagName.lower();
|
| +
|
| + // TODO: enable once we pick up Blink version 31
|
| + // if (!Document::isValidName(localName)) {
|
| + // CustomElementException::throwException(CustomElementException::ExtendsIsInvalidName, type, es);
|
| + // return false;
|
| + // }
|
| + // if (CustomElement::isValidName(localName)) {
|
| + // CustomElementException::throwException(CustomElementException::ExtendsIsCustomElementName, type, es);
|
| + // return false;
|
| + // }
|
| + } else {
|
| + localName = type;
|
| + }
|
| +
|
| + m_localName = localName;
|
| + m_namespaceURI = namespaceURI;
|
| + return true;
|
| +}
|
| +
|
| +bool DartCustomElementConstructorBuilder::findTagName(const AtomicString& customElementType, QualifiedName& tagName)
|
| +{
|
| + if (!m_extendsTagName.isNull() && !m_extendsTagName.isEmpty()) {
|
| + tagName = QualifiedName(nullAtom, m_extendsTagName, m_namespaceURI);
|
| + } else {
|
| + tagName = QualifiedName(nullAtom, m_localName, m_namespaceURI);
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +PassRefPtr<CustomElementLifecycleCallbacks> DartCustomElementConstructorBuilder::createCallbacks()
|
| +{
|
| + RefPtr<ScriptExecutionContext> scriptExecutionContext(toScriptExecutionContext(m_context));
|
| +
|
| + m_callbacks = DartCustomElementLifecycleCallbacks::create(m_isolate, scriptExecutionContext.get());
|
| + return m_callbacks.get();
|
| +}
|
| +
|
| +bool DartCustomElementConstructorBuilder::createConstructor(Document* document, CustomElementDefinition* definition, ExceptionState& es)
|
| +{
|
| + return true;
|
| +}
|
| +
|
| +bool DartCustomElementConstructorBuilder::didRegisterDefinition(CustomElementDefinition* definition) const
|
| +{
|
| + return m_callbacks->setBinding(definition, DartCustomElementBinding::create(m_customType));
|
| +}
|
| +
|
| +ScriptValue DartCustomElementConstructorBuilder::bindingsReturnValue() const
|
| +{
|
| + // Dart does not return a constructor.
|
| + return ScriptValue();
|
| +}
|
| +} // namespace WebCore
|
|
|