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 2b06d7323bce474a4d8d3695062677a4d52ff729..1fec69c5e3ee425857eb3c1e9cc6267f713d14e2 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 11b0825bcebfdab7d40643af6c89eba49dded9e0..b5a6fec88c89c379376ebb5191f61c3ff9022d8e 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 045b556c06f542359dc23036237b7ab20f63100f..4a1cb86562d215d2db961c0a80cd02ca1ce99af9 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 1b47d361965fae48e9d61af9c5b9021d00863c65..e1ee820a49fb7764cbf613c81a6353251b0e21b5 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 c7048acddcae9519b2380fdb3fe341f968ce6811..4710fd0874dae89ebd58b1235099a9eb1019a6e9 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 0f3770c99e1a42f4721100badb0d427b4c4453ae..704ad35825ca2d6154bb67dd1a612f4be4f41a0b 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 bad91908c0251361c07f325673459b94e0298497..0b61af56a4ebf35cf4f02f93ef60a6a8d839e4e5 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 b62b2c579d576154c26976764f74451ecb5776c0..c542e2ae3beb52af114b16a5ca01df3ad19b31c3 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 4b881a5c80337f62e7690222646895d117b99091..cdea97df8e47e1f3031bb271a987edb8bcafa470 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 06bfa3efec591956060558039b21478346f3bff3..e35741cc6e14da3701585c243c77e13a0d36b9f6 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 fe9cda0b9fa0e74c3c775daff7ff9f8c8417b8be..a44d7e0f94bec94de3171e9beba7dfb93af783e0 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 bf10a4bce9c6ee5a9df14e94c237c38568a552fd..bbe27de05f6e8c4e448a8ebce4b2581e128e0d33 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 4b5d94f94721e13b1cbd6f650c2257b0dfcaa4bd..91011977b6933ad5e119cee975b4e0fd1febcb6c 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 45f51d4e1446a359677a536de51038562824d4eb..3b4fca52d884db3c65dd32ccf0c47eb1328344bb 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 9b35d2cd337abb7b63313f44e565389cd3e0c4dc..dbd27c6868d2215716b666d470e446db98475ebf 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 2ba3cc22b7ee4b5756058082546c8ef20f0a2341..6c91d6162566b0dd1010678dce2f93829b053949 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 5026a92c0d1915ea3a74cb7cfabefb7bb6b5c46f..2140d35554e666a4437842638af985808304fa1b 100644 (file)
@@ -83,11 +83,6 @@ HTMLDocument::~HTMLDocument()
 {
 }
 
-Element* HTMLDocument::documentElement() const
-{
-    return static_cast<Element*>(fastFirstChild());
-}
-
 String HTMLDocument::lastModified() const
 {
     if ( frame() )
index b8110e2062ffff35287060898880e0747bdc006a..1e9de08a3c8fad874a5240dc39e3e034bf85083d 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 0398e01db501dcffadaa6dd95ab5d03ffcae5a4c..fabefed05e454ce7eabcf2ff6bc10bec1cbeed8e 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 4ee5220611021aa06b273578dc1566c2093d9d35..58bb0a6458019f61b0c1501a6133297a3e495b82 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 73f4d3077da348b8f3be3c430e0d57eeda51d5b0..a00e2062be0277145624cd61bf17b7d9b3efe15a 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 d4cadea448ddf233fac653170bd86287728ddabd..4989db68c9e34f857168cd9f9dabc3a804701293 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 3cf64ea50e5b680f6e99c676127052b03531461e..52c4ae5fc84ca06ecbd9b1b78cce21d260a2d628 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;