diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:52 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 19:30:52 -0800 |
commit | 8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2 (patch) | |
tree | 11425ea0b299d6fb89c6d3618a22d97d5bf68d0f /WebCore/bindings/objc | |
parent | 648161bb0edfc3d43db63caed5cc5213bc6cb78f (diff) | |
download | external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.zip external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.gz external_webkit-8e35f3cfc7fba1d1c829dc557ebad6409cbe16a2.tar.bz2 |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'WebCore/bindings/objc')
46 files changed, 7710 insertions, 0 deletions
diff --git a/WebCore/bindings/objc/DOM.h b/WebCore/bindings/objc/DOM.h new file mode 100644 index 0000000..a3d6201 --- /dev/null +++ b/WebCore/bindings/objc/DOM.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMCSS.h> +#import <WebCore/DOMExtensions.h> +#import <WebCore/DOMEvents.h> +#import <WebCore/DOMHTML.h> +#import <WebCore/DOMRanges.h> +#import <WebCore/DOMStylesheets.h> +#import <WebCore/DOMTraversal.h> +#import <WebCore/DOMViews.h> +#import <WebCore/DOMXPath.h> diff --git a/WebCore/bindings/objc/DOM.mm b/WebCore/bindings/objc/DOM.mm new file mode 100644 index 0000000..485d011 --- /dev/null +++ b/WebCore/bindings/objc/DOM.mm @@ -0,0 +1,649 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "config.h" +#import "DOM.h" + +#import "DOMHTMLCanvasElement.h" +#import "DOMInternal.h" +#import "ExceptionHandlers.h" +#import "HTMLNames.h" +#import "HTMLPlugInElement.h" +#import "NodeIterator.h" +#import "Range.h" +#import "RenderImage.h" +#import "RenderView.h" +#import "ScriptController.h" +#import "SimpleFontData.h" +#import "TreeWalker.h" + +#import <wtf/HashMap.h> + +#if ENABLE(SVG) +#import "SVGElement.h" +#import "SVGElementInstance.h" +#import "SVGNames.h" +#import "DOMSVG.h" +#endif + +using namespace JSC; +using namespace WebCore; + +//------------------------------------------------------------------------------------------ +// DOMNode + +namespace WebCore { + +typedef HashMap<const QualifiedName::QualifiedNameImpl*, Class> ObjCClassMap; +static ObjCClassMap* elementClassMap; + +static void addElementClass(const QualifiedName& tag, Class objCClass) +{ + elementClassMap->set(tag.impl(), objCClass); +} + +static void createElementClassMap() +{ + // Create the table. + elementClassMap = new ObjCClassMap; + + // FIXME: Reflect marquee once the API has been determined. + + // Populate it with HTML and SVG element classes. + addElementClass(HTMLNames::aTag, [DOMHTMLAnchorElement class]); + addElementClass(HTMLNames::appletTag, [DOMHTMLAppletElement class]); + addElementClass(HTMLNames::areaTag, [DOMHTMLAreaElement class]); + addElementClass(HTMLNames::baseTag, [DOMHTMLBaseElement class]); + addElementClass(HTMLNames::basefontTag, [DOMHTMLBaseFontElement class]); + addElementClass(HTMLNames::bodyTag, [DOMHTMLBodyElement class]); + addElementClass(HTMLNames::brTag, [DOMHTMLBRElement class]); + addElementClass(HTMLNames::buttonTag, [DOMHTMLButtonElement class]); + addElementClass(HTMLNames::canvasTag, [DOMHTMLCanvasElement class]); + addElementClass(HTMLNames::captionTag, [DOMHTMLTableCaptionElement class]); + addElementClass(HTMLNames::colTag, [DOMHTMLTableColElement class]); + addElementClass(HTMLNames::colgroupTag, [DOMHTMLTableColElement class]); + addElementClass(HTMLNames::delTag, [DOMHTMLModElement class]); + addElementClass(HTMLNames::dirTag, [DOMHTMLDirectoryElement class]); + addElementClass(HTMLNames::divTag, [DOMHTMLDivElement class]); + addElementClass(HTMLNames::dlTag, [DOMHTMLDListElement class]); + addElementClass(HTMLNames::embedTag, [DOMHTMLEmbedElement class]); + addElementClass(HTMLNames::fieldsetTag, [DOMHTMLFieldSetElement class]); + addElementClass(HTMLNames::fontTag, [DOMHTMLFontElement class]); + addElementClass(HTMLNames::formTag, [DOMHTMLFormElement class]); + addElementClass(HTMLNames::frameTag, [DOMHTMLFrameElement class]); + addElementClass(HTMLNames::framesetTag, [DOMHTMLFrameSetElement class]); + addElementClass(HTMLNames::h1Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::h2Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::h3Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::h4Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::h5Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::h6Tag, [DOMHTMLHeadingElement class]); + addElementClass(HTMLNames::headTag, [DOMHTMLHeadElement class]); + addElementClass(HTMLNames::hrTag, [DOMHTMLHRElement class]); + addElementClass(HTMLNames::htmlTag, [DOMHTMLHtmlElement class]); + addElementClass(HTMLNames::iframeTag, [DOMHTMLIFrameElement class]); + addElementClass(HTMLNames::imgTag, [DOMHTMLImageElement class]); + addElementClass(HTMLNames::inputTag, [DOMHTMLInputElement class]); + addElementClass(HTMLNames::insTag, [DOMHTMLModElement class]); + addElementClass(HTMLNames::isindexTag, [DOMHTMLIsIndexElement class]); + addElementClass(HTMLNames::labelTag, [DOMHTMLLabelElement class]); + addElementClass(HTMLNames::legendTag, [DOMHTMLLegendElement class]); + addElementClass(HTMLNames::liTag, [DOMHTMLLIElement class]); + addElementClass(HTMLNames::linkTag, [DOMHTMLLinkElement class]); + addElementClass(HTMLNames::listingTag, [DOMHTMLPreElement class]); + addElementClass(HTMLNames::mapTag, [DOMHTMLMapElement class]); + addElementClass(HTMLNames::marqueeTag, [DOMHTMLMarqueeElement class]); + addElementClass(HTMLNames::menuTag, [DOMHTMLMenuElement class]); + addElementClass(HTMLNames::metaTag, [DOMHTMLMetaElement class]); + addElementClass(HTMLNames::objectTag, [DOMHTMLObjectElement class]); + addElementClass(HTMLNames::olTag, [DOMHTMLOListElement class]); + addElementClass(HTMLNames::optgroupTag, [DOMHTMLOptGroupElement class]); + addElementClass(HTMLNames::optionTag, [DOMHTMLOptionElement class]); + addElementClass(HTMLNames::pTag, [DOMHTMLParagraphElement class]); + addElementClass(HTMLNames::paramTag, [DOMHTMLParamElement class]); + addElementClass(HTMLNames::preTag, [DOMHTMLPreElement class]); + addElementClass(HTMLNames::qTag, [DOMHTMLQuoteElement class]); + addElementClass(HTMLNames::scriptTag, [DOMHTMLScriptElement class]); + addElementClass(HTMLNames::keygenTag, [DOMHTMLSelectElement class]); + addElementClass(HTMLNames::selectTag, [DOMHTMLSelectElement class]); + addElementClass(HTMLNames::styleTag, [DOMHTMLStyleElement class]); + addElementClass(HTMLNames::tableTag, [DOMHTMLTableElement class]); + addElementClass(HTMLNames::tbodyTag, [DOMHTMLTableSectionElement class]); + addElementClass(HTMLNames::tdTag, [DOMHTMLTableCellElement class]); + addElementClass(HTMLNames::textareaTag, [DOMHTMLTextAreaElement class]); + addElementClass(HTMLNames::tfootTag, [DOMHTMLTableSectionElement class]); + addElementClass(HTMLNames::thTag, [DOMHTMLTableCellElement class]); + addElementClass(HTMLNames::theadTag, [DOMHTMLTableSectionElement class]); + addElementClass(HTMLNames::titleTag, [DOMHTMLTitleElement class]); + addElementClass(HTMLNames::trTag, [DOMHTMLTableRowElement class]); + addElementClass(HTMLNames::ulTag, [DOMHTMLUListElement class]); + addElementClass(HTMLNames::xmpTag, [DOMHTMLPreElement class]); + +#if ENABLE(SVG) + addElementClass(SVGNames::aTag, [DOMSVGAElement class]); + addElementClass(SVGNames::altGlyphTag, [DOMSVGAltGlyphElement class]); +#if ENABLE(SVG_ANIMATION) + addElementClass(SVGNames::animateTag, [DOMSVGAnimateElement class]); + addElementClass(SVGNames::animateColorTag, [DOMSVGAnimateColorElement class]); + addElementClass(SVGNames::animateTransformTag, [DOMSVGAnimateTransformElement class]); + addElementClass(SVGNames::setTag, [DOMSVGSetElement class]); +#endif + addElementClass(SVGNames::circleTag, [DOMSVGCircleElement class]); + addElementClass(SVGNames::clipPathTag, [DOMSVGClipPathElement class]); + addElementClass(SVGNames::cursorTag, [DOMSVGCursorElement class]); +#if ENABLE(SVG_FONTS) + addElementClass(SVGNames::definition_srcTag, [DOMSVGDefinitionSrcElement class]); +#endif + addElementClass(SVGNames::defsTag, [DOMSVGDefsElement class]); + addElementClass(SVGNames::descTag, [DOMSVGDescElement class]); + addElementClass(SVGNames::ellipseTag, [DOMSVGEllipseElement class]); +#if ENABLE(SVG_FILTERS) + addElementClass(SVGNames::feBlendTag, [DOMSVGFEBlendElement class]); + addElementClass(SVGNames::feColorMatrixTag, [DOMSVGFEColorMatrixElement class]); + addElementClass(SVGNames::feComponentTransferTag, [DOMSVGFEComponentTransferElement class]); + addElementClass(SVGNames::feCompositeTag, [DOMSVGFECompositeElement class]); + addElementClass(SVGNames::feDiffuseLightingTag, [DOMSVGFEDiffuseLightingElement class]); + addElementClass(SVGNames::feDisplacementMapTag, [DOMSVGFEDisplacementMapElement class]); + addElementClass(SVGNames::feDistantLightTag, [DOMSVGFEDistantLightElement class]); + addElementClass(SVGNames::feFloodTag, [DOMSVGFEFloodElement class]); + addElementClass(SVGNames::feFuncATag, [DOMSVGFEFuncAElement class]); + addElementClass(SVGNames::feFuncBTag, [DOMSVGFEFuncBElement class]); + addElementClass(SVGNames::feFuncGTag, [DOMSVGFEFuncGElement class]); + addElementClass(SVGNames::feFuncRTag, [DOMSVGFEFuncRElement class]); + addElementClass(SVGNames::feGaussianBlurTag, [DOMSVGFEGaussianBlurElement class]); + addElementClass(SVGNames::feImageTag, [DOMSVGFEImageElement class]); + addElementClass(SVGNames::feMergeTag, [DOMSVGFEMergeElement class]); + addElementClass(SVGNames::feMergeNodeTag, [DOMSVGFEMergeNodeElement class]); + addElementClass(SVGNames::feOffsetTag, [DOMSVGFEOffsetElement class]); + addElementClass(SVGNames::fePointLightTag, [DOMSVGFEPointLightElement class]); + addElementClass(SVGNames::feSpecularLightingTag, [DOMSVGFESpecularLightingElement class]); + addElementClass(SVGNames::feSpotLightTag, [DOMSVGFESpotLightElement class]); + addElementClass(SVGNames::feTileTag, [DOMSVGFETileElement class]); + addElementClass(SVGNames::feTurbulenceTag, [DOMSVGFETurbulenceElement class]); + addElementClass(SVGNames::filterTag, [DOMSVGFilterElement class]); +#endif +#if ENABLE(SVG_FONTS) + addElementClass(SVGNames::fontTag, [DOMSVGFontElement class]); + addElementClass(SVGNames::font_faceTag, [DOMSVGFontFaceElement class]); + addElementClass(SVGNames::font_face_formatTag, [DOMSVGFontFaceFormatElement class]); + addElementClass(SVGNames::font_face_nameTag, [DOMSVGFontFaceNameElement class]); + addElementClass(SVGNames::font_face_srcTag, [DOMSVGFontFaceSrcElement class]); + addElementClass(SVGNames::font_face_uriTag, [DOMSVGFontFaceUriElement class]); + addElementClass(SVGNames::glyphTag, [DOMSVGGlyphElement class]); +#endif + addElementClass(SVGNames::gTag, [DOMSVGGElement class]); + addElementClass(SVGNames::imageTag, [DOMSVGImageElement class]); + addElementClass(SVGNames::lineTag, [DOMSVGLineElement class]); + addElementClass(SVGNames::linearGradientTag, [DOMSVGLinearGradientElement class]); + addElementClass(SVGNames::markerTag, [DOMSVGMarkerElement class]); + addElementClass(SVGNames::maskTag, [DOMSVGMaskElement class]); + addElementClass(SVGNames::metadataTag, [DOMSVGMetadataElement class]); +#if ENABLE(SVG_FONTS) + addElementClass(SVGNames::missing_glyphTag, [DOMSVGMissingGlyphElement class]); +#endif + addElementClass(SVGNames::pathTag, [DOMSVGPathElement class]); + addElementClass(SVGNames::patternTag, [DOMSVGPatternElement class]); + addElementClass(SVGNames::polygonTag, [DOMSVGPolygonElement class]); + addElementClass(SVGNames::polylineTag, [DOMSVGPolylineElement class]); + addElementClass(SVGNames::radialGradientTag, [DOMSVGRadialGradientElement class]); + addElementClass(SVGNames::rectTag, [DOMSVGRectElement class]); + addElementClass(SVGNames::scriptTag, [DOMSVGScriptElement class]); + addElementClass(SVGNames::stopTag, [DOMSVGStopElement class]); + addElementClass(SVGNames::styleTag, [DOMSVGStyleElement class]); + addElementClass(SVGNames::svgTag, [DOMSVGSVGElement class]); + addElementClass(SVGNames::switchTag, [DOMSVGSwitchElement class]); + addElementClass(SVGNames::symbolTag, [DOMSVGSymbolElement class]); + addElementClass(SVGNames::textTag, [DOMSVGTextElement class]); + addElementClass(SVGNames::titleTag, [DOMSVGTitleElement class]); + addElementClass(SVGNames::trefTag, [DOMSVGTRefElement class]); + addElementClass(SVGNames::tspanTag, [DOMSVGTSpanElement class]); + addElementClass(SVGNames::textPathTag, [DOMSVGTextPathElement class]); + addElementClass(SVGNames::useTag, [DOMSVGUseElement class]); + addElementClass(SVGNames::viewTag, [DOMSVGViewElement class]); +#endif +} + +static Class lookupElementClass(const QualifiedName& tag) +{ + // Do a special lookup to ignore element prefixes + if (tag.hasPrefix()) + return elementClassMap->get(QualifiedName(nullAtom, tag.localName(), tag.namespaceURI()).impl()); + + return elementClassMap->get(tag.impl()); +} + +static Class elementClass(const QualifiedName& tag, Class defaultClass) +{ + if (!elementClassMap) + createElementClassMap(); + Class objcClass = lookupElementClass(tag); + if (!objcClass) + objcClass = defaultClass; + return objcClass; +} + +static NSArray *kit(const Vector<IntRect>& rects) +{ + size_t size = rects.size(); + NSMutableArray *array = [NSMutableArray arrayWithCapacity:size]; + for (size_t i = 0; i < size; ++i) + [array addObject:[NSValue valueWithRect:rects[i]]]; + return array; +} + +} // namespace WebCore + +@implementation DOMNode (WebCoreInternal) + +// FIXME: should this go in the main implementation? +- (NSString *)description +{ + if (!_internal) + return [NSString stringWithFormat:@"<%@: null>", [[self class] description], self]; + + NSString *value = [self nodeValue]; + if (value) + return [NSString stringWithFormat:@"<%@ [%@]: %p '%@'>", + [[self class] description], [self nodeName], _internal, value]; + + return [NSString stringWithFormat:@"<%@ [%@]: %p>", [[self class] description], [self nodeName], _internal]; +} + +- (id)_initWithNode:(WebCore::Node *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMNode *)_wrapNode:(WebCore::Node *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass = nil; + switch (impl->nodeType()) { + case WebCore::Node::ELEMENT_NODE: + if (impl->isHTMLElement()) + wrapperClass = WebCore::elementClass(static_cast<WebCore::HTMLElement*>(impl)->tagQName(), [DOMHTMLElement class]); +#if ENABLE(SVG) + else if (impl->isSVGElement()) + wrapperClass = WebCore::elementClass(static_cast<WebCore::SVGElement*>(impl)->tagQName(), [DOMSVGElement class]); +#endif + else + wrapperClass = [DOMElement class]; + break; + case WebCore::Node::ATTRIBUTE_NODE: + wrapperClass = [DOMAttr class]; + break; + case WebCore::Node::TEXT_NODE: + wrapperClass = [DOMText class]; + break; + case WebCore::Node::CDATA_SECTION_NODE: + wrapperClass = [DOMCDATASection class]; + break; + case WebCore::Node::ENTITY_REFERENCE_NODE: + wrapperClass = [DOMEntityReference class]; + break; + case WebCore::Node::ENTITY_NODE: + wrapperClass = [DOMEntity class]; + break; + case WebCore::Node::PROCESSING_INSTRUCTION_NODE: + wrapperClass = [DOMProcessingInstruction class]; + break; + case WebCore::Node::COMMENT_NODE: + wrapperClass = [DOMComment class]; + break; + case WebCore::Node::DOCUMENT_NODE: + if (static_cast<WebCore::Document*>(impl)->isHTMLDocument()) + wrapperClass = [DOMHTMLDocument class]; +#if ENABLE(SVG) + else if (static_cast<WebCore::Document*>(impl)->isSVGDocument()) + wrapperClass = [DOMSVGDocument class]; +#endif + else + wrapperClass = [DOMDocument class]; + break; + case WebCore::Node::DOCUMENT_TYPE_NODE: + wrapperClass = [DOMDocumentType class]; + break; + case WebCore::Node::DOCUMENT_FRAGMENT_NODE: + wrapperClass = [DOMDocumentFragment class]; + break; + case WebCore::Node::NOTATION_NODE: + wrapperClass = [DOMNotation class]; + break; + case WebCore::Node::XPATH_NAMESPACE_NODE: + // FIXME: Create an XPath objective C wrapper + // See http://bugs.webkit.org/show_bug.cgi?id=8755 + return nil; + } + return [[[wrapperClass alloc] _initWithNode:impl] autorelease]; +} + ++ (id <DOMEventTarget>)_wrapEventTarget:(WebCore::EventTarget *)eventTarget +{ + if (!eventTarget) + return nil; + + // We don't have an ObjC binding for XMLHttpRequest + return [DOMNode _wrapNode:eventTarget->toNode()]; +} + +- (WebCore::Node *)_node +{ + return reinterpret_cast<WebCore::Node*>(_internal); +} + +- (JSC::Bindings::RootObject*)_rootObject +{ + if (WebCore::Node *n = [self _node]) { + if (WebCore::Frame* frame = n->document()->frame()) + return frame->script()->bindingRootObject(); + } + return 0; +} + +@end + +@implementation DOMNode (DOMNodeExtensions) + +// FIXME: This should be implemented in Node so we don't have to fetch the renderer. +// If it was, we could even autogenerate. +- (NSRect)boundingBox +{ + [self _node]->document()->updateLayoutIgnorePendingStylesheets(); + WebCore::RenderObject *renderer = [self _node]->renderer(); + if (renderer) + return renderer->absoluteBoundingBoxRect(); + return NSZeroRect; +} + +// FIXME: This should be implemented in Node so we don't have to fetch the renderer. +// If it was, we could even autogenerate. +- (NSArray *)lineBoxRects +{ + [self _node]->document()->updateLayoutIgnorePendingStylesheets(); + WebCore::RenderObject *renderer = [self _node]->renderer(); + if (renderer) { + Vector<WebCore::IntRect> rects; + renderer->addLineBoxRects(rects); + return kit(rects); + } + return nil; +} + +@end + +#if ENABLE(SVG) +@implementation DOMSVGElementInstance (WebCoreInternal) + +- (id)_initWithSVGElementInstance:(WebCore::SVGElementInstance *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMSVGElementInstance *)_wrapSVGElementInstance:(WebCore::SVGElementInstance *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + return [[[self alloc] _initWithSVGElementInstance:impl] autorelease]; +} + ++ (id <DOMEventTarget>)_wrapEventTarget:(WebCore::EventTarget *)eventTarget +{ + if (!eventTarget) + return nil; + + return [DOMSVGElementInstance _wrapSVGElementInstance:eventTarget->toSVGElementInstance()]; +} + +- (WebCore::SVGElementInstance *)_SVGElementInstance +{ + return reinterpret_cast<WebCore::SVGElementInstance*>(_internal); +} + +@end +#endif + +@implementation DOMNode (DOMNodeExtensionsPendingPublic) + +- (NSImage *)renderedImage +{ + if (WebCore::Node *node = [self _node]) + if (WebCore::Frame* frame = node->document()->frame()) + return frame->nodeImage(node); + return nil; +} + +@end + +@implementation DOMRange (DOMRangeExtensions) + +- (NSRect)boundingBox +{ + [self _range]->ownerDocument()->updateLayoutIgnorePendingStylesheets(); + return [self _range]->boundingBox(); +} + +- (NSArray *)lineBoxRects +{ + Vector<WebCore::IntRect> rects; + [self _range]->ownerDocument()->updateLayoutIgnorePendingStylesheets(); + [self _range]->addLineBoxRects(rects); + return kit(rects); +} + +@end + +//------------------------------------------------------------------------------------------ +// DOMElement + +// FIXME: this should be auto-generated in DOMElement.mm +@implementation DOMElement (DOMElementAppKitExtensions) + +// FIXME: this should be implemented in the implementation +- (NSImage*)image +{ + WebCore::RenderObject* renderer = [self _element]->renderer(); + if (renderer && renderer->isImage()) { + WebCore::RenderImage* img = static_cast<WebCore::RenderImage*>(renderer); + if (img->cachedImage() && !img->cachedImage()->errorOccurred()) + return img->cachedImage()->image()->getNSImage(); + } + return nil; +} + +@end + +@implementation DOMElement (WebPrivate) + +// FIXME: this should be implemented in the implementation +- (NSFont *)_font +{ + WebCore::RenderObject* renderer = [self _element]->renderer(); + if (renderer) + return renderer->style()->font().primaryFont()->getNSFont(); + return nil; +} + +// FIXME: this should be implemented in the implementation +- (NSData *)_imageTIFFRepresentation +{ + WebCore::RenderObject* renderer = [self _element]->renderer(); + if (renderer && renderer->isImage()) { + WebCore::RenderImage* img = static_cast<WebCore::RenderImage*>(renderer); + if (img->cachedImage() && !img->cachedImage()->errorOccurred()) + return (NSData*)(img->cachedImage()->image()->getTIFFRepresentation()); + } + return nil; +} + +- (NSRect)_windowClipRect +{ + WebCore::RenderObject* renderer = [self _element]->renderer(); + if (renderer && renderer->view()) { + WebCore::FrameView* frameView = renderer->view()->frameView(); + if (!frameView) + return WebCore::IntRect(); + return frameView->windowClipRectForLayer(renderer->enclosingLayer(), true); + } + return WebCore::IntRect(); +} + +// FIXME: this should be implemented in the implementation +- (NSURL *)_getURLAttribute:(NSString *)name +{ + ASSERT(name); + WebCore::Element* element = [self _element]; + ASSERT(element); + return element->document()->completeURL(parseURL(element->getAttribute(name))); +} + +// FIXME: this should be implemented in the implementation +- (void *)_NPObject +{ +#if ENABLE(NETSCAPE_PLUGIN_API) + WebCore::Element* element = [self _element]; + if (element->hasTagName(WebCore::HTMLNames::appletTag) || element->hasTagName(WebCore::HTMLNames::embedTag) || element->hasTagName(WebCore::HTMLNames::objectTag)) + return static_cast<WebCore::HTMLPlugInElement*>(element)->getNPObject(); +#endif + return 0; +} + +// FIXME: this should be implemented in the implementation +- (BOOL)isFocused +{ + WebCore::Element* impl = [self _element]; + if (impl->document()->focusedNode() == impl) + return YES; + return NO; +} + +@end + + +//------------------------------------------------------------------------------------------ +// DOMRange + +@implementation DOMRange (WebPrivate) + +- (NSString *)description +{ + if (!_internal) + return @"<DOMRange: null>"; + return [NSString stringWithFormat:@"<DOMRange: %@ %d %@ %d>", + [self startContainer], [self startOffset], [self endContainer], [self endOffset]]; +} + +// FIXME: this should be removed as soon as all internal Apple uses of it have been replaced with +// calls to the public method - (NSString *)text. +- (NSString *)_text +{ + return [self text]; +} + +@end + + +//------------------------------------------------------------------------------------------ +// DOMNodeFilter + +// FIXME: This implementation should be in it's own file. + +@implementation DOMNodeFilter + +- (id)_initWithNodeFilter:(WebCore::NodeFilter *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMNodeFilter *)_wrapNodeFilter:(WebCore::NodeFilter *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + return [[[self alloc] _initWithNodeFilter:impl] autorelease]; +} + +- (WebCore::NodeFilter *)_nodeFilter +{ + return reinterpret_cast<WebCore::NodeFilter*>(_internal); +} + +- (void)dealloc +{ + if (_internal) + reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref(); + [super finalize]; +} + +- (short)acceptNode:(DOMNode *)node +{ + return [self _nodeFilter]->acceptNode([node _node]); +} + +@end diff --git a/WebCore/bindings/objc/DOMAbstractView.mm b/WebCore/bindings/objc/DOMAbstractView.mm new file mode 100644 index 0000000..c751903 --- /dev/null +++ b/WebCore/bindings/objc/DOMAbstractView.mm @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2008 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "config.h" +#import "DOMAbstractView.h" + +#import "DOMDocument.h" +#import "DOMInternal.h" +#import "DOMWindow.h" +#import "Document.h" +#import "ExceptionHandlers.h" +#import "Frame.h" +#import "ThreadCheck.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::Frame*>(_internal) + +@implementation DOMAbstractView + +- (void)dealloc +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheck(); } + [super dealloc]; +} + +- (void)finalize +{ + [super finalize]; +} + +- (DOMDocument *)document +{ + if (!_internal) + return nil; + return [DOMDocument _wrapDocument:WTF::getPtr(IMPL->domWindow()->document())]; +} + +@end + +@implementation DOMAbstractView (Frame) + +- (void)_disconnectFrame +{ + ASSERT(_internal); + WebCore::removeDOMWrapper(_internal); + _internal = 0; +} + +@end + +@implementation DOMAbstractView (WebCoreInternal) + +- (WebCore::DOMWindow *)_abstractView +{ + if (!_internal) + return nil; + return IMPL->domWindow(); +} + +- (id)_initWithFrame:(WebCore::Frame *)impl +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheck(); }; + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMAbstractView *)_wrapAbstractView:(WebCore::DOMWindow *)impl +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheck(); }; + + if (!impl) + return nil; + WebCore::Frame* frame = impl->frame(); + if (!frame) + return nil; + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(frame); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + return [[[self alloc] _initWithFrame:frame] autorelease]; +} + +@end diff --git a/WebCore/bindings/objc/DOMAbstractViewFrame.h b/WebCore/bindings/objc/DOMAbstractViewFrame.h new file mode 100644 index 0000000..386a912 --- /dev/null +++ b/WebCore/bindings/objc/DOMAbstractViewFrame.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2008 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 <WebCore/DOMAbstractView.h> + +@interface DOMAbstractView (Frame) +- (void)_disconnectFrame; +@end diff --git a/WebCore/bindings/objc/DOMCSS.h b/WebCore/bindings/objc/DOMCSS.h new file mode 100644 index 0000000..daaa8a0 --- /dev/null +++ b/WebCore/bindings/objc/DOMCSS.h @@ -0,0 +1,300 @@ +/* + * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMElement.h> +#import <WebCore/DOMObject.h> +#import <WebCore/DOMStylesheets.h> + +#import <WebCore/DOMCSSCharsetRule.h> +#import <WebCore/DOMCSSFontFaceRule.h> +#import <WebCore/DOMCSSImportRule.h> +#import <WebCore/DOMCSSMediaRule.h> +#import <WebCore/DOMCSSPageRule.h> +#import <WebCore/DOMCSSPrimitiveValue.h> +#import <WebCore/DOMCSSRule.h> +#import <WebCore/DOMCSSRuleList.h> +#import <WebCore/DOMCSSStyleDeclaration.h> +#import <WebCore/DOMCSSStyleRule.h> +#import <WebCore/DOMCSSStyleSheet.h> +#import <WebCore/DOMCSSUnknownRule.h> +#import <WebCore/DOMCSSValue.h> +#import <WebCore/DOMCSSValueList.h> +#import <WebCore/DOMCounter.h> +#import <WebCore/DOMRGBColor.h> +#import <WebCore/DOMRect.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +@interface DOMCSSStyleDeclaration (DOMCSS2Properties) +- (NSString *)azimuth; +- (void)setAzimuth:(NSString *)azimuth; +- (NSString *)background; +- (void)setBackground:(NSString *)background; +- (NSString *)backgroundAttachment; +- (void)setBackgroundAttachment:(NSString *)backgroundAttachment; +- (NSString *)backgroundColor; +- (void)setBackgroundColor:(NSString *)backgroundColor; +- (NSString *)backgroundImage; +- (void)setBackgroundImage:(NSString *)backgroundImage; +- (NSString *)backgroundPosition; +- (void)setBackgroundPosition:(NSString *)backgroundPosition; +- (NSString *)backgroundRepeat; +- (void)setBackgroundRepeat:(NSString *)backgroundRepeat; +- (NSString *)border; +- (void)setBorder:(NSString *)border; +- (NSString *)borderCollapse; +- (void)setBorderCollapse:(NSString *)borderCollapse; +- (NSString *)borderColor; +- (void)setBorderColor:(NSString *)borderColor; +- (NSString *)borderSpacing; +- (void)setBorderSpacing:(NSString *)borderSpacing; +- (NSString *)borderStyle; +- (void)setBorderStyle:(NSString *)borderStyle; +- (NSString *)borderTop; +- (void)setBorderTop:(NSString *)borderTop; +- (NSString *)borderRight; +- (void)setBorderRight:(NSString *)borderRight; +- (NSString *)borderBottom; +- (void)setBorderBottom:(NSString *)borderBottom; +- (NSString *)borderLeft; +- (void)setBorderLeft:(NSString *)borderLeft; +- (NSString *)borderTopColor; +- (void)setBorderTopColor:(NSString *)borderTopColor; +- (NSString *)borderRightColor; +- (void)setBorderRightColor:(NSString *)borderRightColor; +- (NSString *)borderBottomColor; +- (void)setBorderBottomColor:(NSString *)borderBottomColor; +- (NSString *)borderLeftColor; +- (void)setBorderLeftColor:(NSString *)borderLeftColor; +- (NSString *)borderTopStyle; +- (void)setBorderTopStyle:(NSString *)borderTopStyle; +- (NSString *)borderRightStyle; +- (void)setBorderRightStyle:(NSString *)borderRightStyle; +- (NSString *)borderBottomStyle; +- (void)setBorderBottomStyle:(NSString *)borderBottomStyle; +- (NSString *)borderLeftStyle; +- (void)setBorderLeftStyle:(NSString *)borderLeftStyle; +- (NSString *)borderTopWidth; +- (void)setBorderTopWidth:(NSString *)borderTopWidth; +- (NSString *)borderRightWidth; +- (void)setBorderRightWidth:(NSString *)borderRightWidth; +- (NSString *)borderBottomWidth; +- (void)setBorderBottomWidth:(NSString *)borderBottomWidth; +- (NSString *)borderLeftWidth; +- (void)setBorderLeftWidth:(NSString *)borderLeftWidth; +- (NSString *)borderWidth; +- (void)setBorderWidth:(NSString *)borderWidth; +- (NSString *)bottom; +- (void)setBottom:(NSString *)bottom; +- (NSString *)captionSide; +- (void)setCaptionSide:(NSString *)captionSide; +- (NSString *)clear; +- (void)setClear:(NSString *)clear; +- (NSString *)clip; +- (void)setClip:(NSString *)clip; +- (NSString *)color; +- (void)setColor:(NSString *)color; +- (NSString *)content; +- (void)setContent:(NSString *)content; +- (NSString *)counterIncrement; +- (void)setCounterIncrement:(NSString *)counterIncrement; +- (NSString *)counterReset; +- (void)setCounterReset:(NSString *)counterReset; +- (NSString *)cue; +- (void)setCue:(NSString *)cue; +- (NSString *)cueAfter; +- (void)setCueAfter:(NSString *)cueAfter; +- (NSString *)cueBefore; +- (void)setCueBefore:(NSString *)cueBefore; +- (NSString *)cursor; +- (void)setCursor:(NSString *)cursor; +- (NSString *)direction; +- (void)setDirection:(NSString *)direction; +- (NSString *)display; +- (void)setDisplay:(NSString *)display; +- (NSString *)elevation; +- (void)setElevation:(NSString *)elevation; +- (NSString *)emptyCells; +- (void)setEmptyCells:(NSString *)emptyCells; +- (NSString *)cssFloat; +- (void)setCssFloat:(NSString *)cssFloat; +- (NSString *)font; +- (void)setFont:(NSString *)font; +- (NSString *)fontFamily; +- (void)setFontFamily:(NSString *)fontFamily; +- (NSString *)fontSize; +- (void)setFontSize:(NSString *)fontSize; +- (NSString *)fontSizeAdjust; +- (void)setFontSizeAdjust:(NSString *)fontSizeAdjust; +- (NSString *)fontStretch; +- (void)setFontStretch:(NSString *)fontStretch; +- (NSString *)fontStyle; +- (void)setFontStyle:(NSString *)fontStyle; +- (NSString *)fontVariant; +- (void)setFontVariant:(NSString *)fontVariant; +- (NSString *)fontWeight; +- (void)setFontWeight:(NSString *)fontWeight; +- (NSString *)height; +- (void)setHeight:(NSString *)height; +- (NSString *)left; +- (void)setLeft:(NSString *)left; +- (NSString *)letterSpacing; +- (void)setLetterSpacing:(NSString *)letterSpacing; +- (NSString *)lineHeight; +- (void)setLineHeight:(NSString *)lineHeight; +- (NSString *)listStyle; +- (void)setListStyle:(NSString *)listStyle; +- (NSString *)listStyleImage; +- (void)setListStyleImage:(NSString *)listStyleImage; +- (NSString *)listStylePosition; +- (void)setListStylePosition:(NSString *)listStylePosition; +- (NSString *)listStyleType; +- (void)setListStyleType:(NSString *)listStyleType; +- (NSString *)margin; +- (void)setMargin:(NSString *)margin; +- (NSString *)marginTop; +- (void)setMarginTop:(NSString *)marginTop; +- (NSString *)marginRight; +- (void)setMarginRight:(NSString *)marginRight; +- (NSString *)marginBottom; +- (void)setMarginBottom:(NSString *)marginBottom; +- (NSString *)marginLeft; +- (void)setMarginLeft:(NSString *)marginLeft; +- (NSString *)markerOffset; +- (void)setMarkerOffset:(NSString *)markerOffset; +- (NSString *)marks; +- (void)setMarks:(NSString *)marks; +- (NSString *)maxHeight; +- (void)setMaxHeight:(NSString *)maxHeight; +- (NSString *)maxWidth; +- (void)setMaxWidth:(NSString *)maxWidth; +- (NSString *)minHeight; +- (void)setMinHeight:(NSString *)minHeight; +- (NSString *)minWidth; +- (void)setMinWidth:(NSString *)minWidth; +- (NSString *)orphans; +- (void)setOrphans:(NSString *)orphans; +- (NSString *)outline; +- (void)setOutline:(NSString *)outline; +- (NSString *)outlineColor; +- (void)setOutlineColor:(NSString *)outlineColor; +- (NSString *)outlineStyle; +- (void)setOutlineStyle:(NSString *)outlineStyle; +- (NSString *)outlineWidth; +- (void)setOutlineWidth:(NSString *)outlineWidth; +- (NSString *)overflow; +- (void)setOverflow:(NSString *)overflow; +- (NSString *)padding; +- (void)setPadding:(NSString *)padding; +- (NSString *)paddingTop; +- (void)setPaddingTop:(NSString *)paddingTop; +- (NSString *)paddingRight; +- (void)setPaddingRight:(NSString *)paddingRight; +- (NSString *)paddingBottom; +- (void)setPaddingBottom:(NSString *)paddingBottom; +- (NSString *)paddingLeft; +- (void)setPaddingLeft:(NSString *)paddingLeft; +- (NSString *)page; +- (void)setPage:(NSString *)page; +- (NSString *)pageBreakAfter; +- (void)setPageBreakAfter:(NSString *)pageBreakAfter; +- (NSString *)pageBreakBefore; +- (void)setPageBreakBefore:(NSString *)pageBreakBefore; +- (NSString *)pageBreakInside; +- (void)setPageBreakInside:(NSString *)pageBreakInside; +- (NSString *)pause; +- (void)setPause:(NSString *)pause; +- (NSString *)pauseAfter; +- (void)setPauseAfter:(NSString *)pauseAfter; +- (NSString *)pauseBefore; +- (void)setPauseBefore:(NSString *)pauseBefore; +- (NSString *)pitch; +- (void)setPitch:(NSString *)pitch; +- (NSString *)pitchRange; +- (void)setPitchRange:(NSString *)pitchRange; +- (NSString *)playDuring; +- (void)setPlayDuring:(NSString *)playDuring; +- (NSString *)position; +- (void)setPosition:(NSString *)position; +- (NSString *)quotes; +- (void)setQuotes:(NSString *)quotes; +- (NSString *)richness; +- (void)setRichness:(NSString *)richness; +- (NSString *)right; +- (void)setRight:(NSString *)right; +- (NSString *)size; +- (void)setSize:(NSString *)size; +- (NSString *)speak; +- (void)setSpeak:(NSString *)speak; +- (NSString *)speakHeader; +- (void)setSpeakHeader:(NSString *)speakHeader; +- (NSString *)speakNumeral; +- (void)setSpeakNumeral:(NSString *)speakNumeral; +- (NSString *)speakPunctuation; +- (void)setSpeakPunctuation:(NSString *)speakPunctuation; +- (NSString *)speechRate; +- (void)setSpeechRate:(NSString *)speechRate; +- (NSString *)stress; +- (void)setStress:(NSString *)stress; +- (NSString *)tableLayout; +- (void)setTableLayout:(NSString *)tableLayout; +- (NSString *)textAlign; +- (void)setTextAlign:(NSString *)textAlign; +- (NSString *)textDecoration; +- (void)setTextDecoration:(NSString *)textDecoration; +- (NSString *)textIndent; +- (void)setTextIndent:(NSString *)textIndent; +- (NSString *)textShadow; +- (void)setTextShadow:(NSString *)textShadow; +- (NSString *)textTransform; +- (void)setTextTransform:(NSString *)textTransform; +- (NSString *)top; +- (void)setTop:(NSString *)top; +- (NSString *)unicodeBidi; +- (void)setUnicodeBidi:(NSString *)unicodeBidi; +- (NSString *)verticalAlign; +- (void)setVerticalAlign:(NSString *)verticalAlign; +- (NSString *)visibility; +- (void)setVisibility:(NSString *)visibility; +- (NSString *)voiceFamily; +- (void)setVoiceFamily:(NSString *)voiceFamily; +- (NSString *)volume; +- (void)setVolume:(NSString *)volume; +- (NSString *)whiteSpace; +- (void)setWhiteSpace:(NSString *)whiteSpace; +- (NSString *)widows; +- (void)setWidows:(NSString *)widows; +- (NSString *)width; +- (void)setWidth:(NSString *)width; +- (NSString *)wordSpacing; +- (void)setWordSpacing:(NSString *)wordSpacing; +- (NSString *)zIndex; +- (void)setZIndex:(NSString *)zIndex; +@end + +#endif diff --git a/WebCore/bindings/objc/DOMCSS.mm b/WebCore/bindings/objc/DOMCSS.mm new file mode 100644 index 0000000..4e9cd0c --- /dev/null +++ b/WebCore/bindings/objc/DOMCSS.mm @@ -0,0 +1,1452 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "config.h" +#import "DOMCSS.h" + +#import "CSSCharsetRule.h" +#import "CSSFontFaceRule.h" +#import "CSSImportRule.h" +#import "CSSMediaRule.h" +#import "CSSPageRule.h" +#import "CSSPrimitiveValue.h" +#import "CSSRule.h" +#import "CSSRuleList.h" +#import "CSSStyleDeclaration.h" +#import "CSSStyleRule.h" +#import "CSSStyleSheet.h" +#import "CSSValueList.h" +#import "DOMInternal.h" +#import "DOMPrivate.h" +#import "StyleSheet.h" +#import <objc/objc-class.h> + +#if ENABLE(SVG) +#import "DOMSVGColor.h" +#import "DOMSVGPaint.h" +#endif + +//------------------------------------------------------------------------------------------ +// DOMStyleSheet + +@implementation DOMStyleSheet (WebCoreInternal) + +- (WebCore::StyleSheet *)_styleSheet +{ + return reinterpret_cast<WebCore::StyleSheet*>(_internal); +} + +- (id)_initWithStyleSheet:(WebCore::StyleSheet *)impl +{ + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMStyleSheet *)_wrapStyleSheet:(WebCore::StyleSheet *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass; + if (impl->isCSSStyleSheet()) + wrapperClass = [DOMCSSStyleSheet class]; + else + wrapperClass = [DOMStyleSheet class]; + return [[[wrapperClass alloc] _initWithStyleSheet:impl] autorelease]; +} + +@end + +//------------------------------------------------------------------------------------------ +// DOMCSSRule + +@implementation DOMCSSRule (WebCoreInternal) + +- (WebCore::CSSRule *)_CSSRule +{ + return reinterpret_cast<WebCore::CSSRule*>(_internal); +} + +- (id)_initWithCSSRule:(WebCore::CSSRule *)impl +{ + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMCSSRule *)_wrapCSSRule:(WebCore::CSSRule *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass = nil; + switch (impl->type()) { + case DOM_UNKNOWN_RULE: + wrapperClass = [DOMCSSUnknownRule class]; + break; + case DOM_STYLE_RULE: + wrapperClass = [DOMCSSStyleRule class]; + break; + case DOM_CHARSET_RULE: + wrapperClass = [DOMCSSCharsetRule class]; + break; + case DOM_IMPORT_RULE: + wrapperClass = [DOMCSSImportRule class]; + break; + case DOM_MEDIA_RULE: + wrapperClass = [DOMCSSMediaRule class]; + break; + case DOM_FONT_FACE_RULE: + wrapperClass = [DOMCSSFontFaceRule class]; + break; + case DOM_PAGE_RULE: + wrapperClass = [DOMCSSPageRule class]; + break; + case DOM_VARIABLES_RULE: + wrapperClass = [DOMCSSVariablesRule class]; + break; + case DOM_WEBKIT_KEYFRAMES_RULE: + wrapperClass = [DOMWebKitCSSKeyframesRule class]; + break; + case DOM_WEBKIT_KEYFRAME_RULE: + wrapperClass = [DOMWebKitCSSKeyframeRule class]; + break; + } + return [[[wrapperClass alloc] _initWithCSSRule:impl] autorelease]; +} + +@end + + +//------------------------------------------------------------------------------------------ +// DOMCSSValue + +@implementation DOMCSSValue (WebCoreInternal) + +- (WebCore::CSSValue *)_CSSValue +{ + return reinterpret_cast<WebCore::CSSValue*>(_internal); +} + +- (id)_initWithCSSValue:(WebCore::CSSValue *)impl +{ + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMCSSValue *)_wrapCSSValue:(WebCore::CSSValue *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass = nil; + switch (impl->cssValueType()) { + case DOM_CSS_PRIMITIVE_VALUE: + wrapperClass = [DOMCSSPrimitiveValue class]; + break; + case DOM_CSS_VALUE_LIST: + wrapperClass = [DOMCSSValueList class]; + break; + case DOM_CSS_INHERIT: + wrapperClass = [DOMCSSValue class]; + break; + case DOM_CSS_CUSTOM: +#if ENABLE(SVG) + if (impl->isSVGPaint()) + wrapperClass = [DOMSVGPaint class]; + else if (impl->isSVGColor()) + wrapperClass = [DOMSVGColor class]; + else +#endif + wrapperClass = [DOMCSSValue class]; + break; + } + return [[[wrapperClass alloc] _initWithCSSValue:impl] autorelease]; +} + +@end + + +//------------------------------------------------------------------------------------------ +// DOMCSSStyleDeclaration CSS2 Properties + +@implementation DOMCSSStyleDeclaration (DOMCSS2Properties) + +- (NSString *)azimuth +{ + return [self getPropertyValue:@"azimuth"]; +} + +- (void)setAzimuth:(NSString *)azimuth +{ + [self setProperty:@"azimuth" value:azimuth priority:@""]; +} + +- (NSString *)background +{ + return [self getPropertyValue:@"background"]; +} + +- (void)setBackground:(NSString *)background +{ + [self setProperty:@"background" value:background priority:@""]; +} + +- (NSString *)backgroundAttachment +{ + return [self getPropertyValue:@"background-attachment"]; +} + +- (void)setBackgroundAttachment:(NSString *)backgroundAttachment +{ + [self setProperty:@"background-attachment" value:backgroundAttachment priority:@""]; +} + +- (NSString *)backgroundColor +{ + return [self getPropertyValue:@"background-color"]; +} + +- (void)setBackgroundColor:(NSString *)backgroundColor +{ + [self setProperty:@"background-color" value:backgroundColor priority:@""]; +} + +- (NSString *)backgroundImage +{ + return [self getPropertyValue:@"background-image"]; +} + +- (void)setBackgroundImage:(NSString *)backgroundImage +{ + [self setProperty:@"background-image" value:backgroundImage priority:@""]; +} + +- (NSString *)backgroundPosition +{ + return [self getPropertyValue:@"background-position"]; +} + +- (void)setBackgroundPosition:(NSString *)backgroundPosition +{ + [self setProperty:@"background-position" value:backgroundPosition priority:@""]; +} + +- (NSString *)backgroundRepeat +{ + return [self getPropertyValue:@"background-repeat"]; +} + +- (void)setBackgroundRepeat:(NSString *)backgroundRepeat +{ + [self setProperty:@"background-repeat" value:backgroundRepeat priority:@""]; +} + +- (NSString *)border +{ + return [self getPropertyValue:@"border"]; +} + +- (void)setBorder:(NSString *)border +{ + [self setProperty:@"border" value:border priority:@""]; +} + +- (NSString *)borderCollapse +{ + return [self getPropertyValue:@"border-collapse"]; +} + +- (void)setBorderCollapse:(NSString *)borderCollapse +{ + [self setProperty:@"border-collapse" value:borderCollapse priority:@""]; +} + +- (NSString *)borderColor +{ + return [self getPropertyValue:@"border-color"]; +} + +- (void)setBorderColor:(NSString *)borderColor +{ + [self setProperty:@"border-color" value:borderColor priority:@""]; +} + +- (NSString *)borderSpacing +{ + return [self getPropertyValue:@"border-spacing"]; +} + +- (void)setBorderSpacing:(NSString *)borderSpacing +{ + [self setProperty:@"border-spacing" value:borderSpacing priority:@""]; +} + +- (NSString *)borderStyle +{ + return [self getPropertyValue:@"border-style"]; +} + +- (void)setBorderStyle:(NSString *)borderStyle +{ + [self setProperty:@"border-style" value:borderStyle priority:@""]; +} + +- (NSString *)borderTop +{ + return [self getPropertyValue:@"border-top"]; +} + +- (void)setBorderTop:(NSString *)borderTop +{ + [self setProperty:@"border-top" value:borderTop priority:@""]; +} + +- (NSString *)borderRight +{ + return [self getPropertyValue:@"border-right"]; +} + +- (void)setBorderRight:(NSString *)borderRight +{ + [self setProperty:@"border-right" value:borderRight priority:@""]; +} + +- (NSString *)borderBottom +{ + return [self getPropertyValue:@"border-bottom"]; +} + +- (void)setBorderBottom:(NSString *)borderBottom +{ + [self setProperty:@"border-bottom" value:borderBottom priority:@""]; +} + +- (NSString *)borderLeft +{ + return [self getPropertyValue:@"border-left"]; +} + +- (void)setBorderLeft:(NSString *)borderLeft +{ + [self setProperty:@"border-left" value:borderLeft priority:@""]; +} + +- (NSString *)borderTopColor +{ + return [self getPropertyValue:@"border-top-color"]; +} + +- (void)setBorderTopColor:(NSString *)borderTopColor +{ + [self setProperty:@"border-top-color" value:borderTopColor priority:@""]; +} + +- (NSString *)borderRightColor +{ + return [self getPropertyValue:@"border-right-color"]; +} + +- (void)setBorderRightColor:(NSString *)borderRightColor +{ + [self setProperty:@"border-right-color" value:borderRightColor priority:@""]; +} + +- (NSString *)borderBottomColor +{ + return [self getPropertyValue:@"border-bottom-color"]; +} + +- (void)setBorderBottomColor:(NSString *)borderBottomColor +{ + [self setProperty:@"border-bottom-color" value:borderBottomColor priority:@""]; +} + +- (NSString *)borderLeftColor +{ + return [self getPropertyValue:@"border-left-color"]; +} + +- (void)setBorderLeftColor:(NSString *)borderLeftColor +{ + [self setProperty:@"border-left-color" value:borderLeftColor priority:@""]; +} + +- (NSString *)borderTopStyle +{ + return [self getPropertyValue:@"border-top-style"]; +} + +- (void)setBorderTopStyle:(NSString *)borderTopStyle +{ + [self setProperty:@"border-top-style" value:borderTopStyle priority:@""]; +} + +- (NSString *)borderRightStyle +{ + return [self getPropertyValue:@"border-right-style"]; +} + +- (void)setBorderRightStyle:(NSString *)borderRightStyle +{ + [self setProperty:@"border-right-style" value:borderRightStyle priority:@""]; +} + +- (NSString *)borderBottomStyle +{ + return [self getPropertyValue:@"border-bottom-style"]; +} + +- (void)setBorderBottomStyle:(NSString *)borderBottomStyle +{ + [self setProperty:@"border-bottom-style" value:borderBottomStyle priority:@""]; +} + +- (NSString *)borderLeftStyle +{ + return [self getPropertyValue:@"border-left-style"]; +} + +- (void)setBorderLeftStyle:(NSString *)borderLeftStyle +{ + [self setProperty:@"border-left-style" value:borderLeftStyle priority:@""]; +} + +- (NSString *)borderTopWidth +{ + return [self getPropertyValue:@"border-top-width"]; +} + +- (void)setBorderTopWidth:(NSString *)borderTopWidth +{ + [self setProperty:@"border-top-width" value:borderTopWidth priority:@""]; +} + +- (NSString *)borderRightWidth +{ + return [self getPropertyValue:@"border-right-width"]; +} + +- (void)setBorderRightWidth:(NSString *)borderRightWidth +{ + [self setProperty:@"border-right-width" value:borderRightWidth priority:@""]; +} + +- (NSString *)borderBottomWidth +{ + return [self getPropertyValue:@"border-bottom-width"]; +} + +- (void)setBorderBottomWidth:(NSString *)borderBottomWidth +{ + [self setProperty:@"border-bottom-width" value:borderBottomWidth priority:@""]; +} + +- (NSString *)borderLeftWidth +{ + return [self getPropertyValue:@"border-left-width"]; +} + +- (void)setBorderLeftWidth:(NSString *)borderLeftWidth +{ + [self setProperty:@"border-left-width" value:borderLeftWidth priority:@""]; +} + +- (NSString *)borderWidth +{ + return [self getPropertyValue:@"border-width"]; +} + +- (void)setBorderWidth:(NSString *)borderWidth +{ + [self setProperty:@"border-width" value:borderWidth priority:@""]; +} + +- (NSString *)bottom +{ + return [self getPropertyValue:@"bottom"]; +} + +- (void)setBottom:(NSString *)bottom +{ + [self setProperty:@"bottom" value:bottom priority:@""]; +} + +- (NSString *)captionSide +{ + return [self getPropertyValue:@"caption-side"]; +} + +- (void)setCaptionSide:(NSString *)captionSide +{ + [self setProperty:@"caption-side" value:captionSide priority:@""]; +} + +- (NSString *)clear +{ + return [self getPropertyValue:@"clear"]; +} + +- (void)setClear:(NSString *)clear +{ + [self setProperty:@"clear" value:clear priority:@""]; +} + +- (NSString *)clip +{ + return [self getPropertyValue:@"clip"]; +} + +- (void)setClip:(NSString *)clip +{ + [self setProperty:@"clip" value:clip priority:@""]; +} + +- (NSString *)color +{ + return [self getPropertyValue:@"color"]; +} + +- (void)setColor:(NSString *)color +{ + [self setProperty:@"color" value:color priority:@""]; +} + +- (NSString *)content +{ + return [self getPropertyValue:@"content"]; +} + +- (void)setContent:(NSString *)content +{ + [self setProperty:@"content" value:content priority:@""]; +} + +- (NSString *)counterIncrement +{ + return [self getPropertyValue:@"counter-increment"]; +} + +- (void)setCounterIncrement:(NSString *)counterIncrement +{ + [self setProperty:@"counter-increment" value:counterIncrement priority:@""]; +} + +- (NSString *)counterReset +{ + return [self getPropertyValue:@"counter-reset"]; +} + +- (void)setCounterReset:(NSString *)counterReset +{ + [self setProperty:@"counter-reset" value:counterReset priority:@""]; +} + +- (NSString *)cue +{ + return [self getPropertyValue:@"cue"]; +} + +- (void)setCue:(NSString *)cue +{ + [self setProperty:@"cue" value:cue priority:@""]; +} + +- (NSString *)cueAfter +{ + return [self getPropertyValue:@"cue-after"]; +} + +- (void)setCueAfter:(NSString *)cueAfter +{ + [self setProperty:@"cue-after" value:cueAfter priority:@""]; +} + +- (NSString *)cueBefore +{ + return [self getPropertyValue:@"cue-before"]; +} + +- (void)setCueBefore:(NSString *)cueBefore +{ + [self setProperty:@"cue-before" value:cueBefore priority:@""]; +} + +- (NSString *)cursor +{ + return [self getPropertyValue:@"cursor"]; +} + +- (void)setCursor:(NSString *)cursor +{ + [self setProperty:@"cursor" value:cursor priority:@""]; +} + +- (NSString *)direction +{ + return [self getPropertyValue:@"direction"]; +} + +- (void)setDirection:(NSString *)direction +{ + [self setProperty:@"direction" value:direction priority:@""]; +} + +- (NSString *)display +{ + return [self getPropertyValue:@"display"]; +} + +- (void)setDisplay:(NSString *)display +{ + [self setProperty:@"display" value:display priority:@""]; +} + +- (NSString *)elevation +{ + return [self getPropertyValue:@"elevation"]; +} + +- (void)setElevation:(NSString *)elevation +{ + [self setProperty:@"elevation" value:elevation priority:@""]; +} + +- (NSString *)emptyCells +{ + return [self getPropertyValue:@"empty-cells"]; +} + +- (void)setEmptyCells:(NSString *)emptyCells +{ + [self setProperty:@"empty-cells" value:emptyCells priority:@""]; +} + +- (NSString *)cssFloat +{ + return [self getPropertyValue:@"css-float"]; +} + +- (void)setCssFloat:(NSString *)cssFloat +{ + [self setProperty:@"css-float" value:cssFloat priority:@""]; +} + +- (NSString *)font +{ + return [self getPropertyValue:@"font"]; +} + +- (void)setFont:(NSString *)font +{ + [self setProperty:@"font" value:font priority:@""]; +} + +- (NSString *)fontFamily +{ + return [self getPropertyValue:@"font-family"]; +} + +- (void)setFontFamily:(NSString *)fontFamily +{ + [self setProperty:@"font-family" value:fontFamily priority:@""]; +} + +- (NSString *)fontSize +{ + return [self getPropertyValue:@"font-size"]; +} + +- (void)setFontSize:(NSString *)fontSize +{ + [self setProperty:@"font-size" value:fontSize priority:@""]; +} + +- (NSString *)fontSizeAdjust +{ + return [self getPropertyValue:@"font-size-adjust"]; +} + +- (void)setFontSizeAdjust:(NSString *)fontSizeAdjust +{ + [self setProperty:@"font-size-adjust" value:fontSizeAdjust priority:@""]; +} + +- (NSString *)_fontSizeDelta +{ + return [self getPropertyValue:@"-webkit-font-size-delta"]; +} + +- (void)_setFontSizeDelta:(NSString *)fontSizeDelta +{ + [self setProperty:@"-webkit-font-size-delta" value:fontSizeDelta priority:@""]; +} + +- (NSString *)fontStretch +{ + return [self getPropertyValue:@"font-stretch"]; +} + +- (void)setFontStretch:(NSString *)fontStretch +{ + [self setProperty:@"font-stretch" value:fontStretch priority:@""]; +} + +- (NSString *)fontStyle +{ + return [self getPropertyValue:@"font-style"]; +} + +- (void)setFontStyle:(NSString *)fontStyle +{ + [self setProperty:@"font-style" value:fontStyle priority:@""]; +} + +- (NSString *)fontVariant +{ + return [self getPropertyValue:@"font-variant"]; +} + +- (void)setFontVariant:(NSString *)fontVariant +{ + [self setProperty:@"font-variant" value:fontVariant priority:@""]; +} + +- (NSString *)fontWeight +{ + return [self getPropertyValue:@"font-weight"]; +} + +- (void)setFontWeight:(NSString *)fontWeight +{ + [self setProperty:@"font-weight" value:fontWeight priority:@""]; +} + +- (NSString *)height +{ + return [self getPropertyValue:@"height"]; +} + +- (void)setHeight:(NSString *)height +{ + [self setProperty:@"height" value:height priority:@""]; +} + +- (NSString *)left +{ + return [self getPropertyValue:@"left"]; +} + +- (void)setLeft:(NSString *)left +{ + [self setProperty:@"left" value:left priority:@""]; +} + +- (NSString *)letterSpacing +{ + return [self getPropertyValue:@"letter-spacing"]; +} + +- (void)setLetterSpacing:(NSString *)letterSpacing +{ + [self setProperty:@"letter-spacing" value:letterSpacing priority:@""]; +} + +- (NSString *)lineHeight +{ + return [self getPropertyValue:@"line-height"]; +} + +- (void)setLineHeight:(NSString *)lineHeight +{ + [self setProperty:@"line-height" value:lineHeight priority:@""]; +} + +- (NSString *)listStyle +{ + return [self getPropertyValue:@"list-style"]; +} + +- (void)setListStyle:(NSString *)listStyle +{ + [self setProperty:@"list-style" value:listStyle priority:@""]; +} + +- (NSString *)listStyleImage +{ + return [self getPropertyValue:@"list-style-image"]; +} + +- (void)setListStyleImage:(NSString *)listStyleImage +{ + [self setProperty:@"list-style-image" value:listStyleImage priority:@""]; +} + +- (NSString *)listStylePosition +{ + return [self getPropertyValue:@"list-style-position"]; +} + +- (void)setListStylePosition:(NSString *)listStylePosition +{ + [self setProperty:@"list-style-position" value:listStylePosition priority:@""]; +} + +- (NSString *)listStyleType +{ + return [self getPropertyValue:@"list-style-type"]; +} + +- (void)setListStyleType:(NSString *)listStyleType +{ + [self setProperty:@"list-style-type" value:listStyleType priority:@""]; +} + +- (NSString *)margin +{ + return [self getPropertyValue:@"margin"]; +} + +- (void)setMargin:(NSString *)margin +{ + [self setProperty:@"margin" value:margin priority:@""]; +} + +- (NSString *)marginTop +{ + return [self getPropertyValue:@"margin-top"]; +} + +- (void)setMarginTop:(NSString *)marginTop +{ + [self setProperty:@"margin-top" value:marginTop priority:@""]; +} + +- (NSString *)marginRight +{ + return [self getPropertyValue:@"margin-right"]; +} + +- (void)setMarginRight:(NSString *)marginRight +{ + [self setProperty:@"margin-right" value:marginRight priority:@""]; +} + +- (NSString *)marginBottom +{ + return [self getPropertyValue:@"margin-bottom"]; +} + +- (void)setMarginBottom:(NSString *)marginBottom +{ + [self setProperty:@"margin-bottom" value:marginBottom priority:@""]; +} + +- (NSString *)marginLeft +{ + return [self getPropertyValue:@"margin-left"]; +} + +- (void)setMarginLeft:(NSString *)marginLeft +{ + [self setProperty:@"margin-left" value:marginLeft priority:@""]; +} + +- (NSString *)markerOffset +{ + return [self getPropertyValue:@"marker-offset"]; +} + +- (void)setMarkerOffset:(NSString *)markerOffset +{ + [self setProperty:@"marker-offset" value:markerOffset priority:@""]; +} + +- (NSString *)marks +{ + return [self getPropertyValue:@"marks"]; +} + +- (void)setMarks:(NSString *)marks +{ + [self setProperty:@"marks" value:marks priority:@""]; +} + +- (NSString *)maxHeight +{ + return [self getPropertyValue:@"max-height"]; +} + +- (void)setMaxHeight:(NSString *)maxHeight +{ + [self setProperty:@"max-height" value:maxHeight priority:@""]; +} + +- (NSString *)maxWidth +{ + return [self getPropertyValue:@"max-width"]; +} + +- (void)setMaxWidth:(NSString *)maxWidth +{ + [self setProperty:@"max-width" value:maxWidth priority:@""]; +} + +- (NSString *)minHeight +{ + return [self getPropertyValue:@"min-height"]; +} + +- (void)setMinHeight:(NSString *)minHeight +{ + [self setProperty:@"min-height" value:minHeight priority:@""]; +} + +- (NSString *)minWidth +{ + return [self getPropertyValue:@"min-width"]; +} + +- (void)setMinWidth:(NSString *)minWidth +{ + [self setProperty:@"min-width" value:minWidth priority:@""]; +} + +- (NSString *)orphans +{ + return [self getPropertyValue:@"orphans"]; +} + +- (void)setOrphans:(NSString *)orphans +{ + [self setProperty:@"orphans" value:orphans priority:@""]; +} + +- (NSString *)outline +{ + return [self getPropertyValue:@"outline"]; +} + +- (void)setOutline:(NSString *)outline +{ + [self setProperty:@"outline" value:outline priority:@""]; +} + +- (NSString *)outlineColor +{ + return [self getPropertyValue:@"outline-color"]; +} + +- (void)setOutlineColor:(NSString *)outlineColor +{ + [self setProperty:@"outline-color" value:outlineColor priority:@""]; +} + +- (NSString *)outlineStyle +{ + return [self getPropertyValue:@"outline-style"]; +} + +- (void)setOutlineStyle:(NSString *)outlineStyle +{ + [self setProperty:@"outline-style" value:outlineStyle priority:@""]; +} + +- (NSString *)outlineWidth +{ + return [self getPropertyValue:@"outline-width"]; +} + +- (void)setOutlineWidth:(NSString *)outlineWidth +{ + [self setProperty:@"outline-width" value:outlineWidth priority:@""]; +} + +- (NSString *)overflow +{ + return [self getPropertyValue:@"overflow"]; +} + +- (void)setOverflow:(NSString *)overflow +{ + [self setProperty:@"overflow" value:overflow priority:@""]; +} + +- (NSString *)padding +{ + return [self getPropertyValue:@"padding"]; +} + +- (void)setPadding:(NSString *)padding +{ + [self setProperty:@"padding" value:padding priority:@""]; +} + +- (NSString *)paddingTop +{ + return [self getPropertyValue:@"padding-top"]; +} + +- (void)setPaddingTop:(NSString *)paddingTop +{ + [self setProperty:@"padding-top" value:paddingTop priority:@""]; +} + +- (NSString *)paddingRight +{ + return [self getPropertyValue:@"padding-right"]; +} + +- (void)setPaddingRight:(NSString *)paddingRight +{ + [self setProperty:@"padding-right" value:paddingRight priority:@""]; +} + +- (NSString *)paddingBottom +{ + return [self getPropertyValue:@"padding-bottom"]; +} + +- (void)setPaddingBottom:(NSString *)paddingBottom +{ + [self setProperty:@"padding-bottom" value:paddingBottom priority:@""]; +} + +- (NSString *)paddingLeft +{ + return [self getPropertyValue:@"padding-left"]; +} + +- (void)setPaddingLeft:(NSString *)paddingLeft +{ + [self setProperty:@"padding-left" value:paddingLeft priority:@""]; +} + +- (NSString *)page +{ + return [self getPropertyValue:@"page"]; +} + +- (void)setPage:(NSString *)page +{ + [self setProperty:@"page" value:page priority:@""]; +} + +- (NSString *)pageBreakAfter +{ + return [self getPropertyValue:@"page-break-after"]; +} + +- (void)setPageBreakAfter:(NSString *)pageBreakAfter +{ + [self setProperty:@"page-break-after" value:pageBreakAfter priority:@""]; +} + +- (NSString *)pageBreakBefore +{ + return [self getPropertyValue:@"page-break-before"]; +} + +- (void)setPageBreakBefore:(NSString *)pageBreakBefore +{ + [self setProperty:@"page-break-before" value:pageBreakBefore priority:@""]; +} + +- (NSString *)pageBreakInside +{ + return [self getPropertyValue:@"page-break-inside"]; +} + +- (void)setPageBreakInside:(NSString *)pageBreakInside +{ + [self setProperty:@"page-break-inside" value:pageBreakInside priority:@""]; +} + +- (NSString *)pause +{ + return [self getPropertyValue:@"pause"]; +} + +- (void)setPause:(NSString *)pause +{ + [self setProperty:@"pause" value:pause priority:@""]; +} + +- (NSString *)pauseAfter +{ + return [self getPropertyValue:@"pause-after"]; +} + +- (void)setPauseAfter:(NSString *)pauseAfter +{ + [self setProperty:@"pause-after" value:pauseAfter priority:@""]; +} + +- (NSString *)pauseBefore +{ + return [self getPropertyValue:@"pause-before"]; +} + +- (void)setPauseBefore:(NSString *)pauseBefore +{ + [self setProperty:@"pause-before" value:pauseBefore priority:@""]; +} + +- (NSString *)pitch +{ + return [self getPropertyValue:@"pitch"]; +} + +- (void)setPitch:(NSString *)pitch +{ + [self setProperty:@"pitch" value:pitch priority:@""]; +} + +- (NSString *)pitchRange +{ + return [self getPropertyValue:@"pitch-range"]; +} + +- (void)setPitchRange:(NSString *)pitchRange +{ + [self setProperty:@"pitch-range" value:pitchRange priority:@""]; +} + +- (NSString *)playDuring +{ + return [self getPropertyValue:@"play-during"]; +} + +- (void)setPlayDuring:(NSString *)playDuring +{ + [self setProperty:@"play-during" value:playDuring priority:@""]; +} + +- (NSString *)position +{ + return [self getPropertyValue:@"position"]; +} + +- (void)setPosition:(NSString *)position +{ + [self setProperty:@"position" value:position priority:@""]; +} + +- (NSString *)quotes +{ + return [self getPropertyValue:@"quotes"]; +} + +- (void)setQuotes:(NSString *)quotes +{ + [self setProperty:@"quotes" value:quotes priority:@""]; +} + +- (NSString *)richness +{ + return [self getPropertyValue:@"richness"]; +} + +- (void)setRichness:(NSString *)richness +{ + [self setProperty:@"richness" value:richness priority:@""]; +} + +- (NSString *)right +{ + return [self getPropertyValue:@"right"]; +} + +- (void)setRight:(NSString *)right +{ + [self setProperty:@"right" value:right priority:@""]; +} + +- (NSString *)size +{ + return [self getPropertyValue:@"size"]; +} + +- (void)setSize:(NSString *)size +{ + [self setProperty:@"size" value:size priority:@""]; +} + +- (NSString *)speak +{ + return [self getPropertyValue:@"speak"]; +} + +- (void)setSpeak:(NSString *)speak +{ + [self setProperty:@"speak" value:speak priority:@""]; +} + +- (NSString *)speakHeader +{ + return [self getPropertyValue:@"speak-header"]; +} + +- (void)setSpeakHeader:(NSString *)speakHeader +{ + [self setProperty:@"speak-header" value:speakHeader priority:@""]; +} + +- (NSString *)speakNumeral +{ + return [self getPropertyValue:@"speak-numeral"]; +} + +- (void)setSpeakNumeral:(NSString *)speakNumeral +{ + [self setProperty:@"speak-numeral" value:speakNumeral priority:@""]; +} + +- (NSString *)speakPunctuation +{ + return [self getPropertyValue:@"speak-punctuation"]; +} + +- (void)setSpeakPunctuation:(NSString *)speakPunctuation +{ + [self setProperty:@"speak-punctuation" value:speakPunctuation priority:@""]; +} + +- (NSString *)speechRate +{ + return [self getPropertyValue:@"speech-rate"]; +} + +- (void)setSpeechRate:(NSString *)speechRate +{ + [self setProperty:@"speech-rate" value:speechRate priority:@""]; +} + +- (NSString *)stress +{ + return [self getPropertyValue:@"stress"]; +} + +- (void)setStress:(NSString *)stress +{ + [self setProperty:@"stress" value:stress priority:@""]; +} + +- (NSString *)tableLayout +{ + return [self getPropertyValue:@"table-layout"]; +} + +- (void)setTableLayout:(NSString *)tableLayout +{ + [self setProperty:@"table-layout" value:tableLayout priority:@""]; +} + +- (NSString *)textAlign +{ + return [self getPropertyValue:@"text-align"]; +} + +- (void)setTextAlign:(NSString *)textAlign +{ + [self setProperty:@"text-align" value:textAlign priority:@""]; +} + +- (NSString *)textDecoration +{ + return [self getPropertyValue:@"text-decoration"]; +} + +- (void)setTextDecoration:(NSString *)textDecoration +{ + [self setProperty:@"text-decoration" value:textDecoration priority:@""]; +} + +- (NSString *)textIndent +{ + return [self getPropertyValue:@"text-indent"]; +} + +- (void)setTextIndent:(NSString *)textIndent +{ + [self setProperty:@"text-indent" value:textIndent priority:@""]; +} + +- (NSString *)textShadow +{ + return [self getPropertyValue:@"text-shadow"]; +} + +- (void)setTextShadow:(NSString *)textShadow +{ + [self setProperty:@"text-shadow" value:textShadow priority:@""]; +} + +- (NSString *)textTransform +{ + return [self getPropertyValue:@"text-transform"]; +} + +- (void)setTextTransform:(NSString *)textTransform +{ + [self setProperty:@"text-transform" value:textTransform priority:@""]; +} + +- (NSString *)top +{ + return [self getPropertyValue:@"top"]; +} + +- (void)setTop:(NSString *)top +{ + [self setProperty:@"top" value:top priority:@""]; +} + +- (NSString *)unicodeBidi +{ + return [self getPropertyValue:@"unicode-bidi"]; +} + +- (void)setUnicodeBidi:(NSString *)unicodeBidi +{ + [self setProperty:@"unicode-bidi" value:unicodeBidi priority:@""]; +} + +- (NSString *)verticalAlign +{ + return [self getPropertyValue:@"vertical-align"]; +} + +- (void)setVerticalAlign:(NSString *)verticalAlign +{ + [self setProperty:@"vertical-align" value:verticalAlign priority:@""]; +} + +- (NSString *)visibility +{ + return [self getPropertyValue:@"visibility"]; +} + +- (void)setVisibility:(NSString *)visibility +{ + [self setProperty:@"visibility" value:visibility priority:@""]; +} + +- (NSString *)voiceFamily +{ + return [self getPropertyValue:@"voice-family"]; +} + +- (void)setVoiceFamily:(NSString *)voiceFamily +{ + [self setProperty:@"voice-family" value:voiceFamily priority:@""]; +} + +- (NSString *)volume +{ + return [self getPropertyValue:@"volume"]; +} + +- (void)setVolume:(NSString *)volume +{ + [self setProperty:@"volume" value:volume priority:@""]; +} + +- (NSString *)whiteSpace +{ + return [self getPropertyValue:@"white-space"]; +} + +- (void)setWhiteSpace:(NSString *)whiteSpace +{ + [self setProperty:@"white-space" value:whiteSpace priority:@""]; +} + +- (NSString *)widows +{ + return [self getPropertyValue:@"widows"]; +} + +- (void)setWidows:(NSString *)widows +{ + [self setProperty:@"widows" value:widows priority:@""]; +} + +- (NSString *)width +{ + return [self getPropertyValue:@"width"]; +} + +- (void)setWidth:(NSString *)width +{ + [self setProperty:@"width" value:width priority:@""]; +} + +- (NSString *)wordSpacing +{ + return [self getPropertyValue:@"word-spacing"]; +} + +- (void)setWordSpacing:(NSString *)wordSpacing +{ + [self setProperty:@"word-spacing" value:wordSpacing priority:@""]; +} + +- (NSString *)zIndex +{ + return [self getPropertyValue:@"z-index"]; +} + +- (void)setZIndex:(NSString *)zIndex +{ + [self setProperty:@"z-index" value:zIndex priority:@""]; +} + +@end diff --git a/WebCore/bindings/objc/DOMCore.h b/WebCore/bindings/objc/DOMCore.h new file mode 100644 index 0000000..afac8ed --- /dev/null +++ b/WebCore/bindings/objc/DOMCore.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMAttr.h> +#import <WebCore/DOMCDATASection.h> +#import <WebCore/DOMCharacterData.h> +#import <WebCore/DOMComment.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMDocumentFragment.h> +#import <WebCore/DOMDocumentType.h> +#import <WebCore/DOMElement.h> +#import <WebCore/DOMEntity.h> +#import <WebCore/DOMEntityReference.h> +#import <WebCore/DOMException.h> +#import <WebCore/DOMDOMImplementation.h> +#import <WebCore/DOMNamedNodeMap.h> +#import <WebCore/DOMNode.h> +#import <WebCore/DOMNodeList.h> +#import <WebCore/DOMNotation.h> +#import <WebCore/DOMObject.h> +#import <WebCore/DOMProcessingInstruction.h> +#import <WebCore/DOMText.h> diff --git a/WebCore/bindings/objc/DOMCustomXPathNSResolver.h b/WebCore/bindings/objc/DOMCustomXPathNSResolver.h new file mode 100644 index 0000000..2609e90 --- /dev/null +++ b/WebCore/bindings/objc/DOMCustomXPathNSResolver.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2007 Alexey Proskuryakov (ap@nypop.com) + * + * 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. + */ + +#ifndef DOMCustomXPathNSResolver_h +#define DOMCustomXPathNSResolver_h + +#if ENABLE(XPATH) + +#include "XPathNSResolver.h" + +#include "DOMXPathNSResolver.h" +#include <wtf/PassRefPtr.h> + +namespace WebCore { + + class Frame; + + class DOMCustomXPathNSResolver : public XPathNSResolver { + public: + static PassRefPtr<DOMCustomXPathNSResolver> create(id <DOMXPathNSResolver> customResolver) { return adoptRef(new DOMCustomXPathNSResolver(customResolver)); } + virtual ~DOMCustomXPathNSResolver(); + + virtual String lookupNamespaceURI(const String& prefix); + + private: + DOMCustomXPathNSResolver(id <DOMXPathNSResolver>); + id <DOMXPathNSResolver> m_customResolver; // DOMCustomXPathNSResolvers are always temporary, thus no need to GC protect the object. + }; + +} // namespace WebCore + +#endif // ENABLE(XPATH) + +#endif // DOMCustomXPathNSResolver_h diff --git a/WebCore/bindings/objc/DOMCustomXPathNSResolver.mm b/WebCore/bindings/objc/DOMCustomXPathNSResolver.mm new file mode 100644 index 0000000..670c836 --- /dev/null +++ b/WebCore/bindings/objc/DOMCustomXPathNSResolver.mm @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2007 Alexey Proskuryakov (ap@nypop.com) + * + * 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. + */ + +#include "config.h" +#include "DOMCustomXPathNSResolver.h" + +#if ENABLE(XPATH) + +#include "BlockExceptions.h" +#include "PlatformString.h" + +namespace WebCore { + +DOMCustomXPathNSResolver::DOMCustomXPathNSResolver(id <DOMXPathNSResolver> customResolver) + : m_customResolver(customResolver) +{ +} + +DOMCustomXPathNSResolver::~DOMCustomXPathNSResolver() +{ +} + +String DOMCustomXPathNSResolver::lookupNamespaceURI(const String& prefix) +{ + NSString *namespaceURI = nil; + + BEGIN_BLOCK_OBJC_EXCEPTIONS; + namespaceURI = [m_customResolver lookupNamespaceURI:prefix]; + END_BLOCK_OBJC_EXCEPTIONS; + + return namespaceURI; +} + +} // namespace WebCore + +#endif // ENABLE(XPATH) diff --git a/WebCore/bindings/objc/DOMEventException.h b/WebCore/bindings/objc/DOMEventException.h new file mode 100644 index 0000000..a485955 --- /dev/null +++ b/WebCore/bindings/objc/DOMEventException.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +@class NSString; + +extern NSString * const DOMEventException; + +enum DOMEventExceptionCode { + DOM_UNSPECIFIED_EVENT_TYPE_ERR = 0 +}; + +#endif diff --git a/WebCore/bindings/objc/DOMEvents.h b/WebCore/bindings/objc/DOMEvents.h new file mode 100644 index 0000000..ba3bd3e --- /dev/null +++ b/WebCore/bindings/objc/DOMEvents.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2004, 2006, 2008 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMDocument.h> +#import <WebCore/DOMNode.h> +#import <WebCore/DOMObject.h> +#import <WebCore/DOMViews.h> + +#import <WebCore/DOMEvent.h> +#import <WebCore/DOMEventException.h> +#import <WebCore/DOMEventListener.h> +#import <WebCore/DOMEventTarget.h> +#import <WebCore/DOMKeyboardEvent.h> +#import <WebCore/DOMMouseEvent.h> +#import <WebCore/DOMMutationEvent.h> +#import <WebCore/DOMOverflowEvent.h> +#import <WebCore/DOMUIEvent.h> +#import <WebCore/DOMWheelEvent.h> diff --git a/WebCore/bindings/objc/DOMEvents.mm b/WebCore/bindings/objc/DOMEvents.mm new file mode 100644 index 0000000..6f7f72d --- /dev/null +++ b/WebCore/bindings/objc/DOMEvents.mm @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2004, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 Jonas Witt <jonas.witt@gmail.com> + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 ec 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 "config.h" +#import "DOMEvents.h" + +#import "DOMInternal.h" +#import "DOMMessageEvent.h" +#import "DOMPrivate.h" +#import "DOMProgressEvent.h" +#import "Event.h" +#import "KeyboardEvent.h" +#import "MessageEvent.h" +#import "MouseEvent.h" +#import "MutationEvent.h" +#import "OverflowEvent.h" +#import "ProgressEvent.h" +#import "UIEvent.h" + +#if ENABLE(SVG) +#import "DOMSVGZoomEvent.h" +#import "SVGZoomEvent.h" +#endif + +//------------------------------------------------------------------------------------------ +// DOMEvent + +@implementation DOMEvent (WebCoreInternal) + +- (WebCore::Event *)_event +{ + return reinterpret_cast<WebCore::Event*>(_internal); +} + +- (id)_initWithEvent:(WebCore::Event *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal *>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMEvent *)_wrapEvent:(WebCore::Event *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass = nil; + if (impl->isUIEvent()) { + if (impl->isKeyboardEvent()) + wrapperClass = [DOMKeyboardEvent class]; + else if (impl->isTextEvent()) + wrapperClass = [DOMTextEvent class]; + else if (impl->isMouseEvent()) + wrapperClass = [DOMMouseEvent class]; + else if (impl->isWheelEvent()) + wrapperClass = [DOMWheelEvent class]; +#if ENABLE(SVG) + else if (impl->isSVGZoomEvent()) + wrapperClass = [DOMSVGZoomEvent class]; +#endif + else + wrapperClass = [DOMUIEvent class]; + } else if (impl->isMutationEvent()) + wrapperClass = [DOMMutationEvent class]; + else if (impl->isOverflowEvent()) + wrapperClass = [DOMOverflowEvent class]; + else if (impl->isMessageEvent()) + wrapperClass = [DOMMessageEvent class]; + else if (impl->isProgressEvent()) + wrapperClass = [DOMProgressEvent class]; + else + wrapperClass = [DOMEvent class]; + + return [[[wrapperClass alloc] _initWithEvent:impl] autorelease]; +} + +@end diff --git a/WebCore/bindings/objc/DOMException.h b/WebCore/bindings/objc/DOMException.h new file mode 100644 index 0000000..64d7194 --- /dev/null +++ b/WebCore/bindings/objc/DOMException.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +@class NSString; + +extern NSString * const DOMException; + +enum DOMExceptionCode { + DOM_INDEX_SIZE_ERR = 1, + DOM_DOMSTRING_SIZE_ERR = 2, + DOM_HIERARCHY_REQUEST_ERR = 3, + DOM_WRONG_DOCUMENT_ERR = 4, + DOM_INVALID_CHARACTER_ERR = 5, + DOM_NO_DATA_ALLOWED_ERR = 6, + DOM_NO_MODIFICATION_ALLOWED_ERR = 7, + DOM_NOT_FOUND_ERR = 8, + DOM_NOT_SUPPORTED_ERR = 9, + DOM_INUSE_ATTRIBUTE_ERR = 10, + DOM_INVALID_STATE_ERR = 11, + DOM_SYNTAX_ERR = 12, + DOM_INVALID_MODIFICATION_ERR = 13, + DOM_NAMESPACE_ERR = 14, + DOM_INVALID_ACCESS_ERR = 15 +}; + +#endif diff --git a/WebCore/bindings/objc/DOMExtensions.h b/WebCore/bindings/objc/DOMExtensions.h new file mode 100644 index 0000000..7748a22 --- /dev/null +++ b/WebCore/bindings/objc/DOMExtensions.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMAttr.h> +#import <WebCore/DOMCSS.h> +#import <WebCore/DOMCSSStyleDeclaration.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMElement.h> +#import <WebCore/DOMHTML.h> +#import <WebCore/DOMHTMLAnchorElement.h> +#import <WebCore/DOMHTMLAreaElement.h> +#import <WebCore/DOMHTMLDocument.h> +#import <WebCore/DOMHTMLElement.h> +#import <WebCore/DOMHTMLEmbedElement.h> +#import <WebCore/DOMHTMLImageElement.h> +#import <WebCore/DOMHTMLInputElement.h> +#import <WebCore/DOMHTMLLinkElement.h> +#import <WebCore/DOMHTMLObjectElement.h> +#import <WebCore/DOMNode.h> +#import <WebCore/DOMRGBColor.h> +#import <WebCore/DOMRange.h> + +@class NSArray; +@class NSImage; +@class NSURL; + +@interface DOMNode (DOMNodeExtensions) +- (NSRect)boundingBox WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); +- (NSArray *)lineBoxRects WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); +@end + +@interface DOMElement (DOMElementAppKitExtensions) +- (NSImage *)image WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); +@end + +@interface DOMHTMLDocument (DOMHTMLDocumentExtensions) +- (DOMDocumentFragment *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); +- (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); +@end diff --git a/WebCore/bindings/objc/DOMHTML.h b/WebCore/bindings/objc/DOMHTML.h new file mode 100644 index 0000000..cd80612 --- /dev/null +++ b/WebCore/bindings/objc/DOMHTML.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> + +#import <WebCore/DOMHTMLAnchorElement.h> +#import <WebCore/DOMHTMLAppletElement.h> +#import <WebCore/DOMHTMLAreaElement.h> +#import <WebCore/DOMHTMLBRElement.h> +#import <WebCore/DOMHTMLBaseElement.h> +#import <WebCore/DOMHTMLBaseFontElement.h> +#import <WebCore/DOMHTMLBodyElement.h> +#import <WebCore/DOMHTMLButtonElement.h> +#import <WebCore/DOMHTMLCollection.h> +#import <WebCore/DOMHTMLDListElement.h> +#import <WebCore/DOMHTMLDirectoryElement.h> +#import <WebCore/DOMHTMLDivElement.h> +#import <WebCore/DOMHTMLDocument.h> +#import <WebCore/DOMHTMLElement.h> +#import <WebCore/DOMHTMLEmbedElement.h> +#import <WebCore/DOMHTMLFieldSetElement.h> +#import <WebCore/DOMHTMLFontElement.h> +#import <WebCore/DOMHTMLFormElement.h> +#import <WebCore/DOMHTMLFrameElement.h> +#import <WebCore/DOMHTMLFrameSetElement.h> +#import <WebCore/DOMHTMLHRElement.h> +#import <WebCore/DOMHTMLHeadElement.h> +#import <WebCore/DOMHTMLHeadingElement.h> +#import <WebCore/DOMHTMLHtmlElement.h> +#import <WebCore/DOMHTMLIFrameElement.h> +#import <WebCore/DOMHTMLImageElement.h> +#import <WebCore/DOMHTMLInputElement.h> +#import <WebCore/DOMHTMLIsIndexElement.h> +#import <WebCore/DOMHTMLLIElement.h> +#import <WebCore/DOMHTMLLabelElement.h> +#import <WebCore/DOMHTMLLegendElement.h> +#import <WebCore/DOMHTMLLinkElement.h> +#import <WebCore/DOMHTMLMapElement.h> +#import <WebCore/DOMHTMLMarqueeElement.h> +#import <WebCore/DOMHTMLMenuElement.h> +#import <WebCore/DOMHTMLMetaElement.h> +#import <WebCore/DOMHTMLModElement.h> +#import <WebCore/DOMHTMLOListElement.h> +#import <WebCore/DOMHTMLObjectElement.h> +#import <WebCore/DOMHTMLOptGroupElement.h> +#import <WebCore/DOMHTMLOptionElement.h> +#import <WebCore/DOMHTMLOptionsCollection.h> +#import <WebCore/DOMHTMLParagraphElement.h> +#import <WebCore/DOMHTMLParamElement.h> +#import <WebCore/DOMHTMLPreElement.h> +#import <WebCore/DOMHTMLQuoteElement.h> +#import <WebCore/DOMHTMLScriptElement.h> +#import <WebCore/DOMHTMLSelectElement.h> +#import <WebCore/DOMHTMLStyleElement.h> +#import <WebCore/DOMHTMLTableCaptionElement.h> +#import <WebCore/DOMHTMLTableCellElement.h> +#import <WebCore/DOMHTMLTableColElement.h> +#import <WebCore/DOMHTMLTableElement.h> +#import <WebCore/DOMHTMLTableRowElement.h> +#import <WebCore/DOMHTMLTableSectionElement.h> +#import <WebCore/DOMHTMLTextAreaElement.h> +#import <WebCore/DOMHTMLTitleElement.h> +#import <WebCore/DOMHTMLUListElement.h> diff --git a/WebCore/bindings/objc/DOMHTML.mm b/WebCore/bindings/objc/DOMHTML.mm new file mode 100644 index 0000000..59f2d7f --- /dev/null +++ b/WebCore/bindings/objc/DOMHTML.mm @@ -0,0 +1,187 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 "config.h" +#import "DOMHTML.h" + +#import "CSSHelper.h" +#import "DOMExtensions.h" +#import "DOMInternal.h" +#import "DOMPrivate.h" +#import "DocumentFragment.h" +#import "FrameView.h" +#import "HTMLDocument.h" +#import "HTMLInputElement.h" +#import "HTMLObjectElement.h" +#import "Range.h" +#import "RenderTextControl.h" +#import "markup.h" + +//------------------------------------------------------------------------------------------ +// DOMHTMLDocument + +@implementation DOMHTMLDocument (DOMHTMLDocumentExtensions) + +- (DOMDocumentFragment *)createDocumentFragmentWithMarkupString:(NSString *)markupString baseURL:(NSURL *)baseURL +{ + return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromMarkup([self _document], markupString, [baseURL absoluteString]).get()]; +} + +- (DOMDocumentFragment *)createDocumentFragmentWithText:(NSString *)text +{ + // FIXME: Since this is not a contextual fragment, it won't handle whitespace properly. + return [DOMDocumentFragment _wrapDocumentFragment:createFragmentFromText([self _document]->createRange().get(), text).get()]; +} + +@end + +@implementation DOMHTMLDocument (WebPrivate) + +- (DOMDocumentFragment *)_createDocumentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString +{ + NSURL *baseURL = [self _document]->completeURL(WebCore::parseURL(baseURLString)); + return [self createDocumentFragmentWithMarkupString:markupString baseURL:baseURL]; +} + +- (DOMDocumentFragment *)_createDocumentFragmentWithText:(NSString *)text +{ + return [self createDocumentFragmentWithText:text]; +} + +@end + +#pragma mark DOM EXTENSIONS + +@implementation DOMHTMLInputElement(FormAutoFillTransition) + +- (BOOL)_isTextField +{ + // We could make this public API as-is, or we could change it into a method that returns whether + // the element is a text field or a button or ... ? + static NSArray *textInputTypes = nil; +#ifndef NDEBUG + static NSArray *nonTextInputTypes = nil; +#endif + + NSString *fieldType = [self type]; + + // No type at all is treated as text type + if ([fieldType length] == 0) + return YES; + + if (textInputTypes == nil) + textInputTypes = [[NSSet alloc] initWithObjects:@"text", @"password", @"search", @"isindex", nil]; + + BOOL isText = [textInputTypes containsObject:[fieldType lowercaseString]]; + +#ifndef NDEBUG + if (nonTextInputTypes == nil) + nonTextInputTypes = [[NSSet alloc] initWithObjects:@"checkbox", @"radio", @"submit", @"reset", @"file", @"hidden", @"image", @"button", @"range", nil]; + + // Catch cases where a new input type has been added that's not in these lists. + ASSERT(isText || [nonTextInputTypes containsObject:[fieldType lowercaseString]]); +#endif + + return isText; +} + +- (NSRect)_rectOnScreen +{ + // Returns bounding rect of text field, in screen coordinates. + NSRect result = [self boundingBox]; + if (![self _HTMLInputElement]->document()->view()) + return result; + + NSView* view = [self _HTMLInputElement]->document()->view()->documentView(); + result = [view convertRect:result toView:nil]; + result.origin = [[view window] convertBaseToScreen:result.origin]; + return result; +} + +- (void)_replaceCharactersInRange:(NSRange)targetRange withString:(NSString *)replacementString selectingFromIndex:(int)index +{ + WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement]; + if (inputElement) { + WebCore::String newValue = inputElement->value(); + newValue.replace(targetRange.location, targetRange.length, replacementString); + inputElement->setValue(newValue); + inputElement->setSelectionRange(index, newValue.length()); + } +} + +- (NSRange)_selectedRange +{ + WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement]; + if (inputElement) { + int start = inputElement->selectionStart(); + int end = inputElement->selectionEnd(); + return NSMakeRange(start, end - start); + } + return NSMakeRange(NSNotFound, 0); +} + +- (void)_setAutofilled:(BOOL)filled +{ + // This notifies the input element that the content has been autofilled + // This allows WebKit to obey the -webkit-autofill pseudo style, which + // changes the background color. + WebCore::HTMLInputElement* inputElement = [self _HTMLInputElement]; + if (inputElement) + inputElement->setAutofilled(filled); +} + +@end + +@implementation DOMHTMLSelectElement(FormAutoFillTransition) + +- (void)_activateItemAtIndex:(int)index +{ + // FIXME: Needs implementation for non-NSView <select>! +} + +@end + +@implementation DOMHTMLInputElement (FormPromptAdditions) +- (BOOL)_isEdited +{ + WebCore::RenderObject *renderer = [self _node]->renderer(); + if (renderer && [self _isTextField]) + return static_cast<WebCore::RenderTextControl *>(renderer)->isUserEdited(); + + return NO; +} +@end + +@implementation DOMHTMLTextAreaElement (FormPromptAdditions) +- (BOOL)_isEdited +{ + WebCore::RenderObject *renderer = [self _node]->renderer(); + if (renderer) + return static_cast<WebCore::RenderTextControl *>(renderer)->isUserEdited(); + + return NO; +} +@end diff --git a/WebCore/bindings/objc/DOMImplementationFront.cpp b/WebCore/bindings/objc/DOMImplementationFront.cpp new file mode 100644 index 0000000..93db83b --- /dev/null +++ b/WebCore/bindings/objc/DOMImplementationFront.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#include "config.h" +#include "DOMImplementationFront.h" + +#include "CSSStyleSheet.h" +#include "DocumentType.h" +#include "DOMImplementation.h" +#include "HTMLDocument.h" +#include "JSDOMImplementation.h" + +namespace WebCore { + +DOMImplementationFront* implementationFront(Document* document) +{ + return reinterpret_cast<DOMImplementationFront*>(document->implementation()); +} + +DOMImplementationFront* implementationFront(JSDOMImplementation* wrapper) +{ + return reinterpret_cast<DOMImplementationFront*>(wrapper->impl()); +} + +void DOMImplementationFront::ref() +{ + reinterpret_cast<DOMImplementation*>(this)->ref(); +} + +void DOMImplementationFront::deref() +{ + reinterpret_cast<DOMImplementation*>(this)->deref(); +} + +bool DOMImplementationFront::hasFeature(const String& feature, const String& version) const +{ + return reinterpret_cast<const DOMImplementation*>(this)->hasFeature(feature, version); +} + +PassRefPtr<DocumentType> DOMImplementationFront::createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId, ExceptionCode& ec) +{ + return reinterpret_cast<DOMImplementation*>(this)->createDocumentType(qualifiedName, publicId, systemId, ec); +} + +PassRefPtr<Document> DOMImplementationFront::createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType* type, ExceptionCode& ec) +{ + return reinterpret_cast<DOMImplementation*>(this)->createDocument(namespaceURI, qualifiedName, type, ec); +} + +DOMImplementationFront* DOMImplementationFront::getInterface(const String& feature) +{ + return reinterpret_cast<DOMImplementationFront*>(reinterpret_cast<DOMImplementation*>(this)->getInterface(feature)); +} + +PassRefPtr<CSSStyleSheet> DOMImplementationFront::createCSSStyleSheet(const String& title, const String& media, ExceptionCode& ec) +{ + return reinterpret_cast<DOMImplementation*>(this)->createCSSStyleSheet(title, media, ec); +} + +PassRefPtr<HTMLDocument> DOMImplementationFront::createHTMLDocument(const String& title) +{ + return reinterpret_cast<DOMImplementation*>(this)->createHTMLDocument(title); +} + +} //namespace diff --git a/WebCore/bindings/objc/DOMImplementationFront.h b/WebCore/bindings/objc/DOMImplementationFront.h new file mode 100644 index 0000000..877a3b6 --- /dev/null +++ b/WebCore/bindings/objc/DOMImplementationFront.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + */ + +#ifndef DOMImplementationFront_h +#define DOMImplementationFront_h + +// FIXME: This source file exists to work around a problem that occurs trying +// to mix DOMImplementation and WebCore::DOMImplementation in DOM.mm. +// It seems to affect only older versions of gcc. Once the buildbot is upgraded, +// we should consider increasing the minimum required version of gcc to build +// WebCore, and rolling the change that introduced this file back. + +#include <wtf/Forward.h> + +namespace WebCore { + +class CSSStyleSheet; +class Document; +class DocumentType; +class HTMLDocument; +class JSDOMImplementation; +class String; + +typedef int ExceptionCode; + +class DOMImplementationFront { +public: + void ref(); + void deref(); + bool hasFeature(const String& feature, const String& version) const; + PassRefPtr<DocumentType> createDocumentType(const String& qualifiedName, const String& publicId, const String& systemId, ExceptionCode&); + PassRefPtr<Document> createDocument(const String& namespaceURI, const String& qualifiedName, DocumentType*, ExceptionCode&); + DOMImplementationFront* getInterface(const String& feature); + PassRefPtr<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&); + PassRefPtr<HTMLDocument> createHTMLDocument(const String& title); +}; + +DOMImplementationFront* implementationFront(Document*); +DOMImplementationFront* implementationFront(JSDOMImplementation*); + +} // namespace WebCore + +#endif // DOMImplementationFront_h diff --git a/WebCore/bindings/objc/DOMInternal.h b/WebCore/bindings/objc/DOMInternal.h new file mode 100644 index 0000000..a1ca9fe --- /dev/null +++ b/WebCore/bindings/objc/DOMInternal.h @@ -0,0 +1,357 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple, Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "DOM.h" + +#import "DOMObject.h" +#import "HitTestResult.h" + +#if ENABLE(XPATH) +#import "DOMXPathExpressionInternal.h" +#import "DOMXPathNSResolver.h" +#import "DOMXPathResultInternal.h" +#endif // ENABLE(XPATH) + +// Auto-generated internal interfaces +#import "DOMAbstractViewInternal.h" +#import "DOMAttrInternal.h" +#import "DOMCDATASectionInternal.h" +#import "DOMCSSCharsetRuleInternal.h" +#import "DOMCSSFontFaceRuleInternal.h" +#import "DOMCSSImportRuleInternal.h" +#import "DOMCSSMediaRuleInternal.h" +#import "DOMCSSPageRuleInternal.h" +#import "DOMCSSPrimitiveValueInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSRuleListInternal.h" +#import "DOMCSSStyleDeclarationInternal.h" +#import "DOMCSSStyleRuleInternal.h" +#import "DOMCSSStyleSheetInternal.h" +#import "DOMCSSUnknownRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMCSSValueListInternal.h" +#import "DOMCSSVariablesRuleInternal.h" +#import "DOMCSSVariablesDeclarationInternal.h" +#import "DOMCharacterDataInternal.h" +#import "DOMCommentInternal.h" +#import "DOMCounterInternal.h" +#import "DOMDOMImplementationInternal.h" +#import "DOMDocumentFragmentInternal.h" +#import "DOMDocumentInternal.h" +#import "DOMDocumentTypeInternal.h" +#import "DOMElementInternal.h" +#import "DOMEntityInternal.h" +#import "DOMEntityReferenceInternal.h" +#import "DOMEventInternal.h" +#import "DOMFileInternal.h" +#import "DOMFileListInternal.h" +#import "DOMHTMLAnchorElementInternal.h" +#import "DOMHTMLAppletElementInternal.h" +#import "DOMHTMLAreaElementInternal.h" +#import "DOMHTMLBRElementInternal.h" +#import "DOMHTMLBaseElementInternal.h" +#import "DOMHTMLBaseFontElementInternal.h" +#import "DOMHTMLBodyElementInternal.h" +#import "DOMHTMLButtonElementInternal.h" +#import "DOMHTMLCollectionInternal.h" +#import "DOMHTMLDListElementInternal.h" +#import "DOMHTMLDirectoryElementInternal.h" +#import "DOMHTMLDivElementInternal.h" +#import "DOMHTMLDocumentInternal.h" +#import "DOMHTMLElementInternal.h" +#import "DOMHTMLEmbedElementInternal.h" +#import "DOMHTMLFieldSetElementInternal.h" +#import "DOMHTMLFontElementInternal.h" +#import "DOMHTMLFormElementInternal.h" +#import "DOMHTMLFrameElementInternal.h" +#import "DOMHTMLFrameSetElementInternal.h" +#import "DOMHTMLHRElementInternal.h" +#import "DOMHTMLHeadElementInternal.h" +#import "DOMHTMLHeadingElementInternal.h" +#import "DOMHTMLHtmlElementInternal.h" +#import "DOMHTMLIFrameElementInternal.h" +#import "DOMHTMLImageElementInternal.h" +#import "DOMHTMLInputElementInternal.h" +#import "DOMHTMLIsIndexElementInternal.h" +#import "DOMHTMLLIElementInternal.h" +#import "DOMHTMLLabelElementInternal.h" +#import "DOMHTMLLegendElementInternal.h" +#import "DOMHTMLLinkElementInternal.h" +#import "DOMHTMLMapElementInternal.h" +#import "DOMHTMLMarqueeElementInternal.h" +#import "DOMHTMLMenuElementInternal.h" +#import "DOMHTMLMetaElementInternal.h" +#import "DOMHTMLModElementInternal.h" +#import "DOMHTMLOListElementInternal.h" +#import "DOMHTMLObjectElementInternal.h" +#import "DOMHTMLOptGroupElementInternal.h" +#import "DOMHTMLOptionElementInternal.h" +#import "DOMHTMLOptionsCollectionInternal.h" +#import "DOMHTMLParagraphElementInternal.h" +#import "DOMHTMLParamElementInternal.h" +#import "DOMHTMLPreElementInternal.h" +#import "DOMHTMLQuoteElementInternal.h" +#import "DOMHTMLScriptElementInternal.h" +#import "DOMHTMLSelectElementInternal.h" +#import "DOMHTMLStyleElementInternal.h" +#import "DOMHTMLTableCaptionElementInternal.h" +#import "DOMHTMLTableCellElementInternal.h" +#import "DOMHTMLTableColElementInternal.h" +#import "DOMHTMLTableElementInternal.h" +#import "DOMHTMLTableRowElementInternal.h" +#import "DOMHTMLTableSectionElementInternal.h" +#import "DOMHTMLTextAreaElementInternal.h" +#import "DOMHTMLTitleElementInternal.h" +#import "DOMHTMLUListElementInternal.h" +#import "DOMKeyboardEventInternal.h" +#import "DOMMediaListInternal.h" +#import "DOMMessagePortInternal.h" +#import "DOMMouseEventInternal.h" +#import "DOMMutationEventInternal.h" +#import "DOMNamedNodeMapInternal.h" +#import "DOMNodeInternal.h" +#import "DOMNodeIteratorInternal.h" +#import "DOMNodeListInternal.h" +#import "DOMNotationInternal.h" +#import "DOMOverflowEventInternal.h" +#import "DOMProcessingInstructionInternal.h" +#import "DOMRGBColorInternal.h" +#import "DOMRangeInternal.h" +#import "DOMRectInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMStyleSheetListInternal.h" +#import "DOMTextEventInternal.h" +#import "DOMTextInternal.h" +#import "DOMTreeWalkerInternal.h" +#import "DOMUIEventInternal.h" +#import "DOMWebKitCSSKeyframeRuleInternal.h" +#import "DOMWebKitCSSKeyframesRuleInternal.h" +#import "DOMWebKitCSSTransformValueInternal.h" +#import "DOMWheelEventInternal.h" + +#if ENABLE(SVG) +#import "DOMSVGAElementInternal.h" +#import "DOMSVGAltGlyphElementInternal.h" +#import "DOMSVGAngleInternal.h" +#import "DOMSVGAnimateColorElementInternal.h" +#import "DOMSVGAnimateElementInternal.h" +#import "DOMSVGAnimateTransformElementInternal.h" +#import "DOMSVGAnimatedAngleInternal.h" +#import "DOMSVGAnimatedBooleanInternal.h" +#import "DOMSVGAnimatedEnumerationInternal.h" +#import "DOMSVGAnimatedIntegerInternal.h" +#import "DOMSVGAnimatedLengthInternal.h" +#import "DOMSVGAnimatedLengthListInternal.h" +#import "DOMSVGAnimatedNumberInternal.h" +#import "DOMSVGAnimatedNumberListInternal.h" +#import "DOMSVGAnimatedPreserveAspectRatioInternal.h" +#import "DOMSVGAnimatedRectInternal.h" +#import "DOMSVGAnimatedStringInternal.h" +#import "DOMSVGAnimatedTransformListInternal.h" +#import "DOMSVGAnimationElementInternal.h" +#import "DOMSVGCircleElementInternal.h" +#import "DOMSVGClipPathElementInternal.h" +#import "DOMSVGColorInternal.h" +#import "DOMSVGComponentTransferFunctionElementInternal.h" +#import "DOMSVGCursorElementInternal.h" +#import "DOMSVGDefsElementInternal.h" +#import "DOMSVGDefinitionSrcElementInternal.h" +#import "DOMSVGDescElementInternal.h" +#import "DOMSVGDocumentInternal.h" +#import "DOMSVGElementInternal.h" +#import "DOMSVGElementInstanceInternal.h" +#import "DOMSVGElementInstanceListInternal.h" +#import "DOMSVGEllipseElementInternal.h" +#import "DOMSVGFEBlendElementInternal.h" +#import "DOMSVGFEColorMatrixElementInternal.h" +#import "DOMSVGFEComponentTransferElementInternal.h" +#import "DOMSVGFECompositeElementInternal.h" +#import "DOMSVGFEDiffuseLightingElementInternal.h" +#import "DOMSVGFEDisplacementMapElementInternal.h" +#import "DOMSVGFEDistantLightElementInternal.h" +#import "DOMSVGFEFloodElementInternal.h" +#import "DOMSVGFEFuncAElementInternal.h" +#import "DOMSVGFEFuncBElementInternal.h" +#import "DOMSVGFEFuncGElementInternal.h" +#import "DOMSVGFEFuncRElementInternal.h" +#import "DOMSVGFEGaussianBlurElementInternal.h" +#import "DOMSVGFEImageElementInternal.h" +#import "DOMSVGFEMergeElementInternal.h" +#import "DOMSVGFEMergeNodeElementInternal.h" +#import "DOMSVGFEOffsetElementInternal.h" +#import "DOMSVGFEPointLightElementInternal.h" +#import "DOMSVGFESpecularLightingElementInternal.h" +#import "DOMSVGFESpotLightElementInternal.h" +#import "DOMSVGFETileElementInternal.h" +#import "DOMSVGFETurbulenceElementInternal.h" +#import "DOMSVGFilterElementInternal.h" +#import "DOMSVGFontElementInternal.h" +#import "DOMSVGFontFaceElementInternal.h" +#import "DOMSVGFontFaceFormatElementInternal.h" +#import "DOMSVGFontFaceNameElementInternal.h" +#import "DOMSVGFontFaceSrcElementInternal.h" +#import "DOMSVGFontFaceUriElementInternal.h" +#import "DOMSVGForeignObjectElementInternal.h" +#import "DOMSVGGElementInternal.h" +#import "DOMSVGGlyphElementInternal.h" +#import "DOMSVGGradientElementInternal.h" +#import "DOMSVGImageElementInternal.h" +#import "DOMSVGLengthInternal.h" +#import "DOMSVGLengthListInternal.h" +#import "DOMSVGLineElementInternal.h" +#import "DOMSVGLinearGradientElementInternal.h" +#import "DOMSVGMarkerElementInternal.h" +#import "DOMSVGMaskElementInternal.h" +#import "DOMSVGMatrixInternal.h" +#import "DOMSVGMetadataElementInternal.h" +#import "DOMSVGMissingGlyphElementInternal.h" +#import "DOMSVGNumberInternal.h" +#import "DOMSVGNumberListInternal.h" +#import "DOMSVGPaintInternal.h" +#import "DOMSVGPathElementInternal.h" +#import "DOMSVGPathSegArcAbsInternal.h" +#import "DOMSVGPathSegArcRelInternal.h" +#import "DOMSVGPathSegClosePathInternal.h" +#import "DOMSVGPathSegCurvetoCubicAbsInternal.h" +#import "DOMSVGPathSegCurvetoCubicRelInternal.h" +#import "DOMSVGPathSegCurvetoCubicSmoothAbsInternal.h" +#import "DOMSVGPathSegCurvetoCubicSmoothRelInternal.h" +#import "DOMSVGPathSegCurvetoQuadraticAbsInternal.h" +#import "DOMSVGPathSegCurvetoQuadraticRelInternal.h" +#import "DOMSVGPathSegCurvetoQuadraticSmoothAbsInternal.h" +#import "DOMSVGPathSegCurvetoQuadraticSmoothRelInternal.h" +#import "DOMSVGPathSegInternal.h" +#import "DOMSVGPathSegLinetoAbsInternal.h" +#import "DOMSVGPathSegLinetoHorizontalAbsInternal.h" +#import "DOMSVGPathSegLinetoHorizontalRelInternal.h" +#import "DOMSVGPathSegLinetoRelInternal.h" +#import "DOMSVGPathSegLinetoVerticalAbsInternal.h" +#import "DOMSVGPathSegLinetoVerticalRelInternal.h" +#import "DOMSVGPathSegListInternal.h" +#import "DOMSVGPathSegMovetoAbsInternal.h" +#import "DOMSVGPathSegMovetoRelInternal.h" +#import "DOMSVGPatternElementInternal.h" +#import "DOMSVGPointInternal.h" +#import "DOMSVGPointListInternal.h" +#import "DOMSVGPolygonElementInternal.h" +#import "DOMSVGPolylineElementInternal.h" +#import "DOMSVGPreserveAspectRatioInternal.h" +#import "DOMSVGRadialGradientElementInternal.h" +#import "DOMSVGRectElementInternal.h" +#import "DOMSVGRectInternal.h" +#import "DOMSVGRenderingIntentInternal.h" +#import "DOMSVGSVGElementInternal.h" +#import "DOMSVGScriptElementInternal.h" +#import "DOMSVGSetElementInternal.h" +#import "DOMSVGStopElementInternal.h" +#import "DOMSVGStringListInternal.h" +#import "DOMSVGStyleElementInternal.h" +#import "DOMSVGSwitchElementInternal.h" +#import "DOMSVGSymbolElementInternal.h" +#import "DOMSVGTRefElementInternal.h" +#import "DOMSVGTSpanElementInternal.h" +#import "DOMSVGTextContentElementInternal.h" +#import "DOMSVGTextElementInternal.h" +#import "DOMSVGTextPathElementInternal.h" +#import "DOMSVGTextPositioningElementInternal.h" +#import "DOMSVGTitleElementInternal.h" +#import "DOMSVGTransformInternal.h" +#import "DOMSVGTransformListInternal.h" +#import "DOMSVGUnitTypesInternal.h" +#import "DOMSVGUseElementInternal.h" +#import "DOMSVGViewElementInternal.h" +#import "DOMSVGZoomEventInternal.h" +#endif // ENABLE(SVG) + +namespace JSC { + class JSObject; + + namespace Bindings { + class RootObject; + } +} + +namespace WebCore { + class NodeFilter; + +#if ENABLE(SVG) + class AffineTransform; + class FloatPoint; + class FloatRect; +#endif // ENABLE(SVG) + +#if ENABLE(XPATH) + class XPathNSResolver; +#endif // ENABLE(XPATH) +} + +// Core Internal Interfaces + +@interface DOMObject (WebCoreInternal) +- (id)_init; +@end + +// Traversal Internal Interfaces + +@interface DOMNodeFilter : DOMObject <DOMNodeFilter> ++ (DOMNodeFilter *)_wrapNodeFilter:(WebCore::NodeFilter *)impl; +@end + +#if ENABLE(XPATH) + +// XPath Internal Interfaces + +@interface DOMNativeXPathNSResolver : DOMObject <DOMXPathNSResolver> ++ (DOMNativeXPathNSResolver *)_wrapXPathNSResolver:(WebCore::XPathNSResolver *)impl; +- (WebCore::XPathNSResolver *)_xpathNSResolver; +@end + +#endif // ENABLE(XPATH) + +// Helper functions for DOM wrappers and gluing to Objective-C + +namespace WebCore { + + id createDOMWrapper(JSC::JSObject*, PassRefPtr<JSC::Bindings::RootObject> origin, PassRefPtr<JSC::Bindings::RootObject> current); + + NSObject* getDOMWrapper(DOMObjectInternal*); + void addDOMWrapper(NSObject* wrapper, DOMObjectInternal*); + void removeDOMWrapper(DOMObjectInternal*); + + template <class Source> + inline id getDOMWrapper(Source impl) + { + return getDOMWrapper(reinterpret_cast<DOMObjectInternal*>(impl)); + } + + template <class Source> + inline void addDOMWrapper(NSObject* wrapper, Source impl) + { + addDOMWrapper(wrapper, reinterpret_cast<DOMObjectInternal*>(impl)); + } + +} // namespace WebCore diff --git a/WebCore/bindings/objc/DOMInternal.mm b/WebCore/bindings/objc/DOMInternal.mm new file mode 100644 index 0000000..f0b6305 --- /dev/null +++ b/WebCore/bindings/objc/DOMInternal.mm @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2004, 2006, 2007 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 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 "config.h" +#import "DOMInternal.h" + +#import "Document.h" +#import "Event.h" +#import "Frame.h" +#import "JSNode.h" +#import "Node.h" +#import "PlatformString.h" +#import "Range.h" +#import "RangeException.h" +#import "SVGException.h" +#import "WebScriptObjectPrivate.h" +#import "XPathEvaluator.h" +#import "ScriptController.h" +#import "runtime_root.h" + +//------------------------------------------------------------------------------------------ +// Wrapping WebCore implementation objects + +namespace WebCore { + +typedef HashMap<DOMObjectInternal*, NSObject*> DOMWrapperMap; +static DOMWrapperMap* DOMWrapperCache; + +NSObject* getDOMWrapper(DOMObjectInternal* impl) +{ + if (!DOMWrapperCache) + return nil; + return DOMWrapperCache->get(impl); +} + +void addDOMWrapper(NSObject* wrapper, DOMObjectInternal* impl) +{ + if (!DOMWrapperCache) + DOMWrapperCache = new DOMWrapperMap; + DOMWrapperCache->set(impl, wrapper); +} + +void removeDOMWrapper(DOMObjectInternal* impl) +{ + if (!DOMWrapperCache) + return; + DOMWrapperCache->remove(impl); +} + +} // namespace WebCore + + +//------------------------------------------------------------------------------------------ + +@implementation WebScriptObject (WebScriptObjectInternal) + +// Only called by DOMObject subclass. +- (id)_init +{ + self = [super init]; + + if (![self isKindOfClass:[DOMObject class]]) { + [NSException raise:NSGenericException format:@"+%@: _init is an internal initializer", [self class]]; + return nil; + } + + _private = [[WebScriptObjectPrivate alloc] init]; + _private->isCreatedByDOMWrapper = YES; + + return self; +} + +- (void)_initializeScriptDOMNodeImp +{ + assert (_private->isCreatedByDOMWrapper); + + if (![self isKindOfClass:[DOMNode class]]) { + // DOMObject can't map back to a document, and thus an interpreter, + // so for now only create wrappers for DOMNodes. + NSLog(@"%s:%d: We don't know how to create ObjC JS wrappers from DOMObjects yet.", __FILE__, __LINE__); + return; + } + + // Extract the WebCore::Node from the ObjectiveC wrapper. + DOMNode *n = (DOMNode *)self; + WebCore::Node *nodeImpl = [n _node]; + + // Dig up Interpreter and ExecState. + WebCore::Frame *frame = 0; + if (WebCore::Document* document = nodeImpl->document()) + frame = document->frame(); + if (!frame) + return; + + JSC::ExecState *exec = frame->script()->globalObject()->globalExec(); + + // Get (or create) a cached JS object for the DOM node. + JSC::JSObject *scriptImp = asObject(WebCore::toJS(exec, nodeImpl)); + + JSC::Bindings::RootObject* rootObject = frame->script()->bindingRootObject(); + + [self _setImp:scriptImp originRootObject:rootObject rootObject:rootObject]; +} + +@end diff --git a/WebCore/bindings/objc/DOMObject.h b/WebCore/bindings/objc/DOMObject.h new file mode 100644 index 0000000..166637d --- /dev/null +++ b/WebCore/bindings/objc/DOMObject.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMException.h> +#import <WebCore/WebScriptObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +@class DOMStyleSheet; + +typedef unsigned long long DOMTimeStamp; + +typedef struct DOMObjectInternal DOMObjectInternal; + +@interface DOMObject : WebScriptObject <NSCopying> +{ + DOMObjectInternal *_internal; +} +@end + +@interface DOMObject (DOMLinkStyle) +#ifndef BUILDING_ON_TIGER +@property(readonly, retain) DOMStyleSheet *sheet; +#else +- (DOMStyleSheet *)sheet; +#endif +@end + +#endif diff --git a/WebCore/bindings/objc/DOMObject.mm b/WebCore/bindings/objc/DOMObject.mm new file mode 100644 index 0000000..f820df9 --- /dev/null +++ b/WebCore/bindings/objc/DOMObject.mm @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth <speth@end.com> + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 "config.h" +#import "DOMObject.h" + +#import "DOMHTMLLinkElement.h" +#import "DOMHTMLStyleElement.h" +#import "DOMInternal.h" +#import "DOMProcessingInstruction.h" +#import "DOMStyleSheet.h" +#import "HTMLLinkElement.h" +#import "HTMLStyleElement.h" +#import "ProcessingInstruction.h" +#import "StyleSheet.h" +#import "WebScriptObjectPrivate.h" + +@implementation DOMObject + +// Prevent creation of DOM objects by clients who just "[[xxx alloc] init]". +- (id)init +{ + [NSException raise:NSGenericException format:@"+[%@ init]: should never be used", NSStringFromClass([self class])]; + [self release]; + return nil; +} + +- (void)dealloc +{ + if (_internal) + WebCore::removeDOMWrapper(_internal); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + WebCore::removeDOMWrapper(_internal); + [super finalize]; +} + +- (id)copyWithZone:(NSZone *)zone +{ + return [self retain]; +} + +@end + +@implementation DOMObject (DOMLinkStyle) + +- (DOMStyleSheet *)sheet +{ + WebCore::StyleSheet *styleSheet; + + if ([self isKindOfClass:[DOMProcessingInstruction class]]) + styleSheet = static_cast<WebCore::ProcessingInstruction*>([(DOMProcessingInstruction *)self _node])->sheet(); + else if ([self isKindOfClass:[DOMHTMLLinkElement class]]) + styleSheet = static_cast<WebCore::HTMLLinkElement*>([(DOMHTMLLinkElement *)self _node])->sheet(); + else if ([self isKindOfClass:[DOMHTMLStyleElement class]]) + styleSheet = static_cast<WebCore::HTMLStyleElement*>([(DOMHTMLStyleElement *)self _node])->sheet(); + else + return nil; + + return [DOMStyleSheet _wrapStyleSheet:styleSheet]; +} + +@end + +@implementation DOMObject (WebCoreInternal) + +- (id)_init +{ + return [super _init]; +} + +@end diff --git a/WebCore/bindings/objc/DOMPrivate.h b/WebCore/bindings/objc/DOMPrivate.h new file mode 100644 index 0000000..0ee5979 --- /dev/null +++ b/WebCore/bindings/objc/DOMPrivate.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2004-2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCSS.h> +#import <WebCore/DOMCSSStyleDeclaration.h> +#import <WebCore/DOMElement.h> +#import <WebCore/DOMEvents.h> +#import <WebCore/DOMHTML.h> +#import <WebCore/DOMHTMLDocument.h> +#import <WebCore/DOMHTMLInputElement.h> +#import <WebCore/DOMHTMLSelectElement.h> +#import <WebCore/DOMNode.h> +#import <WebCore/DOMRGBColor.h> +#import <WebCore/DOMRange.h> + +#import <WebCore/DOMDocumentPrivate.h> +#import <WebCore/DOMElementPrivate.h> +#import <WebCore/DOMHTMLAnchorElementPrivate.h> +#import <WebCore/DOMHTMLAreaElementPrivate.h> +#import <WebCore/DOMHTMLBodyElementPrivate.h> +#import <WebCore/DOMHTMLButtonElementPrivate.h> +#import <WebCore/DOMHTMLDocumentPrivate.h> +#import <WebCore/DOMHTMLFormElementPrivate.h> +#import <WebCore/DOMHTMLFrameElementPrivate.h> +#import <WebCore/DOMHTMLImageElementPrivate.h> +#import <WebCore/DOMHTMLInputElementPrivate.h> +#import <WebCore/DOMHTMLLinkElementPrivate.h> +#import <WebCore/DOMHTMLOptionsCollectionPrivate.h> +#import <WebCore/DOMHTMLPreElementPrivate.h> +#import <WebCore/DOMHTMLStyleElementPrivate.h> +#import <WebCore/DOMHTMLTextAreaElementPrivate.h> +#import <WebCore/DOMKeyboardEventPrivate.h> +#import <WebCore/DOMMouseEventPrivate.h> +#import <WebCore/DOMNodeIteratorPrivate.h> +#import <WebCore/DOMNodePrivate.h> +#import <WebCore/DOMProcessingInstructionPrivate.h> +#import <WebCore/DOMRangePrivate.h> +#import <WebCore/DOMUIEventPrivate.h> +#import <WebCore/DOMWheelEventPrivate.h> + +@interface DOMNode (DOMNodeExtensionsPendingPublic) +- (NSImage *)renderedImage; +@end + +// FIXME: this should be removed as soon as all internal Apple uses of it have been replaced with +// calls to the public method - (NSColor *)color. +@interface DOMRGBColor (WebPrivate) +- (NSColor *)_color; +@end + +// FIXME: this should be removed as soon as all internal Apple uses of it have been replaced with +// calls to the public method - (NSString *)text. +@interface DOMRange (WebPrivate) +- (NSString *)_text; +@end + +@interface DOMRange (DOMRangeExtensions) +- (NSRect)boundingBox; +- (NSArray *)lineBoxRects; +@end + +@interface DOMElement (WebPrivate) +- (NSFont *)_font; +- (NSData *)_imageTIFFRepresentation; +- (NSURL *)_getURLAttribute:(NSString *)name; +- (void *)_NPObject; // For subclasses to implement; we only allow NPObjects to be created for certain element types +- (NSRect)_windowClipRect; // Clip rect in NSWindow coords (used by plugins) +- (BOOL)isFocused; +@end + +@interface DOMCSSStyleDeclaration (WebPrivate) +- (NSString *)_fontSizeDelta; +- (void)_setFontSizeDelta:(NSString *)fontSizeDelta; +@end + +@interface DOMHTMLDocument (WebPrivate) +- (DOMDocumentFragment *)_createDocumentFragmentWithMarkupString:(NSString *)markupString baseURLString:(NSString *)baseURLString; +- (DOMDocumentFragment *)_createDocumentFragmentWithText:(NSString *)text; +@end + +// All the methods in this category are used by Safari forms autofill and should not be used for any other purpose. +// They are stopgap measures until we finish transitioning form controls to not use NSView. Each one should become +// replaceable by public DOM API, and when that happens Safari will switch to implementations using that public API, +// and these will be deleted. +@interface DOMHTMLInputElement (FormsAutoFillTransition) +- (BOOL)_isTextField; +- (NSRect)_rectOnScreen; // bounding box of the text field, in screen coordinates +- (void)_replaceCharactersInRange:(NSRange)targetRange withString:(NSString *)replacementString selectingFromIndex:(int)index; +- (NSRange)_selectedRange; +- (void)_setAutofilled:(BOOL)filled; +@end + +// These changes are necessary to detect whether a form input was modified by a user +// or javascript +@interface DOMHTMLInputElement (FormPromptAdditions) +- (BOOL)_isEdited; +@end + +@interface DOMHTMLTextAreaElement (FormPromptAdditions) +- (BOOL)_isEdited; +@end + +// All the methods in this category are used by Safari forms autofill and should not be used for any other purpose. +// They are stopgap measures until we finish transitioning form controls to not use NSView. Each one should become +// replaceable by public DOM API, and when that happens Safari will switch to implementations using that public API, +// and these will be deleted. +@interface DOMHTMLSelectElement (FormsAutoFillTransition) +- (void)_activateItemAtIndex:(int)index; +@end diff --git a/WebCore/bindings/objc/DOMRGBColor.mm b/WebCore/bindings/objc/DOMRGBColor.mm new file mode 100644 index 0000000..eca2c25 --- /dev/null +++ b/WebCore/bindings/objc/DOMRGBColor.mm @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "config.h" +#import "DOMRGBColor.h" + +#import "CSSPrimitiveValue.h" +#import "Color.h" +#import "ColorMac.h" +#import "DOMCSSPrimitiveValue.h" +#import "DOMInternal.h" +#import "WebCoreObjCExtras.h" +#import <wtf/GetPtr.h> + +namespace WebCore { + +static CFMutableDictionaryRef wrapperCache = NULL; + +id getWrapperForRGB(WebCore::RGBA32 value) +{ + if (!wrapperCache) + return nil; + return (id)CFDictionaryGetValue(wrapperCache, reinterpret_cast<const void*>(value)); +} + +void setWrapperForRGB(id wrapper, WebCore::RGBA32 value) +{ + if (!wrapperCache) + // No need to retain/free either impl key, or id value. Items will be removed + // from the cache in dealloc methods. + wrapperCache = CFDictionaryCreateMutable(NULL, 0, NULL, NULL); + CFDictionarySetValue(wrapperCache, reinterpret_cast<const void*>(value), wrapper); +} + +void removeWrapperForRGB(WebCore::RGBA32 value) +{ + if (!wrapperCache) + return; + CFDictionaryRemoveValue(wrapperCache, reinterpret_cast<const void*>(value)); +} + +} // namespace WebCore + + +@implementation DOMRGBColor + +#ifndef BUILDING_ON_TIGER ++ (void)initialize +{ + WebCoreObjCFinalizeOnMainThread(self); +} +#endif + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMRGBColor class], self)) + return; + + WebCore::removeWrapperForRGB(reinterpret_cast<uintptr_t>(_internal)); + _internal = 0; + [super dealloc]; +} + +- (void)finalize +{ + WebCore::removeWrapperForRGB(reinterpret_cast<uintptr_t>(_internal)); + [super finalize]; +} + +- (DOMCSSPrimitiveValue *)red +{ + WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal); + int value = (rgb >> 16) & 0xFF; + return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()]; +} + +- (DOMCSSPrimitiveValue *)green +{ + WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal); + int value = (rgb >> 8) & 0xFF; + return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()]; +} + +- (DOMCSSPrimitiveValue *)blue +{ + WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal); + int value = rgb & 0xFF; + return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()]; +} + +- (DOMCSSPrimitiveValue *)alpha +{ + WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal); + float value = static_cast<float>(WebCore::Color(rgb).alpha()) / 0xFF; + return [DOMCSSPrimitiveValue _wrapCSSPrimitiveValue:WebCore::CSSPrimitiveValue::create(value, WebCore::CSSPrimitiveValue::CSS_NUMBER).get()]; + +} + +- (NSColor *)color +{ + WebCore::RGBA32 rgb = reinterpret_cast<uintptr_t>(_internal); + return WebCore::nsColor(WebCore::Color(rgb)); +} + +@end + +@implementation DOMRGBColor (WebPrivate) + +// FIXME: this should be removed as soon as all internal Apple uses of it have been replaced with +// calls to the public method - (NSColor *)color. +- (NSColor *)_color +{ + return [self color]; +} + +@end + +@implementation DOMRGBColor (WebCoreInternal) + +- (WebCore::RGBA32)_RGBColor +{ + return static_cast<WebCore::RGBA32>(reinterpret_cast<uintptr_t>(_internal)); +} + +- (id)_initWithRGB:(WebCore::RGBA32)value +{ + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(value); + WebCore::setWrapperForRGB(self, value); + return self; +} + ++ (DOMRGBColor *)_wrapRGBColor:(WebCore::RGBA32)value +{ + id cachedInstance; + cachedInstance = WebCore::getWrapperForRGB(value); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + return [[[self alloc] _initWithRGB:value] autorelease]; +} + +@end diff --git a/WebCore/bindings/objc/DOMRangeException.h b/WebCore/bindings/objc/DOMRangeException.h new file mode 100644 index 0000000..874a540 --- /dev/null +++ b/WebCore/bindings/objc/DOMRangeException.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +@class NSString; + +extern NSString * const DOMRangeException; + +enum DOMRangeExceptionCode { + DOM_BAD_BOUNDARYPOINTS_ERR = 1, + DOM_INVALID_NODE_TYPE_ERR = 2 +}; + +#endif diff --git a/WebCore/bindings/objc/DOMRanges.h b/WebCore/bindings/objc/DOMRanges.h new file mode 100644 index 0000000..c7e9ffc --- /dev/null +++ b/WebCore/bindings/objc/DOMRanges.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMRange.h> +#import <WebCore/DOMRangeException.h> diff --git a/WebCore/bindings/objc/DOMSVG.h b/WebCore/bindings/objc/DOMSVG.h new file mode 100644 index 0000000..f1321d8 --- /dev/null +++ b/WebCore/bindings/objc/DOMSVG.h @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMSVGAElement.h> +#import <WebCore/DOMSVGAltGlyphElement.h> +#import <WebCore/DOMSVGAngle.h> +#import <WebCore/DOMSVGAnimateColorElement.h> +#import <WebCore/DOMSVGAnimateElement.h> +#import <WebCore/DOMSVGAnimateTransformElement.h> +#import <WebCore/DOMSVGAnimatedAngle.h> +#import <WebCore/DOMSVGAnimatedBoolean.h> +#import <WebCore/DOMSVGAnimatedEnumeration.h> +#import <WebCore/DOMSVGAnimatedInteger.h> +#import <WebCore/DOMSVGAnimatedLength.h> +#import <WebCore/DOMSVGAnimatedLengthList.h> +#import <WebCore/DOMSVGAnimatedNumber.h> +#import <WebCore/DOMSVGAnimatedNumberList.h> +#import <WebCore/DOMSVGAnimatedPathData.h> +#import <WebCore/DOMSVGAnimatedPoints.h> +#import <WebCore/DOMSVGAnimatedPreserveAspectRatio.h> +#import <WebCore/DOMSVGAnimatedRect.h> +#import <WebCore/DOMSVGAnimatedString.h> +#import <WebCore/DOMSVGAnimatedTransformList.h> +#import <WebCore/DOMSVGAnimationElement.h> +#import <WebCore/DOMSVGCircleElement.h> +#import <WebCore/DOMSVGClipPathElement.h> +#import <WebCore/DOMSVGColor.h> +#import <WebCore/DOMSVGComponentTransferFunctionElement.h> +#import <WebCore/DOMSVGCursorElement.h> +#import <WebCore/DOMSVGDefinitionSrcElement.h> +#import <WebCore/DOMSVGDefsElement.h> +#import <WebCore/DOMSVGDescElement.h> +#import <WebCore/DOMSVGDocument.h> +#import <WebCore/DOMSVGElement.h> +#import <WebCore/DOMSVGElementInstance.h> +#import <WebCore/DOMSVGElementInstanceList.h> +#import <WebCore/DOMSVGEllipseElement.h> +#import <WebCore/DOMSVGException.h> +#import <WebCore/DOMSVGExternalResourcesRequired.h> +#import <WebCore/DOMSVGFEBlendElement.h> +#import <WebCore/DOMSVGFEColorMatrixElement.h> +#import <WebCore/DOMSVGFEComponentTransferElement.h> +#import <WebCore/DOMSVGFECompositeElement.h> +#import <WebCore/DOMSVGFEDiffuseLightingElement.h> +#import <WebCore/DOMSVGFEDisplacementMapElement.h> +#import <WebCore/DOMSVGFEDistantLightElement.h> +#import <WebCore/DOMSVGFEFloodElement.h> +#import <WebCore/DOMSVGFEFuncAElement.h> +#import <WebCore/DOMSVGFEFuncBElement.h> +#import <WebCore/DOMSVGFEFuncGElement.h> +#import <WebCore/DOMSVGFEFuncRElement.h> +#import <WebCore/DOMSVGFEGaussianBlurElement.h> +#import <WebCore/DOMSVGFEImageElement.h> +#import <WebCore/DOMSVGFEMergeElement.h> +#import <WebCore/DOMSVGFEMergeNodeElement.h> +#import <WebCore/DOMSVGFEOffsetElement.h> +#import <WebCore/DOMSVGFEPointLightElement.h> +#import <WebCore/DOMSVGFESpecularLightingElement.h> +#import <WebCore/DOMSVGFESpotLightElement.h> +#import <WebCore/DOMSVGFETileElement.h> +#import <WebCore/DOMSVGFETurbulenceElement.h> +#import <WebCore/DOMSVGFilterElement.h> +#import <WebCore/DOMSVGFilterPrimitiveStandardAttributes.h> +#import <WebCore/DOMSVGFitToViewBox.h> +#import <WebCore/DOMSVGFontElement.h> +#import <WebCore/DOMSVGFontFaceElement.h> +#import <WebCore/DOMSVGFontFaceFormatElement.h> +#import <WebCore/DOMSVGFontFaceNameElement.h> +#import <WebCore/DOMSVGFontFaceSrcElement.h> +#import <WebCore/DOMSVGFontFaceUriElement.h> +#import <WebCore/DOMSVGForeignObjectElement.h> +#import <WebCore/DOMSVGGElement.h> +#import <WebCore/DOMSVGGlyphElement.h> +#import <WebCore/DOMSVGGradientElement.h> +#import <WebCore/DOMSVGImageElement.h> +#import <WebCore/DOMSVGLangSpace.h> +#import <WebCore/DOMSVGLength.h> +#import <WebCore/DOMSVGLengthList.h> +#import <WebCore/DOMSVGLineElement.h> +#import <WebCore/DOMSVGLinearGradientElement.h> +#import <WebCore/DOMSVGLocatable.h> +#import <WebCore/DOMSVGMarkerElement.h> +#import <WebCore/DOMSVGMaskElement.h> +#import <WebCore/DOMSVGMatrix.h> +#import <WebCore/DOMSVGMetadataElement.h> +#import <WebCore/DOMSVGMissingGlyphElement.h> +#import <WebCore/DOMSVGNumber.h> +#import <WebCore/DOMSVGNumberList.h> +#import <WebCore/DOMSVGPaint.h> +#import <WebCore/DOMSVGPathElement.h> +#import <WebCore/DOMSVGPathSeg.h> +#import <WebCore/DOMSVGPathSegArcAbs.h> +#import <WebCore/DOMSVGPathSegArcRel.h> +#import <WebCore/DOMSVGPathSegClosePath.h> +#import <WebCore/DOMSVGPathSegCurvetoCubicAbs.h> +#import <WebCore/DOMSVGPathSegCurvetoCubicRel.h> +#import <WebCore/DOMSVGPathSegCurvetoCubicSmoothAbs.h> +#import <WebCore/DOMSVGPathSegCurvetoCubicSmoothRel.h> +#import <WebCore/DOMSVGPathSegCurvetoQuadraticAbs.h> +#import <WebCore/DOMSVGPathSegCurvetoQuadraticRel.h> +#import <WebCore/DOMSVGPathSegCurvetoQuadraticSmoothAbs.h> +#import <WebCore/DOMSVGPathSegCurvetoQuadraticSmoothRel.h> +#import <WebCore/DOMSVGPathSegLinetoAbs.h> +#import <WebCore/DOMSVGPathSegLinetoHorizontalAbs.h> +#import <WebCore/DOMSVGPathSegLinetoHorizontalRel.h> +#import <WebCore/DOMSVGPathSegLinetoRel.h> +#import <WebCore/DOMSVGPathSegLinetoVerticalAbs.h> +#import <WebCore/DOMSVGPathSegLinetoVerticalRel.h> +#import <WebCore/DOMSVGPathSegList.h> +#import <WebCore/DOMSVGPathSegMovetoAbs.h> +#import <WebCore/DOMSVGPathSegMovetoRel.h> +#import <WebCore/DOMSVGPatternElement.h> +#import <WebCore/DOMSVGPoint.h> +#import <WebCore/DOMSVGPointList.h> +#import <WebCore/DOMSVGPolygonElement.h> +#import <WebCore/DOMSVGPolylineElement.h> +#import <WebCore/DOMSVGPreserveAspectRatio.h> +#import <WebCore/DOMSVGRadialGradientElement.h> +#import <WebCore/DOMSVGRect.h> +#import <WebCore/DOMSVGRectElement.h> +#import <WebCore/DOMSVGRenderingIntent.h> +#import <WebCore/DOMSVGSVGElement.h> +#import <WebCore/DOMSVGScriptElement.h> +#import <WebCore/DOMSVGSetElement.h> +#import <WebCore/DOMSVGStopElement.h> +#import <WebCore/DOMSVGStringList.h> +#import <WebCore/DOMSVGStylable.h> +#import <WebCore/DOMSVGStyleElement.h> +#import <WebCore/DOMSVGSwitchElement.h> +#import <WebCore/DOMSVGSymbolElement.h> +#import <WebCore/DOMSVGTRefElement.h> +#import <WebCore/DOMSVGTSpanElement.h> +#import <WebCore/DOMSVGTests.h> +#import <WebCore/DOMSVGTextContentElement.h> +#import <WebCore/DOMSVGTextElement.h> +#import <WebCore/DOMSVGTextPathElement.h> +#import <WebCore/DOMSVGTextPositioningElement.h> +#import <WebCore/DOMSVGTitleElement.h> +#import <WebCore/DOMSVGTransform.h> +#import <WebCore/DOMSVGTransformList.h> +#import <WebCore/DOMSVGTransformable.h> +#import <WebCore/DOMSVGURIReference.h> +#import <WebCore/DOMSVGUnitTypes.h> +#import <WebCore/DOMSVGUseElement.h> +#import <WebCore/DOMSVGViewElement.h> +#import <WebCore/DOMSVGZoomAndPan.h> +#import <WebCore/DOMSVGZoomEvent.h> diff --git a/WebCore/bindings/objc/DOMSVGException.h b/WebCore/bindings/objc/DOMSVGException.h new file mode 100644 index 0000000..b757978 --- /dev/null +++ b/WebCore/bindings/objc/DOMSVGException.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class NSString; + +extern NSString * const DOMSVGException; + +enum DOMSVGException { + DOM_SVG_WRONG_TYPE_ERR = 0, + DOM_SVG_INVALID_VALUE_ERR = 1, + DOM_SVG_MATRIX_NOT_INVERTABLE = 2 +}; + +#endif diff --git a/WebCore/bindings/objc/DOMSVGPathSegInternal.mm b/WebCore/bindings/objc/DOMSVGPathSegInternal.mm new file mode 100644 index 0000000..cbbe6bd --- /dev/null +++ b/WebCore/bindings/objc/DOMSVGPathSegInternal.mm @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 "config.h" + +#if ENABLE(SVG) + +#import "DOMSVGPathSegInternal.h" + +#import "DOMInternal.h" +#import "DOMSVGPathSeg.h" +#import "DOMSVGPathSegArcAbs.h" +#import "DOMSVGPathSegArcRel.h" +#import "DOMSVGPathSegClosePath.h" +#import "DOMSVGPathSegCurvetoCubicAbs.h" +#import "DOMSVGPathSegCurvetoCubicRel.h" +#import "DOMSVGPathSegCurvetoCubicSmoothAbs.h" +#import "DOMSVGPathSegCurvetoCubicSmoothRel.h" +#import "DOMSVGPathSegCurvetoQuadraticAbs.h" +#import "DOMSVGPathSegCurvetoQuadraticRel.h" +#import "DOMSVGPathSegCurvetoQuadraticSmoothAbs.h" +#import "DOMSVGPathSegCurvetoQuadraticSmoothRel.h" +#import "DOMSVGPathSegLinetoAbs.h" +#import "DOMSVGPathSegLinetoHorizontalAbs.h" +#import "DOMSVGPathSegLinetoHorizontalRel.h" +#import "DOMSVGPathSegLinetoRel.h" +#import "DOMSVGPathSegLinetoVerticalAbs.h" +#import "DOMSVGPathSegLinetoVerticalRel.h" +#import "DOMSVGPathSegList.h" +#import "DOMSVGPathSegMovetoAbs.h" +#import "DOMSVGPathSegMovetoRel.h" +#import "SVGPathSeg.h" +#import <objc/objc-class.h> + +@implementation DOMSVGPathSeg (WebCoreInternal) + +- (WebCore::SVGPathSeg *)_SVGPathSeg +{ + return reinterpret_cast<WebCore::SVGPathSeg*>(_internal); +} + +- (id)_initWithSVGPathSeg:(WebCore::SVGPathSeg *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMSVGPathSeg *)_wrapSVGPathSeg:(WebCore::SVGPathSeg *)impl +{ + if (!impl) + return nil; + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + Class wrapperClass = nil; + switch (impl->pathSegType()) { + case WebCore::SVGPathSeg::PATHSEG_UNKNOWN: + wrapperClass = [DOMSVGPathSeg class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CLOSEPATH: + wrapperClass = [DOMSVGPathSegClosePath class]; + break; + case WebCore::SVGPathSeg::PATHSEG_MOVETO_ABS: + wrapperClass = [DOMSVGPathSegMovetoAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_MOVETO_REL: + wrapperClass = [DOMSVGPathSegMovetoRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_ABS: + wrapperClass = [DOMSVGPathSegLinetoAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_REL: + wrapperClass = [DOMSVGPathSegLinetoRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_CUBIC_ABS: + wrapperClass = [DOMSVGPathSegCurvetoCubicAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_CUBIC_REL: + wrapperClass = [DOMSVGPathSegCurvetoCubicRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_ABS: + wrapperClass = [DOMSVGPathSegCurvetoQuadraticAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_REL: + wrapperClass = [DOMSVGPathSegCurvetoQuadraticRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_ARC_ABS: + wrapperClass = [DOMSVGPathSegArcAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_ARC_REL: + wrapperClass = [DOMSVGPathSegArcRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_ABS: + wrapperClass = [DOMSVGPathSegLinetoHorizontalAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_HORIZONTAL_REL: + wrapperClass = [DOMSVGPathSegLinetoHorizontalRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS: + wrapperClass = [DOMSVGPathSegLinetoVerticalAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_LINETO_VERTICAL_REL: + wrapperClass = [DOMSVGPathSegLinetoVerticalRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: + wrapperClass = [DOMSVGPathSegCurvetoCubicSmoothAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_REL: + wrapperClass = [DOMSVGPathSegCurvetoCubicSmoothRel class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: + wrapperClass = [DOMSVGPathSegCurvetoQuadraticSmoothAbs class]; + break; + case WebCore::SVGPathSeg::PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: + wrapperClass = [DOMSVGPathSegCurvetoQuadraticSmoothRel class]; + break; + } + + return [[[wrapperClass alloc] _initWithSVGPathSeg:impl] autorelease]; +} + +@end + +#endif // ENABLE(SVG) diff --git a/WebCore/bindings/objc/DOMStylesheets.h b/WebCore/bindings/objc/DOMStylesheets.h new file mode 100644 index 0000000..81b5def --- /dev/null +++ b/WebCore/bindings/objc/DOMStylesheets.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMObject.h> + +#import <WebCore/DOMStyleSheet.h> +#import <WebCore/DOMStyleSheetList.h> +#import <WebCore/DOMMediaList.h> diff --git a/WebCore/bindings/objc/DOMTraversal.h b/WebCore/bindings/objc/DOMTraversal.h new file mode 100644 index 0000000..db9dea8 --- /dev/null +++ b/WebCore/bindings/objc/DOMTraversal.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMObject.h> + +#import <WebCore/DOMNodeFilter.h> +#import <WebCore/DOMNodeIterator.h> +#import <WebCore/DOMTreeWalker.h> diff --git a/WebCore/bindings/objc/DOMUtility.mm b/WebCore/bindings/objc/DOMUtility.mm new file mode 100644 index 0000000..e346c9e --- /dev/null +++ b/WebCore/bindings/objc/DOMUtility.mm @@ -0,0 +1,128 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * + * 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 "config.h" + +#import "DOMImplementationFront.h" +#import "DOMInternal.h" +#import "JSCSSRule.h" +#import "JSCSSRuleList.h" +#import "JSCSSStyleDeclaration.h" +#import "JSCSSValue.h" +#import "JSCounter.h" +#import "JSDOMImplementation.h" +#import "JSDOMWindow.h" +#import "JSDOMWindowShell.h" +#import "JSEvent.h" +#import "JSHTMLCollection.h" +#import "JSHTMLOptionsCollection.h" +#import "JSMediaList.h" +#import "JSNamedNodeMap.h" +#import "JSNode.h" +#import "JSNodeIterator.h" +#import "JSNodeList.h" +#import "JSRGBColor.h" +#import "JSRange.h" +#import "JSRect.h" +#import "JSStyleSheet.h" +#import "JSStyleSheetList.h" +#import "JSTreeWalker.h" +#import "JSXPathExpression.h" +#import "JSXPathResult.h" +#import "Node.h" +#import "WebScriptObjectPrivate.h" +#import "runtime_root.h" +#import <objc/objc-runtime.h> + +// This file makes use of both the ObjC DOM API and the C++ DOM API, so we need to be careful about what +// headers are included and what namespaces we use to avoid naming conflicts. + +// FIXME: This has to be in the KJS namespace to avoid an Objective-C++ ambiguity with C++ and +// Objective-C classes of the same name (even when not in the same namespace). That's also the +// reason for the use of objc_getClass in the WRAP_OLD macro below. + +// Some day if the compiler is fixed, or if all the JS wrappers are named with a "JS" prefix, +// we could move the function into the WebCore namespace where it belongs. + +namespace JSC { + +static inline id createDOMWrapper(JSC::JSObject* object) +{ + #define WRAP(className) \ + if (object->inherits(&WebCore::JS##className::s_info)) \ + return [DOM##className _wrap##className:static_cast<WebCore::JS##className*>(object)->impl()]; + + WRAP(CSSRule) + WRAP(CSSRuleList) + WRAP(CSSStyleDeclaration) + WRAP(CSSValue) + WRAP(Counter) + WRAP(Event) + WRAP(HTMLOptionsCollection) + WRAP(MediaList) + WRAP(NamedNodeMap) + WRAP(Node) + WRAP(NodeIterator) + WRAP(NodeList) + WRAP(RGBColor) + WRAP(Range) + WRAP(Rect) + WRAP(StyleSheet) + WRAP(StyleSheetList) + WRAP(TreeWalker) +#if ENABLE(XPATH) + WRAP(XPathExpression) + WRAP(XPathResult) +#endif + + // This must be after the HTMLOptionsCollection check, because it's a subclass in the JavaScript + // binding, but not a subclass in the ObjC binding. + WRAP(HTMLCollection) + + #undef WRAP + + if (object->inherits(&WebCore::JSDOMWindowShell::s_info)) + return [DOMAbstractView _wrapAbstractView:static_cast<WebCore::JSDOMWindowShell*>(object)->impl()]; + + if (object->inherits(&WebCore::JSDOMImplementation::s_info)) + return [DOMImplementation _wrapDOMImplementation:implementationFront(static_cast<WebCore::JSDOMImplementation*>(object))]; + + return nil; +} + +} + +namespace WebCore { + +id createDOMWrapper(JSC::JSObject* object, PassRefPtr<JSC::Bindings::RootObject> origin, PassRefPtr<JSC::Bindings::RootObject> current) +{ + id wrapper = JSC::createDOMWrapper(object); + if (![wrapper _hasImp]) // new wrapper, not from cache + [wrapper _setImp:object originRootObject:origin rootObject:current]; + return wrapper; +} + +} diff --git a/WebCore/bindings/objc/DOMViews.h b/WebCore/bindings/objc/DOMViews.h new file mode 100644 index 0000000..4b625c8 --- /dev/null +++ b/WebCore/bindings/objc/DOMViews.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2004 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMObject.h> + +#import <WebCore/DOMAbstractView.h> diff --git a/WebCore/bindings/objc/DOMXPath.h b/WebCore/bindings/objc/DOMXPath.h new file mode 100644 index 0000000..f5472c3 --- /dev/null +++ b/WebCore/bindings/objc/DOMXPath.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <WebCore/DOMCore.h> +#import <WebCore/DOMDocument.h> +#import <WebCore/DOMObject.h> + +#import <WebCore/DOMXPathException.h> +#import <WebCore/DOMXPathExpression.h> +#import <WebCore/DOMXPathNSResolver.h> +#import <WebCore/DOMXPathResult.h> diff --git a/WebCore/bindings/objc/DOMXPath.mm b/WebCore/bindings/objc/DOMXPath.mm new file mode 100644 index 0000000..0d008f1 --- /dev/null +++ b/WebCore/bindings/objc/DOMXPath.mm @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 "config.h" + +#if ENABLE(XPATH) + +#import "DOMXPath.h" + +#import "DOMInternal.h" +#import "PlatformString.h" +#import "XPathNSResolver.h" + +//------------------------------------------------------------------------------------------ +// DOMNativeXPathNSResolver + +@implementation DOMNativeXPathNSResolver + +#define IMPL reinterpret_cast<WebCore::XPathNSResolver*>(_internal) + +- (void)dealloc +{ + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (WebCore::XPathNSResolver *)_xpathNSResolver +{ + return IMPL; +} + +- (id)_initWithXPathNSResolver:(WebCore::XPathNSResolver *)impl +{ + ASSERT(impl); + + [super _init]; + _internal = reinterpret_cast<DOMObjectInternal*>(impl); + impl->ref(); + WebCore::addDOMWrapper(self, impl); + return self; +} + ++ (DOMNativeXPathNSResolver *)_wrapXPathNSResolver:(WebCore::XPathNSResolver *)impl +{ + if (!impl) + return nil; + + id cachedInstance; + cachedInstance = WebCore::getDOMWrapper(impl); + if (cachedInstance) + return [[cachedInstance retain] autorelease]; + + return [[[DOMNativeXPathNSResolver alloc] _initWithXPathNSResolver:impl] autorelease]; +} + +- (NSString *)lookupNamespaceURI:(NSString *)prefix +{ + return IMPL->lookupNamespaceURI(prefix); +} + +@end + +#endif // ENABLE(XPATH) diff --git a/WebCore/bindings/objc/DOMXPathException.h b/WebCore/bindings/objc/DOMXPathException.h new file mode 100644 index 0000000..32f95fb --- /dev/null +++ b/WebCore/bindings/objc/DOMXPathException.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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 <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_3_0 + +@class NSString; + +extern NSString * const DOMXPathException; + +enum DOMXPathExceptionCode { + DOM_INVALID_EXPRESSION_ERR = 51, + DOM_TYPE_ERR = 52 +}; + +#endif diff --git a/WebCore/bindings/objc/ExceptionHandlers.h b/WebCore/bindings/objc/ExceptionHandlers.h new file mode 100644 index 0000000..911ae2c --- /dev/null +++ b/WebCore/bindings/objc/ExceptionHandlers.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007 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 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. + */ + +#ifndef ExceptionHandlers_h +#define ExceptionHandlers_h + +#include <wtf/Assertions.h> + +#if !defined(NDEBUG) && !defined(DISABLE_THREAD_CHECK) +#define DOM_ASSERT_MAIN_THREAD() do \ + if (!pthread_main_np()) { \ + WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, "DOM access on non-main thread -- you will probably crash soon!"); \ + } \ +while (0) +#else +#define DOM_ASSERT_MAIN_THREAD() ((void)0) +#endif + +namespace WebCore { + + typedef int ExceptionCode; + + class SelectionController; + class Range; + + void raiseDOMException(ExceptionCode); + + inline void raiseOnDOMError(ExceptionCode ec) + { + if (ec) + raiseDOMException(ec); + } + +} // namespace WebCore + +#endif // ExceptionHandlers_h diff --git a/WebCore/bindings/objc/ExceptionHandlers.mm b/WebCore/bindings/objc/ExceptionHandlers.mm new file mode 100644 index 0000000..e9e42a8 --- /dev/null +++ b/WebCore/bindings/objc/ExceptionHandlers.mm @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2004, 2006, 2007 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 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. + */ + +#include "config.h" +#include "ExceptionHandlers.h" + +#include "ExceptionCode.h" + +NSString * DOMException = @"DOMException"; +NSString * DOMRangeException = @"DOMRangeException"; +NSString * DOMEventException = @"DOMEventException"; +NSString * DOMSVGException = @"DOMSVGException"; +NSString * DOMXPathException = @"DOMXPathException"; + +namespace WebCore { + +void raiseDOMException(ExceptionCode ec) +{ + ASSERT(ec); + + ExceptionCodeDescription description; + getExceptionCodeDescription(ec, description); + + NSString *exceptionName; + if (strcmp(description.typeName, "DOM Range") == 0) + exceptionName = DOMRangeException; + else if (strcmp(description.typeName, "DOM Events") == 0) + exceptionName = DOMEventException; + else if (strcmp(description.typeName, "DOM SVG") == 0) + exceptionName = DOMSVGException; + else if (strcmp(description.typeName, "DOM XPath") == 0) + exceptionName = DOMXPathException; + else + exceptionName = DOMException; + + NSString *reason; + if (description.name) + reason = [[NSString alloc] initWithFormat:@"*** %s: %@ %d", description.name, exceptionName, description.code]; + else + reason = [[NSString alloc] initWithFormat:@"*** %@ %d", exceptionName, description.code]; + + NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:description.code], exceptionName, nil]; + + NSException *exception = [NSException exceptionWithName:exceptionName reason:reason userInfo:userInfo]; + + [reason release]; + [userInfo release]; + + [exception raise]; +} + +} // namespace WebCore diff --git a/WebCore/bindings/objc/ObjCEventListener.h b/WebCore/bindings/objc/ObjCEventListener.h new file mode 100644 index 0000000..6056b01 --- /dev/null +++ b/WebCore/bindings/objc/ObjCEventListener.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2004, 2006, 2008 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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. + */ + +#ifndef ObjCEventListener_h +#define ObjCEventListener_h + +#include "EventListener.h" + +#include <wtf/PassRefPtr.h> + +@protocol DOMEventListener; + +namespace WebCore { + + class ObjCEventListener : public EventListener { + public: + static PassRefPtr<ObjCEventListener> wrap(id <DOMEventListener>); + + private: + static ObjCEventListener* find(id <DOMEventListener>); + + ObjCEventListener(id <DOMEventListener>); + virtual ~ObjCEventListener(); + + virtual void handleEvent(Event*, bool isWindowEvent); + + id <DOMEventListener> m_listener; + }; + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/objc/ObjCEventListener.mm b/WebCore/bindings/objc/ObjCEventListener.mm new file mode 100644 index 0000000..46c04c1 --- /dev/null +++ b/WebCore/bindings/objc/ObjCEventListener.mm @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "config.h" + +#import "ObjCEventListener.h" + +#import "DOMEventInternal.h" +#import "DOMEventListener.h" +#import "Event.h" +#import "EventListener.h" + +#import <objc/objc-class.h> +#import <wtf/HashMap.h> + +namespace WebCore { + +typedef HashMap<id, ObjCEventListener*> ListenerMap; +static ListenerMap* listenerMap; + +ObjCEventListener* ObjCEventListener::find(id <DOMEventListener> listener) +{ + if (ListenerMap* map = listenerMap) + return map->get(listener); + return 0; +} + +PassRefPtr<ObjCEventListener> ObjCEventListener::wrap(id <DOMEventListener> listener) +{ + RefPtr<ObjCEventListener> wrapper = find(listener); + if (wrapper) + return wrapper; + return adoptRef(new ObjCEventListener(listener)); +} + +ObjCEventListener::ObjCEventListener(id <DOMEventListener> listener) + : m_listener([listener retain]) +{ + ListenerMap* map = listenerMap; + if (!map) { + map = new ListenerMap; + listenerMap = map; + } + map->set(listener, this); +} + +ObjCEventListener::~ObjCEventListener() +{ + listenerMap->remove(m_listener); + [m_listener release]; +} + +void ObjCEventListener::handleEvent(Event* event, bool) +{ + [m_listener handleEvent:[DOMEvent _wrapEvent:event]]; +} + +} // namespace WebCore diff --git a/WebCore/bindings/objc/ObjCNodeFilterCondition.h b/WebCore/bindings/objc/ObjCNodeFilterCondition.h new file mode 100644 index 0000000..e136bc4 --- /dev/null +++ b/WebCore/bindings/objc/ObjCNodeFilterCondition.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2004, 2006, 2008 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * 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. + */ + +#ifndef ObjCNodeFilterCondition_h +#define ObjCNodeFilterCondition_h + +#include "NodeFilterCondition.h" + +#include <wtf/PassRefPtr.h> +#include <wtf/RetainPtr.h> + +@protocol DOMNodeFilter; + +namespace WebCore { + class Node; + + class ObjCNodeFilterCondition : public NodeFilterCondition { + public: + static PassRefPtr<ObjCNodeFilterCondition> create(id <DOMNodeFilter> filter) + { + return adoptRef(new ObjCNodeFilterCondition(filter)); + } + + virtual short acceptNode(JSC::ExecState*, Node*) const; + + private: + ObjCNodeFilterCondition(id <DOMNodeFilter> filter) + : m_filter(filter) + { + } + + RetainPtr<id <DOMNodeFilter> > m_filter; + }; + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/objc/ObjCNodeFilterCondition.mm b/WebCore/bindings/objc/ObjCNodeFilterCondition.mm new file mode 100644 index 0000000..982cfe0 --- /dev/null +++ b/WebCore/bindings/objc/ObjCNodeFilterCondition.mm @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2006 James G. Speth (speth@end.com) + * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) + * + * 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 "config.h" + +#import "ObjCNodeFilterCondition.h" + +#import "DOMNodeFilter.h" +#import "DOMNodeInternal.h" +#import "NodeFilter.h" + +using namespace JSC; + +namespace WebCore { + +short ObjCNodeFilterCondition::acceptNode(ExecState*, Node* node) const +{ + if (!node) + return NodeFilter::FILTER_REJECT; + return [m_filter.get() acceptNode:[DOMNode _wrapNode:node]]; +} + +} // namespace WebCore diff --git a/WebCore/bindings/objc/PublicDOMInterfaces.h b/WebCore/bindings/objc/PublicDOMInterfaces.h new file mode 100644 index 0000000..349abaf --- /dev/null +++ b/WebCore/bindings/objc/PublicDOMInterfaces.h @@ -0,0 +1,1079 @@ +// Copyright (C) 2006, 2007 Apple Inc. All rights reserved. +// Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> +// +// 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. + +// This file is used by bindings/scripts/CodeGeneratorObjC.pm to determine public API. +// All public DOM class interfaces, properties and methods need to be in this file. +// Anything not in the file will be generated into the appropriate private header file. + +#ifndef OBJC_CODE_GENERATION +#error Do not include this header, instead include the appropriate DOM header. +#endif + +@interface DOMAttr : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *name; +@property(readonly) BOOL specified; +@property(copy) NSString *value; +@property(readonly, retain) DOMElement *ownerElement; +@property(readonly, retain) DOMCSSStyleDeclaration *style AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMCDATASection : DOMText WEBKIT_VERSION_1_3 +@end + +@interface DOMCharacterData : DOMNode WEBKIT_VERSION_1_3 +@property(copy) NSString *data; +@property(readonly) unsigned length; +- (NSString *)substringData:(unsigned)offset :(unsigned)length; +- (NSString *)substringData:(unsigned)offset length:(unsigned)length AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)appendData:(NSString *)data; +- (void)insertData:(unsigned)offset :(NSString *)data; +- (void)deleteData:(unsigned)offset :(unsigned)length; +- (void)replaceData:(unsigned)offset :(unsigned)length :(NSString *)data; +- (void)insertData:(unsigned)offset data:(NSString *)data AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)deleteData:(unsigned)offset length:(unsigned)length AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)replaceData:(unsigned)offset length:(unsigned)length data:(NSString *)data AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMComment : DOMCharacterData WEBKIT_VERSION_1_3 +@end + +@interface DOMImplementation : DOMObject WEBKIT_VERSION_1_3 +- (BOOL)hasFeature:(NSString *)feature :(NSString *)version; +- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName :(NSString *)publicId :(NSString *)systemId; +- (DOMDocument *)createDocument:(NSString *)namespaceURI :(NSString *)qualifiedName :(DOMDocumentType *)doctype; +- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title :(NSString *)media; +- (BOOL)hasFeature:(NSString *)feature version:(NSString *)version AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMDocumentType *)createDocumentType:(NSString *)qualifiedName publicId:(NSString *)publicId systemId:(NSString *)systemId AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMDocument *)createDocument:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName doctype:(DOMDocumentType *)doctype AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMCSSStyleSheet *)createCSSStyleSheet:(NSString *)title media:(NSString *)media AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMHTMLDocument *)createHTMLDocument:(NSString *)title AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMAbstractView : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMDocument *document; +@end + +@interface DOMDocument : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMDocumentType *doctype; +@property(readonly, retain) DOMImplementation *implementation; +@property(readonly, retain) DOMElement *documentElement; +@property(readonly, retain) DOMAbstractView *defaultView; +@property(readonly, retain) DOMStyleSheetList *styleSheets; +@property(readonly, retain) DOMHTMLCollection *images; +@property(readonly, retain) DOMHTMLCollection *applets; +@property(readonly, retain) DOMHTMLCollection *links; +@property(readonly, retain) DOMHTMLCollection *forms; +@property(readonly, retain) DOMHTMLCollection *anchors; +@property(copy) NSString *title; +@property(readonly, copy) NSString *referrer; +@property(readonly, copy) NSString *domain; +@property(readonly, copy) NSString *URL; +@property(retain) DOMHTMLElement *body; +@property(copy) NSString *cookie; +- (DOMElement *)createElement:(NSString *)tagName; +- (DOMDocumentFragment *)createDocumentFragment; +- (DOMText *)createTextNode:(NSString *)data; +- (DOMComment *)createComment:(NSString *)data; +- (DOMCDATASection *)createCDATASection:(NSString *)data; +- (DOMProcessingInstruction *)createProcessingInstruction:(NSString *)target :(NSString *)data; +- (DOMProcessingInstruction *)createProcessingInstruction:(NSString *)target data:(NSString *)data AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMAttr *)createAttribute:(NSString *)name; +- (DOMEntityReference *)createEntityReference:(NSString *)name; +- (DOMNodeList *)getElementsByTagName:(NSString *)tagname; +- (DOMNode *)importNode:(DOMNode *)importedNode :(BOOL)deep; +- (DOMElement *)createElementNS:(NSString *)namespaceURI :(NSString *)qualifiedName; +- (DOMAttr *)createAttributeNS:(NSString *)namespaceURI :(NSString *)qualifiedName; +- (DOMNodeList *)getElementsByTagNameNS:(NSString *)namespaceURI :(NSString *)localName; +- (DOMNode *)importNode:(DOMNode *)importedNode deep:(BOOL)deep AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNode *)adoptNode:(DOMNode *)source AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMElement *)createElementNS:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMAttr *)createAttributeNS:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNodeList *)getElementsByTagNameNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMElement *)getElementById:(NSString *)elementId; +- (DOMEvent *)createEvent:(NSString *)eventType; +- (DOMRange *)createRange; +- (DOMCSSStyleDeclaration *)createCSSStyleDeclaration AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMCSSStyleDeclaration *)getOverrideStyle:(DOMElement *)element :(NSString *)pseudoElement; +- (DOMCSSStyleDeclaration *)getOverrideStyle:(DOMElement *)element pseudoElement:(NSString *)pseudoElement AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMCSSStyleDeclaration *)getComputedStyle:(DOMElement *)element :(NSString *)pseudoElement; +- (DOMCSSStyleDeclaration *)getComputedStyle:(DOMElement *)element pseudoElement:(NSString *)pseudoElement AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMCSSRuleList *)getMatchedCSSRules:(DOMElement *)element pseudoElement:(NSString *)pseudoElement AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMCSSRuleList *)getMatchedCSSRules:(DOMElement *)element pseudoElement:(NSString *)pseudoElement authorOnly:(BOOL)authorOnly AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNodeList *)getElementsByName:(NSString *)elementName; +- (DOMNodeIterator *)createNodeIterator:(DOMNode *)root whatToShow:(unsigned)whatToShow filter:(id <DOMNodeFilter>)filter expandEntityReferences:(BOOL)expandEntityReferences AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMTreeWalker *)createTreeWalker:(DOMNode *)root whatToShow:(unsigned)whatToShow filter:(id <DOMNodeFilter>)filter expandEntityReferences:(BOOL)expandEntityReferences AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNodeIterator *)createNodeIterator:(DOMNode *)root :(unsigned)whatToShow :(id <DOMNodeFilter>)filter :(BOOL)expandEntityReferences; +- (DOMTreeWalker *)createTreeWalker:(DOMNode *)root :(unsigned)whatToShow :(id <DOMNodeFilter>)filter :(BOOL)expandEntityReferences; +#if ENABLE_XPATH +- (DOMXPathExpression *)createExpression:(NSString *)expression :(id <DOMXPathNSResolver>)resolver AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED; +- (DOMXPathExpression *)createExpression:(NSString *)expression resolver:(id <DOMXPathNSResolver>)resolver AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (id <DOMXPathNSResolver>)createNSResolver:(DOMNode *)nodeResolver AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMXPathResult *)evaluate:(NSString *)expression :(DOMNode *)contextNode :(id <DOMXPathNSResolver>)resolver :(unsigned short)type :(DOMXPathResult *)inResult AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED; +- (DOMXPathResult *)evaluate:(NSString *)expression contextNode:(DOMNode *)contextNode resolver:(id <DOMXPathNSResolver>)resolver type:(unsigned short)type inResult:(DOMXPathResult *)inResult AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +#endif +@end + +@interface DOMDocumentFragment : DOMNode WEBKIT_VERSION_1_3 +@end + +@interface DOMDocumentType : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *name; +@property(readonly, retain) DOMNamedNodeMap *entities; +@property(readonly, retain) DOMNamedNodeMap *notations; +@property(readonly, copy) NSString *publicId; +@property(readonly, copy) NSString *systemId; +@property(readonly, copy) NSString *internalSubset; +@end + +@interface DOMElement : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *tagName; +@property(readonly, retain) DOMCSSStyleDeclaration *style; +@property(readonly) int offsetLeft; +@property(readonly) int offsetTop; +@property(readonly) int offsetWidth; +@property(readonly) int offsetHeight; +@property(readonly, retain) DOMElement *offsetParent; +@property(readonly) int clientWidth; +@property(readonly) int clientHeight; +@property int scrollLeft; +@property int scrollTop; +@property(readonly) int scrollWidth; +@property(readonly) int scrollHeight; +- (NSString *)getAttribute:(NSString *)name; +- (void)setAttribute:(NSString *)name :(NSString *)value; +- (void)setAttribute:(NSString *)name value:(NSString *)value AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)removeAttribute:(NSString *)name; +- (DOMAttr *)getAttributeNode:(NSString *)name; +- (DOMAttr *)setAttributeNode:(DOMAttr *)newAttr; +- (DOMAttr *)removeAttributeNode:(DOMAttr *)oldAttr; +- (DOMNodeList *)getElementsByTagName:(NSString *)name; +- (NSString *)getAttributeNS:(NSString *)namespaceURI :(NSString *)localName; +- (void)setAttributeNS:(NSString *)namespaceURI :(NSString *)qualifiedName :(NSString *)value; +- (void)removeAttributeNS:(NSString *)namespaceURI :(NSString *)localName; +- (DOMNodeList *)getElementsByTagNameNS:(NSString *)namespaceURI :(NSString *)localName; +- (DOMAttr *)getAttributeNodeNS:(NSString *)namespaceURI :(NSString *)localName; +- (NSString *)getAttributeNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)setAttributeNS:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName value:(NSString *)value AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)removeAttributeNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNodeList *)getElementsByTagNameNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMAttr *)getAttributeNodeNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMAttr *)setAttributeNodeNS:(DOMAttr *)newAttr; +- (BOOL)hasAttribute:(NSString *)name; +- (BOOL)hasAttributeNS:(NSString *)namespaceURI :(NSString *)localName; +- (BOOL)hasAttributeNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)scrollIntoView:(BOOL)alignWithTop AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)scrollIntoViewIfNeeded:(BOOL)centerIfNeeded AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMEntity : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *publicId; +@property(readonly, copy) NSString *systemId; +@property(readonly, copy) NSString *notationName; +@end + +@interface DOMEntityReference : DOMNode WEBKIT_VERSION_1_3 +@end + +@interface DOMNamedNodeMap : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMNode *)getNamedItem:(NSString *)name; +- (DOMNode *)setNamedItem:(DOMNode *)node; +- (DOMNode *)removeNamedItem:(NSString *)name; +- (DOMNode *)item:(unsigned)index; +- (DOMNode *)getNamedItemNS:(NSString *)namespaceURI :(NSString *)localName; +- (DOMNode *)getNamedItemNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNode *)setNamedItemNS:(DOMNode *)node; +- (DOMNode *)removeNamedItemNS:(NSString *)namespaceURI :(NSString *)localName; +- (DOMNode *)removeNamedItemNS:(NSString *)namespaceURI localName:(NSString *)localName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMNode : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *nodeName; +@property(copy) NSString *nodeValue; +@property(readonly) unsigned short nodeType; +@property(readonly, retain) DOMNode *parentNode; +@property(readonly, retain) DOMNodeList *childNodes; +@property(readonly, retain) DOMNode *firstChild; +@property(readonly, retain) DOMNode *lastChild; +@property(readonly, retain) DOMNode *previousSibling; +@property(readonly, retain) DOMNode *nextSibling; +@property(readonly, retain) DOMNamedNodeMap *attributes; +@property(readonly, retain) DOMDocument *ownerDocument; +@property(readonly, copy) NSString *namespaceURI; +@property(copy) NSString *prefix; +@property(readonly, copy) NSString *localName; +@property(copy) NSString *textContent AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNode *)insertBefore:(DOMNode *)newChild :(DOMNode *)refChild; +- (DOMNode *)insertBefore:(DOMNode *)newChild refChild:(DOMNode *)refChild AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNode *)replaceChild:(DOMNode *)newChild :(DOMNode *)oldChild; +- (DOMNode *)replaceChild:(DOMNode *)newChild oldChild:(DOMNode *)oldChild AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMNode *)removeChild:(DOMNode *)oldChild; +- (DOMNode *)appendChild:(DOMNode *)newChild; +- (BOOL)hasChildNodes; +- (DOMNode *)cloneNode:(BOOL)deep; +- (void)normalize; +- (BOOL)isSupported:(NSString *)feature :(NSString *)version; +- (BOOL)isSupported:(NSString *)feature version:(NSString *)version AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (BOOL)hasAttributes; +- (BOOL)isSameNode:(DOMNode *)other AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (BOOL)isEqualNode:(DOMNode *)other AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMNodeList : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMNode *)item:(unsigned)index; +@end + +@interface DOMNotation : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *publicId; +@property(readonly, copy) NSString *systemId; +@end + +@interface DOMProcessingInstruction : DOMNode WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *target; +@property(copy) NSString *data; +@end + +@interface DOMText : DOMCharacterData WEBKIT_VERSION_1_3 +- (DOMText *)splitText:(unsigned)offset; +@end + +@interface DOMHTMLAnchorElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *accessKey; +@property(copy) NSString *charset; +@property(copy) NSString *coords; +@property(copy) NSString *href; +@property(copy) NSString *hreflang; +@property(copy) NSString *name; +@property(copy) NSString *rel; +@property(copy) NSString *rev; +@property(copy) NSString *shape; +@property(copy) NSString *target; +@property(copy) NSString *type; +@property(readonly, copy) NSURL *absoluteLinkURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMHTMLAppletElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property(copy) NSString *alt; +@property(copy) NSString *archive; +@property(copy) NSString *code; +@property(copy) NSString *codeBase; +@property(copy) NSString *height; +@property int hspace; +@property(copy) NSString *name; +@property(copy) NSString *object; +@property int vspace; +@property(copy) NSString *width; +@end + +@interface DOMHTMLAreaElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *accessKey; +@property(copy) NSString *alt; +@property(copy) NSString *coords; +@property(copy) NSString *href; +@property BOOL noHref; +@property(copy) NSString *shape; +@property(copy) NSString *target; +@property(readonly, copy) NSURL *absoluteLinkURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMHTMLBRElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *clear; +@end + +@interface DOMHTMLBaseElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *href; +@property(copy) NSString *target; +@end + +@interface DOMHTMLBaseFontElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *color; +@property(copy) NSString *face; +@property(copy) NSString *size; +@end + +@interface DOMHTMLBodyElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *aLink; +@property(copy) NSString *background; +@property(copy) NSString *bgColor; +@property(copy) NSString *link; +@property(copy) NSString *text; +@property(copy) NSString *vLink; +@end + +@interface DOMHTMLButtonElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *accessKey; +@property BOOL disabled; +@property(copy) NSString *name; +@property(readonly, copy) NSString *type; +@property(copy) NSString *value; +@end + +@interface DOMHTMLCanvasElement : DOMHTMLElement WEBKIT_VERSION_3_0 +@property int height; +@property int width; +@end + +@interface DOMHTMLCollection : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMNode *)item:(unsigned)index; +- (DOMNode *)namedItem:(NSString *)name; +@end + +@interface DOMHTMLDListElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL compact; +@end + +@interface DOMHTMLDirectoryElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL compact; +@end + +@interface DOMHTMLDivElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@end + +@interface DOMHTMLDocument : DOMDocument WEBKIT_VERSION_1_3 +- (void)open; +- (void)close; +- (void)write:(NSString *)text; +- (void)writeln:(NSString *)text; +@end + +@interface DOMHTMLElement : DOMElement WEBKIT_VERSION_1_3 +@property(copy) NSString *title; +@property(copy) NSString *idName; +@property(copy) NSString *lang; +@property(copy) NSString *dir; +@property(copy) NSString *className; +@property(copy) NSString *innerHTML; +@property(copy) NSString *innerText; +@property(copy) NSString *outerHTML; +@property(copy) NSString *outerText; +@property(readonly, retain) DOMHTMLCollection *children; +@property(copy) NSString *contentEditable; +@property(readonly) BOOL isContentEditable; +@property(readonly, copy) NSString *titleDisplayString AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@property int tabIndex; +- (void)blur; +- (void)focus; +@end + +@interface DOMHTMLEmbedElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property int height; +@property(copy) NSString *name; +@property(copy) NSString *src; +@property(copy) NSString *type; +@property int width; +@end + +@interface DOMHTMLFieldSetElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@end + +@interface DOMHTMLFontElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *color; +@property(copy) NSString *face; +@property(copy) NSString *size; +@end + +@interface DOMHTMLFormElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLCollection *elements; +@property(readonly) int length; +@property(copy) NSString *name; +@property(copy) NSString *acceptCharset; +@property(copy) NSString *action; +@property(copy) NSString *enctype; +@property(copy) NSString *method; +@property(copy) NSString *target; +- (void)submit; +- (void)reset; +@end + +@interface DOMHTMLFrameElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *frameBorder; +@property(copy) NSString *longDesc; +@property(copy) NSString *marginHeight; +@property(copy) NSString *marginWidth; +@property(copy) NSString *name; +@property BOOL noResize; +@property(copy) NSString *scrolling; +@property(copy) NSString *src; +@property(readonly, retain) DOMDocument *contentDocument; +@end + +@interface DOMHTMLFrameSetElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *cols; +@property(copy) NSString *rows; +@end + +@interface DOMHTMLHRElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property BOOL noShade; +@property(copy) NSString *size; +@property(copy) NSString *width; +@end + +@interface DOMHTMLHeadElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *profile; +@end + +@interface DOMHTMLHeadingElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@end + +@interface DOMHTMLHtmlElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *version; +@end + +@interface DOMHTMLIFrameElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property(copy) NSString *frameBorder; +@property(copy) NSString *height; +@property(copy) NSString *longDesc; +@property(copy) NSString *marginHeight; +@property(copy) NSString *marginWidth; +@property(copy) NSString *name; +@property(copy) NSString *scrolling; +@property(copy) NSString *src; +@property(copy) NSString *width; +@property(readonly, retain) DOMDocument *contentDocument; +@end + +@interface DOMHTMLImageElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *name; +@property(copy) NSString *align; +@property(copy) NSString *alt; +@property(copy) NSString *border; +@property int height; +@property int hspace; +@property BOOL isMap; +@property(copy) NSString *longDesc; +@property(copy) NSString *src; +@property(copy) NSString *useMap; +@property int vspace; +@property int width; +@property(readonly, copy) NSString *altDisplayString AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@property(readonly, copy) NSURL *absoluteImageURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMHTMLInputElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *defaultValue; +@property BOOL defaultChecked; +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *accept; +@property(copy) NSString *accessKey; +@property(copy) NSString *align; +@property(copy) NSString *alt; +@property BOOL checked; +@property BOOL disabled; +@property int maxLength; +@property(copy) NSString *name; +@property BOOL readOnly; +@property(copy) NSString *size; +@property(copy) NSString *src; +@property(copy) NSString *type; +@property(copy) NSString *useMap; +@property(copy) NSString *value; +@property(readonly, copy) NSString *altDisplayString AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@property(readonly, copy) NSURL *absoluteImageURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)select; +- (void)click; +@end + +@interface DOMHTMLIsIndexElement : DOMHTMLInputElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *prompt; +@end + +@interface DOMHTMLLIElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *type; +@property int value; +@end + +@interface DOMHTMLLabelElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *accessKey; +@property(copy) NSString *htmlFor; +@end + +@interface DOMHTMLLegendElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *accessKey; +@property(copy) NSString *align; +@end + +@interface DOMHTMLLinkElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL disabled; +@property(copy) NSString *charset; +@property(copy) NSString *href; +@property(copy) NSString *hreflang; +@property(copy) NSString *media; +@property(copy) NSString *rel; +@property(copy) NSString *rev; +@property(copy) NSString *target; +@property(copy) NSString *type; +@property(readonly, copy) NSURL *absoluteLinkURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMHTMLMapElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLCollection *areas; +@property(copy) NSString *name; +@end + +@interface DOMHTMLMarqueeElement : DOMHTMLElement WEBKIT_VERSION_3_0 +- (void)start; +- (void)stop; +@end + +@interface DOMHTMLMenuElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL compact; +@end + +@interface DOMHTMLMetaElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *content; +@property(copy) NSString *httpEquiv; +@property(copy) NSString *name; +@property(copy) NSString *scheme; +@end + +@interface DOMHTMLModElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *cite; +@property(copy) NSString *dateTime; +@end + +@interface DOMHTMLOListElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL compact; +@property int start; +@property(copy) NSString *type; +@end + +@interface DOMHTMLObjectElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *code; +@property(copy) NSString *align; +@property(copy) NSString *archive; +@property(copy) NSString *border; +@property(copy) NSString *codeBase; +@property(copy) NSString *codeType; +@property(copy) NSString *data; +@property BOOL declare; +@property(copy) NSString *height; +@property int hspace; +@property(copy) NSString *name; +@property(copy) NSString *standby; +@property(copy) NSString *type; +@property(copy) NSString *useMap; +@property int vspace; +@property(copy) NSString *width; +@property(readonly, retain) DOMDocument *contentDocument; +@property(readonly, copy) NSURL *absoluteImageURL AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMHTMLOptGroupElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL disabled; +@property(copy) NSString *label; +@end + +@interface DOMHTMLOptionElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMHTMLFormElement *form; +@property BOOL defaultSelected; +@property(readonly, copy) NSString *text; +@property(readonly) int index; +@property BOOL disabled; +@property(copy) NSString *label; +@property BOOL selected; +@property(copy) NSString *value; +@end + +@interface DOMHTMLOptionsCollection : DOMObject WEBKIT_VERSION_1_3 +@property unsigned length; +- (DOMNode *)item:(unsigned)index; +- (DOMNode *)namedItem:(NSString *)name; +@end + +@interface DOMHTMLParagraphElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@end + +@interface DOMHTMLParamElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *name; +@property(copy) NSString *type; +@property(copy) NSString *value; +@property(copy) NSString *valueType; +@end + +@interface DOMHTMLPreElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property int width; +@end + +@interface DOMHTMLQuoteElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *cite; +@end + +@interface DOMHTMLScriptElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *text; +@property(copy) NSString *htmlFor; +@property(copy) NSString *event; +@property(copy) NSString *charset; +@property BOOL defer; +@property(copy) NSString *src; +@property(copy) NSString *type; +@end + +@interface DOMHTMLSelectElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *type; +@property int selectedIndex; +@property(copy) NSString *value; +@property(readonly) int length; +@property(readonly, retain) DOMHTMLFormElement *form; +@property(readonly, retain) DOMHTMLOptionsCollection *options; +@property BOOL disabled; +@property BOOL multiple; +@property(copy) NSString *name; +@property int size; +- (void)add:(DOMHTMLElement *)element :(DOMHTMLElement *)before; +- (void)add:(DOMHTMLElement *)element before:(DOMHTMLElement *)before AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)remove:(int)index; +@end + +@interface DOMHTMLStyleElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL disabled; +@property(copy) NSString *media; +@property(copy) NSString *type; +@end + +@interface DOMHTMLTableCaptionElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@end + +@interface DOMHTMLTableCellElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly) int cellIndex; +@property(copy) NSString *abbr; +@property(copy) NSString *align; +@property(copy) NSString *axis; +@property(copy) NSString *bgColor; +@property(copy) NSString *ch; +@property(copy) NSString *chOff; +@property int colSpan; +@property(copy) NSString *headers; +@property(copy) NSString *height; +@property BOOL noWrap; +@property int rowSpan; +@property(copy) NSString *scope; +@property(copy) NSString *vAlign; +@property(copy) NSString *width; +@end + +@interface DOMHTMLTableColElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property(copy) NSString *ch; +@property(copy) NSString *chOff; +@property int span; +@property(copy) NSString *vAlign; +@property(copy) NSString *width; +@end + +@interface DOMHTMLTableElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(retain) DOMHTMLTableCaptionElement *caption; +@property(retain) DOMHTMLTableSectionElement *tHead; +@property(retain) DOMHTMLTableSectionElement *tFoot; +@property(readonly, retain) DOMHTMLCollection *rows; +@property(readonly, retain) DOMHTMLCollection *tBodies; +@property(copy) NSString *align; +@property(copy) NSString *bgColor; +@property(copy) NSString *border; +@property(copy) NSString *cellPadding; +@property(copy) NSString *cellSpacing; +@property(copy) NSString *frameBorders; +@property(copy) NSString *rules; +@property(copy) NSString *summary; +@property(copy) NSString *width; +- (DOMHTMLElement *)createTHead; +- (void)deleteTHead; +- (DOMHTMLElement *)createTFoot; +- (void)deleteTFoot; +- (DOMHTMLElement *)createCaption; +- (void)deleteCaption; +- (DOMHTMLElement *)insertRow:(int)index; +- (void)deleteRow:(int)index; +@end + +@interface DOMHTMLTableRowElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(readonly) int rowIndex; +@property(readonly) int sectionRowIndex; +@property(readonly, retain) DOMHTMLCollection *cells; +@property(copy) NSString *align; +@property(copy) NSString *bgColor; +@property(copy) NSString *ch; +@property(copy) NSString *chOff; +@property(copy) NSString *vAlign; +- (DOMHTMLElement *)insertCell:(int)index; +- (void)deleteCell:(int)index; +@end + +@interface DOMHTMLTableSectionElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *align; +@property(copy) NSString *ch; +@property(copy) NSString *chOff; +@property(copy) NSString *vAlign; +@property(readonly, retain) DOMHTMLCollection *rows; +- (DOMHTMLElement *)insertRow:(int)index; +- (void)deleteRow:(int)index; +@end + +@interface DOMHTMLTextAreaElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *defaultValue; +@property(readonly, retain) DOMHTMLFormElement *form; +@property(copy) NSString *accessKey; +@property int cols; +@property BOOL disabled; +@property(copy) NSString *name; +@property BOOL readOnly; +@property int rows; +@property(readonly, copy) NSString *type; +@property(copy) NSString *value; +- (void)select; +@end + +@interface DOMHTMLTitleElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property(copy) NSString *text; +@end + +@interface DOMHTMLUListElement : DOMHTMLElement WEBKIT_VERSION_1_3 +@property BOOL compact; +@property(copy) NSString *type; +@end + +@interface DOMStyleSheetList : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMStyleSheet *)item:(unsigned)index; +@end + +@interface DOMCSSCharsetRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *encoding; +@end + +@interface DOMCSSFontFaceRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMCSSStyleDeclaration *style; +@end + +@interface DOMCSSImportRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *href; +@property(readonly, retain) DOMMediaList *media; +@property(readonly, retain) DOMCSSStyleSheet *styleSheet; +@end + +@interface DOMCSSMediaRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMMediaList *media; +@property(readonly, retain) DOMCSSRuleList *cssRules; +- (unsigned)insertRule:(NSString *)rule :(unsigned)index; +- (unsigned)insertRule:(NSString *)rule index:(unsigned)index AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)deleteRule:(unsigned)index; +@end + +@interface DOMCSSPageRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(copy) NSString *selectorText; +@property(readonly, retain) DOMCSSStyleDeclaration *style; +@end + +@interface DOMCSSPrimitiveValue : DOMCSSValue WEBKIT_VERSION_1_3 +@property(readonly) unsigned short primitiveType; +- (void)setFloatValue:(unsigned short)unitType :(float)floatValue; +- (void)setFloatValue:(unsigned short)unitType floatValue:(float)floatValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (float)getFloatValue:(unsigned short)unitType; +- (void)setStringValue:(unsigned short)stringType :(NSString *)stringValue; +- (void)setStringValue:(unsigned short)stringType stringValue:(NSString *)stringValue AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (NSString *)getStringValue; +- (DOMCounter *)getCounterValue; +- (DOMRect *)getRectValue; +- (DOMRGBColor *)getRGBColorValue; +@end + +@interface DOMRGBColor : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMCSSPrimitiveValue *red; +@property(readonly, retain) DOMCSSPrimitiveValue *green; +@property(readonly, retain) DOMCSSPrimitiveValue *blue; +@property(readonly, retain) DOMCSSPrimitiveValue *alpha; +@property(readonly, copy) NSColor *color AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMCSSRule : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned short type; +@property(copy) NSString *cssText; +@property(readonly, retain) DOMCSSStyleSheet *parentStyleSheet; +@property(readonly, retain) DOMCSSRule *parentRule; +@end + +@interface DOMCSSRuleList : DOMObject WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMCSSRule *)item:(unsigned)index; +@end + +@interface DOMCSSStyleDeclaration : DOMObject WEBKIT_VERSION_1_3 +@property(copy) NSString *cssText; +@property(readonly) unsigned length; +@property(readonly, retain) DOMCSSRule *parentRule; +- (NSString *)getPropertyValue:(NSString *)propertyName; +- (DOMCSSValue *)getPropertyCSSValue:(NSString *)propertyName; +- (NSString *)removeProperty:(NSString *)propertyName; +- (NSString *)getPropertyPriority:(NSString *)propertyName; +- (void)setProperty:(NSString *)propertyName :(NSString *)value :(NSString *)priority; +- (void)setProperty:(NSString *)propertyName value:(NSString *)value priority:(NSString *)priority AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (NSString *)item:(unsigned)index; +- (NSString *)getPropertyShorthand:(NSString *)propertyName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (BOOL)isPropertyImplicit:(NSString *)propertyName AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +@end + +@interface DOMCSSStyleRule : DOMCSSRule WEBKIT_VERSION_1_3 +@property(copy) NSString *selectorText; +@property(readonly, retain) DOMCSSStyleDeclaration *style; +@end + +@interface DOMStyleSheet : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *type; +@property BOOL disabled; +@property(readonly, retain) DOMNode *ownerNode; +@property(readonly, retain) DOMStyleSheet *parentStyleSheet; +@property(readonly, copy) NSString *href; +@property(readonly, copy) NSString *title; +@property(readonly, retain) DOMMediaList *media; +@end + +@interface DOMCSSStyleSheet : DOMStyleSheet WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMCSSRule *ownerRule; +@property(readonly, retain) DOMCSSRuleList *cssRules; +- (unsigned)insertRule:(NSString *)rule :(unsigned)index; +- (unsigned)insertRule:(NSString *)rule index:(unsigned)index AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)deleteRule:(unsigned)index; +@end + +@interface DOMCSSValue : DOMObject WEBKIT_VERSION_1_3 +@property(copy) NSString *cssText; +@property(readonly) unsigned short cssValueType; +@end + +@interface DOMCSSValueList : DOMCSSValue WEBKIT_VERSION_1_3 +@property(readonly) unsigned length; +- (DOMCSSValue *)item:(unsigned)index; +@end + +@interface DOMCSSUnknownRule : DOMCSSRule WEBKIT_VERSION_1_3 +@end + +@interface DOMCounter : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *identifier; +@property(readonly, copy) NSString *listStyle; +@property(readonly, copy) NSString *separator; +@end + +@interface DOMRect : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMCSSPrimitiveValue *top; +@property(readonly, retain) DOMCSSPrimitiveValue *right; +@property(readonly, retain) DOMCSSPrimitiveValue *bottom; +@property(readonly, retain) DOMCSSPrimitiveValue *left; +@end + +@interface DOMEvent : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, copy) NSString *type; +@property(readonly, retain) id <DOMEventTarget> target; +@property(readonly, retain) id <DOMEventTarget> currentTarget; +@property(readonly) unsigned short eventPhase; +@property(readonly) BOOL bubbles; +@property(readonly) BOOL cancelable; +@property(readonly) DOMTimeStamp timeStamp; +- (void)stopPropagation; +- (void)preventDefault; +- (void)initEvent:(NSString *)eventTypeArg canBubbleArg:(BOOL)canBubbleArg cancelableArg:(BOOL)cancelableArg AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)initEvent:(NSString *)eventTypeArg :(BOOL)canBubbleArg :(BOOL)cancelableArg; +@end + +@interface DOMUIEvent : DOMEvent WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMAbstractView *view; +@property(readonly) int detail; +- (void)initUIEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view detail:(int)detail AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)initUIEvent:(NSString *)type :(BOOL)canBubble :(BOOL)cancelable :(DOMAbstractView *)view :(int)detail; +@end + +@interface DOMMutationEvent : DOMEvent WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMNode *relatedNode; +@property(readonly, copy) NSString *prevValue; +@property(readonly, copy) NSString *newValue; +@property(readonly, copy) NSString *attrName; +@property(readonly) unsigned short attrChange; +- (void)initMutationEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable relatedNode:(DOMNode *)relatedNode prevValue:(NSString *)prevValue newValue:(NSString *)newValue attrName:(NSString *)attrName attrChange:(unsigned short)attrChange AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)initMutationEvent:(NSString *)type :(BOOL)canBubble :(BOOL)cancelable :(DOMNode *)relatedNode :(NSString *)prevValue :(NSString *)newValue :(NSString *)attrName :(unsigned short)attrChange; +@end + +@interface DOMOverflowEvent : DOMEvent WEBKIT_VERSION_3_0 +@property(readonly) unsigned short orient; +@property(readonly) BOOL horizontalOverflow; +@property(readonly) BOOL verticalOverflow; +- (void)initOverflowEvent:(unsigned short)orient horizontalOverflow:(BOOL)horizontalOverflow verticalOverflow:(BOOL)verticalOverflow; +@end + +@interface DOMWheelEvent : DOMUIEvent WEBKIT_VERSION_3_0 +@property(readonly) int screenX; +@property(readonly) int screenY; +@property(readonly) int clientX; +@property(readonly) int clientY; +@property(readonly) BOOL ctrlKey; +@property(readonly) BOOL shiftKey; +@property(readonly) BOOL altKey; +@property(readonly) BOOL metaKey; +@property(readonly) BOOL isHorizontal; +@property(readonly) int wheelDelta; +@end + +@interface DOMKeyboardEvent : DOMUIEvent WEBKIT_VERSION_3_0 +@property(readonly, copy) NSString *keyIdentifier; +@property(readonly) unsigned keyLocation; +@property(readonly) BOOL ctrlKey; +@property(readonly) BOOL shiftKey; +@property(readonly) BOOL altKey; +@property(readonly) BOOL metaKey; +@property(readonly) int keyCode; +@property(readonly) int charCode; +- (BOOL)getModifierState:(NSString *)keyIdentifierArg; +@end + +@interface DOMMouseEvent : DOMUIEvent WEBKIT_VERSION_1_3 +@property(readonly) int screenX; +@property(readonly) int screenY; +@property(readonly) int clientX; +@property(readonly) int clientY; +@property(readonly) BOOL ctrlKey; +@property(readonly) BOOL shiftKey; +@property(readonly) BOOL altKey; +@property(readonly) BOOL metaKey; +@property(readonly) unsigned short button; +@property(readonly, retain) id <DOMEventTarget> relatedTarget; +- (void)initMouseEvent:(NSString *)type canBubble:(BOOL)canBubble cancelable:(BOOL)cancelable view:(DOMAbstractView *)view detail:(int)detail screenX:(int)screenX screenY:(int)screenY clientX:(int)clientX clientY:(int)clientY ctrlKey:(BOOL)ctrlKey altKey:(BOOL)altKey shiftKey:(BOOL)shiftKey metaKey:(BOOL)metaKey button:(unsigned short)button relatedTarget:(id <DOMEventTarget>)relatedTarget AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)initMouseEvent:(NSString *)type :(BOOL)canBubble :(BOOL)cancelable :(DOMAbstractView *)view :(int)detail :(int)screenX :(int)screenY :(int)clientX :(int)clientY :(BOOL)ctrlKey :(BOOL)altKey :(BOOL)shiftKey :(BOOL)metaKey :(unsigned short)button :(id <DOMEventTarget>)relatedTarget; +@end + +@interface DOMRange : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMNode *startContainer; +@property(readonly) int startOffset; +@property(readonly, retain) DOMNode *endContainer; +@property(readonly) int endOffset; +@property(readonly) BOOL collapsed; +@property(readonly, retain) DOMNode *commonAncestorContainer; +@property(readonly, copy) NSString *text AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)setStart:(DOMNode *)refNode offset:(int)offset AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)setStart:(DOMNode *)refNode :(int)offset; +- (void)setEnd:(DOMNode *)refNode offset:(int)offset AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)setEnd:(DOMNode *)refNode :(int)offset; +- (void)setStartBefore:(DOMNode *)refNode; +- (void)setStartAfter:(DOMNode *)refNode; +- (void)setEndBefore:(DOMNode *)refNode; +- (void)setEndAfter:(DOMNode *)refNode; +- (void)collapse:(BOOL)toStart; +- (void)selectNode:(DOMNode *)refNode; +- (void)selectNodeContents:(DOMNode *)refNode; +- (short)compareBoundaryPoints:(unsigned short)how sourceRange:(DOMRange *)sourceRange AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (short)compareBoundaryPoints:(unsigned short)how :(DOMRange *)sourceRange; +- (void)deleteContents; +- (DOMDocumentFragment *)extractContents; +- (DOMDocumentFragment *)cloneContents; +- (void)insertNode:(DOMNode *)newNode; +- (void)surroundContents:(DOMNode *)newParent; +- (DOMRange *)cloneRange; +- (NSString *)toString; +- (void)detach; +@end + +@interface DOMNodeIterator : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMNode *root; +@property(readonly) unsigned whatToShow; +@property(readonly, retain) id <DOMNodeFilter> filter; +@property(readonly) BOOL expandEntityReferences; +- (DOMNode *)nextNode; +- (DOMNode *)previousNode; +- (void)detach; +@end + +@interface DOMMediaList : DOMObject WEBKIT_VERSION_1_3 +@property(copy) NSString *mediaText; +@property(readonly) unsigned length; +- (NSString *)item:(unsigned)index; +- (void)deleteMedium:(NSString *)oldMedium; +- (void)appendMedium:(NSString *)newMedium; +@end + +@interface DOMTreeWalker : DOMObject WEBKIT_VERSION_1_3 +@property(readonly, retain) DOMNode *root; +@property(readonly) unsigned whatToShow; +@property(readonly, retain) id <DOMNodeFilter> filter; +@property(readonly) BOOL expandEntityReferences; +@property(retain) DOMNode *currentNode; +- (DOMNode *)parentNode; +- (DOMNode *)firstChild; +- (DOMNode *)lastChild; +- (DOMNode *)previousSibling; +- (DOMNode *)nextSibling; +- (DOMNode *)previousNode; +- (DOMNode *)nextNode; +@end + +@interface DOMXPathResult : DOMObject WEBKIT_VERSION_3_0 +@property(readonly) unsigned short resultType; +@property(readonly) double numberValue; +@property(readonly, copy) NSString *stringValue; +@property(readonly) BOOL booleanValue; +@property(readonly, retain) DOMNode *singleNodeValue; +@property(readonly) BOOL invalidIteratorState; +@property(readonly) unsigned snapshotLength; +- (DOMNode *)iterateNext; +- (DOMNode *)snapshotItem:(unsigned)index; +@end + +@interface DOMXPathExpression : DOMObject WEBKIT_VERSION_3_0 +- (DOMXPathResult *)evaluate:(DOMNode *)contextNode type:(unsigned short)type inResult:(DOMXPathResult *)inResult AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (DOMXPathResult *)evaluate:(DOMNode *)contextNode :(unsigned short)type :(DOMXPathResult *)inResult AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER_BUT_DEPRECATED; +@end + +// Protocols + +@protocol DOMEventListener <NSObject> WEBKIT_VERSION_1_3 +- (void)handleEvent:(DOMEvent *)evt; +@end + +@protocol DOMEventTarget <NSObject, NSCopying> WEBKIT_VERSION_1_3 +- (void)addEventListener:(NSString *)type :(id <DOMEventListener>)listener :(BOOL)useCapture; +- (void)removeEventListener:(NSString *)type :(id <DOMEventListener>)listener :(BOOL)useCapture; +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER; +- (BOOL)dispatchEvent:(DOMEvent *)event; +@end + +@protocol DOMNodeFilter <NSObject> WEBKIT_VERSION_1_3 +- (short)acceptNode:(DOMNode *)n; +@end + +@protocol DOMXPathNSResolver <NSObject> WEBKIT_VERSION_3_0 +- (NSString *)lookupNamespaceURI:(NSString *)prefix; +@end diff --git a/WebCore/bindings/objc/WebScriptObject.h b/WebCore/bindings/objc/WebScriptObject.h new file mode 100644 index 0000000..f75f458 --- /dev/null +++ b/WebCore/bindings/objc/WebScriptObject.h @@ -0,0 +1,318 @@ +/* + * Copyright (C) 2004, 2006, 2007 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. + */ + +#import <Foundation/Foundation.h> +#import <JavaScriptCore/JSBase.h> +#import <JavaScriptCore/WebKitAvailability.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_1_3 + +// NSObject (WebScripting) ----------------------------------------------------- + +/* + Classes may implement one or more methods in WebScripting to export interfaces + to WebKit's JavaScript environment. + + By default, no properties or functions are exported. A class must implement + +isKeyExcludedFromWebScript: and/or +isSelectorExcludedFromWebScript: to + expose selected properties and methods, respectively, to JavaScript. + + Access to exported properties is done using KVC -- specifically, the following + KVC methods: + + - (void)setValue:(id)value forKey:(NSString *)key + - (id)valueForKey:(NSString *)key + + Clients may also intercept property set/get operations that are made by the + scripting environment for properties that are not exported. This is done using + the KVC methods: + + - (void)setValue:(id)value forUndefinedKey:(NSString *)key + - (id)valueForUndefinedKey:(NSString *)key + + Similarly, clients may intercept method invocations that are made by the + scripting environment for methods that are not exported. This is done using + the method: + + - (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)args; + + If clients need to raise an exception in the script environment + they can call [WebScriptObject throwException:]. Note that throwing an + exception using this method will only succeed if the method that throws the exception + is being called within the scope of a script invocation. + + Not all methods are exposed. Only those methods whose parameters and return + type meets the export criteria are exposed. Valid types are Objective-C instances + and scalars. Other types are not allowed. + + Types will be converted automatically between JavaScript and Objective-C in + the following manner: + + JavaScript ObjC + ---------- ---------- + null => nil + undefined => WebUndefined + number => NSNumber + boolean => CFBoolean + string => NSString + object => id + + The object => id conversion occurs as follows: if the object wraps an underlying + Objective-C object (i.e., if it was created by a previous ObjC => JavaScript conversion), + then the underlying Objective-C object is returned. Otherwise, a new WebScriptObject + is created and returned. + + The above conversions occur only if the declared ObjC type is an object type. + For primitive types like int and char, a numeric cast is performed. + + ObjC JavaScript + ---- ---------- + NSNull => null + nil => undefined + WebUndefined => undefined + CFBoolean => boolean + NSNumber => number + NSString => string + NSArray => array object + WebScriptObject => object + + The above conversions occur only if the declared ObjC type is an object type. + For primitive type like int and char, a numeric cast is performed. +*/ +@interface NSObject (WebScripting) + +/*! + @method webScriptNameForSelector: + @param selector The selector that will be exposed to the script environment. + @discussion Use the returned string as the exported name for the selector + in the script environment. It is the responsibility of the class to ensure + uniqueness of the returned name. If nil is returned or this + method is not implemented the default name for the selector will + be used. The default name concatenates the components of the + Objective-C selector name and replaces ':' with '_'. '_' characters + are escaped with an additional '$', i.e. '_' becomes "$_". '$' are + also escaped, i.e. + Objective-C name Default script name + moveTo:: move__ + moveTo_ moveTo$_ + moveTo$_ moveTo$$$_ + @result Returns the name to be used to represent the specified selector in the + scripting environment. +*/ ++ (NSString *)webScriptNameForSelector:(SEL)selector; + +/*! + @method isSelectorExcludedFromWebScript: + @param selector The selector the will be exposed to the script environment. + @discussion Return NO to export the selector to the script environment. + Return YES to prevent the selector from being exported to the script environment. + If this method is not implemented on the class no selectors will be exported. + @result Returns YES to hide the selector, NO to export the selector. +*/ ++ (BOOL)isSelectorExcludedFromWebScript:(SEL)selector; + +/*! + @method webScriptNameForKey: + @param name The name of the instance variable that will be exposed to the + script environment. Only instance variables that meet the export criteria will + be exposed. + @discussion Provide an alternate name for a property. + @result Returns the name to be used to represent the specified property in the + scripting environment. +*/ ++ (NSString *)webScriptNameForKey:(const char *)name; + +/*! + @method isKeyExcludedFromWebScript: + @param name The name of the instance variable that will be exposed to the + script environment. + @discussion Return NO to export the property to the script environment. + Return YES to prevent the property from being exported to the script environment. + @result Returns YES to hide the property, NO to export the property. +*/ ++ (BOOL)isKeyExcludedFromWebScript:(const char *)name; + +/*! + @method invokeUndefinedMethodFromWebScript:withArguments: + @param name The name of the method to invoke. + @param arguments The arguments to pass the method. + @discussion If a script attempts to invoke a method that is not exported, + invokeUndefinedMethodFromWebScript:withArguments: will be called. + @result The return value of the invocation. The value will be converted as appropriate + for the script environment. +*/ +- (id)invokeUndefinedMethodFromWebScript:(NSString *)name withArguments:(NSArray *)arguments; + +/*! + @method invokeDefaultMethodWithArguments: + @param arguments The arguments to pass the method. + @discussion If a script attempts to call an exposed object as a function, + this method will be called. + @result The return value of the call. The value will be converted as appropriate + for the script environment. +*/ +- (id)invokeDefaultMethodWithArguments:(NSArray *)arguments; + +/*! + @method finalizeForWebScript + @discussion finalizeForScript is called on objects exposed to the script + environment just before the script environment garbage collects the object. + Subsequently, any references to WebScriptObjects made by the exposed object will + be invalid and have undefined consequences. +*/ +- (void)finalizeForWebScript; + +@end + + +// WebScriptObject -------------------------------------------------- + +@class WebScriptObjectPrivate; +@class WebFrame; + +/*! + @class WebScriptObject + @discussion WebScriptObjects are used to wrap script objects passed from + script environments to Objective-C. WebScriptObjects cannot be created + directly. In normal uses of WebKit, you gain access to the script + environment using the "windowScriptObject" method on WebView. + + The following KVC methods are commonly used to access properties of the + WebScriptObject: + + - (void)setValue:(id)value forKey:(NSString *)key + - (id)valueForKey:(NSString *)key + + As it possible to remove attributes from web script objects, the following + additional method augments the basic KVC methods: + + - (void)removeWebScriptKey:(NSString *)name; + + Also, since the sparse array access allowed in script objects doesn't map well + to NSArray, the following methods can be used to access index based properties: + + - (id)webScriptValueAtIndex:(unsigned)index; + - (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value; +*/ +@interface WebScriptObject : NSObject +{ + WebScriptObjectPrivate *_private; +} + +/*! + @method throwException: + @discussion Throws an exception in the current script execution context. + @result Either NO if an exception could not be raised, YES otherwise. +*/ ++ (BOOL)throwException:(NSString *)exceptionMessage; + +/*! + @method JSObject + @result The equivalent JSObjectRef for this WebScriptObject. + @discussion Use this method to bridge between the WebScriptObject and + JavaScriptCore APIs. +*/ +- (JSObjectRef)JSObject WEBKIT_OBJC_METHOD_ANNOTATION(AVAILABLE_WEBKIT_VERSION_3_0_AND_LATER); + +/*! + @method callWebScriptMethod:withArguments: + @param name The name of the method to call in the script environment. + @param arguments The arguments to pass to the script environment. + @discussion Calls the specified method in the script environment using the + specified arguments. + @result Returns the result of calling the script method. + Returns WebUndefined when an exception is thrown in the script environment. +*/ +- (id)callWebScriptMethod:(NSString *)name withArguments:(NSArray *)arguments; + +/*! + @method evaluateWebScript: + @param script The script to execute in the target script environment. + @discussion The script will be executed in the target script environment. The format + of the script is dependent of the target script environment. + @result Returns the result of evaluating the script in the script environment. + Returns WebUndefined when an exception is thrown in the script environment. +*/ +- (id)evaluateWebScript:(NSString *)script; + +/*! + @method removeWebScriptKey: + @param name The name of the property to remove. + @discussion Removes the property from the object in the script environment. +*/ +- (void)removeWebScriptKey:(NSString *)name; + +/*! + @method stringRepresentation + @discussion Converts the target object to a string representation. The coercion + of non string objects type is dependent on the script environment. + @result Returns the string representation of the object. +*/ +- (NSString *)stringRepresentation; + +/*! + @method webScriptValueAtIndex: + @param index The index of the property to return. + @discussion Gets the value of the property at the specified index. + @result The value of the property. Returns WebUndefined when an exception is + thrown in the script environment. +*/ +- (id)webScriptValueAtIndex:(unsigned)index; + +/*! + @method setWebScriptValueAtIndex:value: + @param index The index of the property to set. + @param value The value of the property to set. + @discussion Sets the property value at the specified index. +*/ +- (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value; + +/*! + @method setException: + @param description The description of the exception. + @discussion Raises an exception in the script environment in the context of the + current object. +*/ +- (void)setException:(NSString *)description; + +@end + + +// WebUndefined -------------------------------------------------------------- + +/*! + @class WebUndefined +*/ +@interface WebUndefined : NSObject <NSCoding, NSCopying> + +/*! + @method undefined + @result The WebUndefined shared instance. +*/ ++ (WebUndefined *)undefined; + +@end + +#endif diff --git a/WebCore/bindings/objc/WebScriptObject.mm b/WebCore/bindings/objc/WebScriptObject.mm new file mode 100644 index 0000000..6262b97 --- /dev/null +++ b/WebCore/bindings/objc/WebScriptObject.mm @@ -0,0 +1,645 @@ +/* + * Copyright (C) 2004, 2006, 2007 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 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 "config.h" +#import "WebScriptObjectPrivate.h" + +#import "Console.h" +#import "DOMInternal.h" +#import "DOMWindow.h" +#import "Frame.h" +#import "JSDOMWindow.h" +#import "JSDOMWindowCustom.h" +#import "PlatformString.h" +#import "StringSourceProvider.h" +#import "WebCoreObjCExtras.h" +#import "objc_instance.h" +#import "runtime.h" +#import "runtime_object.h" +#import "runtime_root.h" +#import <JavaScriptCore/APICast.h> +#import <runtime/ExecState.h> +#import <runtime/JSGlobalObject.h> +#import <runtime/JSLock.h> +#import <kjs/completion.h> +#import <kjs/interpreter.h> + +#ifdef BUILDING_ON_TIGER +typedef unsigned NSUInteger; +#endif + +using namespace JSC; +using namespace JSC::Bindings; +using namespace WebCore; + +namespace WebCore { + +typedef HashMap<JSObject*, NSObject*> JSWrapperMap; +static JSWrapperMap* JSWrapperCache; + +NSObject* getJSWrapper(JSObject* impl) +{ + if (!JSWrapperCache) + return nil; + return JSWrapperCache->get(impl); +} + +void addJSWrapper(NSObject* wrapper, JSObject* impl) +{ + if (!JSWrapperCache) + JSWrapperCache = new JSWrapperMap; + JSWrapperCache->set(impl, wrapper); +} + +void removeJSWrapper(JSObject* impl) +{ + if (!JSWrapperCache) + return; + JSWrapperCache->remove(impl); +} + +id createJSWrapper(JSC::JSObject* object, PassRefPtr<JSC::Bindings::RootObject> origin, PassRefPtr<JSC::Bindings::RootObject> root) +{ + if (id wrapper = getJSWrapper(object)) + return [[wrapper retain] autorelease]; + return [[[WebScriptObject alloc] _initWithJSObject:object originRootObject:origin rootObject:root] autorelease]; +} + +static void addExceptionToConsole(ExecState* exec) +{ + JSDOMWindow* window = asJSDOMWindow(exec->dynamicGlobalObject()); + if (!window || !exec->hadException()) + return; + window->impl()->console()->reportCurrentException(exec); +} + +} // namespace WebCore + +@implementation WebScriptObjectPrivate + +@end + +@implementation WebScriptObject + +#ifndef BUILDING_ON_TIGER ++ (void)initialize +{ + WebCoreObjCFinalizeOnMainThread(self); +} +#endif + ++ (id)scriptObjectForJSObject:(JSObjectRef)jsObject originRootObject:(RootObject*)originRootObject rootObject:(RootObject*)rootObject +{ + if (id domWrapper = WebCore::createDOMWrapper(toJS(jsObject), originRootObject, rootObject)) + return domWrapper; + + return WebCore::createJSWrapper(toJS(jsObject), originRootObject, rootObject); +} + +static void _didExecute(WebScriptObject *obj) +{ + ASSERT(JSLock::lockCount() > 0); + + RootObject* root = [obj _rootObject]; + if (!root) + return; + + ExecState* exec = root->globalObject()->globalExec(); + KJSDidExecuteFunctionPtr func = Instance::didExecuteFunction(); + if (func) + func(exec, root->globalObject()); +} + +- (void)_setImp:(JSObject*)imp originRootObject:(PassRefPtr<RootObject>)originRootObject rootObject:(PassRefPtr<RootObject>)rootObject +{ + // This function should only be called once, as a (possibly lazy) initializer. + ASSERT(!_private->imp); + ASSERT(!_private->rootObject); + ASSERT(!_private->originRootObject); + ASSERT(imp); + + _private->imp = imp; + _private->rootObject = rootObject.releaseRef(); + _private->originRootObject = originRootObject.releaseRef(); + + WebCore::addJSWrapper(self, imp); + + if (_private->rootObject) + _private->rootObject->gcProtect(imp); +} + +- (void)_setOriginRootObject:(PassRefPtr<RootObject>)originRootObject andRootObject:(PassRefPtr<RootObject>)rootObject +{ + ASSERT(_private->imp); + + if (rootObject) + rootObject->gcProtect(_private->imp); + + if (_private->rootObject && _private->rootObject->isValid()) + _private->rootObject->gcUnprotect(_private->imp); + + if (_private->rootObject) + _private->rootObject->deref(); + + if (_private->originRootObject) + _private->originRootObject->deref(); + + _private->rootObject = rootObject.releaseRef(); + _private->originRootObject = originRootObject.releaseRef(); +} + +- (id)_initWithJSObject:(JSC::JSObject*)imp originRootObject:(PassRefPtr<JSC::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<JSC::Bindings::RootObject>)rootObject +{ + ASSERT(imp); + + self = [super init]; + _private = [[WebScriptObjectPrivate alloc] init]; + [self _setImp:imp originRootObject:originRootObject rootObject:rootObject]; + + return self; +} + +- (JSObject*)_imp +{ + // Associate the WebScriptObject with the JS wrapper for the ObjC DOM wrapper. + // This is done on lazily, on demand. + if (!_private->imp && _private->isCreatedByDOMWrapper) + [self _initializeScriptDOMNodeImp]; + return [self _rootObject] ? _private->imp : 0; +} + +- (BOOL)_hasImp +{ + return _private->imp != nil; +} + +// Node that DOMNode overrides this method. So you should almost always +// use this method call instead of _private->rootObject directly. +- (RootObject*)_rootObject +{ + return _private->rootObject && _private->rootObject->isValid() ? _private->rootObject : 0; +} + +- (RootObject *)_originRootObject +{ + return _private->originRootObject && _private->originRootObject->isValid() ? _private->originRootObject : 0; +} + +- (BOOL)_isSafeScript +{ + RootObject *root = [self _rootObject]; + if (!root) + return false; + + if (!_private->originRootObject) + return true; + + if (!_private->originRootObject->isValid()) + return false; + + return root->globalObject()->allowsAccessFrom(_private->originRootObject->globalObject()); +} + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([WebScriptObject class], self)) + return; + + if (_private->imp) + WebCore::removeJSWrapper(_private->imp); + + if (_private->rootObject && _private->rootObject->isValid()) + _private->rootObject->gcUnprotect(_private->imp); + + if (_private->rootObject) + _private->rootObject->deref(); + + if (_private->originRootObject) + _private->originRootObject->deref(); + + [_private release]; + + [super dealloc]; +} + +- (void)finalize +{ + if (_private->imp) + WebCore::removeJSWrapper(_private->imp); + + if (_private->rootObject && _private->rootObject->isValid()) + _private->rootObject->gcUnprotect(_private->imp); + + if (_private->rootObject) + _private->rootObject->deref(); + + if (_private->originRootObject) + _private->originRootObject->deref(); + + [super finalize]; +} + ++ (BOOL)throwException:(NSString *)exceptionMessage +{ + ObjcInstance::setGlobalException(exceptionMessage); + return YES; +} + +static void getListFromNSArray(ExecState *exec, NSArray *array, RootObject* rootObject, ArgList& aList) +{ + int i, numObjects = array ? [array count] : 0; + + for (i = 0; i < numObjects; i++) { + id anObject = [array objectAtIndex:i]; + aList.append(convertObjcValueToValue(exec, &anObject, ObjcObjectType, rootObject)); + } +} + +- (id)callWebScriptMethod:(NSString *)name withArguments:(NSArray *)args +{ + if (![self _isSafeScript]) + return nil; + + JSLock lock(false); + + // Look up the function object. + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSValue* function = [self _imp]->get(exec, Identifier(exec, String(name))); + CallData callData; + CallType callType = function->getCallData(callData); + if (callType == CallTypeNone) + return nil; + + ArgList argList; + getListFromNSArray(exec, args, [self _rootObject], argList); + + if (![self _isSafeScript]) + return nil; + + [self _rootObject]->globalObject()->startTimeoutCheck(); + JSValue* result = call(exec, function, callType, callData, [self _imp], argList); + [self _rootObject]->globalObject()->stopTimeoutCheck(); + + if (exec->hadException()) { + addExceptionToConsole(exec); + result = jsUndefined(); + exec->clearException(); + } + + // Convert and return the result of the function call. + id resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; + + _didExecute(self); + + return resultObj; +} + +- (id)evaluateWebScript:(NSString *)script +{ + if (![self _isSafeScript]) + return nil; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSValue* result; + JSLock lock(false); + + [self _rootObject]->globalObject()->startTimeoutCheck(); + Completion completion = Interpreter::evaluate([self _rootObject]->globalObject()->globalExec(), [self _rootObject]->globalObject()->globalScopeChain(), makeSource(String(script))); + [self _rootObject]->globalObject()->stopTimeoutCheck(); + ComplType type = completion.complType(); + + if (type == Normal) { + result = completion.value(); + if (!result) + result = jsUndefined(); + } else + result = jsUndefined(); + + if (exec->hadException()) { + addExceptionToConsole(exec); + result = jsUndefined(); + exec->clearException(); + } + + id resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; + + _didExecute(self); + + return resultObj; +} + +- (void)setValue:(id)value forKey:(NSString *)key +{ + if (![self _isSafeScript]) + return; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSLock lock(false); + + PutPropertySlot slot; + [self _imp]->put(exec, Identifier(exec, String(key)), convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject]), slot); + + if (exec->hadException()) { + addExceptionToConsole(exec); + exec->clearException(); + } + + _didExecute(self); +} + +- (id)valueForKey:(NSString *)key +{ + if (![self _isSafeScript]) + return nil; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + id resultObj; + { + // Need to scope this lock to ensure that we release the lock before calling + // [super valueForKey:key] which might throw an exception and bypass the JSLock destructor, + // leaving the lock permanently held + JSLock lock(false); + + JSValue* result = [self _imp]->get(exec, Identifier(exec, String(key))); + + if (exec->hadException()) { + addExceptionToConsole(exec); + result = jsUndefined(); + exec->clearException(); + } + + resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; + } + + if ([resultObj isKindOfClass:[WebUndefined class]]) + resultObj = [super valueForKey:key]; // defaults to throwing an exception + + JSLock lock(false); + _didExecute(self); + + return resultObj; +} + +- (void)removeWebScriptKey:(NSString *)key +{ + if (![self _isSafeScript]) + return; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSLock lock(false); + [self _imp]->deleteProperty(exec, Identifier(exec, String(key))); + + if (exec->hadException()) { + addExceptionToConsole(exec); + exec->clearException(); + } + + _didExecute(self); +} + +- (NSString *)stringRepresentation +{ + if (![self _isSafeScript]) + // This is a workaround for a gcc 3.3 internal compiler error. + return @"Undefined"; + + JSLock lock(false); + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + + id result = convertValueToObjcValue(exec, [self _imp], ObjcObjectType).objectValue; + + NSString *description = [result description]; + + _didExecute(self); + + return description; +} + +- (id)webScriptValueAtIndex:(unsigned)index +{ + if (![self _isSafeScript]) + return nil; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSLock lock(false); + JSValue* result = [self _imp]->get(exec, index); + + if (exec->hadException()) { + addExceptionToConsole(exec); + result = jsUndefined(); + exec->clearException(); + } + + id resultObj = [WebScriptObject _convertValueToObjcValue:result originRootObject:[self _originRootObject] rootObject:[self _rootObject]]; + + _didExecute(self); + + return resultObj; +} + +- (void)setWebScriptValueAtIndex:(unsigned)index value:(id)value +{ + if (![self _isSafeScript]) + return; + + ExecState* exec = [self _rootObject]->globalObject()->globalExec(); + ASSERT(!exec->hadException()); + + JSLock lock(false); + [self _imp]->put(exec, index, convertObjcValueToValue(exec, &value, ObjcObjectType, [self _rootObject])); + + if (exec->hadException()) { + addExceptionToConsole(exec); + exec->clearException(); + } + + _didExecute(self); +} + +- (void)setException:(NSString *)description +{ + if (![self _rootObject]) + return; + ObjcInstance::setGlobalException(description, [self _rootObject]->globalObject()); +} + +- (JSObjectRef)JSObject +{ + if (![self _isSafeScript]) + return NULL; + + return toRef([self _imp]); +} + ++ (id)_convertValueToObjcValue:(JSValue*)value originRootObject:(RootObject*)originRootObject rootObject:(RootObject*)rootObject +{ + if (value->isObject()) { + JSObject* object = asObject(value); + ExecState* exec = rootObject->globalObject()->globalExec(); + JSLock lock(false); + + if (object->classInfo() != &RuntimeObjectImp::s_info) { + JSValue* runtimeObject = object->get(exec, Identifier(exec, "__apple_runtime_object")); + if (runtimeObject && runtimeObject->isObject()) + object = asObject(runtimeObject); + } + + if (object->classInfo() == &RuntimeObjectImp::s_info) { + RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(object); + ObjcInstance *instance = static_cast<ObjcInstance*>(imp->getInternalInstance()); + if (instance) + return instance->getObject(); + return nil; + } + + return [WebScriptObject scriptObjectForJSObject:toRef(object) originRootObject:originRootObject rootObject:rootObject]; + } + + if (value->isString()) { + const UString& u = asString(value)->value(); + return [NSString stringWithCharacters:u.data() length:u.size()]; + } + + if (value->isNumber()) + return [NSNumber numberWithDouble:value->getNumber()]; + + if (value->isBoolean()) + return [NSNumber numberWithBool:value->getBoolean()]; + + if (value->isUndefined()) + return [WebUndefined undefined]; + + // jsNull is not returned as NSNull because existing applications do not expect + // that return value. Return as nil for compatibility. <rdar://problem/4651318> <rdar://problem/4701626> + // Other types (e.g., UnspecifiedType) also return as nil. + return nil; +} + +@end + +@interface WebScriptObject (WebKitCocoaBindings) + +- (id)objectAtIndex:(unsigned)index; + +@end + +@implementation WebScriptObject (WebKitCocoaBindings) + +#if 0 +// FIXME: presence of 'count' method on WebScriptObject breaks Democracy player +// http://bugs.webkit.org/show_bug.cgi?id=13129 + +- (unsigned)count +{ + id length = [self valueForKey:@"length"]; + if ([length respondsToSelector:@selector(intValue)]) + return [length intValue]; + else + return 0; +} + +#endif + +- (id)objectAtIndex:(unsigned)index +{ + return [self webScriptValueAtIndex:index]; +} + +@end + +@implementation WebUndefined + ++ (id)allocWithZone:(NSZone *)zone +{ + static WebUndefined *sharedUndefined = 0; + if (!sharedUndefined) + sharedUndefined = [super allocWithZone:NULL]; + return sharedUndefined; +} + +- (NSString *)description +{ + return @"undefined"; +} + +- (id)initWithCoder:(NSCoder *)coder +{ + return self; +} + +- (void)encodeWithCoder:(NSCoder *)encoder +{ +} + +- (id)copyWithZone:(NSZone *)zone +{ + return self; +} + +- (id)retain +{ + return self; +} + +- (void)release +{ +} + +- (NSUInteger)retainCount +{ + return UINT_MAX; +} + +- (id)autorelease +{ + return self; +} + +- (void)dealloc +{ + ASSERT(false); + return; + [super dealloc]; // make -Wdealloc-check happy +} + ++ (WebUndefined *)undefined +{ + return [WebUndefined allocWithZone:NULL]; +} + +@end + diff --git a/WebCore/bindings/objc/WebScriptObjectPrivate.h b/WebCore/bindings/objc/WebScriptObjectPrivate.h new file mode 100644 index 0000000..569d6f6 --- /dev/null +++ b/WebCore/bindings/objc/WebScriptObjectPrivate.h @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007 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. + */ + +#ifndef _WEB_SCRIPT_OBJECT_PRIVATE_H_ +#define _WEB_SCRIPT_OBJECT_PRIVATE_H_ + +#import "WebScriptObject.h" +#import <runtime/JSValue.h> +#import <wtf/PassRefPtr.h> + +namespace JSC { + + class JSObject; + + namespace Bindings { + class RootObject; + } +} +namespace WebCore { + NSObject* getJSWrapper(JSC::JSObject*); + void addJSWrapper(NSObject* wrapper, JSC::JSObject*); + void removeJSWrapper(JSC::JSObject*); + id createJSWrapper(JSC::JSObject*, PassRefPtr<JSC::Bindings::RootObject> origin, PassRefPtr<JSC::Bindings::RootObject> root); +} + +@interface WebScriptObject (Private) ++ (id)_convertValueToObjcValue:(JSC::JSValue*)value originRootObject:(JSC::Bindings::RootObject*)originRootObject rootObject:(JSC::Bindings::RootObject*)rootObject; ++ (id)scriptObjectForJSObject:(JSObjectRef)jsObject originRootObject:(JSC::Bindings::RootObject*)originRootObject rootObject:(JSC::Bindings::RootObject*)rootObject; +- (id)_init; +- (id)_initWithJSObject:(JSC::JSObject*)imp originRootObject:(PassRefPtr<JSC::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<JSC::Bindings::RootObject>)rootObject; +- (void)_setImp:(JSC::JSObject*)imp originRootObject:(PassRefPtr<JSC::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<JSC::Bindings::RootObject>)rootObject; +- (void)_setOriginRootObject:(PassRefPtr<JSC::Bindings::RootObject>)originRootObject andRootObject:(PassRefPtr<JSC::Bindings::RootObject>)rootObject; +- (void)_initializeScriptDOMNodeImp; +- (JSC::JSObject *)_imp; +- (BOOL)_hasImp; +- (JSC::Bindings::RootObject*)_rootObject; +- (JSC::Bindings::RootObject*)_originRootObject; +@end + +@interface WebScriptObjectPrivate : NSObject +{ +@public + JSC::JSObject *imp; + JSC::Bindings::RootObject* rootObject; + JSC::Bindings::RootObject* originRootObject; + BOOL isCreatedByDOMWrapper; +} +@end + + +#endif |