Changeset 90082 in webkit


Ignore:
Timestamp:
Jun 29, 2011 8:05:03 PM (13 years ago)
Author:
keishi@webkit.org
Message:

2011-06-29 Keishi Hattori <keishi@webkit.org>

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-29 Keishi Hattori <keishi@webkit.org>

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:
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r90068 r90082  
     12011-06-29  Keishi Hattori  <keishi@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Remove extra space at EOL in view source mode
     6        https://bugs.webkit.org/show_bug.cgi?id=63620
     7
     8        * fast/frames/resources/viewsource-frame-5.html: Added.
     9        * fast/frames/viewsource-empty-attribute-value-expected.txt: Regenerated.
     10        * fast/frames/viewsource-linebreak-expected.txt: Added.
     11        * fast/frames/viewsource-linebreak.html: Added. Test that there are no extra spaces at EOL.
     12        And that the multiple consecutive line breaks are maintained in the frame.
     13
    1142011-06-23  Abhishek Arya  <inferno@chromium.org>
    215
  • trunk/LayoutTests/fast/frames/viewsource-empty-attribute-value-expected.txt

    r34134 r90082  
    88Frame: 'sourceFrame'
    99--------
    10 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    11 <hr noshade width=75%>
    12 <div align="center" title="" id="foo">
    13 <p>hello world</p>
    14 </div>
     10<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
     11<hr noshade width=75%>
     12<div align="center" title="" id="foo">
     13<p>hello world</p>
     14</div>
     15
  • trunk/Source/WebCore/ChangeLog

    r90075 r90082  
     12011-06-29  Keishi Hattori  <keishi@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Remove extra space at EOL in view source mode
     6        https://bugs.webkit.org/show_bug.cgi?id=63620
     7
     8        Test: fast/frames/viewsource-linebreak.html
     9
     10        * css/view-source.css:
     11        (tbody:last-child .webkit-line-content:empty:before): If we don't do this
     12        the last line will be empty and the height will be shorter than the rest.
     13        * html/HTMLViewSourceDocument.cpp:
     14        (WebCore::HTMLViewSourceDocument::addSource): If source file is empty, add an empty line.
     15        (WebCore::HTMLViewSourceDocument::finishLine): Call when you are done with the current line.
     16        Adds a BR element if the line is empty and sets current to tbody.
     17        (WebCore::HTMLViewSourceDocument::addText):
     18        * html/HTMLViewSourceDocument.h:
     19
    1202011-06-29  Brent Fulgham  <bfulgham@webkit.org>
    221
  • trunk/Source/WebCore/css/view-source.css

    r71348 r90082  
    7575    counter-increment: lines;
    7676    -webkit-user-select: none
     77}
     78
     79tbody:last-child .webkit-line-content:empty:before {
     80    content: " ";
    7781}
    7882
  • trunk/Source/WebCore/html/HTMLViewSourceDocument.cpp

    r87309 r90082  
    2929#include "DOMImplementation.h"
    3030#include "HTMLAnchorElement.h"
     31#include "HTMLBRElement.h"
    3132#include "HTMLBaseElement.h"
    3233#include "HTMLBodyElement.h"
     
    111112        break;
    112113    case HTMLToken::EndOfFile:
     114        if (!m_tbody->hasChildNodes())
     115            addLine(String());
    113116        break;
    114117    case HTMLToken::StartTag:
     
    235238}
    236239
     240void HTMLViewSourceDocument::finishLine()
     241{
     242    if (!m_current->hasChildNodes()) {
     243        RefPtr<HTMLBRElement> br = HTMLBRElement::create(this);
     244        m_current->parserAddChild(br);
     245        br->attach();
     246    }
     247    m_current = m_tbody;
     248}
     249
    237250void HTMLViewSourceDocument::addText(const String& text, const AtomicString& className)
    238251{
     
    246259    for (unsigned i = 0; i < size; i++) {
    247260        String substring = lines[i];
     261        if (m_current == m_tbody)
     262            addLine(className);
    248263        if (substring.isEmpty()) {
    249264            if (i == size - 1)
    250265                break;
    251             substring = " ";
     266            finishLine();
     267            continue;
    252268        }
    253         if (m_current == m_tbody)
    254             addLine(className);
    255269        RefPtr<Text> t = Text::create(this, substring);
    256270        m_current->parserAddChild(t);
    257271        t->attach();
    258272        if (i < size - 1)
    259             m_current = m_tbody;
    260     }
    261 
    262     // Set current to m_tbody if the last character was a newline.
    263     if (text[text.length() - 1] == '\n')
    264         m_current = m_tbody;
     273            finishLine();
     274    }
    265275}
    266276
  • trunk/Source/WebCore/html/HTMLViewSourceDocument.h

    r66957 r90082  
    5757    PassRefPtr<Element> addSpanWithClassName(const AtomicString&);
    5858    void addLine(const AtomicString& className);
     59    void finishLine();
    5960    void addText(const String& text, const AtomicString& className);
    6061    int addRange(const String& source, int start, int end, const String& className, bool isLink = false, bool isAnchor = false);
Note: See TracChangeset for help on using the changeset viewer.