LayoutTests:
authorthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jul 2006 07:56:54 +0000 (07:56 +0000)
committerthatcher <thatcher@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 9 Jul 2006 07:56:54 +0000 (07:56 +0000)
        Reviewed by Maciej.

        Bug 5312: comments aren't available via DOM
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312

        New tests for DOM comment nodes. Updated results to account for new
        nodes in the DOM (editing offsets changed.)

        * editing/deleting/delete-line-013-expected.txt:
        * editing/deleting/delete-line-014-expected.txt:
        * editing/inserting/insert-3907422-fix-expected.txt:
        * editing/inserting/insert-div-009-expected.txt:
        * editing/inserting/insert-div-010-expected.txt:
        * editing/selection/extend-by-character-006-expected.txt:
        * editing/selection/move-between-blocks-no-001-expected.txt:
        * editing/selection/move-between-blocks-yes-001-expected.txt:
        * fast/dom/HTMLDocument/object-by-name-or-id-expected.txt:
        * fast/dom/HTMLDocument/object-by-name-or-id.html:
        * fast/dom/comment-document-fragment-expected.txt: Added.
        * fast/dom/comment-document-fragment.html: Added.
        * fast/dom/comment-dom-node-expected.txt: Added.
        * fast/dom/comment-dom-node.html: Added.
        * fast/dom/comment-not-documentElement-expected.checksum: Added.
        * fast/dom/comment-not-documentElement-expected.png: Added.
        * fast/dom/comment-not-documentElement-expected.txt: Added.
        * fast/dom/comment-not-documentElement.html: Added.
        * fast/text/atsui-pointtooffset-calls-cg-expected.txt:
        * fast/text/atsui-rtl-override-selection-expected.txt:

WebCore:

        Reviewed by Maciej.

        Bug 5312: comments aren't available via DOM
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312

        <rdar://problem/4564414> getting comments via DOM isn't working (5312)
        <rdar://problem/4545691> DOM_COMMENT node masking out real DOM elements

        * dom/Document.cpp:
        (WebCore::Document::removedLastRef): set m_documentElement to 0
        (WebCore::Document::childrenChanged): invalidate the document element we have cached in case it was replaced
        (WebCore::Document::documentElement): cache the first element as the document node if m_documentElement is 0
        * dom/Document.h: added m_documentElement
        * html/HTMLDocument.cpp: removed documentElement(), HTML documents just use Document's documentElement()
        * html/HTMLDocument.h: ditto
        * html/HTMLParser.cpp:
        (WebCore::HTMLParser::handleError): make a new HTML node is the document's firstChild is NULL or
        the firstChild is not a HTML element (like a comment)
        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::parseComment): removed the #ifdef to include comment nodes

WebKit:

        Reviewed by Maciej.

        Bug 5312: comments aren't available via DOM
        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312

        Makes the Web Inspector show comment node contents.

        * WebInspector/WebInspector.m:
        (-[DOMNode _displayName]): return the contents of the comment
        * WebInspector/webInspector/inspector.js: check for comment nodes

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15247 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/deleting/delete-line-013-expected.txt
LayoutTests/editing/deleting/delete-line-014-expected.txt
LayoutTests/editing/inserting/insert-3907422-fix-expected.txt
LayoutTests/editing/inserting/insert-div-009-expected.txt
LayoutTests/editing/inserting/insert-div-010-expected.txt
LayoutTests/editing/selection/extend-by-character-006-expected.txt
LayoutTests/editing/selection/move-between-blocks-no-001-expected.txt
LayoutTests/editing/selection/move-between-blocks-yes-001-expected.txt
LayoutTests/fast/dom/HTMLDocument/object-by-name-or-id-expected.txt
LayoutTests/fast/dom/HTMLDocument/object-by-name-or-id.html
LayoutTests/fast/dom/comment-document-fragment-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/comment-document-fragment.html [new file with mode: 0644]
LayoutTests/fast/dom/comment-dom-node-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/comment-dom-node.html [new file with mode: 0644]
LayoutTests/fast/dom/comment-not-documentElement-expected.checksum [new file with mode: 0644]
LayoutTests/fast/dom/comment-not-documentElement-expected.png [new file with mode: 0644]
LayoutTests/fast/dom/comment-not-documentElement-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/comment-not-documentElement.html [new file with mode: 0644]
LayoutTests/fast/text/atsui-pointtooffset-calls-cg-expected.txt
LayoutTests/fast/text/atsui-rtl-override-selection-expected.txt
WebCore/ChangeLog
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/html/HTMLDocument.cpp
WebCore/html/HTMLDocument.h
WebCore/html/HTMLParser.cpp
WebCore/html/HTMLTokenizer.cpp
WebKit/ChangeLog
WebKit/WebInspector/WebInspector.m
WebKit/WebInspector/webInspector/inspector.js

index 2b06d73..1fec69c 100644 (file)
@@ -1,3 +1,34 @@
+2006-07-08  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Maciej.
+
+        Bug 5312: comments aren't available via DOM
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312
+
+        New tests for DOM comment nodes. Updated results to account for new
+        nodes in the DOM (editing offsets changed.)
+
+        * editing/deleting/delete-line-013-expected.txt:
+        * editing/deleting/delete-line-014-expected.txt:
+        * editing/inserting/insert-3907422-fix-expected.txt:
+        * editing/inserting/insert-div-009-expected.txt:
+        * editing/inserting/insert-div-010-expected.txt:
+        * editing/selection/extend-by-character-006-expected.txt:
+        * editing/selection/move-between-blocks-no-001-expected.txt:
+        * editing/selection/move-between-blocks-yes-001-expected.txt:
+        * fast/dom/HTMLDocument/object-by-name-or-id-expected.txt:
+        * fast/dom/HTMLDocument/object-by-name-or-id.html:
+        * fast/dom/comment-document-fragment-expected.txt: Added.
+        * fast/dom/comment-document-fragment.html: Added.
+        * fast/dom/comment-dom-node-expected.txt: Added.
+        * fast/dom/comment-dom-node.html: Added.
+        * fast/dom/comment-not-documentElement-expected.checksum: Added.
+        * fast/dom/comment-not-documentElement-expected.png: Added.
+        * fast/dom/comment-not-documentElement-expected.txt: Added.
+        * fast/dom/comment-not-documentElement.html: Added.
+        * fast/text/atsui-pointtooffset-calls-cg-expected.txt:
+        * fast/text/atsui-rtl-override-selection-expected.txt:
+
 2006-07-08  Darin Adler  <darin@apple.com>
 
         Reviewed by Geoff (well, half of it at least).
index 11b0825..b5a6fec 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 7 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
index 045b556..4a1cb86 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 7 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
index 1b47d36..e1ee820 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 5 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
index c7048ac..4710fd0 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 5 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > BODY > HTML > #document to 0 of DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > BODY > HTML > #document to 4 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
index 0f3770c..704ad35 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 5 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 6 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 1 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
index bad9190..0b61af5 100644 (file)
@@ -17,5 +17,5 @@ layer at (0,0) size 800x600
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
-selection start: position 1 of child 0 {#text} of child 1 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 4 of child 0 {#text} of child 1 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection start: position 1 of child 0 {#text} of child 1 {SPAN} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 4 of child 0 {#text} of child 1 {SPAN} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index b62b2c5..c542e2a 100644 (file)
@@ -113,4 +113,4 @@ layer at (0,0) size 800x600
       RenderBlock {DIV} at (0,56) size 784x56 [border: (2px solid #FF0000)]
         RenderText {#text} at (14,14) size 318x28
           text run at (14,14) width 318: "that all men are created equal, ..."
-caret: position 25 of child 0 {#text} of child 1 {SPAN} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 25 of child 0 {#text} of child 1 {SPAN} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 4b881a5..cdea97d 100644 (file)
@@ -1,4 +1,4 @@
-EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 7 of BODY > HTML > #document
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of BODY > HTML > #document to 8 of BODY > HTML > #document
 EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
@@ -64,4 +64,4 @@ layer at (0,0) size 800x600
       RenderBlock {DIV} at (0,56) size 784x56 [border: (2px solid #FF0000)]
         RenderText {#text} at (14,14) size 318x28
           text run at (14,14) width 318: "that all men are created equal, ..."
-caret: position 10 of child 0 {#text} of child 4 {DIV} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 10 of child 0 {#text} of child 5 {DIV} of child 1 {BODY} of child 0 {HTML} of document
index 06bfa3e..e35741c 100644 (file)
@@ -6,8 +6,8 @@ By name:
 no children: PASS
 param: PASS
 param and whitespace: PASS
-param and empty comment (expected to fail): FAIL
-param and non-empty comment (expected to fail): FAIL
+param and empty comment: PASS
+param and non-empty comment: PASS
 param and text: PASS
 param and img: PASS
 
@@ -15,8 +15,8 @@ By id:
 no children: PASS
 param: PASS
 param and whitespace: PASS
-param and empty comment (expected to fail): FAIL
-param and non-empty comment (expected to fail): FAIL
+param and empty comment: PASS
+param and non-empty comment: PASS
 param and text: PASS
 param and img: PASS
 
index fe9cda0..a44d7e0 100644 (file)
@@ -52,16 +52,16 @@ print("By name:<br>");
 testProperty("no children", "object1", true);
 testProperty("param", "object2", true);
 testProperty("param and whitespace", "object5", true);
-testProperty("param and empty comment (expected to fail)", "object9", false);
-testProperty("param and non-empty comment (expected to fail)", "object11", false);
+testProperty("param and empty comment", "object9", false);
+testProperty("param and non-empty comment", "object11", false);
 testProperty("param and text", "object6", false);
 testProperty("param and img", "object13", false);
 print("<br>By id:<br>");
 testProperty("no children", "object3", true);
 testProperty("param", "object4", true);
 testProperty("param and whitespace", "object8", true);
-testProperty("param and empty comment (expected to fail)", "object10", false);
-testProperty("param and non-empty comment (expected to fail)", "object12", false);
+testProperty("param and empty comment", "object10", false);
+testProperty("param and non-empty comment", "object12", false);
 testProperty("param and text", "object7", false);
 testProperty("param and img", "object14", false);
 
diff --git a/LayoutTests/fast/dom/comment-document-fragment-expected.txt b/LayoutTests/fast/dom/comment-document-fragment-expected.txt
new file mode 100644 (file)
index 0000000..d25f1a8
--- /dev/null
@@ -0,0 +1 @@
+SUCESS
diff --git a/LayoutTests/fast/dom/comment-document-fragment.html b/LayoutTests/fast/dom/comment-document-fragment.html
new file mode 100644 (file)
index 0000000..d1745de
--- /dev/null
@@ -0,0 +1,10 @@
+<!-- this comment should show up as the
+     first child of the HTML element in the DOM.
+     the document should also say "SUCESS",
+     if you don't see SUCESS then the DOM was
+     not built correctly because of this comment -->
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+</script>
+SUCESS
diff --git a/LayoutTests/fast/dom/comment-dom-node-expected.txt b/LayoutTests/fast/dom/comment-dom-node-expected.txt
new file mode 100644 (file)
index 0000000..d25f1a8
--- /dev/null
@@ -0,0 +1 @@
+SUCESS
diff --git a/LayoutTests/fast/dom/comment-dom-node.html b/LayoutTests/fast/dom/comment-dom-node.html
new file mode 100644 (file)
index 0000000..39a8215
--- /dev/null
@@ -0,0 +1,14 @@
+<html>
+<body>
+<div id="test"><!--SUCESS--></div>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+x = document.getElementById("test").firstChild;
+if (x && x.nodeType == Node.COMMENT_NODE)
+    document.write(x.nodeValue);
+else
+    document.write("FAIL");
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/comment-not-documentElement-expected.checksum b/LayoutTests/fast/dom/comment-not-documentElement-expected.checksum
new file mode 100644 (file)
index 0000000..5db450f
--- /dev/null
@@ -0,0 +1 @@
+79eaf115bf9e6acb0d43779e84a37b3d
\ No newline at end of file
diff --git a/LayoutTests/fast/dom/comment-not-documentElement-expected.png b/LayoutTests/fast/dom/comment-not-documentElement-expected.png
new file mode 100644 (file)
index 0000000..8699c02
Binary files /dev/null and b/LayoutTests/fast/dom/comment-not-documentElement-expected.png differ
diff --git a/LayoutTests/fast/dom/comment-not-documentElement-expected.txt b/LayoutTests/fast/dom/comment-not-documentElement-expected.txt
new file mode 100644 (file)
index 0000000..7e17bf3
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderText {#text} at (0,0) size 60x18
+        text run at (0,0) width 60: "SUCESS"
+      RenderText {#text} at (0,0) size 0x0
+      RenderText {#text} at (0,0) size 0x0
diff --git a/LayoutTests/fast/dom/comment-not-documentElement.html b/LayoutTests/fast/dom/comment-not-documentElement.html
new file mode 100644 (file)
index 0000000..b5586ee
--- /dev/null
@@ -0,0 +1,12 @@
+<!-- this comment should not become the documentElement,
+     if it does then the page will be blank -->
+<html>
+<body>
+<script>
+if (document.documentElement.nodeType == Node.ELEMENT_NODE)
+    document.write("SUCESS");
+else
+    document.write("FAIL");
+</script>
+</body>
+</html>
index bf10a4b..bbe27de 100644 (file)
@@ -20,4 +20,4 @@ layer at (0,0) size 800x600
           text run at (62,18) width 632: " by clicking the X and verifying that the correct caret position (13) is reported to the editing delegate."
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
-caret: position 13 of child 1 {#text} of child 1 {BODY} of child 0 {HTML} of document
+caret: position 13 of child 2 {#text} of child 1 {BODY} of child 0 {HTML} of document
index 4b5d94f..9101197 100644 (file)
@@ -19,5 +19,5 @@ layer at (0,0) size 800x600
           text run at (0,0) width 281: "\x{201C}remips\x{201D} should be highlighted in the above."
         RenderText {#text} at (0,0) size 0x0
         RenderText {#text} at (0,0) size 0x0
-selection start: position 3 of child 0 {#text} of child 2 {BDO} of child 1 {BODY} of child 0 {HTML} of document
-selection end:   position 9 of child 0 {#text} of child 2 {BDO} of child 1 {BODY} of child 0 {HTML} of document
+selection start: position 3 of child 0 {#text} of child 3 {BDO} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 9 of child 0 {#text} of child 3 {BDO} of child 1 {BODY} of child 0 {HTML} of document
index 45f51d4..3b4fca5 100644 (file)
@@ -1,3 +1,26 @@
+2006-07-08  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Maciej.
+
+        Bug 5312: comments aren't available via DOM
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312
+
+        <rdar://problem/4564414> getting comments via DOM isn't working (5312)
+        <rdar://problem/4545691> DOM_COMMENT node masking out real DOM elements
+
+        * dom/Document.cpp:
+        (WebCore::Document::removedLastRef): set m_documentElement to 0
+        (WebCore::Document::childrenChanged): invalidate the document element we have cached in case it was replaced
+        (WebCore::Document::documentElement): cache the first element as the document node if m_documentElement is 0
+        * dom/Document.h: added m_documentElement
+        * html/HTMLDocument.cpp: removed documentElement(), HTML documents just use Document's documentElement()
+        * html/HTMLDocument.h: ditto
+        * html/HTMLParser.cpp:
+        (WebCore::HTMLParser::handleError): make a new HTML node is the document's firstChild is NULL or
+        the firstChild is not a HTML element (like a comment)
+        * html/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::parseComment): removed the #ifdef to include comment nodes
+
 2006-07-08  Anders Carlsson  <acarlsson@apple.com>
 
         Reviewed by Darin, tweaked slightly and landed by Maciej.
index 9b35d2c..dbd27c6 100644 (file)
@@ -300,6 +300,7 @@ void Document::removedLastRef()
         m_hoverNode = 0;
         m_activeNode = 0;
         m_titleElement = 0;
+        m_documentElement = 0;
 
         removeAllChildren();
 
@@ -391,12 +392,22 @@ DOMImplementation* Document::implementation() const
     return m_implementation.get();
 }
 
+void Document::childrenChanged()
+{
+    // invalidate the document element we have cached in case it was replaced
+    m_documentElement = 0;
+}
+
 Element* Document::documentElement() const
 {
-    Node* n = firstChild();
-    while (n && !n->isElementNode())
-      n = n->nextSibling();
-    return static_cast<Element*>(n);
+    if (!m_documentElement) {
+        Node* n = firstChild();
+        while (n && !n->isElementNode())
+            n = n->nextSibling();
+        m_documentElement = static_cast<Element*>(n);
+    }
+
+    return m_documentElement.get();
 }
 
 PassRefPtr<Element> Document::createElement(const String &name, ExceptionCode& ec)
index 2ba3cc2..6c91d61 100644 (file)
@@ -160,7 +160,8 @@ public:
     DocumentType* realDocType() const { return m_docType.get(); }
 
     DOMImplementation* implementation() const;
-    virtual Element* documentElement() const;
+    virtual void childrenChanged();
+    Element* documentElement() const;
     virtual PassRefPtr<Element> createElement(const String& tagName, ExceptionCode&);
     PassRefPtr<DocumentFragment> createDocumentFragment ();
     PassRefPtr<Text> createTextNode(const String& data);
@@ -633,6 +634,7 @@ protected:
     RefPtr<Node> m_focusNode;
     RefPtr<Node> m_hoverNode;
     RefPtr<Node> m_activeNode;
+    mutable RefPtr<Element> m_documentElement;
 
     unsigned m_domtree_version;
     
index 5026a92..2140d35 100644 (file)
@@ -83,11 +83,6 @@ HTMLDocument::~HTMLDocument()
 {
 }
 
-Element* HTMLDocument::documentElement() const
-{
-    return static_cast<Element*>(fastFirstChild());
-}
-
 String HTMLDocument::lastModified() const
 {
     if ( frame() )
index b8110e2..1e9de08 100644 (file)
@@ -43,7 +43,6 @@ public:
     ~HTMLDocument();
 
     virtual bool isHTMLDocument() const { return true; }
-    virtual Element* documentElement() const;
 
     String lastModified() const;
     String cookie() const;
index 0398e01..fabefed 100644 (file)
@@ -671,7 +671,7 @@ bool HTMLParser::handleError(Node* n, bool flat, const AtomicString& localName,
             }
         }
     } else if (current->isDocumentNode()) {
-        if (current->firstChild() == 0) {
+        if (current->firstChild() == 0 || !current->firstChild()->isHTMLElement()) {
             e = new HTMLHtmlElement(document);
             insertNode(e);
             handled = true;
index 4ee5220..58bb0a6 100644 (file)
@@ -543,7 +543,6 @@ HTMLTokenizer::State HTMLTokenizer::parseComment(SegmentedString &src, State sta
             if (handleBrokenComments || endCharsCount > 1) {
                 ++src;
                 if (!(state.inScript() || state.inXmp() || state.inTextArea() || state.inStyle())) {
-#ifdef INCLUDE_COMMENTS_IN_DOM // FIXME: Turn this on soon.
                     checkScriptBuffer();
                     scriptCode[scriptCodeSize] = 0;
                     scriptCode[scriptCodeSize + 1] = 0;
@@ -554,7 +553,6 @@ HTMLTokenizer::State HTMLTokenizer::parseComment(SegmentedString &src, State sta
                     currToken.tagName = commentAtom;
                     currToken.beginTag = false;
                     processToken();
-#endif
                     scriptCodeSize = 0;
                 }
                 state.setInComment(false);
index 73f4d30..a00e206 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-08  Timothy Hatcher  <timothy@apple.com>
+
+        Reviewed by Maciej.
+
+        Bug 5312: comments aren't available via DOM
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=5312
+
+        Makes the Web Inspector show comment node contents.
+
+        * WebInspector/WebInspector.m:
+        (-[DOMNode _displayName]): return the contents of the comment
+        * WebInspector/webInspector/inspector.js: check for comment nodes
+
 2006-07-09  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index d4cadea..4989db6 100644 (file)
@@ -1347,6 +1347,8 @@ static NSMapTable *lastChildIgnoringWhitespaceCache = NULL;
             CFStringTrimWhitespace((CFMutableStringRef)value);
             return [NSString stringWithFormat:@"\"%@\"", value];
         }
+        case DOM_COMMENT_NODE:
+            return [NSString stringWithFormat:@"<!--%@-->", [self nodeValue]];
     }
     return [[self nodeName] lowercaseString];
 }
index 3cf64ea..52c4ae5 100644 (file)
@@ -349,7 +349,7 @@ function updateElementAttributes()
 function updateNodePane() {
     var focusedNode = Inspector.focusedDOMNode();
 
-    if (focusedNode.nodeType == Node.TEXT_NODE) {
+    if (focusedNode.nodeType == Node.TEXT_NODE || focusedNode.nodeType == Node.COMMENT_NODE) {
         document.getElementById("nodeNamespaceRow").style.display = "none";
         document.getElementById("elementAttributes").style.display = "none";
         document.getElementById("nodeContents").style.display = null;