Skip to content

Commit 0c1e71f

Browse files
committed
LayoutTests:
Reviewed by Eric. - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7480 non-HTML elems w/o children in HTML docs get serialized self-closing - update tests for problem where the HTML tokenizer would discard the first newline after </pre> * fast/innerHTML/innerHTML-custom-tag.html: Added. * fast/innerHTML/innerHTML-custom-tag-expected.txt: Added. * fast/innerHTML/005-expected.txt: Updated. Now matches the original document as expected. Old result had the <div> after a <pre> put on the same line. * editing/inserting/4278698-expected.txt: Updated because offset of node changed since we have one more text node (from after a /pre). * fast/text/whitespace/pre-wrap-overflow-selection-expected.txt: Ditto. WebCore: Reviewed by Eric. - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7480 non-HTML elems w/o children in HTML docs get serialized self-closing - fix problem where the HTML tokenizer would discard the first newline after </pre> Test: fast/innerHTML/innerHTML-custom-tag.html * editing/markup.cpp: (WebCore::shouldSelfClose): Refined rule so that it doesn't try to do any self-closing tags in HTML documents at all; updated comment. * khtml/html/htmltokenizer.cpp: (WebCore::HTMLTokenizer::parseTag): Added a check of beginTag in the <pre> tag case. We were accidentally discarding a newline after a </pre> tag. Canonical link: https://commits.webkit.org/11091@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13117 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent d313317 commit 0c1e71f

9 files changed

Lines changed: 102 additions & 19 deletions

File tree

LayoutTests/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2006-03-01 Darin Adler <darin@apple.com>
2+
3+
Reviewed by Eric.
4+
5+
- test for http://bugzilla.opendarwin.org/show_bug.cgi?id=7480
6+
non-HTML elems w/o children in HTML docs get serialized self-closing
7+
- update tests for problem where the HTML tokenizer would discard the
8+
first newline after </pre>
9+
10+
* fast/innerHTML/innerHTML-custom-tag.html: Added.
11+
* fast/innerHTML/innerHTML-custom-tag-expected.txt: Added.
12+
13+
* fast/innerHTML/005-expected.txt: Updated. Now matches the original document as expected.
14+
Old result had the <div> after a <pre> put on the same line.
15+
16+
* editing/inserting/4278698-expected.txt: Updated because offset of node changed since we
17+
have one more text node (from after a /pre).
18+
* fast/text/whitespace/pre-wrap-overflow-selection-expected.txt: Ditto.
19+
120
2006-03-02 Andrew Wellington <proton@wiretapped.net>
221

322
Reviewed by Darin, landed by Beth.

LayoutTests/editing/inserting/4278698-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
1+
EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
22
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
33
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
44
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification

LayoutTests/fast/innerHTML/005-expected.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Content:
44
<TITLE>html innerHTML test</TITLE>
55
</HEAD><BODY>
66
<SPAN>Content:</SPAN>
7-
<PRE id="content">placeholder</PRE><DIV></DIV>
7+
<PRE id="content">placeholder</PRE>
8+
<DIV></DIV>
89
<SPAN></SPAN>
910
<B>test</B>
1011
<BR>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Content:
2+
3+
<SPAN>Content:</SPAN>
4+
<PRE id="content">placeholder</PRE>
5+
<DIV></DIV>
6+
<SPAN></SPAN>
7+
<B>test</B>
8+
<BR>
9+
<EMPTYCUSTOMTAG></EMPTYCUSTOMTAG>
10+
<anotherEmptyCustomTag></anotherEmptyCustomTag>
11+
<CUSTOMTAG>more test</CUSTOMTAG>
12+
<DIV id="testArea"></DIV>
13+
14+
15+
16+
test
17+
more test
18+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
4+
<head>
5+
<meta name="description" content="This tests html output">
6+
<title>HTML innerHTML test, including custom tags</title>
7+
<script>
8+
function test() {
9+
if (window.layoutTestController)
10+
layoutTestController.dumpAsText();
11+
var n = document.getElementsByTagName("emptyCustomTag")[0];
12+
n.parentNode.insertBefore(document.createElementNS("http://webkit.org/test", "anotherEmptyCustomTag"), n.nextSibling);
13+
n.parentNode.insertBefore(document.createTextNode("\n"), n.nextSibling);
14+
document.getElementById("content").firstChild.nodeValue = document.body.innerHTML;
15+
}
16+
</script>
17+
</head>
18+
19+
<body onload="test()">
20+
<span>Content:</span>
21+
<pre id="content">placeholder</pre>
22+
<div></div>
23+
<span></span>
24+
<b>test</b>
25+
<br>
26+
<emptyCustomTag></emptyCustomTag>
27+
<customTag>more test</customTag>
28+
<div id="testArea"></div>
29+
</body>
30+
31+
</html>

LayoutTests/fast/text/whitespace/pre-wrap-overflow-selection-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ layer at (8,109) size 108x83 clip at (12,113) size 100x75
3737
text run at (4,49) width 80: "within the"
3838
text run at (4,64) width 32: "box."
3939
selection start: position 7 of child 0 {TEXT} of child 7 {PRE} of child 1 {BODY} of child 0 {HTML} of document
40-
selection end: position 15 of child 0 {TEXT} of child 10 {PRE} of child 1 {BODY} of child 0 {HTML} of document
40+
selection end: position 15 of child 0 {TEXT} of child 11 {PRE} of child 1 {BODY} of child 0 {HTML} of document

WebCore/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2006-03-03 Darin Adler <darin@apple.com>
2+
3+
Reviewed by Eric.
4+
5+
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=7480
6+
non-HTML elems w/o children in HTML docs get serialized self-closing
7+
- fix problem where the HTML tokenizer would discard the first newline after </pre>
8+
9+
Test: fast/innerHTML/innerHTML-custom-tag.html
10+
11+
* editing/markup.cpp: (WebCore::shouldSelfClose): Refined rule so that it doesn't
12+
try to do any self-closing tags in HTML documents at all; updated comment.
13+
14+
* khtml/html/htmltokenizer.cpp: (WebCore::HTMLTokenizer::parseTag): Added a check
15+
of beginTag in the <pre> tag case. We were accidentally discarding a newline after
16+
a </pre> tag.
17+
118
2006-03-03 Maciej Stachowiak <mjs@apple.com>
219

320
Rubber stamped by Eric.

WebCore/editing/markup.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ namespace WebCore {
4747

4848
using namespace HTMLNames;
4949

50-
static inline bool doesHTMLForbidEndTag(const NodeImpl *node);
5150
static inline bool shouldSelfClose(const NodeImpl *node);
5251

5352
static QString escapeTextForMarkup(const QString &in)
@@ -253,20 +252,19 @@ static inline bool doesHTMLForbidEndTag(const NodeImpl *node)
253252
}
254253

255254
// Rules of self-closure
256-
// 1. all html elements in html documents close with >
257-
// 2. all elements w/ children close with >
258-
// 3. all non-html elements w/o children close with />
259-
// 4. all html elements with a FORBIDDEN close tag, self close in XML docs
255+
// 1. No elements in HTML documents use the self-closing syntax.
256+
// 2. Elements w/ children never self-close because they use a separate end tag.
257+
// 3. HTML elements which do not have a "forbidden" end tag will close with a separate end tag.
258+
// 4. Other elements self-close.
260259
static inline bool shouldSelfClose(const NodeImpl *node)
261260
{
262-
bool htmlForbidsEndTag = doesHTMLForbidEndTag(node);
263-
bool documentIsHTML = node->getDocument()->isHTMLDocument();
264-
265-
if (node->isHTMLElement() && (documentIsHTML || !htmlForbidsEndTag))
261+
if (node->getDocument()->isHTMLDocument())
266262
return false;
267-
else if (!node->hasChildNodes() || htmlForbidsEndTag)
268-
return true;
269-
return false;
263+
if (node->hasChildNodes())
264+
return false;
265+
if (node->isHTMLElement() && !doesHTMLForbidEndTag(node))
266+
return false;
267+
return true;
270268
}
271269

272270
static QString endMarkup(const NodeImpl *node)

WebCore/khtml/html/htmltokenizer.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ HTMLTokenizer::State HTMLTokenizer::scriptHandler(State state)
406406
prependingSrc = src;
407407
setSrc(SegmentedString());
408408
scriptCodeSize = scriptCodeResync = 0;
409-
//QTime dt;
410-
//dt.start();
411409
state = scriptExecution(exScript, state, QString::null, scriptStartLineno);
412410
}
413411
}
@@ -1237,7 +1235,8 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
12371235
RefPtr<NodeImpl> n = processToken();
12381236

12391237
if (tagName == preTag) {
1240-
state.setDiscardLF(true); // Discard the first LF after we open a pre.
1238+
if (beginTag)
1239+
state.setDiscardLF(true); // Discard the first LF after we open a pre.
12411240
} else if (tagName == scriptTag) {
12421241
ASSERT(!scriptNode);
12431242
scriptNode = n;
@@ -1258,7 +1257,7 @@ HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString &src, State state)
12581257
state = parseSpecial(src, state);
12591258
}
12601259
} else if (tagName == textareaTag) {
1261-
if(beginTag) {
1260+
if (beginTag) {
12621261
searchStopper = textareaEnd;
12631262
searchStopperLen = 10;
12641263
state.setInTextArea(true);

0 commit comments

Comments
 (0)