diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /WebCore/html/HTMLParser.cpp | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebCore/html/HTMLParser.cpp')
-rw-r--r-- | WebCore/html/HTMLParser.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/WebCore/html/HTMLParser.cpp b/WebCore/html/HTMLParser.cpp index 644f63e..c5839a8 100644 --- a/WebCore/html/HTMLParser.cpp +++ b/WebCore/html/HTMLParser.cpp @@ -400,7 +400,7 @@ bool HTMLParser::insertNode(Node* n, bool flat) n->finishParsingChildren(); } - if (localName == htmlTag && m_document->frame()) + if (localName == htmlTag && m_document->frame() && !m_isParsingFragment) m_document->frame()->loader()->dispatchDocumentElementAvailable(); return true; @@ -446,7 +446,7 @@ bool HTMLParser::handleError(Node* n, bool flat, const AtomicString& localName, } } else if (h->hasLocalName(htmlTag)) { if (!m_current->isDocumentNode() ) { - if (m_document->documentElement() && m_document->documentElement()->hasTagName(htmlTag)) { + if (m_document->documentElement() && m_document->documentElement()->hasTagName(htmlTag) && !m_isParsingFragment) { reportError(RedundantHTMLBodyError, &localName); // we have another <HTML> element.... apply attributes to existing one // make sure we don't overwrite already existing attributes @@ -489,7 +489,7 @@ bool HTMLParser::handleError(Node* n, bool flat, const AtomicString& localName, return false; } } else if (h->hasLocalName(bodyTag)) { - if (m_inBody && m_document->body()) { + if (m_inBody && m_document->body() && !m_isParsingFragment) { // we have another <BODY> element.... apply attributes to existing one // make sure we don't overwrite already existing attributes // some sites use <body bgcolor=rightcolor>...<body bgcolor=wrongcolor> @@ -503,8 +503,7 @@ bool HTMLParser::handleError(Node* n, bool flat, const AtomicString& localName, existingBody->setAttribute(it->name(), it->value()); } return false; - } - else if (!m_current->isDocumentNode()) + } else if (!m_current->isDocumentNode()) return false; } else if (h->hasLocalName(areaTag)) { if (m_currentMapElement) { @@ -551,7 +550,7 @@ bool HTMLParser::handleError(Node* n, bool flat, const AtomicString& localName, if (!m_haveFrameSet) { // Ensure that head exists. // But not for older versions of Mail, where the implicit <head> isn't expected - <rdar://problem/6863795> - if (shouldCreateImplicitHead(m_document)) + if (!m_isParsingFragment && shouldCreateImplicitHead(m_document)) createHead(); popBlock(headTag); @@ -758,7 +757,7 @@ bool HTMLParser::framesetCreateErrorCheck(Token*, RefPtr<Node>&) // we can't implement that behaviour now because it could cause too many // regressions and the headaches are not worth the work as long as there is // no site actually relying on that detail (Dirk) - if (m_document->body()) + if (m_document->body() && !m_isParsingFragment) m_document->body()->setAttribute(styleAttr, "display:none"); m_inBody = false; } @@ -876,8 +875,8 @@ bool HTMLParser::noframesCreateErrorCheck(Token*, RefPtr<Node>&) bool HTMLParser::noscriptCreateErrorCheck(Token*, RefPtr<Node>&) { if (!m_isParsingFragment) { - Settings* settings = m_document->settings(); - if (settings && settings->isJavaScriptEnabled()) + Frame* frame = m_document->frame(); + if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript)) setSkipMode(noscriptTag); } return true; @@ -939,6 +938,7 @@ PassRefPtr<Node> HTMLParser::getNode(Token* t) gFunctionMap.set(h6Tag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); gFunctionMap.set(headTag.localName().impl(), &HTMLParser::headCreateErrorCheck); gFunctionMap.set(headerTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); + gFunctionMap.set(hgroupTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); gFunctionMap.set(hrTag.localName().impl(), &HTMLParser::pCloserCreateErrorCheck); gFunctionMap.set(iTag.localName().impl(), &HTMLParser::nestedStyleCreateErrorCheck); gFunctionMap.set(isindexTag.localName().impl(), &HTMLParser::isindexCreateErrorCheck); @@ -1061,8 +1061,8 @@ bool HTMLParser::isInline(Node* node) const return true; #if !ENABLE(XHTMLMP) if (e->hasLocalName(noscriptTag) && !m_isParsingFragment) { - Settings* settings = m_document->settings(); - if (settings && settings->isJavaScriptEnabled()) + Frame* frame = m_document->frame(); + if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript)) return true; } #endif @@ -1590,12 +1590,16 @@ void HTMLParser::createHead() if (m_head) return; - if (!m_document->documentElement()) { + if (!m_document->documentElement() && !m_isParsingFragment) { insertNode(new HTMLHtmlElement(htmlTag, m_document)); - ASSERT(m_document->documentElement()); + ASSERT(m_document->documentElement() || m_isParsingFragment); } m_head = new HTMLHeadElement(headTag, m_document); + + if (m_isParsingFragment) + return; + HTMLElement* body = m_document->body(); ExceptionCode ec = 0; m_document->documentElement()->insertBefore(m_head.get(), body, ec); |