Changeset 160330 in webkit


Ignore:
Timestamp:
Dec 9, 2013 2:06:45 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

Implement Document.cloneNode()
https://bugs.webkit.org/show_bug.cgi?id=11646

Reviewed by Darin Adler.

Source/WebCore:

Merge https://chromium.googlesource.com/chromium/blink/+/dc7879025e01d63be9fcf6a84ca6c9b8b5768a80

Implement the behavior specified in the current DOM4 working draft:
http://www.w3.org/TR/2013/WD-dom-20131107/#dom-node-clonenode

Tests: fast/dom/Document/clone-node.html

fast/dom/HTMLDocument/clone-node-quirks-mode.html
svg/custom/clone-node.html

  • dom/Document.cpp:

(WebCore::Document::cloneNode):
(WebCore::Document::cloneDocumentWithoutChildren):
(WebCore::Document::cloneDataFromDocument):

  • dom/Document.h:
  • html/HTMLDocument.cpp:

(WebCore::HTMLDocument::cloneDocumentWithoutChildren):

  • html/HTMLDocument.h:
  • svg/SVGDocument.cpp:

(WebCore::SVGDocument::cloneDocumentWithoutChildren):

  • svg/SVGDocument.h:

LayoutTests:

  • dom/xhtml/level3/core/documentgetinputencoding04-expected.txt:
  • dom/xhtml/level3/core/documentgetxmlencoding05-expected.txt:
  • dom/xhtml/level3/core/nodeisequalnode01-expected.txt:
  • dom/xhtml/level3/core/nodeisequalnode21-expected.txt:
  • dom/xhtml/level3/core/nodeisequalnode25-expected.txt:
  • dom/xhtml/level3/core/nodeisequalnode26-expected.txt:
  • fast/dom/Document/clone-node-expected.txt: Added.
  • fast/dom/Document/clone-node.html: Added.
  • fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt: Added.
  • fast/dom/HTMLDocument/clone-node-quirks-mode.html: Added.
  • svg/custom/clone-node-expected.txt: Added.
  • svg/custom/clone-node.html: Added.
Location:
trunk
Files:
6 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r160323 r160330  
     12013-12-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Implement Document.cloneNode()
     4        https://bugs.webkit.org/show_bug.cgi?id=11646
     5
     6        Reviewed by Darin Adler.
     7
     8        * dom/xhtml/level3/core/documentgetinputencoding04-expected.txt:
     9        * dom/xhtml/level3/core/documentgetxmlencoding05-expected.txt:
     10        * dom/xhtml/level3/core/nodeisequalnode01-expected.txt:
     11        * dom/xhtml/level3/core/nodeisequalnode21-expected.txt:
     12        * dom/xhtml/level3/core/nodeisequalnode25-expected.txt:
     13        * dom/xhtml/level3/core/nodeisequalnode26-expected.txt:
     14        * fast/dom/Document/clone-node-expected.txt: Added.
     15        * fast/dom/Document/clone-node.html: Added.
     16        * fast/dom/HTMLDocument/clone-node-quirks-mode-expected.txt: Added.
     17        * fast/dom/HTMLDocument/clone-node-quirks-mode.html: Added.
     18        * svg/custom/clone-node-expected.txt: Added.
     19        * svg/custom/clone-node.html: Added.
     20
    1212013-12-09  Mario Sanchez Prada  <mario.prada@samsung.com>
    222
  • trunk/LayoutTests/dom/xhtml/level3/core/documentgetinputencoding04-expected.txt

    r33979 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentgetinputencoding04
    2 Status  error
    3 Message Line 98: TypeError
     2Status  Success
  • trunk/LayoutTests/dom/xhtml/level3/core/documentgetxmlencoding05-expected.txt

    r33979 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentgetxmlencoding05
    2 Status  error
    3 Message Line 98: TypeError
     2Status  Success
  • trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode01-expected.txt

    r30431 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode01
    2 Status  failure
    3 Message nodeisequalnode01: assertTrue failed
     2Status  Success
  • trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode21-expected.txt

    r11962 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode21
    2 Status  failure
    3 Message nodeisequalnode21: assertTrue failed
     2Status  Success
  • trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode25-expected.txt

    r33979 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode25
    22Status  error
    3 Message Line 123: TypeError
     3Message Line 125: TypeError
  • trunk/LayoutTests/dom/xhtml/level3/core/nodeisequalnode26-expected.txt

    r33979 r160330  
    11Test    http://www.w3.org/2001/DOM-Test-Suite/level3/core/nodeisequalnode26
    22Status  error
    3 Message Line 123: TypeError
     3Message Line 125: TypeError
  • trunk/Source/WebCore/ChangeLog

    r160327 r160330  
     12013-12-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Implement Document.cloneNode()
     4        https://bugs.webkit.org/show_bug.cgi?id=11646
     5
     6        Reviewed by Darin Adler.
     7
     8        Merge https://chromium.googlesource.com/chromium/blink/+/dc7879025e01d63be9fcf6a84ca6c9b8b5768a80
     9
     10        Implement the behavior specified in the current DOM4 working draft:
     11        http://www.w3.org/TR/2013/WD-dom-20131107/#dom-node-clonenode
     12
     13        Tests: fast/dom/Document/clone-node.html
     14               fast/dom/HTMLDocument/clone-node-quirks-mode.html
     15               svg/custom/clone-node.html
     16
     17        * dom/Document.cpp:
     18        (WebCore::Document::cloneNode):
     19        (WebCore::Document::cloneDocumentWithoutChildren):
     20        (WebCore::Document::cloneDataFromDocument):
     21        * dom/Document.h:
     22        * html/HTMLDocument.cpp:
     23        (WebCore::HTMLDocument::cloneDocumentWithoutChildren):
     24        * html/HTMLDocument.h:
     25        * svg/SVGDocument.cpp:
     26        (WebCore::SVGDocument::cloneDocumentWithoutChildren):
     27        * svg/SVGDocument.h:
     28
    1292013-12-09  Andreas Kling  <akling@apple.com>
    230
  • trunk/Source/WebCore/dom/Document.cpp

    r159856 r160330  
    30263026}
    30273027
    3028 PassRefPtr<Node> Document::cloneNode(bool /*deep*/)
    3029 {
    3030     // Spec says cloning Document nodes is "implementation dependent" and we do not support it.
    3031     return nullptr;
     3028PassRefPtr<Node> Document::cloneNode(bool deep)
     3029{
     3030    RefPtr<Document> clone = cloneDocumentWithoutChildren();
     3031    clone->cloneDataFromDocument(*this);
     3032    if (deep)
     3033        cloneChildNodes(clone.get());
     3034    return clone.release();
     3035}
     3036
     3037PassRefPtr<Document> Document::cloneDocumentWithoutChildren() const
     3038{
     3039    return isXHTMLDocument() ? createXHTML(nullptr, url()) : create(nullptr, url());
     3040}
     3041
     3042void Document::cloneDataFromDocument(const Document& other)
     3043{
     3044    ASSERT(m_url == other.url());
     3045    m_baseURL = other.baseURL();
     3046    m_baseURLOverride = other.baseURLOverride();
     3047    m_documentURI = other.documentURI();
     3048
     3049    setCompatibilityMode(other.compatibilityMode());
     3050    setSecurityOrigin(other.securityOrigin());
     3051    setDecoder(other.decoder());
    30323052}
    30333053
  • trunk/Source/WebCore/dom/Document.h

    r159246 r160330  
    11891189    void clearXMLVersion() { m_xmlVersion = String(); }
    11901190
     1191    virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const;
     1192
    11911193private:
    11921194    friend class Node;
     
    12151217    virtual bool childTypeAllowed(NodeType) const OVERRIDE;
    12161218    virtual PassRefPtr<Node> cloneNode(bool deep) OVERRIDE;
     1219    void cloneDataFromDocument(const Document&);
    12171220
    12181221    virtual void refScriptExecutionContext() OVERRIDE { ref(); }
  • trunk/Source/WebCore/html/HTMLDocument.cpp

    r160157 r160330  
    366366}
    367367
    368 }
     368PassRefPtr<Document> HTMLDocument::cloneDocumentWithoutChildren() const
     369{
     370    return create(nullptr, url());
     371}
     372
     373}
  • trunk/Source/WebCore/html/HTMLDocument.h

    r160072 r160330  
    8989    virtual PassRefPtr<DocumentParser> createParser();
    9090
     91    virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const OVERRIDE FINAL;
     92
    9193    DocumentOrderedMap m_documentNamedItem;
    9294    DocumentOrderedMap m_windowNamedItem;
  • trunk/Source/WebCore/svg/SVGDocument.cpp

    r159036 r160330  
    101101}
    102102
     103PassRefPtr<Document> SVGDocument::cloneDocumentWithoutChildren() const
     104{
     105    return create(nullptr, url());
     106}
     107
    103108}
    104109
  • trunk/Source/WebCore/svg/SVGDocument.h

    r159036 r160330  
    5454    virtual bool childShouldCreateRenderer(const Node&) const OVERRIDE;
    5555
     56    virtual PassRefPtr<Document> cloneDocumentWithoutChildren() const OVERRIDE;
     57
    5658    FloatPoint m_translate;
    5759};
Note: See TracChangeset for help on using the changeset viewer.