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 DEFINE_PSEUDO_CONSTRUCTOR(HTMLDocumentPseudoCtor)
00057
00058 class HTMLElement : public DOMElement {
00059 public:
00060 HTMLElement(ExecState *exec, const DOM::HTMLElement& e) : DOMElement(exec, e) { }
00061 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
00062 Value getValueProperty(ExecState *exec, int token) const;
00063 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
00064 void putValueProperty(ExecState *exec, int token, const Value& value, int);
00065 virtual bool hasProperty(ExecState *exec, const Identifier &propertyName) const;
00066 virtual UString toString(ExecState *exec) const;
00067 virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
00068 virtual const ClassInfo* classInfo() const;
00069 static const ClassInfo info;
00070
00071 static const ClassInfo html_info, head_info, link_info, title_info,
00072 meta_info, base_info, isIndex_info, style_info, body_info, form_info,
00073 select_info, optGroup_info, option_info, input_info, textArea_info,
00074 button_info, label_info, fieldSet_info, legend_info, ul_info, ol_info,
00075 dl_info, dir_info, menu_info, li_info, div_info, p_info, heading_info,
00076 blockQuote_info, q_info, pre_info, br_info, baseFont_info, font_info,
00077 hr_info, mod_info, a_info, img_info, object_info, param_info,
00078 applet_info, map_info, area_info, script_info, table_info,
00079 caption_info, col_info, tablesection_info, tr_info,
00080 tablecell_info, frameSet_info, frame_info, iFrame_info, marquee_info, layer_info;
00081
00082 enum { HtmlVersion, HeadProfile, LinkHref, LinkRel, LinkMedia,
00083 LinkCharset, LinkDisabled, LinkHrefLang, LinkRev, LinkTarget, LinkType,
00084 LinkSheet, TitleText, MetaName, MetaHttpEquiv, MetaContent, MetaScheme,
00085 BaseHref, BaseTarget, IsIndexForm, IsIndexPrompt, StyleDisabled,
00086 StyleSheet, StyleType, StyleMedia, BodyBackground, BodyVLink, BodyText,
00087 BodyLink, BodyALink, BodyBgColor, BodyOnLoad,
00088 FormAction, FormEncType, FormElements, FormLength, FormAcceptCharset,
00089 FormReset, FormTarget, FormName, FormMethod, FormSubmit, SelectAdd,
00090 SelectTabIndex, SelectValue, SelectSelectedIndex, SelectLength,
00091 SelectRemove, SelectForm, SelectBlur, SelectType, SelectOptions,
00092 SelectDisabled, SelectMultiple, SelectName, SelectSize, SelectFocus,
00093 OptGroupDisabled, OptGroupLabel, OptionIndex, OptionSelected,
00094 OptionForm, OptionText, OptionDefaultSelected, OptionDisabled,
00095 OptionLabel, OptionValue, InputBlur, InputReadOnly, InputAccept,
00096 InputSize, InputDefaultValue, InputTabIndex, InputValue, InputType,
00097 InputFocus, InputMaxLength, InputDefaultChecked, InputDisabled,
00098 InputChecked, InputIndeterminate, InputForm, InputAccessKey, InputAlign, InputAlt,
00099 InputName, InputSrc, InputUseMap, InputSelect, InputClick,
00100 InputSelectionStart, InputSelectionEnd, InputSetSelectionRange,
00101 TextAreaAccessKey, TextAreaName, TextAreaDefaultValue, TextAreaSelect,
00102 TextAreaCols, TextAreaDisabled, TextAreaForm, TextAreaType,
00103 TextAreaTabIndex, TextAreaReadOnly, TextAreaRows, TextAreaValue,
00104 TextAreaBlur, TextAreaFocus, TextAreaSelectionStart, TextAreaSelectionEnd, TextAreaSetSelectionRange,
00105 TextAreaTextLength, ButtonBlur, ButtonFocus, ButtonForm, ButtonTabIndex, ButtonName,
00106 ButtonDisabled, ButtonAccessKey, ButtonType, ButtonValue, LabelHtmlFor,
00107 LabelForm, LabelAccessKey, FieldSetForm, LegendForm, LegendAccessKey,
00108 LegendAlign, UListType, UListCompact, OListStart, OListCompact,
00109 OListType, DListCompact, DirectoryCompact, MenuCompact, LIType,
00110 LIValue, DivAlign, ParagraphAlign, HeadingAlign, BlockQuoteCite,
00111 QuoteCite, PreWidth, BRClear, BaseFontColor, BaseFontSize,
00112 BaseFontFace, FontColor, FontSize, FontFace, HRWidth, HRNoShade,
00113 HRAlign, HRSize, ModCite, ModDateTime, AnchorShape, AnchorRel,
00114 AnchorAccessKey, AnchorCoords, AnchorHref, AnchorProtocol, AnchorHost,
00115 AnchorCharset, AnchorHrefLang, AnchorHostname, AnchorType, AnchorFocus,
00116 AnchorPort, AnchorPathName, AnchorHash, AnchorSearch, AnchorName,
00117 AnchorRev, AnchorTabIndex, AnchorTarget, AnchorText, AnchorBlur, AnchorClick,
00118 ImageName, ImageAlign, ImageHspace, ImageVspace, ImageUseMap, ImageAlt,
00119 ImageLowSrc, ImageWidth, ImageIsMap, ImageBorder, ImageHeight,
00120 ImageLongDesc, ImageSrc, ImageX, ImageY, ImageComplete, ObjectHspace, ObjectHeight, ObjectAlign,
00121 ObjectBorder, ObjectCode, ObjectType, ObjectVspace, ObjectArchive,
00122 ObjectDeclare, ObjectForm, ObjectCodeBase, ObjectCodeType, ObjectData,
00123 ObjectName, ObjectStandby, ObjectTabIndex, ObjectUseMap, ObjectWidth, ObjectContentDocument,
00124 ParamName, ParamType, ParamValueType, ParamValue, AppletArchive,
00125 AppletAlt, AppletCode, AppletWidth, AppletAlign, AppletCodeBase,
00126 AppletName, AppletHeight, AppletHspace, AppletObject, AppletVspace,
00127 MapAreas, MapName, AreaHash, AreaHref, AreaTarget, AreaPort, AreaShape,
00128 AreaCoords, AreaAlt, AreaAccessKey, AreaNoHref, AreaHost, AreaProtocol,
00129 AreaHostName, AreaPathName, AreaSearch, AreaTabIndex, ScriptEvent,
00130 ScriptType, ScriptHtmlFor, ScriptText, ScriptSrc, ScriptCharset,
00131 ScriptDefer, TableSummary, TableTBodies, TableTHead, TableCellPadding,
00132 TableDeleteCaption, TableCreateCaption, TableCaption, TableWidth,
00133 TableCreateTFoot, TableAlign, TableTFoot, TableDeleteRow,
00134 TableCellSpacing, TableRows, TableBgColor, TableBorder, TableFrame,
00135 TableRules, TableCreateTHead, TableDeleteTHead, TableDeleteTFoot,
00136 TableInsertRow, TableCaptionAlign, TableColCh, TableColChOff,
00137 TableColAlign, TableColSpan, TableColVAlign, TableColWidth,
00138 TableSectionCh, TableSectionDeleteRow, TableSectionChOff,
00139 TableSectionRows, TableSectionAlign, TableSectionVAlign,
00140 TableSectionInsertRow, TableRowSectionRowIndex, TableRowRowIndex,
00141 TableRowChOff, TableRowCells, TableRowVAlign, TableRowCh,
00142 TableRowAlign, TableRowBgColor, TableRowDeleteCell, TableRowInsertCell,
00143 TableCellColSpan, TableCellNoWrap, TableCellAbbr, TableCellHeight,
00144 TableCellWidth, TableCellCellIndex, TableCellChOff, TableCellBgColor,
00145 TableCellCh, TableCellVAlign, TableCellRowSpan, TableCellHeaders,
00146 TableCellAlign, TableCellAxis, TableCellScope, FrameSetCols,
00147 FrameSetRows, FrameSrc, FrameLocation, FrameFrameBorder, FrameScrolling,
00148 FrameMarginWidth, FrameLongDesc, FrameMarginHeight, FrameName,
00149 FrameContentDocument, FrameContentWindow,
00150 FrameNoResize, FrameWidth, FrameHeight, IFrameLongDesc, IFrameAlign,
00151 IFrameFrameBorder, IFrameSrc, IFrameName, IFrameHeight,
00152 IFrameMarginHeight, IFrameMarginWidth, IFrameScrolling, IFrameWidth,
00153 IFrameContentDocument, IFrameContentWindow,
00154 MarqueeStart, MarqueeStop,
00155 LayerTop, LayerLeft, LayerVisibility, LayerBgColor, LayerClip, LayerDocument, LayerLayers,
00156 ElementInnerHTML, ElementTitle, ElementId, ElementDir, ElementLang,
00157 ElementClassName, ElementInnerText, ElementDocument,
00158 ElementChildren, ElementAll, ElementScrollIntoView };
00159
00160 DOM::HTMLElement toElement() const { return static_cast<DOM::HTMLElement>(node); }
00161 };
00162
00163
00164 class HTMLElementFunction : public DOMFunction {
00165 public:
00166 HTMLElementFunction(ExecState *exec, int i, int len);
00167 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
00168 private:
00169 int id;
00170 };
00171
00172 class HTMLCollection : public DOMObject {
00173 public:
00174 HTMLCollection(ExecState *exec, const DOM::HTMLCollection& c);
00175 HTMLCollection(const KJS::Object& proto, const DOM::HTMLCollection& c);
00176 ~HTMLCollection();
00177 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
00178 virtual Value call(ExecState *exec, Object &thisObj, const List&args);
00179 virtual Value tryCall(ExecState *exec, Object &thisObj, const List&args);
00180 virtual bool implementsCall() const { return true; }
00181 virtual bool toBoolean(ExecState *) const;
00182 virtual bool hasProperty(ExecState *exec, const Identifier &p) const;
00183 virtual ReferenceList propList(ExecState *exec, bool recursive);
00184 enum { Item, NamedItem, Tags };
00185 Value getNamedItems(ExecState *exec, const Identifier &propertyName) const;
00186 virtual const ClassInfo* classInfo() const { return &info; }
00187 static const ClassInfo info;
00188 DOM::HTMLCollection toCollection() const { return collection; }
00189 virtual void hide() { hidden = true; }
00190 protected:
00191 DOM::HTMLCollection collection;
00192 bool hidden;
00193 };
00194
00195 class HTMLSelectCollection : public HTMLCollection {
00196 public:
00197 enum { Add };
00198 HTMLSelectCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e);
00199 virtual Value tryGet(ExecState *exec, const Identifier &propertyName) const;
00200 virtual void tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr = None);
00201
00202 virtual const ClassInfo* classInfo() const { return &info; }
00203 static const ClassInfo info;
00204
00205 DOM::HTMLSelectElement toElement() const { return element; }
00206 private:
00207 DOM::HTMLSelectElement element;
00208 };
00209
00211
00212 class OptionConstructorImp : public ObjectImp {
00213 public:
00214 OptionConstructorImp(ExecState *exec, const DOM::Document &d);
00215 virtual bool implementsConstruct() const;
00216 virtual Object construct(ExecState *exec, const List &args);
00217 private:
00218 DOM::Document doc;
00219 };
00220
00222
00223 class ImageConstructorImp : public ObjectImp {
00224 public:
00225 ImageConstructorImp(ExecState *exec, const DOM::Document &d);
00226 virtual bool implementsConstruct() const;
00227 virtual Object construct(ExecState *exec, const List &args);
00228 private:
00229 DOM::Document doc;
00230 };
00231
00232 Value getHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, bool hide=false);
00233 Value getSelectHTMLCollection(ExecState *exec, const DOM::HTMLCollection& c, const DOM::HTMLSelectElement& e);
00234 }
00235
00236 #endif