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
+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).
-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
-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
-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
-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
-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
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
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
-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
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
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
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
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);
--- /dev/null
+<!-- 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
--- /dev/null
+<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>
--- /dev/null
+79eaf115bf9e6acb0d43779e84a37b3d
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+<!-- 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>
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
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
+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.
m_hoverNode = 0;
m_activeNode = 0;
m_titleElement = 0;
+ m_documentElement = 0;
removeAllChildren();
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)
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);
RefPtr<Node> m_focusNode;
RefPtr<Node> m_hoverNode;
RefPtr<Node> m_activeNode;
+ mutable RefPtr<Element> m_documentElement;
unsigned m_domtree_version;
{
}
-Element* HTMLDocument::documentElement() const
-{
- return static_cast<Element*>(fastFirstChild());
-}
-
String HTMLDocument::lastModified() const
{
if ( frame() )
~HTMLDocument();
virtual bool isHTMLDocument() const { return true; }
- virtual Element* documentElement() const;
String lastModified() const;
String cookie() const;
}
}
} else if (current->isDocumentNode()) {
- if (current->firstChild() == 0) {
+ if (current->firstChild() == 0 || !current->firstChild()->isHTMLElement()) {
e = new HTMLHtmlElement(document);
insertNode(e);
handled = true;
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;
currToken.tagName = commentAtom;
currToken.beginTag = false;
processToken();
-#endif
scriptCodeSize = 0;
}
state.setInComment(false);
+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.
CFStringTrimWhitespace((CFMutableStringRef)value);
return [NSString stringWithFormat:@"\"%@\"", value];
}
+ case DOM_COMMENT_NODE:
+ return [NSString stringWithFormat:@"<!--%@-->", [self nodeValue]];
}
return [[self nodeName] lowercaseString];
}
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;