| /* |
| * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT. |
| * |
| * This file was generated by the dom/make_names.pl script. |
| * |
| * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2013 Apple 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: |
| * 1. Redistributions of source code must retain the above copyright |
| * notice, this list of conditions and the following disclaimer. |
| * 2. 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. |
| * |
| * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``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 APPLE INC. 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 "JSMathMLElementWrapperFactory.h" |
| |
| |
| #if ENABLE(MATHML) |
| |
| #include "JSMathMLAnnotationElement.h" |
| #include "JSMathMLSelectElement.h" |
| #include "JSMathMLPresentationElement.h" |
| #include "JSMathMLMathElement.h" |
| #include "JSMathMLMencloseElement.h" |
| #include "JSMathMLRowElement.h" |
| #include "JSMathMLFractionElement.h" |
| #include "JSMathMLTokenElement.h" |
| #include "JSMathMLScriptsElement.h" |
| #include "JSMathMLOperatorElement.h" |
| #include "JSMathMLUnderOverElement.h" |
| #include "JSMathMLPaddedElement.h" |
| #include "JSMathMLSpaceElement.h" |
| #include "JSMathMLUnknownElement.h" |
| #include "MathMLAnnotationElement.h" |
| #include "MathMLSelectElement.h" |
| #include "MathMLPresentationElement.h" |
| #include "MathMLMathElement.h" |
| #include "MathMLMencloseElement.h" |
| #include "MathMLRowElement.h" |
| #include "MathMLFractionElement.h" |
| #include "MathMLTokenElement.h" |
| #include "MathMLScriptsElement.h" |
| #include "MathMLOperatorElement.h" |
| #include "MathMLUnderOverElement.h" |
| #include "MathMLPaddedElement.h" |
| #include "MathMLSpaceElement.h" |
| #include "MathMLUnknownElement.h" |
| |
| #include "MathMLNames.h" |
| |
| #include "Document.h" |
| #include "RuntimeEnabledFeatures.h" |
| #include "Settings.h" |
| #include <wtf/NeverDestroyed.h> |
| #include <wtf/StdLibExtras.h> |
| |
| using namespace JSC; |
| |
| namespace WebCore { |
| |
| using namespace MathMLNames; |
| |
| typedef JSDOMObject* (*CreateMathMLElementWrapperFunction)(JSDOMGlobalObject*, Ref<MathMLElement>&&); |
| |
| static JSDOMObject* createMathMLAnnotationElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLAnnotationElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLSelectElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLSelectElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLPresentationElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLPresentationElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLMathElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLMathElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLMencloseElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLMencloseElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLRowElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLRowElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLFractionElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLFractionElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLTokenElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLTokenElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLScriptsElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLScriptsElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLOperatorElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLOperatorElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLUnderOverElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLUnderOverElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLPaddedElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLPaddedElement>(globalObject, WTFMove(element)); |
| } |
| |
| static JSDOMObject* createMathMLSpaceElementWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| return createWrapper<MathMLSpaceElement>(globalObject, WTFMove(element)); |
| } |
| |
| |
| static NEVER_INLINE void populateMathMLWrapperMap(HashMap<AtomicStringImpl*, CreateMathMLElementWrapperFunction>& map) |
| { |
| struct TableEntry { |
| const QualifiedName& name; |
| CreateMathMLElementWrapperFunction function; |
| }; |
| |
| static const TableEntry table[] = { |
| { annotationTag, createMathMLAnnotationElementWrapper }, |
| { annotation_xmlTag, createMathMLAnnotationElementWrapper }, |
| { mactionTag, createMathMLSelectElementWrapper }, |
| { maligngroupTag, createMathMLPresentationElementWrapper }, |
| { malignmarkTag, createMathMLPresentationElementWrapper }, |
| { mathTag, createMathMLMathElementWrapper }, |
| { mencloseTag, createMathMLMencloseElementWrapper }, |
| { merrorTag, createMathMLRowElementWrapper }, |
| { mfencedTag, createMathMLRowElementWrapper }, |
| { mfracTag, createMathMLFractionElementWrapper }, |
| { mglyphTag, createMathMLPresentationElementWrapper }, |
| { miTag, createMathMLTokenElementWrapper }, |
| { mlabeledtrTag, createMathMLPresentationElementWrapper }, |
| { mlongdivTag, createMathMLPresentationElementWrapper }, |
| { mmultiscriptsTag, createMathMLScriptsElementWrapper }, |
| { mnTag, createMathMLTokenElementWrapper }, |
| { moTag, createMathMLOperatorElementWrapper }, |
| { moverTag, createMathMLUnderOverElementWrapper }, |
| { mpaddedTag, createMathMLPaddedElementWrapper }, |
| { mphantomTag, createMathMLRowElementWrapper }, |
| { mprescriptsTag, createMathMLPresentationElementWrapper }, |
| { mrootTag, createMathMLRowElementWrapper }, |
| { mrowTag, createMathMLRowElementWrapper }, |
| { msTag, createMathMLTokenElementWrapper }, |
| { mscarriesTag, createMathMLPresentationElementWrapper }, |
| { mscarryTag, createMathMLPresentationElementWrapper }, |
| { msgroupTag, createMathMLPresentationElementWrapper }, |
| { mslineTag, createMathMLPresentationElementWrapper }, |
| { mspaceTag, createMathMLSpaceElementWrapper }, |
| { msqrtTag, createMathMLRowElementWrapper }, |
| { msrowTag, createMathMLPresentationElementWrapper }, |
| { mstackTag, createMathMLPresentationElementWrapper }, |
| { mstyleTag, createMathMLRowElementWrapper }, |
| { msubTag, createMathMLScriptsElementWrapper }, |
| { msubsupTag, createMathMLScriptsElementWrapper }, |
| { msupTag, createMathMLScriptsElementWrapper }, |
| { mtableTag, createMathMLPresentationElementWrapper }, |
| { mtdTag, createMathMLPresentationElementWrapper }, |
| { mtextTag, createMathMLTokenElementWrapper }, |
| { mtrTag, createMathMLPresentationElementWrapper }, |
| { munderTag, createMathMLUnderOverElementWrapper }, |
| { munderoverTag, createMathMLUnderOverElementWrapper }, |
| { noneTag, createMathMLPresentationElementWrapper }, |
| { semanticsTag, createMathMLSelectElementWrapper }, |
| }; |
| |
| for (unsigned i = 0; i < WTF_ARRAY_LENGTH(table); ++i) |
| map.add(table[i].name.localName().impl(), table[i].function); |
| } |
| |
| JSDOMObject* createJSMathMLWrapper(JSDOMGlobalObject* globalObject, Ref<MathMLElement>&& element) |
| { |
| static NeverDestroyed<HashMap<AtomicStringImpl*, CreateMathMLElementWrapperFunction>> functions; |
| if (functions.get().isEmpty()) |
| populateMathMLWrapperMap(functions); |
| if (auto function = functions.get().get(element->localName().impl())) |
| return function(globalObject, WTFMove(element)); |
| return createWrapper<MathMLUnknownElement>(globalObject, WTFMove(element)); |
| } |
| |
| } |
| |
| #endif |