Changeset 52235 in webkit


Ignore:
Timestamp:
Dec 16, 2009 10:30:20 PM (14 years ago)
Author:
hamaji@chromium.org
Message:

2009-12-15 MORITA Hajime <morrita@gmail.com>

Reviewed by Eric Seidel.

Bug 28306: double-clicking a word inside <b> beside newline select two words
https://bugs.webkit.org/show_bug.cgi?id=28306


SimplifiedBackwardsTextIterator missed trailing whitespaces just
before folding line-break, which is used to detect word
boundaries. This fix checks strings on RenderText and expand text
range on SimplifiedBackwardsTextIterator to include trailing
whitespaces if availble.

Test: editing/selection/doubleclick-beside-cr-span.html

  • editing/TextIterator.cpp: (WebCore::collapsedSpaceLength): (WebCore::maxOffsetIncludingCollapsedSpaces): (WebCore::SimplifiedBackwardsTextIterator::advance):

2009-12-16 MORITA Hajime <morrita@gmail.com>

Reviewed by Eric Seidel.

Bug 28306: double-clicking a word inside <b> beside newline select two words
https://bugs.webkit.org/show_bug.cgi?id=28306

SimplifiedBackwardsTextIterator missed trailing whitespaces just
before folding line-break, which is used to detect word
boundaries. This fix checks strings on RenderText and expand text
range on SimplifiedBackwardsTextIterator to include trailing
whitespaces if availble.

  • editing/selection/doubleclick-beside-cr-span-expected.txt: Added.
  • editing/selection/doubleclick-beside-cr-span.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52233 r52235  
     12009-12-16  MORITA Hajime <morrita@gmail.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Bug 28306: double-clicking a word inside <b> beside newline select two words
     6        https://bugs.webkit.org/show_bug.cgi?id=28306
     7
     8        SimplifiedBackwardsTextIterator missed trailing whitespaces just
     9        before folding line-break, which is used to detect word
     10        boundaries. This fix checks strings on RenderText and expand text
     11        range on SimplifiedBackwardsTextIterator to include trailing
     12        whitespaces if availble.
     13
     14        * editing/selection/doubleclick-beside-cr-span-expected.txt: Added.
     15        * editing/selection/doubleclick-beside-cr-span.html: Added.
     16
    1172009-12-16  Jon Honeycutt  <jhoneycutt@apple.com>
    218
  • trunk/WebCore/ChangeLog

    r52234 r52235  
     12009-12-15 MORITA Hajime <morrita@gmail.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Bug 28306: double-clicking a word inside <b> beside newline select two words
     6        https://bugs.webkit.org/show_bug.cgi?id=28306
     7       
     8        SimplifiedBackwardsTextIterator missed trailing whitespaces just
     9        before folding line-break, which is used to detect word
     10        boundaries. This fix checks strings on RenderText and expand text
     11        range on SimplifiedBackwardsTextIterator to include trailing
     12        whitespaces if availble.
     13
     14        Test: editing/selection/doubleclick-beside-cr-span.html
     15
     16        * editing/TextIterator.cpp:
     17        (WebCore::collapsedSpaceLength):
     18        (WebCore::maxOffsetIncludingCollapsedSpaces):
     19        (WebCore::SimplifiedBackwardsTextIterator::advance):
     20
    1212009-12-16  Fumitoshi Ukai  <ukai@chromium.org>
    222
  • trunk/WebCore/editing/TextIterator.cpp

    r50675 r52235  
    704704   
    705705    return false;
     706}
     707
     708static int collapsedSpaceLength(RenderText* renderer, int textEnd)
     709{
     710    const UChar* characters = renderer->text()->characters();
     711    int length = renderer->text()->length();
     712    for (int i = textEnd; i < length; ++i) {
     713        if (!renderer->style()->isCollapsibleWhiteSpace(characters[i]))
     714            return i - textEnd;
     715    }
     716
     717    return length - textEnd;
     718}
     719
     720static int maxOffsetIncludingCollapsedSpaces(Node* node)
     721{
     722    int offset = caretMaxOffset(node);
     723
     724    if (node->renderer() && node->renderer()->isText())
     725        offset += collapsedSpaceLength(toRenderText(node->renderer()), offset);
     726
     727    return offset;
    706728}
    707729
     
    10301052        if (m_node)
    10311053            pushFullyClippedState(m_fullyClippedStack, m_node);
    1032         m_offset = m_node ? caretMaxOffset(m_node) : 0;
     1054        // For the purpose of word boundary detection,
     1055        // we should iterate all visible text and trailing (collapsed) whitespaces.
     1056        m_offset = m_node ? maxOffsetIncludingCollapsedSpaces(m_node) : 0;
    10331057        m_handledNode = false;
    10341058        m_handledChildren = false;
Note: See TracChangeset for help on using the changeset viewer.