Changeset 165002 in webkit


Ignore:
Timestamp:
Mar 3, 2014, 1:11:24 PM (11 years ago)
Author:
Antti Koivisto
Message:

Find results on simple lines are not marked correctly
https://bugs.webkit.org/show_bug.cgi?id=129586

Reviewed by Andreas Kling.

Source/WebCore:

Tests: editing/text-iterator/count-mark-lineboxes.html

editing/text-iterator/count-mark-simple-lines.html


TextIterator operating on simple lines failed to take the end of the range into account.
This also causes performance issues on long documents as range traversals would miss the end
node and end up going through the entire document.

  • editing/TextIterator.cpp:

(WebCore::TextIterator::handleTextNode):

Stop when hitting the range end on simple text nodes.

(WebCore::SimplifiedBackwardsTextIterator::handleTextNode):

Use hasRenderedText test instead of linebox-only firstTextBox.

  • testing/Internals.cpp:

(WebCore::Internals::countMatchesForText):

  • testing/Internals.h:
  • testing/Internals.idl:


Add testing interface for counting and marking matches.

LayoutTests:

  • editing/text-iterator/count-mark-lineboxes-expected.txt: Added.
  • editing/text-iterator/count-mark-lineboxes.html: Added.
  • editing/text-iterator/count-mark-simple-lines-expected.txt: Added.
  • editing/text-iterator/count-mark-simple-lines.html: Added.
Location:
trunk
Files:
4 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r164999 r165002  
     12014-03-03  Antti Koivisto  <antti@apple.com>
     2
     3        Find results on simple lines are not marked correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=129586
     5
     6        Reviewed by Andreas Kling.
     7
     8        * editing/text-iterator/count-mark-lineboxes-expected.txt: Added.
     9        * editing/text-iterator/count-mark-lineboxes.html: Added.
     10        * editing/text-iterator/count-mark-simple-lines-expected.txt: Added.
     11        * editing/text-iterator/count-mark-simple-lines.html: Added.
     12
    1132014-03-03  Jer Noble  <jer.noble@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r165001 r165002  
     12014-03-03  Antti Koivisto  <antti@apple.com>
     2
     3        Find results on simple lines are not marked correctly
     4        https://bugs.webkit.org/show_bug.cgi?id=129586
     5
     6        Reviewed by Andreas Kling.
     7
     8        Tests: editing/text-iterator/count-mark-lineboxes.html
     9               editing/text-iterator/count-mark-simple-lines.html
     10               
     11        TextIterator operating on simple lines failed to take the end of the range into account.
     12        This also causes performance issues on long documents as range traversals would miss the end
     13        node and end up going through the entire document.
     14
     15        * editing/TextIterator.cpp:
     16        (WebCore::TextIterator::handleTextNode):
     17       
     18            Stop when hitting the range end on simple text nodes.
     19
     20        (WebCore::SimplifiedBackwardsTextIterator::handleTextNode):
     21       
     22            Use hasRenderedText test instead of linebox-only firstTextBox.
     23
     24        * testing/Internals.cpp:
     25        (WebCore::Internals::countMatchesForText):
     26        * testing/Internals.h:
     27        * testing/Internals.idl:
     28       
     29            Add testing interface for counting and marking matches.
     30
    1312014-03-03  Benjamin Poulain  <benjamin@webkit.org>
    232
  • trunk/Source/WebCore/editing/TextIterator.cpp

    r164964 r165002  
    539539            return true;
    540540        // This code aims to produce same results as handleTextBox() below so test results don't change. It does not make much logical sense.
     541        const unsigned end = (m_node == m_endContainer) ? static_cast<unsigned>(m_endOffset) : str.length();
    541542        unsigned runEnd = m_offset;
    542543        unsigned runStart = m_offset;
    543         while (runEnd < str.length() && (deprecatedIsCollapsibleWhitespace(str[runEnd]) || str[runEnd] == '\t'))
     544        while (runEnd < end && (deprecatedIsCollapsibleWhitespace(str[runEnd]) || str[runEnd] == '\t'))
    544545            ++runEnd;
    545546        bool addSpaceForPrevious = m_lastTextNodeEndedWithCollapsedSpace && m_lastCharacter && !deprecatedIsCollapsibleWhitespace(m_lastCharacter);
     
    557558            runStart = runEnd;
    558559        }
    559         while (runEnd < str.length() && !deprecatedIsCollapsibleWhitespace(str[runEnd]))
     560        while (runEnd < end && !deprecatedIsCollapsibleWhitespace(str[runEnd]))
    560561            ++runEnd;
    561         if (runStart < str.length())
     562        if (runStart < end)
    562563            emitText(m_node, renderer, runStart, runEnd);
    563564        m_offset = runEnd;
    564         return runEnd == str.length();
     565        return runEnd == end;
    565566    }
    566567
     
    13011302
    13021303    String text = renderer->text();
    1303     if (!renderer->firstTextBox() && text.length() > 0)
     1304    if (!renderer->hasRenderedText() && text.length() > 0)
    13041305        return true;
    13051306
  • trunk/Source/WebCore/testing/Internals.cpp

    r164830 r165002  
    14361436}
    14371437
     1438unsigned Internals::countMatchesForText(const String& text, unsigned findOptions, const String& markMatches, ExceptionCode&)
     1439{
     1440    Document* document = contextDocument();
     1441    if (!document || !document->frame())
     1442        return 0;
     1443
     1444    bool mark = markMatches == "mark";
     1445    return document->frame()->editor().countMatchesForText(text, nullptr, findOptions, std::numeric_limits<unsigned>::max(), mark, nullptr);
     1446}
     1447
    14381448const ProfilesArray& Internals::consoleProfiles() const
    14391449{
  • trunk/Source/WebCore/testing/Internals.h

    r164830 r165002  
    188188    void toggleOverwriteModeEnabled(ExceptionCode&);
    189189
     190    unsigned countMatchesForText(const String&, unsigned findOptions, const String& markMatches, ExceptionCode&);
     191
    190192    unsigned numberOfScrollableAreas(ExceptionCode&);
    191193
  • trunk/Source/WebCore/testing/Internals.idl

    r164830 r165002  
    9999    [RaisesException] void setEditingValue(Element inputElement, DOMString value);
    100100    [RaisesException] void setAutofilled(Element inputElement, boolean enabled);
     101    [RaisesException] unsigned long countMatchesForText(DOMString text, unsigned long findOptions, DOMString markMatches);
    101102
    102103    [RaisesException] void paintControlTints();
  • trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

    r164969 r165002  
    336336        symbolWithPointer(?toggleContinuousSpellChecking@Editor@WebCore@@QAEXXZ, ?toggleContinuousSpellChecking@Editor@WebCore@@QEAAXXZ)
    337337        symbolWithPointer(?toggleOverwriteModeEnabled@Editor@WebCore@@QAEXXZ, ?toggleOverwriteModeEnabled@Editor@WebCore@@QEAAXXZ)
     338        symbolWithPointer(?countMatchesForText@Editor@WebCore@@QAEIABVString@WTF@@PAVRange@2@EI_NPAV?$Vector@V?$RefPtr@VRange@WebCore@@@WTF@@$0A@VCrashOnOverflow@2@@4@@Z, ?countMatchesForText@Editor@WebCore@@QEAAIABVString@WTF@@PAVRange@2@EI_NPAV?$Vector@V?$RefPtr@VRange@WebCore@@@WTF@@$0A@VCrashOnOverflow@2@@4@@Z)
    338339#if ENABLE(FULLSCREEN_API)
    339340        symbolWithPointer(?webkitWillEnterFullScreenForElement@Document@WebCore@@QAEXPAVElement@2@@Z, ?webkitWillEnterFullScreenForElement@Document@WebCore@@QEAAXPEAVElement@2@@Z)
Note: See TracChangeset for help on using the changeset viewer.