Changeset 171376 in webkit


Ignore:
Timestamp:
Jul 22, 2014 5:36:13 PM (10 years ago)
Author:
timothy_horton@apple.com
Message:

REGRESSION (r171016): Reproducible infinite spin selecting phone number
https://bugs.webkit.org/show_bug.cgi?id=135183
<rdar://problem/17727342>

Reviewed by Ryosuke Niwa.

  • editing/Editor.cpp:

(WebCore::Editor::scanRangeForTelephoneNumbers):
Make use of TextIterator::subrange, which knows how to make a subrange from character positions,
instead of assuming that our character positions translate directly to positions in the incoming range.
Make use of DocumentMarkerController::addMarker, which takes a range and applies the marker to
all text nodes inside the range as appropriate.
Fix naming of the shadowed 'length' local.
Fix a typo in the comment.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171375 r171376  
     12014-07-22  Tim Horton  <timothy_horton@apple.com>
     2
     3        REGRESSION (r171016): Reproducible infinite spin selecting phone number
     4        https://bugs.webkit.org/show_bug.cgi?id=135183
     5        <rdar://problem/17727342>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * editing/Editor.cpp:
     10        (WebCore::Editor::scanRangeForTelephoneNumbers):
     11        Make use of TextIterator::subrange, which knows how to make a subrange from character positions,
     12        instead of assuming that our character positions translate directly to positions in the incoming range.
     13        Make use of DocumentMarkerController::addMarker, which takes a range and applies the marker to
     14        all text nodes inside the range as appropriate.
     15        Fix naming of the shadowed 'length' local.
     16        Fix a typo in the comment.
     17
    1182014-07-22  Myles C. Maxfield  <mmaxfield@apple.com>
    219
  • trunk/Source/WebCore/editing/Editor.cpp

    r171016 r171376  
    34613461    while (scannerPosition < length && TelephoneNumberDetector::find(&characters[scannerPosition], length - scannerPosition, &relativeStartPosition, &relativeEndPosition)) {
    34623462        // The convention in the Data Detectors framework is that the end position is the first character NOT in the phone number
    3463         // (that is, the length of the range is relativeEndPosition - relativeStartPosition). So substract 1 to get the same
     3463        // (that is, the length of the range is relativeEndPosition - relativeStartPosition). So subtract 1 to get the same
    34643464        // convention as the old WebCore phone number parser (so that the rest of the code is still valid if we want to go back
    34653465        // to the old parser).
     
    34683468        ASSERT(scannerPosition + relativeEndPosition < length);
    34693469
    3470         // It doesn't make sense to add the document marker to a match that's not in a text node.
    3471         if (!startNode->isTextNode())
    3472             continue;
    3473 
    3474         unsigned startOffset = range.startOffset() + scannerPosition + relativeStartPosition;
    3475         unsigned length = relativeEndPosition - relativeStartPosition + 1;
    3476 
    3477         markedRanges.append(Range::create(range.ownerDocument(), startNode, startOffset, startNode, startOffset + length));
    3478         range.ownerDocument().markers().addMarkerToNode(startNode, startOffset, length, DocumentMarker::TelephoneNumber);
     3470        unsigned subrangeOffset = scannerPosition + relativeStartPosition;
     3471        unsigned subrangeLength = relativeEndPosition - relativeStartPosition + 1;
     3472
     3473        RefPtr<Range> subrange = TextIterator::subrange(&range, subrangeOffset, subrangeLength);
     3474        markedRanges.append(subrange);
     3475        range.ownerDocument().markers().addMarker(subrange.get(), DocumentMarker::TelephoneNumber);
    34793476
    34803477        scannerPosition += relativeEndPosition + 1;
Note: See TracChangeset for help on using the changeset viewer.