Diff
Modified: trunk/LayoutTests/ChangeLog (90081 => 90082)
--- trunk/LayoutTests/ChangeLog 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/LayoutTests/ChangeLog 2011-06-30 03:05:03 UTC (rev 90082)
@@ -1,3 +1,16 @@
+2011-06-29 Keishi Hattori <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Remove extra space at EOL in view source mode
+ https://bugs.webkit.org/show_bug.cgi?id=63620
+
+ * fast/frames/resources/viewsource-frame-5.html: Added.
+ * fast/frames/viewsource-empty-attribute-value-expected.txt: Regenerated.
+ * fast/frames/viewsource-linebreak-expected.txt: Added.
+ * fast/frames/viewsource-linebreak.html: Added. Test that there are no extra spaces at EOL.
+ And that the multiple consecutive line breaks are maintained in the frame.
+
2011-06-23 Abhishek Arya <[email protected]>
Reviewed by James Robinson.
Added: trunk/LayoutTests/fast/frames/resources/viewsource-frame-5.html (0 => 90082)
--- trunk/LayoutTests/fast/frames/resources/viewsource-frame-5.html (rev 0)
+++ trunk/LayoutTests/fast/frames/resources/viewsource-frame-5.html 2011-06-30 03:05:03 UTC (rev 90082)
@@ -0,0 +1,10 @@
+
+
+<p>
+
+<input
+
+
+type="text">
+</p>
+
Modified: trunk/LayoutTests/fast/frames/viewsource-empty-attribute-value-expected.txt (90081 => 90082)
--- trunk/LayoutTests/fast/frames/viewsource-empty-attribute-value-expected.txt 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/LayoutTests/fast/frames/viewsource-empty-attribute-value-expected.txt 2011-06-30 03:05:03 UTC (rev 90082)
@@ -7,8 +7,9 @@
--------
Frame: 'sourceFrame'
--------
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
-<hr noshade width=75%>
-<div align="center" title="" id="foo">
-<p>hello world</p>
-</div>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<hr noshade width=75%>
+<div align="center" title="" id="foo">
+<p>hello world</p>
+</div>
+
Added: trunk/LayoutTests/fast/frames/viewsource-linebreak-expected.txt (0 => 90082)
--- trunk/LayoutTests/fast/frames/viewsource-linebreak-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/frames/viewsource-linebreak-expected.txt 2011-06-30 03:05:03 UTC (rev 90082)
@@ -0,0 +1,20 @@
+You should see a frame in 'view source' mode below.
+
+There should be no additional space at end of line. Number of line breaks should match source file.
+
+
+
+--------
+Frame: 'sourceFrame'
+--------
+
+
+<p>
+
+<input
+
+
+type="text">
+</p>
+
+
Added: trunk/LayoutTests/fast/frames/viewsource-linebreak.html (0 => 90082)
--- trunk/LayoutTests/fast/frames/viewsource-linebreak.html (rev 0)
+++ trunk/LayoutTests/fast/frames/viewsource-linebreak.html 2011-06-30 03:05:03 UTC (rev 90082)
@@ -0,0 +1,16 @@
+<html>
+<head>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+ layoutTestController.dumpChildFramesAsText();
+ }
+</script>
+</head>
+<body>
+<p>You should see a frame in 'view source' mode below.</p>
+<p>There should be no additional space at end of line. Number of line breaks should match source file.</p>
+<hr>
+<iframe viewsource name="sourceFrame" src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (90081 => 90082)
--- trunk/Source/WebCore/ChangeLog 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/Source/WebCore/ChangeLog 2011-06-30 03:05:03 UTC (rev 90082)
@@ -1,3 +1,22 @@
+2011-06-29 Keishi Hattori <[email protected]>
+
+ Reviewed by Adam Barth.
+
+ Remove extra space at EOL in view source mode
+ https://bugs.webkit.org/show_bug.cgi?id=63620
+
+ Test: fast/frames/viewsource-linebreak.html
+
+ * css/view-source.css:
+ (tbody:last-child .webkit-line-content:empty:before): If we don't do this
+ the last line will be empty and the height will be shorter than the rest.
+ * html/HTMLViewSourceDocument.cpp:
+ (WebCore::HTMLViewSourceDocument::addSource): If source file is empty, add an empty line.
+ (WebCore::HTMLViewSourceDocument::finishLine): Call when you are done with the current line.
+ Adds a BR element if the line is empty and sets current to tbody.
+ (WebCore::HTMLViewSourceDocument::addText):
+ * html/HTMLViewSourceDocument.h:
+
2011-06-29 Brent Fulgham <[email protected]>
[WinCE] Correct logical state of WINCE test.
Modified: trunk/Source/WebCore/css/view-source.css (90081 => 90082)
--- trunk/Source/WebCore/css/view-source.css 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/Source/WebCore/css/view-source.css 2011-06-30 03:05:03 UTC (rev 90082)
@@ -76,6 +76,10 @@
-webkit-user-select: none
}
+tbody:last-child .webkit-line-content:empty:before {
+ content: " ";
+}
+
.webkit-line-content {
padding: 0 5px !important;
}
Modified: trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp (90081 => 90082)
--- trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp 2011-06-30 03:05:03 UTC (rev 90082)
@@ -28,6 +28,7 @@
#include "Attribute.h"
#include "DOMImplementation.h"
#include "HTMLAnchorElement.h"
+#include "HTMLBRElement.h"
#include "HTMLBaseElement.h"
#include "HTMLBodyElement.h"
#include "HTMLDivElement.h"
@@ -110,6 +111,8 @@
processDoctypeToken(source, token);
break;
case HTMLToken::EndOfFile:
+ if (!m_tbody->hasChildNodes())
+ addLine(String());
break;
case HTMLToken::StartTag:
case HTMLToken::EndTag:
@@ -234,6 +237,16 @@
}
}
+void HTMLViewSourceDocument::finishLine()
+{
+ if (!m_current->hasChildNodes()) {
+ RefPtr<HTMLBRElement> br = HTMLBRElement::create(this);
+ m_current->parserAddChild(br);
+ br->attach();
+ }
+ m_current = m_tbody;
+}
+
void HTMLViewSourceDocument::addText(const String& text, const AtomicString& className)
{
if (text.isEmpty())
@@ -245,23 +258,20 @@
unsigned size = lines.size();
for (unsigned i = 0; i < size; i++) {
String substring = lines[i];
+ if (m_current == m_tbody)
+ addLine(className);
if (substring.isEmpty()) {
if (i == size - 1)
break;
- substring = " ";
+ finishLine();
+ continue;
}
- if (m_current == m_tbody)
- addLine(className);
RefPtr<Text> t = Text::create(this, substring);
m_current->parserAddChild(t);
t->attach();
if (i < size - 1)
- m_current = m_tbody;
+ finishLine();
}
-
- // Set current to m_tbody if the last character was a newline.
- if (text[text.length() - 1] == '\n')
- m_current = m_tbody;
}
int HTMLViewSourceDocument::addRange(const String& source, int start, int end, const String& className, bool isLink, bool isAnchor)
Modified: trunk/Source/WebCore/html/HTMLViewSourceDocument.h (90081 => 90082)
--- trunk/Source/WebCore/html/HTMLViewSourceDocument.h 2011-06-30 02:30:02 UTC (rev 90081)
+++ trunk/Source/WebCore/html/HTMLViewSourceDocument.h 2011-06-30 03:05:03 UTC (rev 90082)
@@ -56,6 +56,7 @@
void createContainingTable();
PassRefPtr<Element> addSpanWithClassName(const AtomicString&);
void addLine(const AtomicString& className);
+ void finishLine();
void addText(const String& text, const AtomicString& className);
int addRange(const String& source, int start, int end, const String& className, bool isLink = false, bool isAnchor = false);
PassRefPtr<Element> addLink(const AtomicString& url, bool isAnchor);