khtml Library API Documentation

kjs_html.h

00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 1999 Harri Porten (porten@kde.org) 00005 * Copyright (C) 2003 Apple Computer, Inc. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef _KJS_HTML_H_ 00023 #define _KJS_HTML_H_ 00024 00025 #include "dom/html_document.h" 00026 #include "dom/html_base.h" 00027 #include "dom/html_misc.h" 00028 #include "dom/html_form.h" 00029 #include "misc/loader_client.h" 00030 00031 #include "ecma/kjs_binding.h" 00032 #include "ecma/kjs_dom.h" 00033 #include "xml/dom_nodeimpl.h" // for NodeImpl::Id 00034 00035 namespace KJS { 00036 00037 class HTMLElement; 00038 00039 class HTMLDocument : public DOMDocument { 00040 public: 00041 HTMLDocument(ExecState *exec, const DOM::HTMLDocument& d); 00042 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00043 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None); 00044 void putValueProperty(ExecState *exec, int token, const Value& value, int /*attr*/); 00045 virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const; 00046 virtual const ClassInfo* classInfo() const { return &info; } 00047 static const ClassInfo info; 00048 enum { Title, Referrer, Domain, URL, Body, Location, Cookie, 00049 Images, Applets, Links, Forms, Anchors, Scripts, All, Clear, Open, Close, 00050 Write, WriteLn, GetElementsByName, GetSelection, CaptureEvents, ReleaseEvents, 00051 BgColor, FgColor, AlinkColor, LinkColor, VlinkColor, LastModified, 00052 Height, Width, Dir, Frames, CompatMode }; 00053 DOM::Document toDocument() const { return static_cast<DOM::Document>( node ); } 00054 }; 00055 00056 class HTMLElement : public DOMElement { 00057 public: 00058 HTMLElement(ExecState *exec, const DOM::HTMLElement& e) : DOMElement(exec, e) { } 00059 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00060 Value getValueProperty(ExecState *exec, int token) const; 00061 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None); 00062 void putValueProperty(ExecState *exec, int token, const Value& value, int); 00063 virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const; 00064 virtual UString toString(ExecState *exec) const; 00065 virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const; 00066 virtual const ClassInfo* classInfo() const; 00067 static const ClassInfo info; 00068 00069 static const ClassInfo html_info, head_info, link_info, title_info, 00070 meta_info, base_info, isIndex_info, style_info, body_info, form_info, 00071 select_info, optGroup_info, option_info, input_info, textArea_info, 00072 button_info, label_info, fieldSet_info, legend_info, ul_info, ol_info, 00073 dl_info, dir_info, menu_info, li_info, div_info, p_info, heading_info, 00074 blockQuote_info, q_info, pre_info, br_info, baseFont_info, font_info, 00075 hr_info, mod_info, a_info, img_info, object_info, param_info, 00076 applet_info, map_info, area_info, script_info, table_info, 00077 caption_info, col_info, tablesection_info, tr_info, 00078 tablecell_info, frameSet_info, frame_info, iFrame_info, marquee_info; 00079 00080 enum { HtmlVersion, HeadProfile, LinkHref, LinkRel, LinkMedia, 00081 LinkCharset, LinkDisabled, LinkHrefLang, LinkRev, LinkTarget, LinkType, 00082 LinkSheet, TitleText, MetaName, MetaHttpEquiv, MetaContent, MetaScheme, 00083 BaseHref, BaseTarget, IsIndexForm, IsIndexPrompt, StyleDisabled, 00084 StyleSheet, StyleType, StyleMedia, BodyBackground, BodyVLink, BodyText, 00085 BodyLink, BodyALink, BodyBgColor, BodyScrollLeft, BodyScrollTop, BodyScrollHeight, BodyScrollWidth, 00086 FormAction, FormEncType, FormElements, FormLength, FormAcceptCharset, 00087 FormReset, FormTarget, FormName, FormMethod, FormSubmit, SelectAdd, 00088 SelectTabIndex, SelectValue, SelectSelectedIndex, SelectLength, 00089 SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions, 00090 SelectDisabled, SelectMultiple, SelectName, SelectSize, SelectFocus, 00091 OptGroupDisabled, OptGroupLabel, OptionIndex, OptionSelected, 00092 OptionForm, OptionText, OptionDefaultSelected, OptionDisabled, 00093 OptionLabel, OptionValue, InputBlur, InputReadOnly, InputAccept, 00094 InputSize, InputDefaultValue, InputTabIndex, InputValue, InputType, 00095 InputFocus, InputMaxLength, InputDefaultChecked, InputDisabled, 00096 InputChecked, InputForm, InputAccessKey, InputAlign, InputAlt, 00097 InputName, InputSrc, InputUseMap, InputSelect, InputClick, 00098 TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect, 00099 TextAreaCols, TextAreaDisabled, TextAreaForm, TextAreaType, 00100 TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue, 00101 TextAreaBlur, TextAreaFocus, ButtonForm, ButtonTabIndex, ButtonName, 00102 ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor, 00103 LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey, 00104 LegendAlign, UListType, UListCompact, OListStart, OListCompact, 00105 OListType, DListCompact, DirectoryCompact, MenuCompact, LIType, 00106 LIValue, DivAlign, ParagraphAlign, HeadingAlign, BlockQuoteCite, 00107 QuoteCite, PreWidth, BRClear, BaseFontColor, BaseFontSize, 00108 BaseFontFace, FontColor, FontSize, FontFace, HRWidth, HRNoShade, 00109 HRAlign, HRSize, ModCite, ModDateTime, AnchorShape, AnchorRel, 00110 AnchorAccessKey, AnchorCoords, AnchorHref, AnchorProtocol, AnchorHost, 00111 AnchorCharset, AnchorHrefLang, AnchorHostname, AnchorType, AnchorFocus, 00112 AnchorPort, AnchorPathName, AnchorHash, AnchorSearch, AnchorName, 00113 AnchorRev, AnchorTabIndex, AnchorTarget, AnchorText, AnchorBlur, 00114 ImageName, ImageAlign, ImageHspace, ImageVspace, ImageUseMap, ImageAlt, 00115 ImageLowSrc, ImageWidth, ImageIsMap, ImageBorder, ImageHeight, 00116 ImageLongDesc, ImageSrc, ImageX, ImageY, ImageComplete, ObjectHspace, ObjectHeight, ObjectAlign, 00117 ObjectBorder, ObjectCode, ObjectType, ObjectVspace, ObjectArchive, 00118 ObjectDeclare, ObjectForm, ObjectCodeBase, ObjectCodeType, ObjectData, 00119 ObjectName, ObjectStandby, ObjectTabIndex, ObjectUseMap, ObjectWidth, ObjectContentDocument, 00120 ParamName, ParamType, ParamValueType, ParamValue, AppletArchive, 00121 AppletAlt, AppletCode, AppletWidth, AppletAlign, AppletCodeBase, 00122 AppletName, AppletHeight, AppletHspace, AppletObject, AppletVspace, 00123 MapAreas, MapName, AreaHash, AreaHref, AreaTarget, AreaPort, AreaShape, 00124 AreaCoords, AreaAlt, AreaAccessKey, AreaNoHref, AreaHost, AreaProtocol, 00125 AreaHostName, AreaPathName, AreaSearch, AreaTabIndex, ScriptEvent, 00126 ScriptType, ScriptHtmlFor, ScriptText, ScriptSrc, ScriptCharset, 00127 ScriptDefer, TableSummary, TableTBodies, TableTHead, TableCellPadding, 00128 TableDeleteCaption, TableCreateCaption, TableCaption, TableWidth, 00129 TableCreateTFoot, TableAlign, TableTFoot, TableDeleteRow, 00130 TableCellSpacing, TableRows, TableBgColor, TableBorder, TableFrame, 00131 TableRules, TableCreateTHead, TableDeleteTHead, TableDeleteTFoot, 00132 TableInsertRow, TableCaptionAlign, TableColCh, TableColChOff, 00133 TableColAlign, TableColSpan, TableColVAlign, TableColWidth, 00134 TableSectionCh, TableSectionDeleteRow, TableSectionChOff, 00135 TableSectionRows, TableSectionAlign, TableSectionVAlign, 00136 TableSectionInsertRow, TableRowSectionRowIndex, TableRowRowIndex, 00137 TableRowChOff, TableRowCells, TableRowVAlign, TableRowCh, 00138 TableRowAlign, TableRowBgColor, TableRowDeleteCell, TableRowInsertCell, 00139 TableCellColSpan, TableCellNoWrap, TableCellAbbr, TableCellHeight, 00140 TableCellWidth, TableCellCellIndex, TableCellChOff, TableCellBgColor, 00141 TableCellCh, TableCellVAlign, TableCellRowSpan, TableCellHeaders, 00142 TableCellAlign, TableCellAxis, TableCellScope, FrameSetCols, 00143 FrameSetRows, FrameSrc, FrameLocation, FrameFrameBorder, FrameScrolling, 00144 FrameMarginWidth, FrameLongDesc, FrameMarginHeight, FrameName, FrameContentDocument, 00145 FrameNoResize, IFrameLongDesc, IFrameAlign, 00146 IFrameFrameBorder, IFrameSrc, IFrameName, IFrameHeight, 00147 IFrameMarginHeight, IFrameMarginWidth, IFrameScrolling, IFrameWidth, IFrameContentDocument, 00148 MarqueeStart, MarqueeStop, 00149 ElementInnerHTML, ElementTitle, ElementId, ElementDir, ElementLang, 00150 ElementClassName, ElementInnerText, ElementDocument, ElementChildren, ElementAll }; 00151 00152 DOM::HTMLElement toElement() const { return static_cast<DOM::HTMLElement>(node); } 00153 }; 00154 00155 00156 class HTMLElementFunction : public DOMFunction { 00157 public: 00158 HTMLElementFunction(ExecState *exec, int i, int len); 00159 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args); 00160 private: 00161 int id; 00162 }; 00163 00164 class HTMLCollection : public DOMObject { 00165 public: 00166 HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c); 00167 ~HTMLCollection(); 00168 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00169 virtual Value call(ExecState *exec, Object &thisObj, const List&args); 00170 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args); 00171 virtual bool implementsCall() const { return true; } 00172 virtual bool toBoolean(ExecState *) const { return true; } 00173 virtual bool hasProperty(ExecState *exec, const Identifier &p) const; 00174 enum { Item, NamedItem, Tags }; 00175 Value getNamedItems(ExecState *exec, const Identifier &propertyName) const; 00176 virtual const ClassInfo* classInfo() const { return &info; } 00177 static const ClassInfo info; 00178 DOM::HTMLCollection toCollection() const { return collection; } 00179 protected: 00180 DOM::HTMLCollection collection; 00181 }; 00182 00183 class HTMLSelectCollection : public HTMLCollection { 00184 public: 00185 HTMLSelectCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e) 00186 : HTMLCollection(exec, c), element(e) { } 00187 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00188 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None); 00189 private: 00190 DOM::HTMLSelectElement element; 00191 }; 00192 00194 00195 class OptionConstructorImp : public ObjectImp { 00196 public: 00197 OptionConstructorImp(ExecState *exec, const DOM::Document &d); 00198 virtual bool implementsConstruct() const; 00199 virtual Object construct(ExecState *exec, const List &args); 00200 private: 00201 DOM::Document doc; 00202 }; 00203 00205 00206 class ImageConstructorImp : public ObjectImp { 00207 public: 00208 ImageConstructorImp(ExecState *exec, const DOM::Document &d); 00209 virtual bool implementsConstruct() const; 00210 virtual Object construct(ExecState *exec, const List &args); 00211 private: 00212 DOM::Document doc; 00213 }; 00214 00215 class Image : public DOMObject, public khtml::CachedObjectClient { 00216 public: 00217 Image(ExecState*, const DOM::Document &d); 00218 ~Image(); 00219 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const; 00220 Value getValueProperty(ExecState *exec, int token) const; 00221 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None); 00222 void putValueProperty(ExecState *exec, int token, const Value& value, int); 00223 virtual bool toBoolean(ExecState *) const { return true; } 00224 virtual void notifyFinished(khtml::CachedObject * finishedObj); 00225 virtual const ClassInfo* classInfo() const { return &info; } 00226 static const ClassInfo info; 00227 enum { Src, Complete, Width, Height, OnLoad }; 00228 private: 00229 UString src; 00230 DOM::Document doc; 00231 khtml::CachedImage* img; 00232 JSEventListener *m_onLoadListener; 00233 }; 00234 00235 Value getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c); 00236 Value getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e); 00237 00238 /* Helper function object for determining the number 00239 * of occurrences of xxxx as in document.xxxx or window.xxxx. 00240 * The order of the TagLength array is the order of preference. 00241 */ 00242 class NamedTagLengthDeterminer { 00243 public: 00244 struct TagLength { 00245 DOM::NodeImpl::Id id; unsigned long length; DOM::NodeImpl *last; 00246 }; 00247 NamedTagLengthDeterminer(const DOM::DOMString& n, TagLength *t, int l) 00248 : name(n), tags(t), nrTags(l) {} 00249 void operator () (DOM::NodeImpl *start); 00250 private: 00251 const DOM::DOMString& name; 00252 TagLength *tags; 00253 int nrTags; 00254 }; 00255 00256 00257 } // namespace 00258 00259 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Oct 17 11:34:05 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003