kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 2 | * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
ddkilzer | a7bfea3 | 2006-06-24 20:51:21 +0000 | [diff] [blame] | 3 | * Copyright (C) 2006 James G. Speth (speth@end.com) |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 4 | * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: |
darin | 8d1badc | 2006-03-06 16:50:13 +0000 | [diff] [blame] | 9 | * 1. Redistributions of source code must retain the above copyright |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 10 | * notice, this list of conditions and the following disclaimer. |
| 11 | * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer in the |
| 13 | * documentation and/or other materials provided with the distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 16 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 19 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 22 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 25 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
darin | bbe6466 | 2006-01-16 17:52:23 +0000 | [diff] [blame] | 28 | #import "config.h" |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 29 | #import "DOMInternal.h" // import first to make the private/public trick work |
kocienda | 49ed539 | 2004-03-11 23:37:58 +0000 | [diff] [blame] | 30 | #import "DOM.h" |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 31 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 32 | #import "DOMElementInternal.h" |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 33 | #import "DOMHTMLCanvasElement.h" |
darin@apple.com | 3a3edd4 | 2009-08-19 00:17:59 +0000 | [diff] [blame] | 34 | #import "DOMNodeInternal.h" |
antti@apple.com | 1129eec | 2009-10-06 19:13:55 +0000 | [diff] [blame] | 35 | #import "DOMPrivate.h" |
darin@apple.com | 3a3edd4 | 2009-08-19 00:17:59 +0000 | [diff] [blame] | 36 | #import "DOMRangeInternal.h" |
mrowe@apple.com | fc8aa69 | 2009-03-09 03:44:38 +0000 | [diff] [blame] | 37 | #import "Frame.h" |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 38 | #import "HTMLElement.h" |
darin@apple.com | 3a3edd4 | 2009-08-19 00:17:59 +0000 | [diff] [blame] | 39 | #import "HTMLNames.h" |
darin@apple.com | 7b7981b | 2010-10-01 00:04:02 +0000 | [diff] [blame] | 40 | #import "HTMLParserIdioms.h" |
mrowe@apple.com | d48fd2e | 2010-03-08 01:52:22 +0000 | [diff] [blame] | 41 | #import "Image.h" |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 42 | #import "NodeFilter.h" |
darin@apple.com | 3a3edd4 | 2009-08-19 00:17:59 +0000 | [diff] [blame] | 43 | #import "RenderImage.h" |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 44 | #import "WebScriptObjectPrivate.h" |
weinig | ac93628 | 2006-09-29 20:29:16 +0000 | [diff] [blame] | 45 | #import <wtf/HashMap.h> |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 46 | |
ddkilzer@apple.com | 28c34e3 | 2009-04-09 16:33:15 +0000 | [diff] [blame] | 47 | #if ENABLE(SVG_DOM_OBJC_BINDINGS) |
eseidel | baf9f6b | 2007-10-23 03:49:17 +0000 | [diff] [blame] | 48 | #import "DOMSVG.h" |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 49 | #import "SVGElementInstance.h" |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 50 | #import "SVGNames.h" |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 51 | #endif |
darin | 8d1badc | 2006-03-06 16:50:13 +0000 | [diff] [blame] | 52 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 53 | using namespace JSC; |
darin@apple.com | e4f9a66 | 2008-02-08 10:35:20 +0000 | [diff] [blame] | 54 | using namespace WebCore; |
| 55 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 56 | // FIXME: Would be nice to break this up into separate files to match how other WebKit |
| 57 | // code is organized. |
| 58 | |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 59 | //------------------------------------------------------------------------------------------ |
kocienda | f9c26e6 | 2004-03-03 00:42:49 +0000 | [diff] [blame] | 60 | // DOMNode |
| 61 | |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 62 | namespace WebCore { |
| 63 | |
sullivan | 70d4764 | 2006-10-11 23:15:18 +0000 | [diff] [blame] | 64 | typedef HashMap<const QualifiedName::QualifiedNameImpl*, Class> ObjCClassMap; |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 65 | static ObjCClassMap* elementClassMap; |
| 66 | |
| 67 | static void addElementClass(const QualifiedName& tag, Class objCClass) |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 68 | { |
sullivan | 70d4764 | 2006-10-11 23:15:18 +0000 | [diff] [blame] | 69 | elementClassMap->set(tag.impl(), objCClass); |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 70 | } |
| 71 | |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 72 | static void createElementClassMap() |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 73 | { |
| 74 | // Create the table. |
| 75 | elementClassMap = new ObjCClassMap; |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 76 | |
| 77 | // FIXME: Reflect marquee once the API has been determined. |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 78 | |
| 79 | // Populate it with HTML and SVG element classes. |
| 80 | addElementClass(HTMLNames::aTag, [DOMHTMLAnchorElement class]); |
| 81 | addElementClass(HTMLNames::appletTag, [DOMHTMLAppletElement class]); |
| 82 | addElementClass(HTMLNames::areaTag, [DOMHTMLAreaElement class]); |
| 83 | addElementClass(HTMLNames::baseTag, [DOMHTMLBaseElement class]); |
| 84 | addElementClass(HTMLNames::basefontTag, [DOMHTMLBaseFontElement class]); |
| 85 | addElementClass(HTMLNames::bodyTag, [DOMHTMLBodyElement class]); |
| 86 | addElementClass(HTMLNames::brTag, [DOMHTMLBRElement class]); |
| 87 | addElementClass(HTMLNames::buttonTag, [DOMHTMLButtonElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 88 | addElementClass(HTMLNames::canvasTag, [DOMHTMLCanvasElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 89 | addElementClass(HTMLNames::captionTag, [DOMHTMLTableCaptionElement class]); |
| 90 | addElementClass(HTMLNames::colTag, [DOMHTMLTableColElement class]); |
| 91 | addElementClass(HTMLNames::colgroupTag, [DOMHTMLTableColElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 92 | addElementClass(HTMLNames::delTag, [DOMHTMLModElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 93 | addElementClass(HTMLNames::dirTag, [DOMHTMLDirectoryElement class]); |
| 94 | addElementClass(HTMLNames::divTag, [DOMHTMLDivElement class]); |
| 95 | addElementClass(HTMLNames::dlTag, [DOMHTMLDListElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 96 | addElementClass(HTMLNames::embedTag, [DOMHTMLEmbedElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 97 | addElementClass(HTMLNames::fieldsetTag, [DOMHTMLFieldSetElement class]); |
| 98 | addElementClass(HTMLNames::fontTag, [DOMHTMLFontElement class]); |
| 99 | addElementClass(HTMLNames::formTag, [DOMHTMLFormElement class]); |
| 100 | addElementClass(HTMLNames::frameTag, [DOMHTMLFrameElement class]); |
| 101 | addElementClass(HTMLNames::framesetTag, [DOMHTMLFrameSetElement class]); |
| 102 | addElementClass(HTMLNames::h1Tag, [DOMHTMLHeadingElement class]); |
| 103 | addElementClass(HTMLNames::h2Tag, [DOMHTMLHeadingElement class]); |
| 104 | addElementClass(HTMLNames::h3Tag, [DOMHTMLHeadingElement class]); |
| 105 | addElementClass(HTMLNames::h4Tag, [DOMHTMLHeadingElement class]); |
| 106 | addElementClass(HTMLNames::h5Tag, [DOMHTMLHeadingElement class]); |
| 107 | addElementClass(HTMLNames::h6Tag, [DOMHTMLHeadingElement class]); |
| 108 | addElementClass(HTMLNames::headTag, [DOMHTMLHeadElement class]); |
| 109 | addElementClass(HTMLNames::hrTag, [DOMHTMLHRElement class]); |
| 110 | addElementClass(HTMLNames::htmlTag, [DOMHTMLHtmlElement class]); |
| 111 | addElementClass(HTMLNames::iframeTag, [DOMHTMLIFrameElement class]); |
| 112 | addElementClass(HTMLNames::imgTag, [DOMHTMLImageElement class]); |
| 113 | addElementClass(HTMLNames::inputTag, [DOMHTMLInputElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 114 | addElementClass(HTMLNames::insTag, [DOMHTMLModElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 115 | addElementClass(HTMLNames::isindexTag, [DOMHTMLIsIndexElement class]); |
| 116 | addElementClass(HTMLNames::labelTag, [DOMHTMLLabelElement class]); |
| 117 | addElementClass(HTMLNames::legendTag, [DOMHTMLLegendElement class]); |
| 118 | addElementClass(HTMLNames::liTag, [DOMHTMLLIElement class]); |
| 119 | addElementClass(HTMLNames::linkTag, [DOMHTMLLinkElement class]); |
| 120 | addElementClass(HTMLNames::listingTag, [DOMHTMLPreElement class]); |
| 121 | addElementClass(HTMLNames::mapTag, [DOMHTMLMapElement class]); |
weinig | 40d22ab | 2007-05-23 01:26:00 +0000 | [diff] [blame] | 122 | addElementClass(HTMLNames::marqueeTag, [DOMHTMLMarqueeElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 123 | addElementClass(HTMLNames::menuTag, [DOMHTMLMenuElement class]); |
| 124 | addElementClass(HTMLNames::metaTag, [DOMHTMLMetaElement class]); |
| 125 | addElementClass(HTMLNames::objectTag, [DOMHTMLObjectElement class]); |
| 126 | addElementClass(HTMLNames::olTag, [DOMHTMLOListElement class]); |
| 127 | addElementClass(HTMLNames::optgroupTag, [DOMHTMLOptGroupElement class]); |
| 128 | addElementClass(HTMLNames::optionTag, [DOMHTMLOptionElement class]); |
| 129 | addElementClass(HTMLNames::pTag, [DOMHTMLParagraphElement class]); |
| 130 | addElementClass(HTMLNames::paramTag, [DOMHTMLParamElement class]); |
| 131 | addElementClass(HTMLNames::preTag, [DOMHTMLPreElement class]); |
| 132 | addElementClass(HTMLNames::qTag, [DOMHTMLQuoteElement class]); |
| 133 | addElementClass(HTMLNames::scriptTag, [DOMHTMLScriptElement class]); |
kdecker | b42fb66 | 2007-03-06 22:38:17 +0000 | [diff] [blame] | 134 | addElementClass(HTMLNames::keygenTag, [DOMHTMLSelectElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 135 | addElementClass(HTMLNames::selectTag, [DOMHTMLSelectElement class]); |
| 136 | addElementClass(HTMLNames::styleTag, [DOMHTMLStyleElement class]); |
| 137 | addElementClass(HTMLNames::tableTag, [DOMHTMLTableElement class]); |
| 138 | addElementClass(HTMLNames::tbodyTag, [DOMHTMLTableSectionElement class]); |
| 139 | addElementClass(HTMLNames::tdTag, [DOMHTMLTableCellElement class]); |
| 140 | addElementClass(HTMLNames::textareaTag, [DOMHTMLTextAreaElement class]); |
| 141 | addElementClass(HTMLNames::tfootTag, [DOMHTMLTableSectionElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 142 | addElementClass(HTMLNames::thTag, [DOMHTMLTableCellElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 143 | addElementClass(HTMLNames::theadTag, [DOMHTMLTableSectionElement class]); |
| 144 | addElementClass(HTMLNames::titleTag, [DOMHTMLTitleElement class]); |
| 145 | addElementClass(HTMLNames::trTag, [DOMHTMLTableRowElement class]); |
| 146 | addElementClass(HTMLNames::ulTag, [DOMHTMLUListElement class]); |
darin | 4547111 | 2007-03-13 00:49:02 +0000 | [diff] [blame] | 147 | addElementClass(HTMLNames::xmpTag, [DOMHTMLPreElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 148 | |
ddkilzer@apple.com | 28c34e3 | 2009-04-09 16:33:15 +0000 | [diff] [blame] | 149 | #if ENABLE(SVG_DOM_OBJC_BINDINGS) |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 150 | addElementClass(SVGNames::aTag, [DOMSVGAElement class]); |
mjs@apple.com | 283503e | 2008-03-24 05:36:30 +0000 | [diff] [blame] | 151 | addElementClass(SVGNames::altGlyphTag, [DOMSVGAltGlyphElement class]); |
oliver@apple.com | 22b1ad9 | 2007-12-09 00:27:57 +0000 | [diff] [blame] | 152 | #if ENABLE(SVG_ANIMATION) |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 153 | addElementClass(SVGNames::animateTag, [DOMSVGAnimateElement class]); |
| 154 | addElementClass(SVGNames::animateColorTag, [DOMSVGAnimateColorElement class]); |
| 155 | addElementClass(SVGNames::animateTransformTag, [DOMSVGAnimateTransformElement class]); |
antti@apple.com | 39ef7d1 | 2008-04-11 20:33:29 +0000 | [diff] [blame] | 156 | addElementClass(SVGNames::setTag, [DOMSVGSetElement class]); |
mjs | d2948ef | 2007-02-26 19:29:04 +0000 | [diff] [blame] | 157 | #endif |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 158 | addElementClass(SVGNames::circleTag, [DOMSVGCircleElement class]); |
| 159 | addElementClass(SVGNames::clipPathTag, [DOMSVGClipPathElement class]); |
| 160 | addElementClass(SVGNames::cursorTag, [DOMSVGCursorElement class]); |
zimmermann@webkit.org | fe31d2d | 2007-12-23 12:30:24 +0000 | [diff] [blame] | 161 | addElementClass(SVGNames::defsTag, [DOMSVGDefsElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 162 | addElementClass(SVGNames::descTag, [DOMSVGDescElement class]); |
| 163 | addElementClass(SVGNames::ellipseTag, [DOMSVGEllipseElement class]); |
krit@webkit.org | bfb80bf | 2009-05-28 22:10:29 +0000 | [diff] [blame] | 164 | #if ENABLE(FILTERS) |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 165 | addElementClass(SVGNames::feBlendTag, [DOMSVGFEBlendElement class]); |
| 166 | addElementClass(SVGNames::feColorMatrixTag, [DOMSVGFEColorMatrixElement class]); |
| 167 | addElementClass(SVGNames::feComponentTransferTag, [DOMSVGFEComponentTransferElement class]); |
| 168 | addElementClass(SVGNames::feCompositeTag, [DOMSVGFECompositeElement class]); |
zherczeg@webkit.org | e4b0f76 | 2010-06-29 07:05:58 +0000 | [diff] [blame] | 169 | addElementClass(SVGNames::feConvolveMatrixTag, [DOMSVGFEConvolveMatrixElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 170 | addElementClass(SVGNames::feDiffuseLightingTag, [DOMSVGFEDiffuseLightingElement class]); |
| 171 | addElementClass(SVGNames::feDisplacementMapTag, [DOMSVGFEDisplacementMapElement class]); |
| 172 | addElementClass(SVGNames::feDistantLightTag, [DOMSVGFEDistantLightElement class]); |
| 173 | addElementClass(SVGNames::feFloodTag, [DOMSVGFEFloodElement class]); |
| 174 | addElementClass(SVGNames::feFuncATag, [DOMSVGFEFuncAElement class]); |
| 175 | addElementClass(SVGNames::feFuncBTag, [DOMSVGFEFuncBElement class]); |
| 176 | addElementClass(SVGNames::feFuncGTag, [DOMSVGFEFuncGElement class]); |
| 177 | addElementClass(SVGNames::feFuncRTag, [DOMSVGFEFuncRElement class]); |
| 178 | addElementClass(SVGNames::feGaussianBlurTag, [DOMSVGFEGaussianBlurElement class]); |
| 179 | addElementClass(SVGNames::feImageTag, [DOMSVGFEImageElement class]); |
| 180 | addElementClass(SVGNames::feMergeTag, [DOMSVGFEMergeElement class]); |
| 181 | addElementClass(SVGNames::feMergeNodeTag, [DOMSVGFEMergeNodeElement class]); |
krit@webkit.org | 5a9a31f | 2009-10-09 19:13:55 +0000 | [diff] [blame] | 182 | addElementClass(SVGNames::feMorphologyTag, [DOMSVGFEMorphologyElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 183 | addElementClass(SVGNames::feOffsetTag, [DOMSVGFEOffsetElement class]); |
| 184 | addElementClass(SVGNames::fePointLightTag, [DOMSVGFEPointLightElement class]); |
| 185 | addElementClass(SVGNames::feSpecularLightingTag, [DOMSVGFESpecularLightingElement class]); |
| 186 | addElementClass(SVGNames::feSpotLightTag, [DOMSVGFESpotLightElement class]); |
| 187 | addElementClass(SVGNames::feTileTag, [DOMSVGFETileElement class]); |
| 188 | addElementClass(SVGNames::feTurbulenceTag, [DOMSVGFETurbulenceElement class]); |
| 189 | addElementClass(SVGNames::filterTag, [DOMSVGFilterElement class]); |
mjs | d2948ef | 2007-02-26 19:29:04 +0000 | [diff] [blame] | 190 | #endif |
oliver@apple.com | 22b1ad9 | 2007-12-09 00:27:57 +0000 | [diff] [blame] | 191 | #if ENABLE(SVG_FONTS) |
zimmermann@webkit.org | ce57f04 | 2007-12-29 02:41:53 +0000 | [diff] [blame] | 192 | addElementClass(SVGNames::fontTag, [DOMSVGFontElement class]); |
eseidel | baf9f6b | 2007-10-23 03:49:17 +0000 | [diff] [blame] | 193 | addElementClass(SVGNames::font_faceTag, [DOMSVGFontFaceElement class]); |
| 194 | addElementClass(SVGNames::font_face_formatTag, [DOMSVGFontFaceFormatElement class]); |
| 195 | addElementClass(SVGNames::font_face_nameTag, [DOMSVGFontFaceNameElement class]); |
| 196 | addElementClass(SVGNames::font_face_srcTag, [DOMSVGFontFaceSrcElement class]); |
| 197 | addElementClass(SVGNames::font_face_uriTag, [DOMSVGFontFaceUriElement class]); |
zimmermann@webkit.org | ce57f04 | 2007-12-29 02:41:53 +0000 | [diff] [blame] | 198 | addElementClass(SVGNames::glyphTag, [DOMSVGGlyphElement class]); |
oliver@apple.com | 22b1ad9 | 2007-12-09 00:27:57 +0000 | [diff] [blame] | 199 | #endif |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 200 | addElementClass(SVGNames::gTag, [DOMSVGGElement class]); |
| 201 | addElementClass(SVGNames::imageTag, [DOMSVGImageElement class]); |
| 202 | addElementClass(SVGNames::lineTag, [DOMSVGLineElement class]); |
| 203 | addElementClass(SVGNames::linearGradientTag, [DOMSVGLinearGradientElement class]); |
| 204 | addElementClass(SVGNames::markerTag, [DOMSVGMarkerElement class]); |
| 205 | addElementClass(SVGNames::maskTag, [DOMSVGMaskElement class]); |
| 206 | addElementClass(SVGNames::metadataTag, [DOMSVGMetadataElement class]); |
zimmermann@webkit.org | ce57f04 | 2007-12-29 02:41:53 +0000 | [diff] [blame] | 207 | #if ENABLE(SVG_FONTS) |
| 208 | addElementClass(SVGNames::missing_glyphTag, [DOMSVGMissingGlyphElement class]); |
| 209 | #endif |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 210 | addElementClass(SVGNames::pathTag, [DOMSVGPathElement class]); |
| 211 | addElementClass(SVGNames::patternTag, [DOMSVGPatternElement class]); |
| 212 | addElementClass(SVGNames::polygonTag, [DOMSVGPolygonElement class]); |
| 213 | addElementClass(SVGNames::polylineTag, [DOMSVGPolylineElement class]); |
| 214 | addElementClass(SVGNames::radialGradientTag, [DOMSVGRadialGradientElement class]); |
| 215 | addElementClass(SVGNames::rectTag, [DOMSVGRectElement class]); |
| 216 | addElementClass(SVGNames::scriptTag, [DOMSVGScriptElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 217 | addElementClass(SVGNames::stopTag, [DOMSVGStopElement class]); |
| 218 | addElementClass(SVGNames::styleTag, [DOMSVGStyleElement class]); |
| 219 | addElementClass(SVGNames::svgTag, [DOMSVGSVGElement class]); |
| 220 | addElementClass(SVGNames::switchTag, [DOMSVGSwitchElement class]); |
| 221 | addElementClass(SVGNames::symbolTag, [DOMSVGSymbolElement class]); |
| 222 | addElementClass(SVGNames::textTag, [DOMSVGTextElement class]); |
| 223 | addElementClass(SVGNames::titleTag, [DOMSVGTitleElement class]); |
| 224 | addElementClass(SVGNames::trefTag, [DOMSVGTRefElement class]); |
| 225 | addElementClass(SVGNames::tspanTag, [DOMSVGTSpanElement class]); |
oliver | 25a9ee8 | 2007-10-12 13:18:43 +0000 | [diff] [blame] | 226 | addElementClass(SVGNames::textPathTag, [DOMSVGTextPathElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 227 | addElementClass(SVGNames::useTag, [DOMSVGUseElement class]); |
| 228 | addElementClass(SVGNames::viewTag, [DOMSVGViewElement class]); |
| 229 | #endif |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 230 | } |
| 231 | |
oliver | e36c406 | 2007-10-12 14:07:59 +0000 | [diff] [blame] | 232 | static Class lookupElementClass(const QualifiedName& tag) |
| 233 | { |
| 234 | // Do a special lookup to ignore element prefixes |
| 235 | if (tag.hasPrefix()) |
| 236 | return elementClassMap->get(QualifiedName(nullAtom, tag.localName(), tag.namespaceURI()).impl()); |
| 237 | |
| 238 | return elementClassMap->get(tag.impl()); |
| 239 | } |
| 240 | |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 241 | static Class elementClass(const QualifiedName& tag, Class defaultClass) |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 242 | { |
| 243 | if (!elementClassMap) |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 244 | createElementClassMap(); |
oliver | e36c406 | 2007-10-12 14:07:59 +0000 | [diff] [blame] | 245 | Class objcClass = lookupElementClass(tag); |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 246 | if (!objcClass) |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 247 | objcClass = defaultClass; |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 248 | return objcClass; |
| 249 | } |
| 250 | |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 251 | static NSArray *kit(const Vector<IntRect>& rects) |
| 252 | { |
| 253 | size_t size = rects.size(); |
| 254 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:size]; |
| 255 | for (size_t i = 0; i < size; ++i) |
| 256 | [array addObject:[NSValue valueWithRect:rects[i]]]; |
| 257 | return array; |
| 258 | } |
| 259 | |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 260 | } // namespace WebCore |
| 261 | |
kocienda | f9c26e6 | 2004-03-03 00:42:49 +0000 | [diff] [blame] | 262 | @implementation DOMNode (WebCoreInternal) |
kocienda | 03a86c7 | 2004-02-26 19:16:09 +0000 | [diff] [blame] | 263 | |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 264 | - (NSString *)description |
| 265 | { |
weinig | c6bbaeb | 2006-09-15 22:23:50 +0000 | [diff] [blame] | 266 | if (!_internal) |
| 267 | return [NSString stringWithFormat:@"<%@: null>", [[self class] description], self]; |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 268 | |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 269 | NSString *value = [self nodeValue]; |
weinig | c6bbaeb | 2006-09-15 22:23:50 +0000 | [diff] [blame] | 270 | if (value) |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 271 | return [NSString stringWithFormat:@"<%@ [%@]: %p '%@'>", |
| 272 | [[self class] description], [self nodeName], _internal, value]; |
weinig | c6bbaeb | 2006-09-15 22:23:50 +0000 | [diff] [blame] | 273 | |
| 274 | return [NSString stringWithFormat:@"<%@ [%@]: %p>", [[self class] description], [self nodeName], _internal]; |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 275 | } |
| 276 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 277 | - (JSC::Bindings::RootObject*)_rootObject |
kocienda | 117559f | 2004-03-01 17:04:26 +0000 | [diff] [blame] | 278 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 279 | WebCore::Frame* frame = core(self)->document()->frame(); |
| 280 | if (!frame) |
| 281 | return 0; |
| 282 | return frame->script()->bindingRootObject(); |
kocienda | 117559f | 2004-03-01 17:04:26 +0000 | [diff] [blame] | 283 | } |
| 284 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 285 | @end |
| 286 | |
| 287 | Class kitClass(WebCore::Node* impl) |
kocienda | 117559f | 2004-03-01 17:04:26 +0000 | [diff] [blame] | 288 | { |
kocienda | f9c26e6 | 2004-03-03 00:42:49 +0000 | [diff] [blame] | 289 | switch (impl->nodeType()) { |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 290 | case WebCore::Node::ELEMENT_NODE: |
darin | 7f1d170 | 2006-05-10 07:12:56 +0000 | [diff] [blame] | 291 | if (impl->isHTMLElement()) |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 292 | return WebCore::elementClass(static_cast<WebCore::HTMLElement*>(impl)->tagQName(), [DOMHTMLElement class]); |
ddkilzer@apple.com | 28c34e3 | 2009-04-09 16:33:15 +0000 | [diff] [blame] | 293 | #if ENABLE(SVG_DOM_OBJC_BINDINGS) |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 294 | if (impl->isSVGElement()) |
| 295 | return WebCore::elementClass(static_cast<WebCore::SVGElement*>(impl)->tagQName(), [DOMSVGElement class]); |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 296 | #endif |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 297 | return [DOMElement class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 298 | case WebCore::Node::ATTRIBUTE_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 299 | return [DOMAttr class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 300 | case WebCore::Node::TEXT_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 301 | return [DOMText class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 302 | case WebCore::Node::CDATA_SECTION_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 303 | return [DOMCDATASection class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 304 | case WebCore::Node::ENTITY_REFERENCE_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 305 | return [DOMEntityReference class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 306 | case WebCore::Node::ENTITY_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 307 | return [DOMEntity class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 308 | case WebCore::Node::PROCESSING_INSTRUCTION_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 309 | return [DOMProcessingInstruction class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 310 | case WebCore::Node::COMMENT_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 311 | return [DOMComment class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 312 | case WebCore::Node::DOCUMENT_NODE: |
| 313 | if (static_cast<WebCore::Document*>(impl)->isHTMLDocument()) |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 314 | return [DOMHTMLDocument class]; |
ddkilzer@apple.com | 28c34e3 | 2009-04-09 16:33:15 +0000 | [diff] [blame] | 315 | #if ENABLE(SVG_DOM_OBJC_BINDINGS) |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 316 | if (static_cast<WebCore::Document*>(impl)->isSVGDocument()) |
| 317 | return [DOMSVGDocument class]; |
weinig | c0f8d23 | 2006-10-11 03:46:36 +0000 | [diff] [blame] | 318 | #endif |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 319 | return [DOMDocument class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 320 | case WebCore::Node::DOCUMENT_TYPE_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 321 | return [DOMDocumentType class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 322 | case WebCore::Node::DOCUMENT_FRAGMENT_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 323 | return [DOMDocumentFragment class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 324 | case WebCore::Node::NOTATION_NODE: |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 325 | return [DOMNotation class]; |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 326 | case WebCore::Node::XPATH_NAMESPACE_NODE: |
andersca | 75fd42c | 2006-05-08 21:27:25 +0000 | [diff] [blame] | 327 | // FIXME: Create an XPath objective C wrapper |
darin | c370e7e | 2006-11-08 05:52:27 +0000 | [diff] [blame] | 328 | // See http://bugs.webkit.org/show_bug.cgi?id=8755 |
andersca | 75fd42c | 2006-05-08 21:27:25 +0000 | [diff] [blame] | 329 | return nil; |
kocienda | bb0f452 | 2004-03-02 17:03:56 +0000 | [diff] [blame] | 330 | } |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 331 | ASSERT_NOT_REACHED(); |
weinig | 6b67533 | 2006-09-16 03:30:49 +0000 | [diff] [blame] | 332 | return nil; |
| 333 | } |
| 334 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 335 | id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget) |
zimmermann@webkit.org | 29d2203 | 2008-09-23 23:44:20 +0000 | [diff] [blame] | 336 | { |
| 337 | if (!eventTarget) |
| 338 | return nil; |
| 339 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 340 | if (WebCore::Node* node = eventTarget->toNode()) |
| 341 | return kit(node); |
| 342 | |
| 343 | #if ENABLE(SVG_DOM_OBJC_BINDINGS) |
| 344 | if (WebCore::SVGElementInstance* svgElementInstance = eventTarget->toSVGElementInstance()) |
| 345 | return kit(svgElementInstance); |
| 346 | #endif |
| 347 | |
| 348 | // We don't have an ObjC binding for XMLHttpRequest. |
| 349 | |
| 350 | return nil; |
zimmermann@webkit.org | 29d2203 | 2008-09-23 23:44:20 +0000 | [diff] [blame] | 351 | } |
| 352 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 353 | @implementation DOMNode (DOMNodeExtensions) |
| 354 | |
| 355 | - (NSRect)boundingBox |
zimmermann@webkit.org | 29d2203 | 2008-09-23 23:44:20 +0000 | [diff] [blame] | 356 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 357 | // FIXME: Could we move this function to WebCore::Node and autogenerate? |
| 358 | core(self)->document()->updateLayoutIgnorePendingStylesheets(); |
| 359 | WebCore::RenderObject* renderer = core(self)->renderer(); |
| 360 | if (!renderer) |
| 361 | return NSZeroRect; |
| 362 | return renderer->absoluteBoundingBoxRect(); |
| 363 | } |
| 364 | |
timothy@apple.com | df6a405 | 2009-04-29 00:17:07 +0000 | [diff] [blame] | 365 | - (NSArray *)lineBoxRects |
| 366 | { |
| 367 | return [self textRects]; |
| 368 | } |
| 369 | |
zimmermann@webkit.org | 29d2203 | 2008-09-23 23:44:20 +0000 | [diff] [blame] | 370 | @end |
zimmermann@webkit.org | 29d2203 | 2008-09-23 23:44:20 +0000 | [diff] [blame] | 371 | |
timothy@apple.com | 4320343 | 2008-09-12 04:44:40 +0000 | [diff] [blame] | 372 | @implementation DOMNode (DOMNodeExtensionsPendingPublic) |
| 373 | |
| 374 | - (NSImage *)renderedImage |
| 375 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 376 | // FIXME: Could we move this function to WebCore::Node and autogenerate? |
| 377 | WebCore::Node* node = core(self); |
| 378 | WebCore::Frame* frame = node->document()->frame(); |
| 379 | if (!frame) |
| 380 | return nil; |
commit-queue@webkit.org | 14df318 | 2010-08-24 16:06:36 +0000 | [diff] [blame] | 381 | return frame->nodeImage(node).get(); |
timothy@apple.com | 4320343 | 2008-09-12 04:44:40 +0000 | [diff] [blame] | 382 | } |
| 383 | |
antti@apple.com | 1129eec | 2009-10-06 19:13:55 +0000 | [diff] [blame] | 384 | - (NSArray *)textRects |
| 385 | { |
| 386 | // FIXME: Could we move this function to WebCore::Node and autogenerate? |
| 387 | core(self)->document()->updateLayoutIgnorePendingStylesheets(); |
| 388 | if (!core(self)->renderer()) |
| 389 | return nil; |
| 390 | RefPtr<Range> range = Range::create(core(self)->document()); |
| 391 | WebCore::ExceptionCode ec = 0; |
| 392 | range->selectNodeContents(core(self), ec); |
| 393 | Vector<WebCore::IntRect> rects; |
| 394 | range->textRects(rects); |
| 395 | return kit(rects); |
| 396 | } |
timothy@apple.com | 4320343 | 2008-09-12 04:44:40 +0000 | [diff] [blame] | 397 | @end |
| 398 | |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 399 | @implementation DOMRange (DOMRangeExtensions) |
| 400 | |
| 401 | - (NSRect)boundingBox |
| 402 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 403 | // FIXME: The call to updateLayoutIgnorePendingStylesheets should be moved into WebCore::Range. |
| 404 | core(self)->ownerDocument()->updateLayoutIgnorePendingStylesheets(); |
| 405 | return core(self)->boundingBox(); |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 406 | } |
| 407 | |
timothy@apple.com | df6a405 | 2009-04-29 00:17:07 +0000 | [diff] [blame] | 408 | - (NSArray *)textRects |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 409 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 410 | // FIXME: The call to updateLayoutIgnorePendingStylesheets should be moved into WebCore::Range. |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 411 | Vector<WebCore::IntRect> rects; |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 412 | core(self)->ownerDocument()->updateLayoutIgnorePendingStylesheets(); |
timothy@apple.com | df6a405 | 2009-04-29 00:17:07 +0000 | [diff] [blame] | 413 | core(self)->textRects(rects); |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 414 | return kit(rects); |
| 415 | } |
| 416 | |
timothy@apple.com | df6a405 | 2009-04-29 00:17:07 +0000 | [diff] [blame] | 417 | - (NSArray *)lineBoxRects |
| 418 | { |
| 419 | // FIXME: Remove this once all clients stop using it and we drop Leopard support. |
| 420 | return [self textRects]; |
| 421 | } |
| 422 | |
thatcher | b7557c2 | 2006-11-08 22:24:26 +0000 | [diff] [blame] | 423 | @end |
| 424 | |
kocienda | bb0f452 | 2004-03-02 17:03:56 +0000 | [diff] [blame] | 425 | //------------------------------------------------------------------------------------------ |
kocienda | 117559f | 2004-03-01 17:04:26 +0000 | [diff] [blame] | 426 | // DOMElement |
| 427 | |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 428 | @implementation DOMElement (DOMElementAppKitExtensions) |
adele | 9988152 | 2005-11-15 02:05:45 +0000 | [diff] [blame] | 429 | |
thatcher | 3166fbf | 2006-03-01 17:49:47 +0000 | [diff] [blame] | 430 | - (NSImage*)image |
| 431 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 432 | // FIXME: Could we move this function to WebCore::Node and autogenerate? |
| 433 | WebCore::RenderObject* renderer = core(self)->renderer(); |
| 434 | if (!renderer || !renderer->isImage()) |
| 435 | return nil; |
| 436 | WebCore::CachedImage* cachedImage = static_cast<WebCore::RenderImage*>(renderer)->cachedImage(); |
| 437 | if (!cachedImage || cachedImage->errorOccurred()) |
| 438 | return nil; |
| 439 | return cachedImage->image()->getNSImage(); |
thatcher | 3166fbf | 2006-03-01 17:49:47 +0000 | [diff] [blame] | 440 | } |
| 441 | |
adele | 9988152 | 2005-11-15 02:05:45 +0000 | [diff] [blame] | 442 | @end |
| 443 | |
cblu | 4dc540a | 2004-12-06 23:39:15 +0000 | [diff] [blame] | 444 | @implementation DOMElement (WebPrivate) |
| 445 | |
| 446 | - (NSFont *)_font |
| 447 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 448 | // FIXME: Could we move this function to WebCore::Element and autogenerate? |
| 449 | WebCore::RenderObject* renderer = core(self)->renderer(); |
| 450 | if (!renderer) |
| 451 | return nil; |
| 452 | return renderer->style()->font().primaryFont()->getNSFont(); |
cblu | 4dc540a | 2004-12-06 23:39:15 +0000 | [diff] [blame] | 453 | } |
| 454 | |
weinig | b5e0816 | 2006-10-09 23:49:21 +0000 | [diff] [blame] | 455 | - (NSData *)_imageTIFFRepresentation |
hyatt | 3059a51 | 2006-02-02 08:40:45 +0000 | [diff] [blame] | 456 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 457 | // FIXME: Could we move this function to WebCore::Element and autogenerate? |
| 458 | WebCore::RenderObject* renderer = core(self)->renderer(); |
| 459 | if (!renderer || !renderer->isImage()) |
| 460 | return nil; |
| 461 | WebCore::CachedImage* cachedImage = static_cast<WebCore::RenderImage*>(renderer)->cachedImage(); |
| 462 | if (!cachedImage || cachedImage->errorOccurred()) |
| 463 | return nil; |
| 464 | return (NSData *)cachedImage->image()->getTIFFRepresentation(); |
hyatt | 3059a51 | 2006-02-02 08:40:45 +0000 | [diff] [blame] | 465 | } |
| 466 | |
sullivan | 111f110 | 2005-02-17 00:14:30 +0000 | [diff] [blame] | 467 | - (NSURL *)_getURLAttribute:(NSString *)name |
| 468 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 469 | // FIXME: Could we move this function to WebCore::Element and autogenerate? |
sullivan | 111f110 | 2005-02-17 00:14:30 +0000 | [diff] [blame] | 470 | ASSERT(name); |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 471 | WebCore::Element* element = core(self); |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 472 | ASSERT(element); |
darin@apple.com | 7b7981b | 2010-10-01 00:04:02 +0000 | [diff] [blame] | 473 | return element->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(element->getAttribute(name))); |
sullivan | 111f110 | 2005-02-17 00:14:30 +0000 | [diff] [blame] | 474 | } |
cblu | 4dc540a | 2004-12-06 23:39:15 +0000 | [diff] [blame] | 475 | |
adele | 90285b7 | 2006-07-19 23:54:49 +0000 | [diff] [blame] | 476 | - (BOOL)isFocused |
| 477 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 478 | // FIXME: Could we move this function to WebCore::Element and autogenerate? |
| 479 | WebCore::Element* element = core(self); |
| 480 | return element->document()->focusedNode() == element; |
adele | 90285b7 | 2006-07-19 23:54:49 +0000 | [diff] [blame] | 481 | } |
| 482 | |
sullivan | 111f110 | 2005-02-17 00:14:30 +0000 | [diff] [blame] | 483 | @end |
cblu | 4dc540a | 2004-12-06 23:39:15 +0000 | [diff] [blame] | 484 | |
kocienda | 117559f | 2004-03-01 17:04:26 +0000 | [diff] [blame] | 485 | //------------------------------------------------------------------------------------------ |
kocienda | bb0f452 | 2004-03-02 17:03:56 +0000 | [diff] [blame] | 486 | // DOMRange |
| 487 | |
weinig | c0880e7 | 2006-10-07 17:24:56 +0000 | [diff] [blame] | 488 | @implementation DOMRange (WebPrivate) |
darin | 2de03ad | 2004-06-15 07:46:22 +0000 | [diff] [blame] | 489 | |
darin | 9649a0f | 2004-09-15 05:55:43 +0000 | [diff] [blame] | 490 | - (NSString *)description |
| 491 | { |
| 492 | if (!_internal) |
darin | 02ad24b | 2005-01-20 18:05:19 +0000 | [diff] [blame] | 493 | return @"<DOMRange: null>"; |
adele | 704e8bb | 2005-09-16 22:42:30 +0000 | [diff] [blame] | 494 | return [NSString stringWithFormat:@"<DOMRange: %@ %d %@ %d>", |
weinig | 6d74c0d | 2006-09-18 21:40:34 +0000 | [diff] [blame] | 495 | [self startContainer], [self startOffset], [self endContainer], [self endOffset]]; |
darin | 9649a0f | 2004-09-15 05:55:43 +0000 | [diff] [blame] | 496 | } |
| 497 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 498 | // FIXME: This should be removed as soon as all internal Apple uses of it have been replaced with |
weinig | c0880e7 | 2006-10-07 17:24:56 +0000 | [diff] [blame] | 499 | // calls to the public method - (NSString *)text. |
darin | 36cb7c2 | 2004-08-03 18:09:44 +0000 | [diff] [blame] | 500 | - (NSString *)_text |
| 501 | { |
thatcher | 2a6da87 | 2006-07-10 03:02:04 +0000 | [diff] [blame] | 502 | return [self text]; |
darin | 36cb7c2 | 2004-08-03 18:09:44 +0000 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | @end |
| 506 | |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 507 | //------------------------------------------------------------------------------------------ |
weinig@apple.com | 5b942cb | 2009-07-22 04:27:22 +0000 | [diff] [blame] | 508 | // DOMRGBColor |
| 509 | |
| 510 | @implementation DOMRGBColor (WebPrivate) |
| 511 | |
| 512 | // FIXME: This should be removed as soon as all internal Apple uses of it have been replaced with |
| 513 | // calls to the public method - (NSColor *)color. |
| 514 | - (NSColor *)_color |
| 515 | { |
| 516 | return [self color]; |
| 517 | } |
| 518 | |
| 519 | @end |
| 520 | |
| 521 | |
| 522 | //------------------------------------------------------------------------------------------ |
weinig | a8192c0 | 2006-08-28 03:33:34 +0000 | [diff] [blame] | 523 | // DOMNodeFilter |
cblu | 1846a5a | 2004-04-29 02:05:28 +0000 | [diff] [blame] | 524 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 525 | DOMNodeFilter *kit(WebCore::NodeFilter* impl) |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 526 | { |
| 527 | if (!impl) |
| 528 | return nil; |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 529 | |
| 530 | if (DOMNodeFilter *wrapper = getDOMWrapper(impl)) |
| 531 | return [[wrapper retain] autorelease]; |
| 532 | |
| 533 | DOMNodeFilter *wrapper = [[DOMNodeFilter alloc] _init]; |
| 534 | wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(impl); |
| 535 | impl->ref(); |
| 536 | addDOMWrapper(wrapper, impl); |
| 537 | return [wrapper autorelease]; |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 538 | } |
| 539 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 540 | WebCore::NodeFilter* core(DOMNodeFilter *wrapper) |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 541 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 542 | return wrapper ? reinterpret_cast<WebCore::NodeFilter*>(wrapper->_internal) : 0; |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 543 | } |
| 544 | |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 545 | @implementation DOMNodeFilter |
| 546 | |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 547 | - (void)dealloc |
| 548 | { |
| 549 | if (_internal) |
weinig | 4f67b13 | 2006-09-24 19:34:43 +0000 | [diff] [blame] | 550 | reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref(); |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 551 | [super dealloc]; |
| 552 | } |
| 553 | |
darin | 2de03ad | 2004-06-15 07:46:22 +0000 | [diff] [blame] | 554 | - (void)finalize |
| 555 | { |
| 556 | if (_internal) |
weinig | 4f67b13 | 2006-09-24 19:34:43 +0000 | [diff] [blame] | 557 | reinterpret_cast<WebCore::NodeFilter*>(_internal)->deref(); |
darin | 2de03ad | 2004-06-15 07:46:22 +0000 | [diff] [blame] | 558 | [super finalize]; |
| 559 | } |
| 560 | |
kocienda | f6ea03e | 2004-05-04 22:38:00 +0000 | [diff] [blame] | 561 | - (short)acceptNode:(DOMNode *)node |
| 562 | { |
darin@apple.com | ea40f5a | 2009-04-17 19:16:19 +0000 | [diff] [blame] | 563 | return core(self)->acceptNode(core(node)); |
cblu | 1846a5a | 2004-04-29 02:05:28 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | @end |