Commit 317a9c13 authored by ppi@chromium.org's avatar ppi@chromium.org

Revert of Fix to keep the selection of the text field in input element after...

Revert of Fix to keep the selection of the text field in input element after setSelectionRange is called by d… (patchset #7 id:160001 of https://codereview.chromium.org/507533002/)

Reason for revert:
Suspected cause of flaky failures of org.chromium.content.browser.input.ImeTest on Android bots - see http://crbug.com/411756

Original issue's description:
> Fix to keep the selection of the text field in input element after setSelectionRange is called by dom events related to mouse
> 
> The problem is that the selection is cleared when handling mouse release.
> The selection should be kept if the selection is set by setSelectionRange during handling mouse event.
> 
> BUG=32865
> R=yosin@chromium.org
> R=rbyers@chromium.org
> TEST=LayoutTests/fast/forms/setrangetext-within-events.html
> 
> Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=181490

TBR=yosin@chromium.org,yoichio@chromium.org,rbyers@chromium.org,kenjibaheux@chromium.org,myid.o.shin@gmail.com
NOTREECHECKS=true
NOTRY=true
BUG=32865

Review URL: https://codereview.chromium.org/548413002

git-svn-id: svn://svn.chromium.org/blink/trunk@181565 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0d886b67
This tests the selection of the text field after setSelectionRange is called
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
focus test :
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 5
the selection should be cleared
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 0
mousedown test :
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 0
the selection should be cleared
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 0
mouseup test :
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 5
the selection should be cleared
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 0
click test :
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 5
the selection should be cleared
PASS textfield.selectionStart is 0
PASS textfield.selectionEnd is 0
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
description("This tests the selection of the text field after setSelectionRange is called");
window.onload = function() {
if (window.eventSender) {
doSetSelectionRange('focus');
doSetSelectionRange('mousedown');
doSetSelectionRange('mouseup');
doSetSelectionRange('click');
}
}
function doSetSelectionRange(event) {
debug(event + ' test :');
var textfield = document.getElementById('textfield');
textfield.setSelectionRange(0, 1);
var tx = textfield.offsetLeft + 4;
var ty = textfield.offsetTop + 4;
textfield.addEventListener(event, setSelectionRange);
eventSender.mouseMoveTo(tx, ty);
eventSender.mouseDown();
eventSender.mouseUp();
if (event == 'mousedown') {
shouldBe('textfield.selectionStart', '0');
shouldBe('textfield.selectionEnd', '0');
} else {
shouldBe('textfield.selectionStart', '0');
shouldBe('textfield.selectionEnd', '5');
}
eventSender.mouseMoveTo(tx, ty + 30);
eventSender.mouseDown();
eventSender.mouseUp();
debug('the selection should be cleared');
shouldBe('textfield.selectionStart', '0');
shouldBe('textfield.selectionEnd', '0');
textfield.removeEventListener(event, setSelectionRange);
}
function setSelectionRange(e) {
var textfield = document.getElementById('textfield');
textfield.setSelectionRange(0, textfield.value.length);
}
</script>
<input type="text" value="value" id="textfield"></input>
\ No newline at end of file
......@@ -296,7 +296,6 @@ void FrameSelection::setSelection(const VisibleSelection& newSelection, SetSelec
notifyAccessibilityForSelectionChange();
notifyCompositorForSelectionChange();
notifyEventHandlerForSelectionChange();
m_frame->domWindow()->enqueueDocumentEvent(Event::create(EventTypeNames::selectionchange));
}
......@@ -1452,11 +1451,6 @@ void FrameSelection::notifyCompositorForSelectionChange()
scheduleVisualUpdate();
}
void FrameSelection::notifyEventHandlerForSelectionChange()
{
m_frame->eventHandler().notifySelectionChanged();
}
void FrameSelection::focusedOrActiveStateChanged()
{
bool activeAndFocused = isFocusedAndActive();
......
......@@ -246,7 +246,6 @@ private:
void notifyAccessibilityForSelectionChange();
void notifyCompositorForSelectionChange();
void notifyEventHandlerForSelectionChange();
void focusedOrActiveStateChanged();
......
......@@ -619,6 +619,7 @@ bool EventHandler::handleMousePressEvent(const MouseEventWithHitTestResults& eve
bool swallowEvent = false;
m_mousePressed = true;
m_selectionInitiationState = HaveNotStartedSelection;
if (event.event().clickCount() == 2)
swallowEvent = handleMousePressEventDoubleClick(event);
......@@ -1284,10 +1285,6 @@ bool EventHandler::handleMousePressEvent(const PlatformMouseEvent& mouseEvent)
m_frame->selection().setCaretBlinkingSuspended(true);
bool swallowEvent = !dispatchMouseEvent(EventTypeNames::mousedown, mev.targetNode(), m_clickCount, mouseEvent, true);
// m_selectionInitiationState is initialized after dispatching mousedown event in order not to keep the selection by DOM APIs
// Because we can't give the user the chance to handle the selection by user action like dragging if we keep the selection in case of mousedown.
// FireFox also has the same behavior and it's more compatible with other browsers.
m_selectionInitiationState = HaveNotStartedSelection;
swallowEvent = swallowEvent || handleMouseFocus(mouseEvent);
m_capturesDragging = !swallowEvent || mev.scrollbar();
......@@ -2954,11 +2951,6 @@ void EventHandler::notifyElementActivated()
m_lastDeferredTapElement = nullptr;
}
void EventHandler::notifySelectionChanged()
{
m_selectionInitiationState = ExtendedSelection;
}
bool EventHandler::handleAccessKey(const PlatformKeyboardEvent& evt)
{
// FIXME: Ignoring the state of Shift key is what neither IE nor Firefox do.
......
......@@ -194,7 +194,6 @@ public:
bool useHandCursor(Node*, bool isOverLink);
void notifyElementActivated();
void notifySelectionChanged();
PassRefPtr<UserGestureToken> takeLastMouseDownGestureToken() { return m_lastMouseDownUserGestureToken.release(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment