📄 htmlelement.cpp
字号:
}}void HTMLElement::setContentEditable(const String &enabled){ if (enabled == "inherit") { ExceptionCode ec; removeAttribute(contenteditableAttr, ec); } else setAttribute(contenteditableAttr, enabled.isEmpty() ? "true" : enabled);}void HTMLElement::click(){ dispatchSimulatedClick(0, false, false);}// accessKeyAction is used by the accessibility support code// to send events to elements that our JavaScript caller does// does not. The elements JS is interested in have subclasses// that override this method to direct the click appropriately.// Here in the base class, then, we only send the click if// the caller wants it to go to any HTMLElement, and we say// to send the mouse events in addition to the click.void HTMLElement::accessKeyAction(bool sendToAnyElement){ if (sendToAnyElement) dispatchSimulatedClick(0, true);}String HTMLElement::id() const{ return getAttribute(idAttr);}void HTMLElement::setId(const String& value){ setAttribute(idAttr, value);}String HTMLElement::title() const{ return getAttribute(titleAttr);}void HTMLElement::setTitle(const String& value){ setAttribute(titleAttr, value);}String HTMLElement::lang() const{ return getAttribute(langAttr);}void HTMLElement::setLang(const String& value){ setAttribute(langAttr, value);}String HTMLElement::dir() const{ return getAttribute(dirAttr);}void HTMLElement::setDir(const String &value){ setAttribute(dirAttr, value);}String HTMLElement::className() const{ return getAttribute(classAttr);}void HTMLElement::setClassName(const String &value){ setAttribute(classAttr, value);}short HTMLElement::tabIndex() const{ if (supportsFocus()) return Element::tabIndex(); return -1;}void HTMLElement::setTabIndex(int value){ setAttribute(tabindexAttr, String::number(value));}PassRefPtr<HTMLCollection> HTMLElement::children(){ return HTMLCollection::create(this, HTMLCollection::NodeChildren);}// DOM Section 1.1.1bool HTMLElement::childAllowed(Node *newChild){ if (!Element::childAllowed(newChild)) return false; // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements. if (!document()->isHTMLDocument()) return true; // Future-proof for XML content inside HTML documents (we may allow this some day). if (newChild->isElementNode() && !newChild->isHTMLElement()) return true; // Elements with forbidden tag status can never have children if (endTagRequirement() == TagStatusForbidden) return false; // Comment nodes are always allowed. if (newChild->isCommentNode()) return true; // Now call checkDTD. return checkDTD(newChild);}// DTD Stuff// This unfortunate function is only needed when checking against the DTD. Other languages (like SVG) won't need this.bool HTMLElement::isRecognizedTagName(const QualifiedName& tagName){ DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ()); if (tagList.isEmpty()) { size_t tagCount = 0; WebCore::QualifiedName** tags = HTMLNames::getHTMLTags(&tagCount); for (size_t i = 0; i < tagCount; i++) tagList.add(tags[i]->localName().impl()); } return tagList.contains(tagName.localName().impl());}// The terms inline and block are used here loosely. Don't make the mistake of assuming all inlines or all blocks// need to be in these two lists.static HashSet<AtomicStringImpl*>* inlineTagList(){ DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ()); if (tagList.isEmpty()) { tagList.add(ttTag.localName().impl()); tagList.add(iTag.localName().impl()); tagList.add(bTag.localName().impl()); tagList.add(uTag.localName().impl()); tagList.add(sTag.localName().impl()); tagList.add(strikeTag.localName().impl()); tagList.add(bigTag.localName().impl()); tagList.add(smallTag.localName().impl()); tagList.add(emTag.localName().impl()); tagList.add(strongTag.localName().impl()); tagList.add(dfnTag.localName().impl()); tagList.add(codeTag.localName().impl()); tagList.add(sampTag.localName().impl()); tagList.add(kbdTag.localName().impl()); tagList.add(varTag.localName().impl()); tagList.add(citeTag.localName().impl()); tagList.add(abbrTag.localName().impl()); tagList.add(acronymTag.localName().impl()); tagList.add(aTag.localName().impl()); tagList.add(canvasTag.localName().impl()); tagList.add(imgTag.localName().impl()); tagList.add(appletTag.localName().impl()); tagList.add(objectTag.localName().impl()); tagList.add(embedTag.localName().impl()); tagList.add(fontTag.localName().impl()); tagList.add(basefontTag.localName().impl()); tagList.add(brTag.localName().impl()); tagList.add(scriptTag.localName().impl()); tagList.add(styleTag.localName().impl()); tagList.add(linkTag.localName().impl()); tagList.add(mapTag.localName().impl()); tagList.add(qTag.localName().impl()); tagList.add(subTag.localName().impl()); tagList.add(supTag.localName().impl()); tagList.add(spanTag.localName().impl()); tagList.add(bdoTag.localName().impl()); tagList.add(iframeTag.localName().impl()); tagList.add(inputTag.localName().impl()); tagList.add(keygenTag.localName().impl()); tagList.add(selectTag.localName().impl()); tagList.add(textareaTag.localName().impl()); tagList.add(labelTag.localName().impl()); tagList.add(buttonTag.localName().impl()); tagList.add(insTag.localName().impl()); tagList.add(delTag.localName().impl()); tagList.add(nobrTag.localName().impl()); tagList.add(wbrTag.localName().impl());#if ENABLE(VIDEO) tagList.add(audioTag.localName().impl()); tagList.add(videoTag.localName().impl());#endif } return &tagList;}static HashSet<AtomicStringImpl*>* blockTagList(){ DEFINE_STATIC_LOCAL(HashSet<AtomicStringImpl*>, tagList, ()); if (tagList.isEmpty()) { tagList.add(addressTag.localName().impl()); tagList.add(blockquoteTag.localName().impl()); tagList.add(centerTag.localName().impl()); tagList.add(ddTag.localName().impl()); tagList.add(dirTag.localName().impl()); tagList.add(divTag.localName().impl()); tagList.add(dlTag.localName().impl()); tagList.add(dtTag.localName().impl()); tagList.add(fieldsetTag.localName().impl()); tagList.add(formTag.localName().impl()); tagList.add(h1Tag.localName().impl()); tagList.add(h2Tag.localName().impl()); tagList.add(h3Tag.localName().impl()); tagList.add(h4Tag.localName().impl()); tagList.add(h5Tag.localName().impl()); tagList.add(h6Tag.localName().impl()); tagList.add(hrTag.localName().impl()); tagList.add(isindexTag.localName().impl()); tagList.add(layerTag.localName().impl()); tagList.add(liTag.localName().impl()); tagList.add(listingTag.localName().impl()); tagList.add(marqueeTag.localName().impl()); tagList.add(menuTag.localName().impl()); tagList.add(noembedTag.localName().impl()); tagList.add(noframesTag.localName().impl()); tagList.add(nolayerTag.localName().impl()); tagList.add(noscriptTag.localName().impl()); tagList.add(olTag.localName().impl()); tagList.add(pTag.localName().impl()); tagList.add(plaintextTag.localName().impl()); tagList.add(preTag.localName().impl()); tagList.add(tableTag.localName().impl()); tagList.add(ulTag.localName().impl()); tagList.add(xmpTag.localName().impl()); } return &tagList;}bool HTMLElement::inEitherTagList(const Node* newChild){ if (newChild->isTextNode()) return true; if (newChild->isHTMLElement()) { const HTMLElement* child = static_cast<const HTMLElement*>(newChild); if (inlineTagList()->contains(child->tagQName().localName().impl())) return true; if (blockTagList()->contains(child->tagQName().localName().impl())) return true; return !isRecognizedTagName(child->tagQName()); // Accept custom html tags } return false;}bool HTMLElement::inInlineTagList(const Node* newChild){ if (newChild->isTextNode()) return true; if (newChild->isHTMLElement()) { const HTMLElement* child = static_cast<const HTMLElement*>(newChild); if (inlineTagList()->contains(child->tagQName().localName().impl())) return true; return !isRecognizedTagName(child->tagQName()); // Accept custom html tags } return false;}bool HTMLElement::inBlockTagList(const Node* newChild){ if (newChild->isTextNode()) return true; if (newChild->isHTMLElement()) { const HTMLElement* child = static_cast<const HTMLElement*>(newChild); return (blockTagList()->contains(child->tagQName().localName().impl())); } return false;}bool HTMLElement::checkDTD(const Node* newChild){ if (hasLocalName(addressTag) && newChild->hasTagName(pTag)) return true; return inEitherTagList(newChild);} bool HTMLElement::rendererIsNeeded(RenderStyle *style){ if (hasLocalName(noscriptTag)) { Settings* settings = document()->settings(); if (settings && settings->isJavaScriptEnabled()) return false; } return StyledElement::rendererIsNeeded(style);} RenderObject* HTMLElement::createRenderer(RenderArena* arena, RenderStyle* style){ if (hasLocalName(wbrTag)) return new (arena) RenderWordBreak(this); return RenderObject::createObject(this, style);}HTMLFormElement* HTMLElement::findFormAncestor() const{ for (Node* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) if (ancestor->hasTagName(formTag)) return static_cast<HTMLFormElement*>(ancestor); return 0;}HTMLFormElement* HTMLElement::virtualForm() const{ return findFormAncestor();}} // namespace WebCore#ifndef NDEBUG// For use in the debuggervoid dumpInnerHTML(WebCore::HTMLElement*);void dumpInnerHTML(WebCore::HTMLElement* element){ printf("%s\n", element->innerHTML().ascii().data());}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -