Changeset 146897 in webkit


Ignore:
Timestamp:
Mar 26, 2013 9:45:15 AM (11 years ago)
Author:
apavlov@chromium.org
Message:

Web Inspector: [Elements] Unable to "Edit as HTML" XHTML/SVG documents.
https://bugs.webkit.org/show_bug.cgi?id=113290

Reviewed by Pavel Feldman.

Source/WebCore:

DOMPatchSupport has been slightly augmented to handle XML (XHTML and SVG) documents.

Test: inspector/elements/set-outer-html-for-xhtml.xhtml

  • inspector/DOMPatchSupport.cpp:

(WebCore::DOMPatchSupport::patchDocument):
(WebCore::DOMPatchSupport::patchNode):

  • inspector/InspectorDOMAgent.cpp:

(WebCore::InspectorDOMAgent::setOuterHTML): Let HTML, XHTML, and SVG documents through.

LayoutTests:

  • inspector/elements/set-outer-html-for-xhtml-expected.txt: Added.
  • inspector/elements/set-outer-html-for-xhtml.xhtml: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r146896 r146897  
     12013-03-26  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: [Elements] Unable to "Edit as HTML" XHTML/SVG documents.
     4        https://bugs.webkit.org/show_bug.cgi?id=113290
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/elements/set-outer-html-for-xhtml-expected.txt: Added.
     9        * inspector/elements/set-outer-html-for-xhtml.xhtml: Added.
     10
    1112013-03-26  Hajime Morrita  <morrita@google.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r146896 r146897  
     12013-03-26  Alexander Pavlov  <apavlov@chromium.org>
     2
     3        Web Inspector: [Elements] Unable to "Edit as HTML" XHTML/SVG documents.
     4        https://bugs.webkit.org/show_bug.cgi?id=113290
     5
     6        Reviewed by Pavel Feldman.
     7
     8        DOMPatchSupport has been slightly augmented to handle XML (XHTML and SVG) documents.
     9
     10        Test: inspector/elements/set-outer-html-for-xhtml.xhtml
     11
     12        * inspector/DOMPatchSupport.cpp:
     13        (WebCore::DOMPatchSupport::patchDocument):
     14        (WebCore::DOMPatchSupport::patchNode):
     15        * inspector/InspectorDOMAgent.cpp:
     16        (WebCore::InspectorDOMAgent::setOuterHTML): Let HTML, XHTML, and SVG documents through.
     17
    1182013-03-26  Hajime Morrita  <morrita@google.com>
    219
  • trunk/Source/WebCore/inspector/DOMPatchSupport.cpp

    r145818 r146897  
    4747#include "InspectorHistory.h"
    4848#include "Node.h"
     49#include "XMLDocumentParser.h"
    4950
    5051#include <wtf/Deque.h>
     
    9091void DOMPatchSupport::patchDocument(const String& markup)
    9192{
    92     RefPtr<HTMLDocument> newDocument = HTMLDocument::create(0, KURL());
     93    RefPtr<Document> newDocument;
     94    if (m_document->isHTMLDocument())
     95        newDocument = HTMLDocument::create(0, KURL());
     96    else if (m_document->isXHTMLDocument())
     97        newDocument = HTMLDocument::createXHTML(0, KURL());
     98#if ENABLE(SVG)
     99    else if (m_document->isSVGDocument())
     100        newDocument = Document::create(0, KURL());
     101#endif
     102
     103    ASSERT(newDocument);
    93104    newDocument->setContextFeatures(m_document->contextFeatures());
    94     RefPtr<DocumentParser> parser = HTMLDocumentParser::create(newDocument.get(), false);
     105    RefPtr<DocumentParser> parser;
     106    if (m_document->isHTMLDocument())
     107        parser = HTMLDocumentParser::create(static_cast<HTMLDocument*>(newDocument.get()), false);
     108    else
     109        parser = XMLDocumentParser::create(newDocument.get(), 0);
    95110    parser->insert(markup); // Use insert() so that the parser will not yield.
    96111    parser->finish();
     
    118133    // FIXME: This code should use one of createFragment* in markup.h
    119134    RefPtr<DocumentFragment> fragment = DocumentFragment::create(m_document);
    120     fragment->parseHTML(markup, node->parentElement() ? node->parentElement() : m_document->documentElement());
     135    if (m_document->isHTMLDocument())
     136        fragment->parseHTML(markup, node->parentElement() ? node->parentElement() : m_document->documentElement());
     137    else
     138        fragment->parseXML(markup, node->parentElement() ? node->parentElement() : m_document->documentElement());
    121139
    122140    // Compose the old list.
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r145818 r146897  
    735735
    736736    Document* document = node->isDocumentNode() ? toDocument(node) : node->ownerDocument();
    737     if (!document || !document->isHTMLDocument()) {
    738         *errorString = "Not an HTML document";
     737    if (!document || (!document->isHTMLDocument() && !document->isXHTMLDocument()
     738#if ENABLE(SVG)
     739        && !document->isSVGDocument()
     740#endif
     741    )) {
     742        *errorString = "Not an HTML/XML document";
    739743        return;
    740744    }
Note: See TracChangeset for help on using the changeset viewer.