00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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"
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 );
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, Layers, 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, layer_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,
00086 BodyScrollHeight, BodyScrollWidth, BodyOnLoad,
00087 FormAction, FormEncType, FormElements, FormLength, FormAcceptCharset,
00088 FormReset, FormTarget, FormName, FormMethod, FormSubmit, SelectAdd,
00089 SelectTabIndex, SelectValue, SelectSelectedIndex, SelectLength,
00090 SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions,
00091 SelectDisabled, SelectMultiple, SelectName, SelectSize, SelectFocus,
00092 OptGroupDisabled, OptGroupLabel, OptionIndex, OptionSelected,
00093 OptionForm, OptionText, OptionDefaultSelected, OptionDisabled,
00094 OptionLabel, OptionValue, InputBlur, InputReadOnly, InputAccept,
00095 InputSize, InputDefaultValue, InputTabIndex, InputValue, InputType,
00096 InputFocus, InputMaxLength, InputDefaultChecked, InputDisabled,
00097 InputChecked, InputIndeterminate, InputForm, InputAccessKey, InputAlign, InputAlt,
00098 InputName, InputSrc, InputUseMap, InputSelect, InputClick,
00099 InputSelectionStart, InputSelectionEnd, InputSetSelectionRange,
00100 TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect,
00101 TextAreaCols, TextAreaDisabled, TextAreaForm, TextAreaType,
00102 TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue,
00103 TextAreaBlur, TextAreaFocus, TextAreaSelectionStart, TextAreaSelectionEnd, TextAreaSetSelectionRange,
00104 TextAreaTextLength, ButtonBlur, ButtonFocus, ButtonForm, ButtonTabIndex, ButtonName,
00105 ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor,
00106 LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
00107 LegendAlign, UListType, UListCompact, OListStart, OListCompact,
00108 OListType, DListCompact, DirectoryCompact, MenuCompact, LIType,
00109 LIValue, DivAlign, ParagraphAlign, HeadingAlign, BlockQuoteCite,
00110 QuoteCite, PreWidth, BRClear, BaseFontColor, BaseFontSize,
00111 BaseFontFace, FontColor, FontSize, FontFace, HRWidth, HRNoShade,
00112 HRAlign, HRSize, ModCite, ModDateTime, AnchorShape, AnchorRel,
00113 AnchorAccessKey, AnchorCoords, AnchorHref, AnchorProtocol, AnchorHost,
00114 AnchorCharset, AnchorHrefLang, AnchorHostname, AnchorType, AnchorFocus,
00115 AnchorPort, AnchorPathName, AnchorHash, AnchorSearch, AnchorName,
00116 AnchorRev, AnchorTabIndex, AnchorTarget, AnchorText, AnchorBlur, AnchorClick,
00117 ImageName, ImageAlign, ImageHspace, ImageVspace, ImageUseMap, ImageAlt,
00118 ImageLowSrc, ImageWidth, ImageIsMap, ImageBorder, ImageHeight,
00119 ImageLongDesc, ImageSrc, ImageX, ImageY, ImageComplete, ObjectHspace, ObjectHeight, ObjectAlign,
00120 ObjectBorder, ObjectCode, ObjectType, ObjectVspace, ObjectArchive,
00121 ObjectDeclare, ObjectForm, ObjectCodeBase, ObjectCodeType, ObjectData,
00122 ObjectName, ObjectStandby, ObjectTabIndex, ObjectUseMap, ObjectWidth, ObjectContentDocument,
00123 ParamName, ParamType, ParamValueType, ParamValue, AppletArchive,
00124 AppletAlt, AppletCode, AppletWidth, AppletAlign, AppletCodeBase,
00125 AppletName, AppletHeight, AppletHspace, AppletObject, AppletVspace,
00126 MapAreas, MapName, AreaHash, AreaHref, AreaTarget, AreaPort, AreaShape,
00127 AreaCoords, AreaAlt, AreaAccessKey, AreaNoHref, AreaHost, AreaProtocol,
00128 AreaHostName, AreaPathName, AreaSearch, AreaTabIndex, ScriptEvent,
00129 ScriptType, ScriptHtmlFor, ScriptText, ScriptSrc, ScriptCharset,
00130 ScriptDefer, TableSummary, TableTBodies, TableTHead, TableCellPadding,
00131 TableDeleteCaption, TableCreateCaption, TableCaption, TableWidth,
00132 TableCreateTFoot, TableAlign, TableTFoot, TableDeleteRow,
00133 TableCellSpacing, TableRows, TableBgColor, TableBorder, TableFrame,
00134 TableRules, TableCreateTHead, TableDeleteTHead, TableDeleteTFoot,
00135 TableInsertRow, TableCaptionAlign, TableColCh, TableColChOff,
00136 TableColAlign, TableColSpan, TableColVAlign, TableColWidth,
00137 TableSectionCh, TableSectionDeleteRow, TableSectionChOff,
00138 TableSectionRows, TableSectionAlign, TableSectionVAlign,
00139 TableSectionInsertRow, TableRowSectionRowIndex, TableRowRowIndex,
00140 TableRowChOff, TableRowCells, TableRowVAlign, TableRowCh,
00141 TableRowAlign, TableRowBgColor, TableRowDeleteCell, TableRowInsertCell,
00142 TableCellColSpan, TableCellNoWrap, TableCellAbbr, TableCellHeight,
00143 TableCellWidth, TableCellCellIndex, TableCellChOff, TableCellBgColor,
00144 TableCellCh, TableCellVAlign, TableCellRowSpan, TableCellHeaders,
00145 TableCellAlign, TableCellAxis, TableCellScope, FrameSetCols,
00146 FrameSetRows, FrameSrc, FrameLocation, FrameFrameBorder, FrameScrolling,
00147 FrameMarginWidth, FrameLongDesc, FrameMarginHeight, FrameName,
00148 FrameContentDocument, FrameContentWindow,
00149 FrameNoResize, IFrameLongDesc, IFrameAlign,
00150 IFrameFrameBorder, IFrameSrc, IFrameName, IFrameHeight,
00151 IFrameMarginHeight, IFrameMarginWidth, IFrameScrolling, IFrameWidth,
00152 IFrameContentDocument, IFrameContentWindow,
00153 MarqueeStart, MarqueeStop,
00154 LayerTop, LayerLeft, LayerVisibility, LayerBgColor, LayerClip, LayerDocument, LayerLayers,
00155 ElementInnerHTML, ElementTitle, ElementId, ElementDir, ElementLang,
00156 ElementClassName, ElementInnerText, ElementDocument,
00157 ElementChildren, ElementAll, ElementScrollIntoView };
00158
00159 DOM::HTMLElement toElement() const { return static_cast<DOM::HTMLElement>(node); }
00160 };
00161
00162
00163 class HTMLElementFunction : public DOMFunction {
00164 public:
00165 HTMLElementFunction(ExecState *exec, int i, int len);
00166 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
00167 private:
00168 int id;
00169 };
00170
00171 class HTMLCollection : public DOMObject {
00172 public:
00173 HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c);
00174 ~HTMLCollection();
00175 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
00176 virtual Value call(ExecState *exec, Object &thisObj, const List&args);
00177 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
00178 virtual bool implementsCall() const { return true; }
00179 virtual bool toBoolean(ExecState *) const;
00180 virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
00181 virtual ReferenceList propList(ExecState *exec, bool recursive);
00182 enum { Item, NamedItem, Tags };
00183 Value getNamedItems(ExecState *exec, const Identifier &propertyName) const;
00184 virtual const ClassInfo* classInfo() const { return &info; }
00185 static const ClassInfo info;
00186 DOM::HTMLCollection toCollection() const { return collection; }
00187 virtual void hide() { hidden = true; }
00188 protected:
00189 DOM::HTMLCollection collection;
00190 bool hidden;
00191 };
00192
00193 class HTMLSelectCollection : public HTMLCollection {
00194 public:
00195 HTMLSelectCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e)
00196 : HTMLCollection(exec, c), element(e) { }
00197 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
00198 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
00199 private:
00200 DOM::HTMLSelectElement element;
00201 };
00202
00204
00205 class OptionConstructorImp : public ObjectImp {
00206 public:
00207 OptionConstructorImp(ExecState *exec, const DOM::Document &d);
00208 virtual bool implementsConstruct() const;
00209 virtual Object construct(ExecState *exec, const List &args);
00210 private:
00211 DOM::Document doc;
00212 };
00213
00215
00216 class ImageConstructorImp : public ObjectImp {
00217 public:
00218 ImageConstructorImp(ExecState *exec, const DOM::Document &d);
00219 virtual bool implementsConstruct() const;
00220 virtual Object construct(ExecState *exec, const List &args);
00221 private:
00222 DOM::Document doc;
00223 };
00224
00225 Value getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, bool hide=false);
00226 Value getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e);
00227 }
00228
00229 #endif