📄 kjs_html.cpp
字号:
DOM::HTMLCollection coll2 = doc.forms(); DOM::HTMLElement element = coll.namedItem(propertyName.string()); DOM::HTMLElement element2; if (element.isNull()) { element = coll2.namedItem(propertyName.string()); element2 = coll2.nextNamedItem(propertyName.string()); } else { element2 = coll.nextNamedItem(propertyName.string()); if (element2.isNull()) element2 = coll2.namedItem(propertyName.string()); } if (!element.isNull() && (element.elementId() == ID_IMG || element.elementId() == ID_FORM)) { if (element2.isNull()) return getDOMNode(exec, element); else { DOM::HTMLCollection collAll = doc.all(); KJS::HTMLCollection htmlcoll(exec,collAll); return htmlcoll.getNamedItems(exec, propertyName); // Get all the items with the same name } } return Undefined();}void KJS::HTMLDocument::tryPut(ExecState *exec, const Identifier &propertyName, const Value& value, int attr){#ifdef KJS_VERBOSE kdDebug(6070) << "KJS::HTMLDocument::tryPut " << propertyName.qstring() << endl;#endif DOMObjectLookupPut<HTMLDocument, DOMDocument>( exec, propertyName, value, attr, &HTMLDocumentTable, this );}void KJS::HTMLDocument::putValue(ExecState *exec, int token, const Value& value, int /*attr*/){ DOM::HTMLDocument doc = static_cast<DOM::HTMLDocument>(node); DOM::HTMLBodyElement body = doc.body(); switch (token) { case Title: doc.setTitle(value.toString(exec).string()); break; case Body: { DOMNode *node = new DOMNode(exec, KJS::toNode(value)); // This is required to avoid leaking the node. Value nodeValue(node); doc.setBody(node->toNode()); break; } case Domain: { // not part of the DOM DOM::HTMLDocumentImpl* docimpl = static_cast<DOM::HTMLDocumentImpl*>(doc.handle()); if (docimpl) docimpl->setDomain(value.toString(exec).string()); break; } case Cookie: doc.setCookie(value.toString(exec).string()); break; case Location: { KHTMLPart *part = static_cast<DOM::DocumentImpl *>( doc.handle() )->part(); if (part) { QString str = value.toString(exec).qstring(); // When assinging location, IE and Mozilla both resolve the URL // relative to the frame where the JavaScript is executing not // the target frame. KHTMLPart *activePart = static_cast<KJS::ScriptInterpreter *>( exec->dynamicInterpreter() )->part(); if (activePart) { KURL resolvedURL(activePart->baseURL(), str); str = resolvedURL.url(); }#if APPLE_CHANGES // We want a new history item if this JS was called via a user gesture bool userGesture = static_cast<ScriptInterpreter *>(exec->dynamicInterpreter())->wasRunByUserGesture(); part->scheduleRedirection(0, str, !userGesture);#else part->scheduleRedirection(0, str, false/*don't lock history*/);#endif } break; } case BgColor: body.setBgColor(value.toString(exec).string()); break; case FgColor: body.setText(value.toString(exec).string()); break; case AlinkColor: // this check is a bit silly, but some benchmarks like to set the // document's link colors over and over to the same value and we // don't want to incur a style update each time. { DOM::DOMString newColor = value.toString(exec).string(); if (body.aLink() != newColor) { body.setALink(newColor); } } break; case LinkColor: // this check is a bit silly, but some benchmarks like to set the // document's link colors over and over to the same value and we // don't want to incur a style update each time. { DOM::DOMString newColor = value.toString(exec).string(); if (body.link() != newColor) { body.setLink(newColor); } } break; case VlinkColor: // this check is a bit silly, but some benchmarks like to set the // document's link colors over and over to the same value and we // don't want to incur a style update each time. { DOM::DOMString newColor = value.toString(exec).string(); if (body.vLink() != newColor) { body.setVLink(newColor); } } break; case Dir: body.setDir(value.toString(exec).string()); break; default: kdWarning() << "HTMLDocument::putValue unhandled token " << token << endl; }}// -------------------------------------------------------------------------const ClassInfo KJS::HTMLElement::info = { "HTMLElement", &DOMElement::info, &HTMLElementTable, 0 };const ClassInfo KJS::HTMLElement::html_info = { "HTMLHtmlElement", &KJS::HTMLElement::info, &HTMLHtmlElementTable, 0 };const ClassInfo KJS::HTMLElement::head_info = { "HTMLHeadElement", &KJS::HTMLElement::info, &HTMLHeadElementTable, 0 };const ClassInfo KJS::HTMLElement::link_info = { "HTMLLinkElement", &KJS::HTMLElement::info, &HTMLLinkElementTable, 0 };const ClassInfo KJS::HTMLElement::title_info = { "HTMLTitleElement", &KJS::HTMLElement::info, &HTMLTitleElementTable, 0 };const ClassInfo KJS::HTMLElement::meta_info = { "HTMLMetaElement", &KJS::HTMLElement::info, &HTMLMetaElementTable, 0 };const ClassInfo KJS::HTMLElement::base_info = { "HTMLBaseElement", &KJS::HTMLElement::info, &HTMLBaseElementTable, 0 };const ClassInfo KJS::HTMLElement::isIndex_info = { "HTMLIsIndexElement", &KJS::HTMLElement::info, &HTMLIsIndexElementTable, 0 };const ClassInfo KJS::HTMLElement::style_info = { "HTMLStyleElement", &KJS::HTMLElement::info, &HTMLStyleElementTable, 0 };const ClassInfo KJS::HTMLElement::body_info = { "HTMLBodyElement", &KJS::HTMLElement::info, &HTMLBodyElementTable, 0 };const ClassInfo KJS::HTMLElement::form_info = { "HTMLFormElement", &KJS::HTMLElement::info, &HTMLFormElementTable, 0 };const ClassInfo KJS::HTMLElement::select_info = { "HTMLSelectElement", &KJS::HTMLElement::info, &HTMLSelectElementTable, 0 };const ClassInfo KJS::HTMLElement::optGroup_info = { "HTMLOptGroupElement", &KJS::HTMLElement::info, &HTMLOptGroupElementTable, 0 };const ClassInfo KJS::HTMLElement::option_info = { "HTMLOptionElement", &KJS::HTMLElement::info, &HTMLOptionElementTable, 0 };const ClassInfo KJS::HTMLElement::input_info = { "HTMLInputElement", &KJS::HTMLElement::info, &HTMLInputElementTable, 0 };const ClassInfo KJS::HTMLElement::textArea_info = { "HTMLTextAreaElement", &KJS::HTMLElement::info, &HTMLTextAreaElementTable, 0 };const ClassInfo KJS::HTMLElement::button_info = { "HTMLButtonElement", &KJS::HTMLElement::info, &HTMLButtonElementTable, 0 };const ClassInfo KJS::HTMLElement::label_info = { "HTMLLabelElement", &KJS::HTMLElement::info, &HTMLLabelElementTable, 0 };const ClassInfo KJS::HTMLElement::fieldSet_info = { "HTMLFieldSetElement", &KJS::HTMLElement::info, &HTMLFieldSetElementTable, 0 };const ClassInfo KJS::HTMLElement::legend_info = { "HTMLLegendElement", &KJS::HTMLElement::info, &HTMLLegendElementTable, 0 };const ClassInfo KJS::HTMLElement::ul_info = { "HTMLUListElement", &KJS::HTMLElement::info, &HTMLUListElementTable, 0 };const ClassInfo KJS::HTMLElement::ol_info = { "HTMLOListElement", &KJS::HTMLElement::info, &HTMLOListElementTable, 0 };const ClassInfo KJS::HTMLElement::dl_info = { "HTMLDListElement", &KJS::HTMLElement::info, &HTMLDListElementTable, 0 };const ClassInfo KJS::HTMLElement::dir_info = { "HTMLDirectoryElement", &KJS::HTMLElement::info, &HTMLDirectoryElementTable, 0 };const ClassInfo KJS::HTMLElement::menu_info = { "HTMLMenuElement", &KJS::HTMLElement::info, &HTMLMenuElementTable, 0 };const ClassInfo KJS::HTMLElement::li_info = { "HTMLLIElement", &KJS::HTMLElement::info, &HTMLLIElementTable, 0 };const ClassInfo KJS::HTMLElement::div_info = { "HTMLDivElement", &KJS::HTMLElement::info, &HTMLDivElementTable, 0 };const ClassInfo KJS::HTMLElement::p_info = { "HTMLParagraphElement", &KJS::HTMLElement::info, &HTMLParagraphElementTable, 0 };const ClassInfo KJS::HTMLElement::heading_info = { "HTMLHeadingElement", &KJS::HTMLElement::info, &HTMLHeadingElementTable, 0 };const ClassInfo KJS::HTMLElement::blockQuote_info = { "HTMLBlockQuoteElement", &KJS::HTMLElement::info, &HTMLBlockQuoteElementTable, 0 };const ClassInfo KJS::HTMLElement::q_info = { "HTMLQuoteElement", &KJS::HTMLElement::info, &HTMLQuoteElementTable, 0 };const ClassInfo KJS::HTMLElement::pre_info = { "HTMLPreElement", &KJS::HTMLElement::info, &HTMLPreElementTable, 0 };const ClassInfo KJS::HTMLElement::br_info = { "HTMLBRElement", &KJS::HTMLElement::info, &HTMLBRElementTable, 0 };const ClassInfo KJS::HTMLElement::baseFont_info = { "HTMLBaseFontElement", &KJS::HTMLElement::info, &HTMLBaseFontElementTable, 0 };const ClassInfo KJS::HTMLElement::font_info = { "HTMLFontElement", &KJS::HTMLElement::info, &HTMLFontElementTable, 0 };const ClassInfo KJS::HTMLElement::hr_info = { "HTMLHRElement", &KJS::HTMLElement::info, &HTMLHRElementTable, 0 };const ClassInfo KJS::HTMLElement::mod_info = { "HTMLModElement", &KJS::HTMLElement::info, &HTMLModElementTable, 0 };const ClassInfo KJS::HTMLElement::a_info = { "HTMLAnchorElement", &KJS::HTMLElement::info, &HTMLAnchorElementTable, 0 };const ClassInfo KJS::HTMLElement::canvas_info = { "HTMLCanvasElement", &KJS::HTMLElement::info, &HTMLCanvasElementTable, 0 };const ClassInfo KJS::HTMLElement::img_info = { "HTMLImageElement", &KJS::HTMLElement::info, &HTMLImageElementTable, 0 };const ClassInfo KJS::HTMLElement::object_info = { "HTMLObjectElement", &KJS::HTMLElement::info, &HTMLObjectElementTable, 0 };const ClassInfo KJS::HTMLElement::param_info = { "HTMLParamElement", &KJS::HTMLElement::info, &HTMLParamElementTable, 0 };const ClassInfo KJS::HTMLElement::applet_info = { "HTMLAppletElement", &KJS::HTMLElement::info, &HTMLAppletElementTable, 0 };const ClassInfo KJS::HTMLElement::map_info = { "HTMLMapElement", &KJS::HTMLElement::info, &HTMLMapElementTable, 0 };const ClassInfo KJS::HTMLElement::area_info = { "HTMLAreaElement", &KJS::HTMLElement::info, &HTMLAreaElementTable, 0 };const ClassInfo KJS::HTMLElement::script_info = { "HTMLScriptElement", &KJS::HTMLElement::info, &HTMLScriptElementTable, 0 };const ClassInfo KJS::HTMLElement::table_info = { "HTMLTableElement", &KJS::HTMLElement::info, &HTMLTableElementTable, 0 };const ClassInfo KJS::HTMLElement::caption_info = { "HTMLTableCaptionElement", &KJS::HTMLElement::info, &HTMLTableCaptionElementTable, 0 };const ClassInfo KJS::HTMLElement::col_info = { "HTMLTableColElement", &KJS::HTMLElement::info, &HTMLTableColElementTable, 0 };const ClassInfo KJS::HTMLElement::tablesection_info = { "HTMLTableSectionElement", &KJS::HTMLElement::info, &HTMLTableSectionElementTable, 0 };const ClassInfo KJS::HTMLElement::tr_info = { "HTMLTableRowElement", &KJS::HTMLElement::info, &HTMLTableRowElementTable, 0 };const ClassInfo KJS::HTMLElement::tablecell_info = { "HTMLTableCellElement", &KJS::HTMLElement::info, &HTMLTableCellElementTable, 0 };const ClassInfo KJS::HTMLElement::frameSet_info = { "HTMLFrameSetElement", &KJS::HTMLElement::info, &HTMLFrameSetElementTable, 0 };const ClassInfo KJS::HTMLElement::frame_info = { "HTMLFrameElement", &KJS::HTMLElement::info, &HTMLFrameElementTable, 0 };const ClassInfo KJS::HTMLElement::iFrame_info = { "HTMLIFrameElement", &KJS::HTMLElement::info, &HTMLIFrameElementTable, 0 };const ClassInfo KJS::HTMLElement::marquee_info = { "HTMLMarqueeElement", &KJS::HTMLElement::info, &HTMLMarqueeElementTable, 0 };const ClassInfo* KJS::HTMLElement::classInfo() const{ DOM::HTMLElement element = static_cast<DOM::HTMLElement>(node); switch (element.elementId()) { case ID_HTML: return &html_info; case ID_HEAD: return &head_info; case ID_LINK: return &link_info; case ID_TITLE: return &title_info; case ID_META: return &meta_info; case ID_BASE: return &base_info; case ID_ISINDEX: return &isIndex_info; case ID_STYLE: return &style_info; case ID_BODY: return &body_info; case ID_FORM: return &form_info; case ID_SELECT: return &select_info; case ID_OPTGROUP: return &optGroup_info; case ID_OPTION: return &option_info; case ID_INPUT: return &input_info; case ID_TEXTAREA: return &textArea_info; case ID_BUTTON: return &button_info; case ID_LABEL: return &label_info; case ID_FIELDSET: return &fieldSet_info; case ID_LEGEND: return &legend_info; case ID_UL: return &ul_info; case ID_OL: return &ol_info; case ID_DL: return &dl_info; case ID_DIR: return &dir_info; case ID_MENU: return &menu_info; case ID_LI: return &li_info; case ID_DIV: return &div_info; case ID_P: return &p_info; case ID_H1: case ID_H2: case ID_H3: case ID_H4: case ID_H5: case ID_H6: return &heading_info; case ID_BLOCKQUOTE: return &blockQuote_info; case ID_Q: return &q_info; case ID_PRE: return &pre_info; case ID_BR: return &br_info; case ID_BASEFONT: return &baseFont_info; case ID_FONT: return &font_info; case ID_HR: return &hr_info; case ID_INS: case ID_DEL: return &mod_info; case ID_A: return &a_info; case ID_CANVAS: return &canvas_info; case ID_IMG: return &img_info; case ID_OBJECT: return &object_info; case ID_PARAM: return ¶m_info; case ID_APPLET: return &applet_info; case ID_MAP: return &map_info; case ID_AREA: return &area_info; case ID_SCRIPT: return &script_info; case ID_TABLE: return &table_info; case ID_CAPTION: return &caption_info; case ID_COL: return &col_info; case ID_THEAD: return &tablesection_info; case ID_TBODY: return &tablesection_info; case ID_TFOOT: return &tablesection_info; case ID_TR: return &tr_info; case ID_TH: return &tablecell_info; case ID_TD: return &tablecell_info; case ID_FRAMESET: return &frameSet_info; case ID_FRAME: return &frame_info; case ID_IFRAME: return &iFrame_info; case ID_MARQUEE: return &marquee_info; default: return &info; }}/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -