/* * Copyright (C) 2004 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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. */ #import namespace DOM { class CSSStyleDeclarationImpl; class CSSStyleSheetImpl; class DocumentFragmentImpl; class DocumentImpl; class ElementImpl; class NodeFilterImpl; class NodeImpl; class NodeIteratorImpl; class NodeListImpl; class RangeImpl; class StyleSheetListImpl; class TreeWalkerImpl; } @interface DOMNode (WebCoreInternal) + (DOMNode *)_nodeWithImpl:(DOM::NodeImpl *)impl; - (DOM::NodeImpl *)_nodeImpl; @end @interface DOMNodeList (WebCoreInternal) + (DOMNodeList *)_nodeListWithImpl:(DOM::NodeListImpl *)impl; @end @interface DOMElement (WebCoreInternal) + (DOMElement *)_elementWithImpl:(DOM::ElementImpl *)impl; - (DOM::ElementImpl *)_elementImpl; @end @interface DOMDocument (WebCoreInternal) + (DOMDocument *)_documentWithImpl:(DOM::DocumentImpl *)impl; - (DOM::DocumentImpl *)_documentImpl; - (DOMElement *)_ownerElement; @end @interface DOMDocumentFragment (WebCoreInternal) + (DOMDocumentFragment *)_documentFragmentWithImpl:(DOM::DocumentFragmentImpl *)impl; - (DOM::DocumentFragmentImpl *)_fragmentImpl; @end @interface DOMRange (WebCoreInternal) + (DOMRange *)_rangeWithImpl:(DOM::RangeImpl *)impl; - (DOM::RangeImpl *)_rangeImpl; @end @interface DOMNodeIterator (WebCoreInternal) + (DOMNodeIterator *)_nodeIteratorWithImpl:(DOM::NodeIteratorImpl *)impl filter:(id )filter; @end @interface DOMTreeWalker (WebCoreInternal) + (DOMTreeWalker *)_treeWalkerWithImpl:(DOM::TreeWalkerImpl *)impl filter:(id )filter; @end @interface DOMObject (WebCoreInternal) - (id)_init; @end @interface DOMCSSStyleDeclaration (WebCoreInternal) + (DOMCSSStyleDeclaration *)_styleDeclarationWithImpl:(DOM::CSSStyleDeclarationImpl *)impl; - (DOM::CSSStyleDeclarationImpl *)_styleDeclarationImpl; @end @interface DOMStyleSheetList (WebCoreInternal) + (DOMStyleSheetList *)_styleSheetListWithImpl:(DOM::StyleSheetListImpl *)impl; @end @interface DOMCSSStyleSheet (WebCoreInternal) + (DOMCSSStyleSheet *)_CSSStyleSheetWithImpl:(DOM::CSSStyleSheetImpl *)impl; @end @interface DOMNodeFilter : DOMObject + (DOMNodeFilter *)_nodeFilterWithImpl:(DOM::NodeFilterImpl *)impl; @end // Helper functions for DOM wrappers and gluing to Objective-C // Like reinterpret_cast, but a compiler error if you use it on the wrong type. template Target DOM_cast(Source) { failToCompile(); } // Type safe DOM wrapper access. id getDOMWrapperImpl(DOMObjectInternal *impl); void addDOMWrapperImpl(id wrapper, DOMObjectInternal *impl); template inline id getDOMWrapper(Source impl) { return getDOMWrapperImpl(DOM_cast(impl)); } template inline void addDOMWrapper(id wrapper, Source impl) { addDOMWrapperImpl(wrapper, DOM_cast(impl)); } void removeDOMWrapper(DOMObjectInternal *impl); void raiseDOMException(int code); inline void raiseOnDOMError(int code) { if (code) raiseDOMException(code); } // Implementation details for the above. #define ALLOW_DOM_CAST(type) \ namespace DOM { class type; } \ template <> inline DOMObjectInternal *DOM_cast(DOM::type *p) \ { return reinterpret_cast(p); } \ template <> inline DOM::type *DOM_cast(DOMObjectInternal *p) \ { return reinterpret_cast(p); } // No class should appear in this list if it's base class is already here. ALLOW_DOM_CAST(CounterImpl) ALLOW_DOM_CAST(CSSRuleImpl) ALLOW_DOM_CAST(CSSRuleListImpl) ALLOW_DOM_CAST(CSSStyleDeclarationImpl) ALLOW_DOM_CAST(CSSStyleSheetImpl) ALLOW_DOM_CAST(CSSValueImpl) ALLOW_DOM_CAST(DOMImplementationImpl) ALLOW_DOM_CAST(HTMLCollectionImpl) ALLOW_DOM_CAST(HTMLOptionsCollectionImpl) ALLOW_DOM_CAST(MediaListImpl) ALLOW_DOM_CAST(NamedNodeMapImpl) ALLOW_DOM_CAST(NodeFilterImpl) ALLOW_DOM_CAST(NodeImpl) ALLOW_DOM_CAST(NodeIteratorImpl) ALLOW_DOM_CAST(NodeListImpl) ALLOW_DOM_CAST(RangeImpl) ALLOW_DOM_CAST(RectImpl) ALLOW_DOM_CAST(StyleSheetImpl) ALLOW_DOM_CAST(StyleSheetListImpl) ALLOW_DOM_CAST(TreeWalkerImpl)