Changeset 20127 in webkit


Ignore:
Timestamp:
Mar 12, 2007 4:57:56 PM (17 years ago)
Author:
antti
Message:

LayoutTests:

Reviewed by Alexey


Test that this works correctly with composed characters
http://bugs.webkit.org/show_bug.cgi?id=12833
REGRESSION: Selecting text in 6.6MB txt file is sluggish as of the Feb 19th nightly
<rdar://problem/5028159>

  • fast/text/large-text-composed-char-expected.checksum: Added.
  • fast/text/large-text-composed-char-expected.png: Added.
  • fast/text/large-text-composed-char-expected.txt: Added.
  • fast/text/large-text-composed-char.html: Added.

WebCore:

Reviewed by Alexey.

Fix http://bugs.webkit.org/show_bug.cgi?id=12833
REGRESSION: Selecting text in 6.6MB txt file is sluggish as of the Feb 19th nightly
<rdar://problem/5028159>


Divide large text blocks (>64kB) over multiple text nodes. This limits linebox searches to
a manageable subset.


  • dom/Text.cpp: (WebCore::Text::createWithLengthLimit):
  • dom/Text.h:
  • html/HTMLParser.cpp: (WebCore::HTMLParser::parseToken):
  • loader/TextDocument.cpp: (WebCore::TextTokenizer::write):
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r20122 r20127  
     12007-03-12  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Alexey
     4       
     5        Test that this works correctly with composed characters
     6        http://bugs.webkit.org/show_bug.cgi?id=12833
     7        REGRESSION: Selecting text in 6.6MB txt file is sluggish as of the Feb 19th nightly
     8        <rdar://problem/5028159>
     9
     10        * fast/text/large-text-composed-char-expected.checksum: Added.
     11        * fast/text/large-text-composed-char-expected.png: Added.
     12        * fast/text/large-text-composed-char-expected.txt: Added.
     13        * fast/text/large-text-composed-char.html: Added.
     14
    1152007-03-09  Rob Buis  <buis@kde.org>
    216
  • trunk/WebCore/ChangeLog

    r20126 r20127  
     12007-03-12  Antti Koivisto  <antti@apple.com>
     2
     3        Reviewed by Alexey.
     4
     5        Fix http://bugs.webkit.org/show_bug.cgi?id=12833
     6        REGRESSION: Selecting text in 6.6MB txt file is sluggish as of the Feb 19th nightly
     7        <rdar://problem/5028159>
     8       
     9        Divide large text blocks (>64kB) over multiple text nodes. This limits linebox searches to
     10        a manageable subset.
     11       
     12        * dom/Text.cpp:
     13        (WebCore::Text::createWithLengthLimit):
     14        * dom/Text.h:
     15        * html/HTMLParser.cpp:
     16        (WebCore::HTMLParser::parseToken):
     17        * loader/TextDocument.cpp:
     18        (WebCore::TextTokenizer::write):
     19
    1202007-03-12  David Hyatt  <hyatt@apple.com>
    221
  • trunk/WebCore/dom/Text.cpp

    r19855 r20127  
    2828#include "ExceptionCode.h"
    2929#include "RenderText.h"
     30#include "TextBreakIterator.h"
    3031
    3132#if ENABLE(SVG)
     
    197198}
    198199
     200PassRefPtr<Text> Text::createWithLengthLimit(Document* doc, const String& text, unsigned& charsLeft, unsigned maxChars)
     201{
     202    if (charsLeft == text.length() && charsLeft <= maxChars) {
     203        charsLeft = 0;
     204        return new Text(doc, text);
     205    }
     206   
     207    unsigned start = text.length() - charsLeft;
     208    unsigned end = start + std::min(charsLeft, maxChars);
     209   
     210    // check we are not on an unbreakable boundary
     211    TextBreakIterator* it = characterBreakIterator(text.characters(), text.length());
     212    if (end < text.length() && !isTextBreak(it, end))
     213        end = textBreakPreceding(it, end);
     214       
     215    String nodeText = text.substring(start, end - start);
     216    charsLeft = text.length() - end;
     217       
     218    return new Text(doc, nodeText);
     219}
     220
    199221#ifndef NDEBUG
    200222void Text::formatForDebugger(char *buffer, unsigned length) const
  • trunk/WebCore/dom/Text.h

    r18874 r20127  
    2929
    3030namespace WebCore {
     31   
     32const unsigned cTextNodeLengthLimit = 1 << 16;
    3133
    3234class Text : public CharacterData
     
    5759
    5860    virtual String toString() const;
     61   
     62    static PassRefPtr<Text> createWithLengthLimit(Document*, const String&, unsigned& charsLeft, unsigned maxChars = cTextNodeLengthLimit);
    5963
    6064#ifndef NDEBUG
  • trunk/WebCore/html/HTMLParser.cpp

    r18848 r20127  
    196196            current->localName() != scriptTag && !t->text->containsOnlyWhitespace())
    197197            haveContent = true;
     198       
     199        RefPtr<Node> n;
     200        String text = t->text.get();
     201        unsigned charsLeft = text.length();
     202        while (charsLeft) {
     203            // split large blocks of text to nodes of manageable size
     204            n = Text::createWithLengthLimit(document, text, charsLeft);
     205            if (!insertNode(n.get(), t->flat))
     206                return 0;
     207        }
     208        return n;
    198209    }
    199210
  • trunk/WebCore/loader/TextDocument.cpp

    r19868 r20127  
    128128   
    129129    String string = String(m_buffer, m_dest - m_buffer);
    130    
    131     RefPtr<Text> text = m_doc->createTextNode(string);
    132     m_preElement->appendChild(text, ec);
     130    unsigned charsLeft = string.length();
     131    while (charsLeft) {
     132        // split large text to nodes of manageable size
     133        RefPtr<Text> text = Text::createWithLengthLimit(m_doc, string, charsLeft);
     134        m_preElement->appendChild(text, ec);
     135    }
    133136
    134137    return false;
Note: See TracChangeset for help on using the changeset viewer.