[Webkit-unassigned] [Bug 25253] REGRESSION: 'maxLength' of input text field doesn't work for CJK characters

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 25 04:18:10 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=25253





--- Comment #5 from TAMURA, Kent <tkent at chromium.org>  2009-08-25 04:18:09 PDT ---
Bono-san gave me some information.
InputElement::handleBeforeTextInsertedEvent() makes this problem.

void InputElement::handleBeforeTextInsertedEvent(InputElementData& data,
InputElement* inputElement, Document* document, Event* event)
{
    ASSERT(event->isBeforeTextInsertedEvent());

    // Make sure that the text to be inserted will not violate the maxLength.
    int oldLength = numGraphemeClusters(inputElement->value().impl());
    ASSERT(oldLength <= data.maxLength());
    int selectionLength =
numGraphemeClusters(plainText(document->frame()->selection()->selection().toNormalizedRange().get()).impl());
    ASSERT(oldLength >= selectionLength);
    int maxNewLength = data.maxLength() - (oldLength - selectionLength);

    // Truncate the inserted text to avoid violating the maxLength and other
constraints.
    BeforeTextInsertedEvent* textEvent =
static_cast<BeforeTextInsertedEvent*>(event);
    textEvent->setText(constrainValue(inputElement, textEvent->text(),
maxNewLength));
}

selectionLength represents the length to be removed by the next text insertion.
 However, frame()->selection()->selection() can be IME's pre-edit text, which
is outside of the current inputElement->value().  So maxNewLength can be larger
than expectation.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list