18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/* 28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Copyright (C) 2007 Apple Inc. All rights reserved. 38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Redistribution and use in source and binary forms, with or without 58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * modification, are permitted provided that the following conditions 68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * are met: 78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 1. Redistributions of source code must retain the above copyright 98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer. 108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright 118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * notice, this list of conditions and the following disclaimer in the 128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * documentation and/or other materials provided with the distribution. 138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * its contributors may be used to endorse or promote products derived 158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * from this software without specific prior written permission. 168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * 178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */ 288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// This file is a temporary hack to implement the createInstance methods for 308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// the COM DOM bindings. 318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "config.h" 338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "DOMCreateInstance.h" 348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMNode.h" 368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMElement.h" 378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMDocument.h" 388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMAttr.h" 398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMText.h" 408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCDATASection.h" 418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMEntityReference.h" 428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMEntity.h" 438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMProcessingInstruction.h" 448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMComment.h" 458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMHTMLElement.h" 468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMHTMLDocument.h" 478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMHTMLCollection.h" 488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMDocumentType.h" 498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMDocumentFragment.h" 508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMNotation.h" 518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSCharsetRule.h" 528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSFontFaceRule.h" 538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSImportRule.h" 548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSMediaRule.h" 558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSPageRule.h" 568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSPrimitiveValue.h" 578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSRule.h" 588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSRuleList.h" 598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSStyleDeclaration.h" 608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSStyleRule.h" 618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSStyleSheet.h" 628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSValueList.h" 638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMStyleSheet.h" 648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMDOMImplementation.h" 658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMNamedNodeMap.h" 668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMNodeList.h" 678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCounter.h" 688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSRuleList.h" 698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMCSSStyleDeclaration.h" 708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMMediaList.h" 718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMRect.h" 728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMStyleSheet.h" 738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMStyleSheetList.h" 748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMEvent.h" 758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "GEN_DOMEvent.h" 768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <wtf/HashMap.h> 778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#pragma warning(push, 0) 798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Node.h> 808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Element.h> 818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Document.h> 828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Attr.h> 838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Text.h> 848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/COMPtr.h> 858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CDATASection.h> 868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/EntityReference.h> 878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Entity.h> 888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/ProcessingInstruction.h> 898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Comment.h> 908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/HTMLDocument.h> 918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/HTMLElement.h> 928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/HTMLCollection.h> 938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/DocumentType.h> 948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/DocumentFragment.h> 958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Notation.h> 968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSCharsetRule.h> 978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSFontFaceRule.h> 988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSImportRule.h> 998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSMediaRule.h> 1008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSPageRule.h> 1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSPrimitiveValue.h> 1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSRule.h> 1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSRuleList.h> 1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSStyleDeclaration.h> 1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSStyleRule.h> 1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSStyleSheet.h> 1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSValueList.h> 1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/StyleSheet.h> 1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/DOMImplementation.h> 1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/NamedNodeMap.h> 1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/NodeList.h> 1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Counter.h> 1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSRuleList.h> 1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/CSSStyleDeclaration.h> 1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/MediaList.h> 1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Rect.h> 1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/StyleSheet.h> 1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/StyleSheetList.h> 1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/Event.h> 1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include <WebCore/EventListener.h> 1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#pragma warning(pop) 1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projecttypedef HashMap<void*, GEN_DOMObject*> DOMWrapperCache; 1248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectstatic DOMWrapperCache& domWrapperCache() 1268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project static DOMWrapperCache cache; 1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return cache; 1298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 1308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMObject* getDOMWrapper(void* objectHandle) 1328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 1338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return domWrapperCache().get(objectHandle); 1348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 1358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectvoid setDOMWrapper(void* objectHandle, GEN_DOMObject* wrapper) 1378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 1388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domWrapperCache().set(objectHandle, wrapper); 1398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 1408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectvoid removeDOMWrapper(void* objectHandle) 1428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 1438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domWrapperCache().remove(objectHandle); 1448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 1458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define COM_DOM_PREFIX(Type) GEN_DOM##Type 1478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define CREATE_ONLY_SELF(Type) \ 1488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COM_DOM_PREFIX(Type)* COM_DOM_PREFIX(Type)::createInstance(WebCore::Type* impl) \ 1498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project { \ 1508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!impl) \ 1518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; \ 1528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(impl)) { \ 1538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); \ 1548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<COM_DOM_PREFIX(Type)*>(cachedInstance); \ 1558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } \ 1568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<COM_DOM_PREFIX(Type)> comDOMObject = new COM_DOM_PREFIX(Type)(impl); \ 1578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(impl, comDOMObject.get()); \ 1588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return comDOMObject.releaseRef(); \ 1598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } \ 1608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// Core 1628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMNode* GEN_DOMNode::createInstance(WebCore::Node* node) 1648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 1658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!node) 1668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; 1678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(node)) { 1698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); 1708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<GEN_DOMNode*>(cachedInstance); 1718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 1728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 1738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<GEN_DOMNode> domNode; 1748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project switch (node->nodeType()) { 1758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::ELEMENT_NODE: 1768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // FIXME: add support for creating subclasses of HTMLElement. 1778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // FIXME: add support for creating SVGElements and its subclasses. 1788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (node->isHTMLElement()) 1798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMHTMLElement(static_cast<WebCore::HTMLElement*>(node)); 1808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project else 1818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMElement(static_cast<WebCore::Element*>(node)); 1828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::ATTRIBUTE_NODE: 1848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMAttr(static_cast<WebCore::Attr*>(node)); 1858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::TEXT_NODE: 1878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMText(static_cast<WebCore::Text*>(node)); 1888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::CDATA_SECTION_NODE: 1908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMCDATASection(static_cast<WebCore::CDATASection*>(node)); 1918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::ENTITY_REFERENCE_NODE: 1938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMEntityReference(static_cast<WebCore::EntityReference*>(node)); 1948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::ENTITY_NODE: 1968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMEntity(static_cast<WebCore::Entity*>(node)); 1978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 1988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::PROCESSING_INSTRUCTION_NODE: 1998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMProcessingInstruction(static_cast<WebCore::ProcessingInstruction*>(node)); 2008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::COMMENT_NODE: 2028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMComment(static_cast<WebCore::Comment*>(node)); 2038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::DOCUMENT_NODE: 2058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // FIXME: add support for SVGDocument. 2068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (static_cast<WebCore::Document*>(node)->isHTMLDocument()) 2078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMHTMLDocument(static_cast<WebCore::HTMLDocument*>(node)); 2088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project else 2098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMDocument(static_cast<WebCore::Document*>(node)); 2108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::DOCUMENT_TYPE_NODE: 2128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMDocumentType(static_cast<WebCore::DocumentType*>(node)); 2138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::DOCUMENT_FRAGMENT_NODE: 2158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMDocumentFragment(static_cast<WebCore::DocumentFragment*>(node)); 2168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::Node::NOTATION_NODE: 2188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMNotation(static_cast<WebCore::Notation*>(node)); 2198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project default: 2218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domNode = new GEN_DOMNode(node); 2228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 2248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(node, domNode.get()); 2268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return domNode.releaseRef(); 2278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 2288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMImplementation* GEN_DOMImplementation::createInstance(WebCore::DOMImplementation* impl) 2308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 2318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!impl) 2328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; 2338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(impl)) { 2358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); 2368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<GEN_DOMImplementation*>(cachedInstance); 2378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 2388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<GEN_DOMImplementation> comDOMObject = new GEN_DOMImplementation(impl); 2408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(impl, comDOMObject.get()); 2418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return comDOMObject.releaseRef(); 2428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 2438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(NamedNodeMap) 2458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(NodeList) 2468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// Events 2488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// FIXME: Add the subclasses for Event when they get generated. 2508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(Event) 2518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// CSS 2548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMCSSRule* GEN_DOMCSSRule::createInstance(WebCore::CSSRule* rule) 2568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 2578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!rule) 2588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; 2598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(rule)) { 2618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); 2628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<GEN_DOMCSSRule*>(cachedInstance); 2638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 2648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<GEN_DOMCSSRule> domRule; 2668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project switch (rule->type()) { 2678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::STYLE_RULE: 2688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSStyleRule(static_cast<WebCore::CSSStyleRule*>(rule)); 2698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::CHARSET_RULE: 2718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSCharsetRule(static_cast<WebCore::CSSCharsetRule*>(rule)); 2728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::IMPORT_RULE: 2748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSImportRule(static_cast<WebCore::CSSImportRule*>(rule)); 2758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::MEDIA_RULE: 2778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSMediaRule(static_cast<WebCore::CSSMediaRule*>(rule)); 2788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::FONT_FACE_RULE: 2808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSFontFaceRule(static_cast<WebCore::CSSFontFaceRule*>(rule)); 2818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::PAGE_RULE: 2838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSPageRule(static_cast<WebCore::CSSPageRule*>(rule)); 2848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSRule::UNKNOWN_RULE: 2868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project default: 2878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domRule = new GEN_DOMCSSRule(rule); 2888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 2898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 2908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(rule, domRule.get()); 2928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return domRule.releaseRef(); 2938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 2948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 2958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMStyleSheet* GEN_DOMStyleSheet::createInstance(WebCore::StyleSheet* styleSheet) 2968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 2978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!styleSheet) 2988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; 2998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(styleSheet)) { 3018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); 3028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<GEN_DOMStyleSheet*>(cachedInstance); 3038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 3048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<GEN_DOMStyleSheet> domStyleSheet; 3068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (styleSheet->isCSSStyleSheet()) 3078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domStyleSheet = new GEN_DOMCSSStyleSheet(static_cast<WebCore::CSSStyleSheet*>(styleSheet)); 3088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project else 3098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domStyleSheet = new GEN_DOMStyleSheet(styleSheet); 3108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(styleSheet, domStyleSheet.get()); 3128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return domStyleSheet.releaseRef(); 3138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 3148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectGEN_DOMCSSValue* GEN_DOMCSSValue::createInstance(WebCore::CSSValue* value) 3178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project{ 3188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (!value) 3198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return 0; 3208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project if (GEN_DOMObject* cachedInstance = getDOMWrapper(value)) { 3228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project cachedInstance->AddRef(); 3238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return static_cast<GEN_DOMCSSValue*>(cachedInstance); 3248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 3258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project COMPtr<GEN_DOMCSSValue> domValue; 3278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project switch (value->cssValueType()) { 3288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSValue::CSS_PRIMITIVE_VALUE: 3298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domValue = new GEN_DOMCSSPrimitiveValue(static_cast<WebCore::CSSPrimitiveValue*>(value)); 3308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 3318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSValue::CSS_VALUE_LIST: 3328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domValue = new GEN_DOMCSSValueList(static_cast<WebCore::CSSValueList*>(value)); 3338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 3348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSValue::CSS_INHERIT: 3358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domValue = new GEN_DOMCSSValue(value); 3368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 3378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project case WebCore::CSSValue::CSS_CUSTOM: 3388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project // FIXME: add support for SVGPaint and SVGColor 3398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project domValue = new GEN_DOMCSSValue(value); 3408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project break; 3418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project } 3428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project setDOMWrapper(value, domValue.get()); 3448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project return domValue.releaseRef(); 3458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project} 3468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(Counter) 3488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(CSSRuleList) 3498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(CSSStyleDeclaration) 3508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(MediaList) 3518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(Rect) 3528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(StyleSheetList) 3538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project// HTML 3568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project 3578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectCREATE_ONLY_SELF(HTMLCollection) 358