diff options
Diffstat (limited to 'Source/WebCore/html/HTMLDocument.cpp')
-rw-r--r-- | Source/WebCore/html/HTMLDocument.cpp | 143 |
1 files changed, 35 insertions, 108 deletions
diff --git a/Source/WebCore/html/HTMLDocument.cpp b/Source/WebCore/html/HTMLDocument.cpp index c6067d88a..f7b0978a9 100644 --- a/Source/WebCore/html/HTMLDocument.cpp +++ b/Source/WebCore/html/HTMLDocument.cpp @@ -54,26 +54,25 @@ #include "HTMLDocument.h" #include "CSSPropertyNames.h" +#include "CommonVM.h" #include "CookieJar.h" #include "DocumentLoader.h" #include "DocumentType.h" -#include "ExceptionCode.h" +#include "ElementChildIterator.h" #include "FocusController.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameTree.h" #include "FrameView.h" -#include "HashTools.h" -#include "HTMLDocumentParser.h" #include "HTMLBodyElement.h" +#include "HTMLDocumentParser.h" #include "HTMLElementFactory.h" #include "HTMLFrameOwnerElement.h" #include "HTMLFrameSetElement.h" +#include "HTMLHtmlElement.h" #include "HTMLNames.h" -#include "JSDOMBinding.h" -#include "Page.h" +#include "HashTools.h" #include "ScriptController.h" -#include "Settings.h" #include "StyleResolver.h" #include <wtf/text/CString.h> @@ -105,138 +104,74 @@ int HTMLDocument::height() return frameView ? frameView->contentsHeight() : 0; } -String HTMLDocument::dir() -{ - HTMLElement* b = body(); - if (!b) - return String(); - return b->getAttribute(dirAttr); -} - -void HTMLDocument::setDir(const String& value) -{ - HTMLElement* b = body(); - if (b) - b->setAttribute(dirAttr, value); -} - -String HTMLDocument::designMode() const -{ - return inDesignMode() ? "on" : "off"; -} - -void HTMLDocument::setDesignMode(const String& value) -{ - InheritedBool mode; - if (equalIgnoringCase(value, "on")) - mode = on; - else if (equalIgnoringCase(value, "off")) - mode = off; - else - mode = inherit; - Document::setDesignMode(mode); -} - -Element* HTMLDocument::activeElement() -{ - document().updateStyleIfNeeded(); - if (Element* element = treeScope().focusedElement()) - return element; - return body(); -} - -bool HTMLDocument::hasFocus() -{ - Page* page = this->page(); - if (!page) - return false; - if (!page->focusController().isActive()) - return false; - if (Frame* focusedFrame = page->focusController().focusedFrame()) { - if (focusedFrame->tree().isDescendantOf(frame())) - return true; - } - return false; -} - const AtomicString& HTMLDocument::bgColor() const { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) + auto* bodyElement = body(); + if (!bodyElement) return emptyAtom; - return bodyElement->fastGetAttribute(bgcolorAttr); + return bodyElement->attributeWithoutSynchronization(bgcolorAttr); } void HTMLDocument::setBgColor(const String& value) { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) - return; - bodyElement->setAttribute(bgcolorAttr, value); + if (auto* bodyElement = body()) + bodyElement->setAttributeWithoutSynchronization(bgcolorAttr, value); } const AtomicString& HTMLDocument::fgColor() const { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) + auto* bodyElement = body(); + if (!bodyElement) return emptyAtom; - return bodyElement->fastGetAttribute(textAttr); + return bodyElement->attributeWithoutSynchronization(textAttr); } void HTMLDocument::setFgColor(const String& value) { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) - return; - bodyElement->setAttribute(textAttr, value); + if (auto* bodyElement = body()) + bodyElement->setAttributeWithoutSynchronization(textAttr, value); } const AtomicString& HTMLDocument::alinkColor() const { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) + auto* bodyElement = body(); + if (!bodyElement) return emptyAtom; - return bodyElement->fastGetAttribute(alinkAttr); + return bodyElement->attributeWithoutSynchronization(alinkAttr); } void HTMLDocument::setAlinkColor(const String& value) { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) - return; - bodyElement->setAttribute(alinkAttr, value); + if (auto* bodyElement = body()) + bodyElement->setAttributeWithoutSynchronization(alinkAttr, value); } const AtomicString& HTMLDocument::linkColor() const { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) + auto* bodyElement = body(); + if (!bodyElement) return emptyAtom; - return bodyElement->fastGetAttribute(linkAttr); + return bodyElement->attributeWithoutSynchronization(linkAttr); } void HTMLDocument::setLinkColor(const String& value) { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) - return; - return bodyElement->setAttribute(linkAttr, value); + if (auto* bodyElement = body()) + bodyElement->setAttributeWithoutSynchronization(linkAttr, value); } const AtomicString& HTMLDocument::vlinkColor() const { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) + auto* bodyElement = body(); + if (!bodyElement) return emptyAtom; - return bodyElement->fastGetAttribute(vlinkAttr); + return bodyElement->attributeWithoutSynchronization(vlinkAttr); } void HTMLDocument::setVlinkColor(const String& value) { - HTMLElement* bodyElement = body(); - if (!bodyElement || !isHTMLBodyElement(bodyElement)) - return; - return bodyElement->setAttribute(vlinkAttr, value); + if (auto* bodyElement = body()) + bodyElement->setAttributeWithoutSynchronization(vlinkAttr, value); } void HTMLDocument::captureEvents() @@ -247,7 +182,7 @@ void HTMLDocument::releaseEvents() { } -PassRefPtr<DocumentParser> HTMLDocument::createParser() +Ref<DocumentParser> HTMLDocument::createParser() { return HTMLDocumentParser::create(*this); } @@ -256,15 +191,6 @@ PassRefPtr<DocumentParser> HTMLDocument::createParser() // not part of the DOM // -------------------------------------------------------------------------- -PassRefPtr<Element> HTMLDocument::createElement(const AtomicString& name, ExceptionCode& ec) -{ - if (!isValidName(name)) { - ec = INVALID_CHARACTER_ERR; - return 0; - } - return HTMLElementFactory::createElement(QualifiedName(nullAtom, name.lower(), xhtmlNamespaceURI), *this); -} - static void addLocalNameToSet(HashSet<AtomicStringImpl*>* set, const QualifiedName& qName) { set->add(qName.localName().impl()); @@ -362,11 +288,12 @@ void HTMLDocument::clear() bool HTMLDocument::isFrameSet() const { - HTMLElement* bodyElement = body(); - return bodyElement && isHTMLFrameSetElement(bodyElement); + if (!documentElement()) + return false; + return !!childrenOfType<HTMLFrameSetElement>(*documentElement()).first(); } -PassRefPtr<Document> HTMLDocument::cloneDocumentWithoutChildren() const +Ref<Document> HTMLDocument::cloneDocumentWithoutChildren() const { return create(nullptr, url()); } |