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