| Differences between
and this patch
- a/LayoutTests/ChangeLog +24 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2009-05-04  Shinichiro Hamaji  <set EMAIL_ADDRESS environment variable>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=25512
6
        Handle texts after unfinished special tags (i.e., script, style, textarea, title, xmp, and iframe) as the text node under the tags.
7
8
        This was already done only for title. This change allows other special tags to be handled as well.
9
10
        This patch is especially benefitical for view-source mode. Before this change, all texts in unfinished special tags cannot be seen even in view-source mode.
11
12
        The test case verifies if the texts in the unfinished special tags are visible in view-source mode.
13
14
	Also, fixed window-shadow-location-using-* tests so that they don't use unfinished iframe anymore.
15
16
        * fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString-expected.txt:
17
        * fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString.html:
18
        * fast/dom/Window/Location/window-shadow-location-using-string-expected.txt:
19
        * fast/dom/Window/Location/window-shadow-location-using-string.html:
20
        * fast/frames/resources/viewsource-frame-unfinished-script.html: Added.
21
        * fast/frames/resources/viewsource-frame-unfinished-textarea.html: Added.
22
        * fast/frames/viewsource-unfinished-tags-expected.txt: Copied from LayoutTests/http/tests/misc/iframe-domain-test-expected.txt.
23
        * fast/frames/viewsource-unfinished-tags.html: Added.
24
1
2009-04-30  Kevin McCullough  <kmccullough@apple.com>
25
2009-04-30  Kevin McCullough  <kmccullough@apple.com>
2
26
3
        Reviewed by Adele Peterson and Darin Adler.
27
        Reviewed by Adele Peterson and Darin Adler.
- a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString-expected.txt +3 lines
Lines 1-2 a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString-expected.txt_sec1
1
PASS successfullyParsed is true
2
3
TEST COMPLETE
1
PASS result is 'pass.html'
4
PASS result is 'pass.html'
2
5
- a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString.html -2 / +2 lines
Lines 22-28 a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-js-object-with-toString.html_sec1
22
22
23
    successfullyParsed = true;
23
    successfullyParsed = true;
24
</script>
24
</script>
25
<iframe onload="frameLoaded()" src="resources/window-shadow-location-using-js-object-with-toString-iframe.html">
25
<iframe onload="frameLoaded()" src="resources/window-shadow-location-using-js-object-with-toString-iframe.html"></iframe>
26
<script src="../../../js/resources/js-test-post.js"></script>
26
<script src="../../../js/resources/js-test-post.js"></script>
27
</body>
27
</body>
28
</html>
28
</html>
- a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-string-expected.txt +3 lines
Lines 1-2 a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-string-expected.txt_sec1
1
PASS successfullyParsed is true
2
3
TEST COMPLETE
1
PASS result is 'pass.html'
4
PASS result is 'pass.html'
2
5
- a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-string.html -2 / +2 lines
Lines 22-28 a/LayoutTests/fast/dom/Window/Location/window-shadow-location-using-string.html_sec1
22
22
23
    successfullyParsed = true;
23
    successfullyParsed = true;
24
</script>
24
</script>
25
<iframe onload="frameLoaded()" src="resources/window-shadow-location-using-string-iframe.html">
25
<iframe onload="frameLoaded()" src="resources/window-shadow-location-using-string-iframe.html"></iframe>
26
<script src="../../../js/resources/js-test-post.js"></script>
26
<script src="../../../js/resources/js-test-post.js"></script>
27
</body>
27
</body>
28
</html>
28
</html>
- a/LayoutTests/fast/frames/resources/viewsource-frame-unfinished-script.html +1 lines
Line 0 a/LayoutTests/fast/frames/resources/viewsource-frame-unfinished-script.html_sec1
1
<script>foobar in script
- a/LayoutTests/fast/frames/resources/viewsource-frame-unfinished-textarea.html +1 lines
Line 0 a/LayoutTests/fast/frames/resources/viewsource-frame-unfinished-textarea.html_sec1
1
<textarea>foobar in textarea
- a/LayoutTests/fast/frames/viewsource-unfinished-tags-expected.txt +3 lines
Line 0 a/LayoutTests/fast/frames/viewsource-unfinished-tags-expected.txt_sec1
1
script: PASS
2
textarea: PASS
3
- a/LayoutTests/fast/frames/viewsource-unfinished-tags.html +46 lines
Line 0 a/LayoutTests/fast/frames/viewsource-unfinished-tags.html_sec1
1
<html>
2
<head>
3
<script>
4
    if (window.layoutTestController) {
5
        layoutTestController.dumpAsText();
6
        layoutTestController.waitUntilDone();
7
    }
8
9
    var results = {};
10
    function report(frame, tag) {
11
        var result = frame.contentDocument.documentElement.innerHTML;
12
        var regex = new RegExp("foobar", "g");
13
        matches = result.match(regex);
14
15
        if (matches)
16
            var resultText = "PASS";
17
        else
18
            var resultText = "FAIL";
19
20
        results[tag] = resultText;
21
        if (window.layoutTestController && results["script"] && results["textarea"]) {
22
            document.open();
23
            document.write("script: " + results["script"] + "<br>");
24
            document.write("textarea: " + results["textarea"] + "<br>");
25
            document.close();
26
27
            layoutTestController.notifyDone();
28
        } else {
29
            document.getElementById(tag + "_result").textContent = resultText;
30
        }
31
    }
32
</script>
33
</head>
34
<body>
35
<p>You should see a frame in 'view source' mode below.</p>
36
<p>"foobar" should be seen after the &lt;script&gt; tag and &lt;textarea&gt; tag.</p>
37
<hr>
38
<iframe viewsource src="resources/viewsource-frame-unfinished-script.html" height="250" onload="report(this, 'script')"></iframe>
39
<iframe viewsource src="resources/viewsource-frame-unfinished-textarea.html" height="250" onload="report(this, 'textarea')"></iframe>
40
<hr>
41
<div id="result">
42
<div id="script_result"></div>
43
<div id="textarea_result"></div>
44
</div>
45
</body>
46
</html>
- a/WebCore/ChangeLog +20 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2009-05-04  Shinichiro Hamaji  <set EMAIL_ADDRESS environment variable>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        https://bugs.webkit.org/show_bug.cgi?id=25512
6
        Handle texts after unfinished special tags (i.e., script, style, textarea, title, xmp, and iframe) as the text node under the tags.
7
8
        This was already done only for title. This change allows other special tags to be handled as well.
9
10
        This patch is especially benefitical for view-source mode. Before this change, all texts in unfinished special tags cannot be seen even in view-source mode.
11
12
        Test: fast/frames/viewsource-unfinished-tags.html
13
14
        * html/HTMLTokenizer.cpp:
15
        (WebCore::HTMLTokenizer::parseNonHTMLText):
16
        (WebCore::HTMLTokenizer::parseTag):
17
        (WebCore::HTMLTokenizer::write):
18
        * html/HTMLTokenizer.h:
19
        (WebCore::HTMLTokenizer::State::inAnyNonHTMLText):
20
1
2009-05-01  Anders Carlsson  <andersca@apple.com>
21
2009-05-01  Anders Carlsson  <andersca@apple.com>
2
22
3
        Reviewed by Adele Peterson.
23
        Reviewed by Adele Peterson.
- a/WebCore/html/HTMLTokenizer.cpp -25 / +25 lines
Lines 314-320 HTMLTokenizer::State HTMLTokenizer::processListing(SegmentedString list, State s a/WebCore/html/HTMLTokenizer.cpp_sec1
314
    return state;
314
    return state;
315
}
315
}
316
316
317
HTMLTokenizer::State HTMLTokenizer::parseSpecial(SegmentedString& src, State state)
317
HTMLTokenizer::State HTMLTokenizer::parseNonHTMLText(SegmentedString& src, State state)
318
{
318
{
319
    ASSERT(state.inTextArea() || state.inTitle() || state.inIFrame() || !state.hasEntityState());
319
    ASSERT(state.inTextArea() || state.inTitle() || state.inIFrame() || !state.hasEntityState());
320
    ASSERT(!state.hasTagState());
320
    ASSERT(!state.hasTagState());
Lines 1471-1476 HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) a/WebCore/html/HTMLTokenizer.cpp_sec2
1471
            RefPtr<Node> n = processToken();
1471
            RefPtr<Node> n = processToken();
1472
            m_cBufferPos = cBufferPos;
1472
            m_cBufferPos = cBufferPos;
1473
            if (n || inViewSourceMode()) {
1473
            if (n || inViewSourceMode()) {
1474
                State savedState = state;
1475
                SegmentedString savedSrc = src;
1476
                long savedLineno = m_lineNumber;
1474
                if ((tagName == preTag || tagName == listingTag) && !inViewSourceMode()) {
1477
                if ((tagName == preTag || tagName == listingTag) && !inViewSourceMode()) {
1475
                    if (beginTag)
1478
                    if (beginTag)
1476
                        state.setDiscardLF(true); // Discard the first LF after we open a pre.
1479
                        state.setDiscardLF(true); // Discard the first LF after we open a pre.
Lines 1483-1489 HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) a/WebCore/html/HTMLTokenizer.cpp_sec3
1483
                        m_searchStopper = scriptEnd;
1486
                        m_searchStopper = scriptEnd;
1484
                        m_searchStopperLength = 8;
1487
                        m_searchStopperLength = 8;
1485
                        state.setInScript(true);
1488
                        state.setInScript(true);
1486
                        state = parseSpecial(src, state);
1489
                        state = parseNonHTMLText(src, state);
1487
                    } else if (isSelfClosingScript) { // Handle <script src="foo"/>
1490
                    } else if (isSelfClosingScript) { // Handle <script src="foo"/>
1488
                        state.setInScript(true);
1491
                        state.setInScript(true);
1489
                        state = scriptHandler(state);
1492
                        state = scriptHandler(state);
Lines 1493-1545 HTMLTokenizer::State HTMLTokenizer::parseTag(SegmentedString& src, State state) a/WebCore/html/HTMLTokenizer.cpp_sec4
1493
                        m_searchStopper = styleEnd;
1496
                        m_searchStopper = styleEnd;
1494
                        m_searchStopperLength = 7;
1497
                        m_searchStopperLength = 7;
1495
                        state.setInStyle(true);
1498
                        state.setInStyle(true);
1496
                        state = parseSpecial(src, state);
1499
                        state = parseNonHTMLText(src, state);
1497
                    }
1500
                    }
1498
                } else if (tagName == textareaTag) {
1501
                } else if (tagName == textareaTag) {
1499
                    if (beginTag) {
1502
                    if (beginTag) {
1500
                        m_searchStopper = textareaEnd;
1503
                        m_searchStopper = textareaEnd;
1501
                        m_searchStopperLength = 10;
1504
                        m_searchStopperLength = 10;
1502
                        state.setInTextArea(true);
1505
                        state.setInTextArea(true);
1503
                        state = parseSpecial(src, state);
1506
                        state = parseNonHTMLText(src, state);
1504
                    }
1507
                    }
1505
                } else if (tagName == titleTag) {
1508
                } else if (tagName == titleTag) {
1506
                    if (beginTag) {
1509
                    if (beginTag) {
1507
                        m_searchStopper = titleEnd;
1510
                        m_searchStopper = titleEnd;
1508
                        m_searchStopperLength = 7;
1511
                        m_searchStopperLength = 7;
1509
                        State savedState = state;
1510
                        SegmentedString savedSrc = src;
1511
                        long savedLineno = m_lineNumber;
1512
                        state.setInTitle(true);
1512
                        state.setInTitle(true);
1513
                        state = parseSpecial(src, state);
1513
                        state = parseNonHTMLText(src, state);
1514
                        if (state.inTitle() && src.isEmpty()) {
1515
                            // We just ate the rest of the document as the title #text node!
1516
                            // Reset the state then retokenize without special title handling.
1517
                            // Let the parser clean up the missing </title> tag.
1518
                            // FIXME: This is incorrect, because src.isEmpty() doesn't mean we're
1519
                            // at the end of the document unless m_noMoreData is also true. We need
1520
                            // to detect this case elsewhere, and save the state somewhere other
1521
                            // than a local variable.
1522
                            state = savedState;
1523
                            src = savedSrc;
1524
                            m_lineNumber = savedLineno;
1525
                            m_scriptCodeSize = 0;
1526
                        }
1527
                    }
1514
                    }
1528
                } else if (tagName == xmpTag) {
1515
                } else if (tagName == xmpTag) {
1529
                    if (beginTag) {
1516
                    if (beginTag) {
1530
                        m_searchStopper = xmpEnd;
1517
                        m_searchStopper = xmpEnd;
1531
                        m_searchStopperLength = 5;
1518
                        m_searchStopperLength = 5;
1532
                        state.setInXmp(true);
1519
                        state.setInXmp(true);
1533
                        state = parseSpecial(src, state);
1520
                        state = parseNonHTMLText(src, state);
1534
                    }
1521
                    }
1535
                } else if (tagName == iframeTag) {
1522
                } else if (tagName == iframeTag) {
1536
                    if (beginTag) {
1523
                    if (beginTag) {
1537
                        m_searchStopper = iframeEnd;
1524
                        m_searchStopper = iframeEnd;
1538
                        m_searchStopperLength = 8;
1525
                        m_searchStopperLength = 8;
1539
                        state.setInIFrame(true);
1526
                        state.setInIFrame(true);
1540
                        state = parseSpecial(src, state);
1527
                        state = parseNonHTMLText(src, state);
1541
                    }
1528
                    }
1542
                }
1529
                }
1530
                if (src.isEmpty() && state.inAnyNonHTMLText() && !(state.inScript() && m_currentScriptTagStartLineNumber)) {
1531
                    // We just ate the rest of the document as the #text node under the special tag!
1532
                    // Reset the state then retokenize without special handling.
1533
                    // Let the parser clean up the missing close tag.
1534
                    // FIXME: This is incorrect, because src.isEmpty() doesn't mean we're
1535
                    // at the end of the document unless m_noMoreData is also true. We need
1536
                    // to detect this case elsewhere, and save the state somewhere other
1537
                    // than a local variable.
1538
                    state = savedState;
1539
                    src = savedSrc;
1540
                    m_lineNumber = savedLineno;
1541
                    m_scriptCodeSize = 0;
1542
                }
1543
            }
1543
            }
1544
            if (tagName == plaintextTag)
1544
            if (tagName == plaintextTag)
1545
                state.setInPlainText(beginTag);
1545
                state.setInPlainText(beginTag);
Lines 1655-1662 void HTMLTokenizer::write(const SegmentedString& str, bool appendData) a/WebCore/html/HTMLTokenizer.cpp_sec5
1655
                state = parseEntity(m_src, m_dest, state, m_cBufferPos, false, state.hasTagState());
1655
                state = parseEntity(m_src, m_dest, state, m_cBufferPos, false, state.hasTagState());
1656
            else if (state.inPlainText())
1656
            else if (state.inPlainText())
1657
                state = parseText(m_src, state);
1657
                state = parseText(m_src, state);
1658
            else if (state.inAnySpecial())
1658
            else if (state.inAnyNonHTMLText())
1659
                state = parseSpecial(m_src, state);
1659
                state = parseNonHTMLText(m_src, state);
1660
            else if (state.inComment())
1660
            else if (state.inComment())
1661
                state = parseComment(m_src, state);
1661
                state = parseComment(m_src, state);
1662
            else if (state.inDoctype())
1662
            else if (state.inDoctype())
- a/WebCore/html/HTMLTokenizer.h -2 / +2 lines
Lines 173-179 private: a/WebCore/html/HTMLTokenizer.h_sec1
173
    State parseDoctype(SegmentedString&, State);
173
    State parseDoctype(SegmentedString&, State);
174
    State parseServer(SegmentedString&, State);
174
    State parseServer(SegmentedString&, State);
175
    State parseText(SegmentedString&, State);
175
    State parseText(SegmentedString&, State);
176
    State parseSpecial(SegmentedString&, State);
176
    State parseNonHTMLText(SegmentedString&, State);
177
    State parseTag(SegmentedString&, State);
177
    State parseTag(SegmentedString&, State);
178
    State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& cBufferPos, bool start, bool parsingTag);
178
    State parseEntity(SegmentedString&, UChar*& dest, State, unsigned& cBufferPos, bool start, bool parsingTag);
179
    State parseProcessingInstruction(SegmentedString&, State);
179
    State parseProcessingInstruction(SegmentedString&, State);
Lines 288-294 private: a/WebCore/html/HTMLTokenizer.h_sec2
288
        bool forceSynchronous() const { return testBit(ForceSynchronous); }
288
        bool forceSynchronous() const { return testBit(ForceSynchronous); }
289
        void setForceSynchronous(bool v) { setBit(ForceSynchronous, v); }
289
        void setForceSynchronous(bool v) { setBit(ForceSynchronous, v); }
290
290
291
        bool inAnySpecial() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame); }
291
        bool inAnyNonHTMLText() const { return m_bits & (InScript | InStyle | InXmp | InTextArea | InTitle | InIFrame); }
292
        bool hasTagState() const { return m_bits & TagMask; }
292
        bool hasTagState() const { return m_bits & TagMask; }
293
        bool hasEntityState() const { return m_bits & EntityMask; }
293
        bool hasEntityState() const { return m_bits & EntityMask; }
294
294

Return to Bug 25512