Changeset 164329 in webkit


Ignore:
Timestamp:
Feb 18, 2014 4:04:07 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

TextFieldInputType::handleBeforeTextInsertedEvent shouldn't use plainText
https://bugs.webkit.org/show_bug.cgi?id=128953

Reviewed by Alexey Proskuryakov.

Don't use FrameSelection's toNormalizedRange and plainText. Instead, use the cached selection start and selection
end to extract the selected text. The caches are updated inside FrameSelection::setSelection whenever selection
is inside a text form control via HTMLTextFormControlElement::selectionChanged.

  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r164324 r164329  
     12014-02-18  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        TextFieldInputType::handleBeforeTextInsertedEvent shouldn't use plainText
     4        https://bugs.webkit.org/show_bug.cgi?id=128953
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Don't use FrameSelection's toNormalizedRange and plainText. Instead, use the cached selection start and selection
     9        end to extract the selected text. The caches are updated inside FrameSelection::setSelection whenever selection
     10        is inside a text form control via HTMLTextFormControlElement::selectionChanged.
     11
     12        * html/TextFieldInputType.cpp:
     13        (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
     14
    1152014-02-18  Viatcheslav Ostapenko  <sl.ostapenko@samsung.com>
    216
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r164184 r164329  
    375375    // because they can be mismatched by sanitizeValue() in
    376376    // HTMLInputElement::subtreeHasChanged() in some cases.
    377     unsigned oldLength = numGraphemeClusters(element().innerTextValue());
     377    String innerText = element().innerTextValue();
     378    unsigned oldLength = numGraphemeClusters(innerText);
    378379
    379380    // selectionLength represents the selection length of this text field to be
     
    382383    // selection length. The selection is the source of text drag-and-drop in
    383384    // that case, and nothing in the text field will be removed.
    384     unsigned selectionLength = element().focused() ? numGraphemeClusters(plainText(element().document().frame()->selection().selection().toNormalizedRange().get())) : 0;
     385    unsigned selectionLength = 0;
     386    if (element().focused()) {
     387        ASSERT(enclosingTextFormControl(element().document().frame()->selection().selection().start()) == &element());
     388        selectionLength = numGraphemeClusters(innerText.substring(element().selectionStart(), element().selectionEnd()));
     389    }
    385390    ASSERT(oldLength >= selectionLength);
    386391
Note: See TracChangeset for help on using the changeset viewer.