1/* 2 * Copyright (C) 2013 Igalia S.L. 3 * 4 * This file is derived by hand from an automatically generated file. 5 * Keeping it up-to-date could potentially be done by adding 6 * a make_names.pl generator, or by writing a separate 7 * generater which takes JSHTMLElementWrapperFactory.h as input. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include "config.h" 32#include "WebKitDOMHTMLPrivate.h" 33 34#include "HTMLAnchorElement.h" 35#include "HTMLAppletElement.h" 36#include "HTMLAreaElement.h" 37#include "HTMLAudioElement.h" 38#include "HTMLBRElement.h" 39#include "HTMLBaseElement.h" 40#include "HTMLBaseFontElement.h" 41#include "HTMLBodyElement.h" 42#include "HTMLButtonElement.h" 43#include "HTMLCanvasElement.h" 44#include "HTMLDListElement.h" 45#include "HTMLDirectoryElement.h" 46#include "HTMLDivElement.h" 47#include "HTMLElement.h" 48#include "HTMLEmbedElement.h" 49#include "HTMLFieldSetElement.h" 50#include "HTMLFontElement.h" 51#include "HTMLFormElement.h" 52#include "HTMLFrameElement.h" 53#include "HTMLFrameSetElement.h" 54#include "HTMLHRElement.h" 55#include "HTMLHeadElement.h" 56#include "HTMLHeadingElement.h" 57#include "HTMLHtmlElement.h" 58#include "HTMLIFrameElement.h" 59#include "HTMLImageElement.h" 60#include "HTMLInputElement.h" 61#include "HTMLKeygenElement.h" 62#include "HTMLLIElement.h" 63#include "HTMLLabelElement.h" 64#include "HTMLLegendElement.h" 65#include "HTMLLinkElement.h" 66#include "HTMLMapElement.h" 67#include "HTMLMarqueeElement.h" 68#include "HTMLMenuElement.h" 69#include "HTMLMetaElement.h" 70#include "HTMLModElement.h" 71#include "HTMLNames.h" 72#include "HTMLOListElement.h" 73#include "HTMLObjectElement.h" 74#include "HTMLOptGroupElement.h" 75#include "HTMLOptionElement.h" 76#include "HTMLParagraphElement.h" 77#include "HTMLParamElement.h" 78#include "HTMLPreElement.h" 79#include "HTMLQuoteElement.h" 80#include "HTMLScriptElement.h" 81#include "HTMLSelectElement.h" 82#include "HTMLStyleElement.h" 83#include "HTMLTableCaptionElement.h" 84#include "HTMLTableCellElement.h" 85#include "HTMLTableColElement.h" 86#include "HTMLTableElement.h" 87#include "HTMLTableRowElement.h" 88#include "HTMLTableSectionElement.h" 89#include "HTMLTextAreaElement.h" 90#include "HTMLTitleElement.h" 91#include "HTMLUListElement.h" 92#include "HTMLVideoElement.h" 93#include "WebKitDOMHTMLAnchorElementPrivate.h" 94#include "WebKitDOMHTMLAppletElementPrivate.h" 95#include "WebKitDOMHTMLAreaElementPrivate.h" 96#include "WebKitDOMHTMLBRElementPrivate.h" 97#include "WebKitDOMHTMLBaseElementPrivate.h" 98#include "WebKitDOMHTMLBaseFontElementPrivate.h" 99#include "WebKitDOMHTMLBodyElementPrivate.h" 100#include "WebKitDOMHTMLButtonElementPrivate.h" 101#include "WebKitDOMHTMLCanvasElementPrivate.h" 102#include "WebKitDOMHTMLDListElementPrivate.h" 103#include "WebKitDOMHTMLDirectoryElementPrivate.h" 104#include "WebKitDOMHTMLDivElementPrivate.h" 105#include "WebKitDOMHTMLElementPrivate.h" 106#include "WebKitDOMHTMLEmbedElementPrivate.h" 107#include "WebKitDOMHTMLFieldSetElementPrivate.h" 108#include "WebKitDOMHTMLFontElementPrivate.h" 109#include "WebKitDOMHTMLFormElementPrivate.h" 110#include "WebKitDOMHTMLFrameElementPrivate.h" 111#include "WebKitDOMHTMLFrameSetElementPrivate.h" 112#include "WebKitDOMHTMLHRElementPrivate.h" 113#include "WebKitDOMHTMLHeadElementPrivate.h" 114#include "WebKitDOMHTMLHeadingElementPrivate.h" 115#include "WebKitDOMHTMLHtmlElementPrivate.h" 116#include "WebKitDOMHTMLIFrameElementPrivate.h" 117#include "WebKitDOMHTMLImageElementPrivate.h" 118#include "WebKitDOMHTMLInputElementPrivate.h" 119#include "WebKitDOMHTMLKeygenElementPrivate.h" 120#include "WebKitDOMHTMLLIElementPrivate.h" 121#include "WebKitDOMHTMLLabelElementPrivate.h" 122#include "WebKitDOMHTMLLegendElementPrivate.h" 123#include "WebKitDOMHTMLLinkElementPrivate.h" 124#include "WebKitDOMHTMLMapElementPrivate.h" 125#include "WebKitDOMHTMLMarqueeElementPrivate.h" 126#include "WebKitDOMHTMLMenuElementPrivate.h" 127#include "WebKitDOMHTMLMetaElementPrivate.h" 128#include "WebKitDOMHTMLModElementPrivate.h" 129#include "WebKitDOMHTMLOListElementPrivate.h" 130#include "WebKitDOMHTMLObjectElementPrivate.h" 131#include "WebKitDOMHTMLOptGroupElementPrivate.h" 132#include "WebKitDOMHTMLOptionElementPrivate.h" 133#include "WebKitDOMHTMLParagraphElementPrivate.h" 134#include "WebKitDOMHTMLParamElementPrivate.h" 135#include "WebKitDOMHTMLPreElementPrivate.h" 136#include "WebKitDOMHTMLQuoteElementPrivate.h" 137#include "WebKitDOMHTMLScriptElementPrivate.h" 138#include "WebKitDOMHTMLSelectElementPrivate.h" 139#include "WebKitDOMHTMLStyleElementPrivate.h" 140#include "WebKitDOMHTMLTableCaptionElementPrivate.h" 141#include "WebKitDOMHTMLTableCellElementPrivate.h" 142#include "WebKitDOMHTMLTableColElementPrivate.h" 143#include "WebKitDOMHTMLTableElementPrivate.h" 144#include "WebKitDOMHTMLTableRowElementPrivate.h" 145#include "WebKitDOMHTMLTableSectionElementPrivate.h" 146#include "WebKitDOMHTMLTextAreaElementPrivate.h" 147#include "WebKitDOMHTMLTitleElementPrivate.h" 148#include "WebKitDOMHTMLUListElementPrivate.h" 149 150#if ENABLE(VIDEO) 151#include "WebKitDOMHTMLAudioElementPrivate.h" 152#include "WebKitDOMHTMLVideoElementPrivate.h" 153#endif 154 155namespace WebKit { 156 157using namespace WebCore; 158using namespace WebCore::HTMLNames; 159 160// macro(TagName, ElementName) 161 162#if ENABLE(VIDEO) 163#define FOR_EACH_HTML_VIDEO_TAG(macro) \ 164 macro(audio, Audio) \ 165 macro(video, Video) 166#else 167#define FOR_EACH_HTML_VIDEO_TAG(macro) 168#endif 169 170#define FOR_EACH_HTML_TAG(macro) \ 171 FOR_EACH_HTML_VIDEO_TAG(macro) \ 172 macro(a, Anchor) \ 173 macro(applet, Applet) \ 174 macro(area, Area) \ 175 macro(base, Base) \ 176 macro(basefont, BaseFont) \ 177 macro(blockquote, Quote) \ 178 macro(body, Body) \ 179 macro(br, BR) \ 180 macro(button, Button) \ 181 macro(canvas, Canvas) \ 182 macro(caption, TableCaption) \ 183 macro(col, TableCol) \ 184 macro(del, Mod) \ 185 macro(dir, Directory) \ 186 macro(div, Div) \ 187 macro(dl, DList) \ 188 macro(embed, Embed) \ 189 macro(fieldset, FieldSet) \ 190 macro(font, Font) \ 191 macro(form, Form) \ 192 macro(frame, Frame) \ 193 macro(frameset, FrameSet) \ 194 macro(h1, Heading) \ 195 macro(head, Head) \ 196 macro(hr, HR) \ 197 macro(html, Html) \ 198 macro(iframe, IFrame) \ 199 macro(img, Image) \ 200 macro(input, Input) \ 201 macro(label, Label) \ 202 macro(legend, Legend) \ 203 macro(li, LI) \ 204 macro(link, Link) \ 205 macro(map, Map) \ 206 macro(marquee, Marquee) \ 207 macro(menu, Menu) \ 208 macro(meta, Meta) \ 209 macro(object, Object) \ 210 macro(ol, OList) \ 211 macro(optgroup, OptGroup) \ 212 macro(option, Option) \ 213 macro(p, Paragraph) \ 214 macro(param, Param) \ 215 macro(pre, Pre) \ 216 macro(q, Quote) \ 217 macro(script, Script) \ 218 macro(select, Select) \ 219 macro(style, Style) \ 220 macro(table, Table) \ 221 macro(tbody, TableSection) \ 222 macro(td, TableCell) \ 223 macro(textarea, TextArea) \ 224 macro(title, Title) \ 225 macro(tr, TableRow) \ 226 macro(ul, UList) \ 227 macro(colgroup, TableCol) \ 228 macro(h2, Heading) \ 229 macro(h3, Heading) \ 230 macro(h4, Heading) \ 231 macro(h5, Heading) \ 232 macro(h6, Heading) \ 233 macro(image, Image) \ 234 macro(ins, Mod) \ 235 macro(keygen, Keygen) \ 236 macro(listing, Pre) \ 237 macro(tfoot, TableSection) \ 238 macro(th, TableCell) \ 239 macro(thead, TableSection) \ 240 macro(xmp, Pre) 241 242#define DEFINE_HTML_WRAPPER(TagName, ElementName) \ 243 static WebKitDOMHTMLElement* TagName##Wrapper(HTMLElement* element) \ 244 { \ 245 return WEBKIT_DOM_HTML_ELEMENT(wrapHTML##ElementName##Element(static_cast<HTML##ElementName##Element*>(element))); \ 246 } 247 FOR_EACH_HTML_TAG(DEFINE_HTML_WRAPPER) 248#undef DEFINE_HTML_WRAPPER 249 250typedef WebKitDOMHTMLElement* (*HTMLElementWrapFunction)(HTMLElement*); 251 252WebKitDOMHTMLElement* wrap(HTMLElement* element) 253{ 254 static HashMap<const QualifiedName::QualifiedNameImpl*, HTMLElementWrapFunction> map; 255 if (map.isEmpty()) { 256#define ADD_HTML_WRAPPER(TagName, ElementName) map.set(TagName##Tag.impl(), TagName##Wrapper); 257 FOR_EACH_HTML_TAG(ADD_HTML_WRAPPER) 258#undef ADD_HTML_WRAPPER 259 } 260 261 if (HTMLElementWrapFunction wrapFunction = map.get(element->tagQName().impl())) 262 return wrapFunction(element); 263 264 return wrapHTMLElement(element); 265} 266 267} 268