Add methods to select between offsets in an editable field.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jun 2012 00:49:25 +0000 (00:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jun 2012 00:49:25 +0000 (00:49 +0000)
commite1da7eda7f5877c1423a480c68b5803f8bd6c7b3
tree17db739fde8f8ccfa0cbf007297e5bc37170bc15
parent1a8091830b9a8a28178971a8c4dec7276f516a63
Add methods to select between offsets in an editable field.
https://bugs.webkit.org/show_bug.cgi?id=89098

Patch by Oli Lan <olilan@chromium.org> on 2012-06-21
Reviewed by Ryosuke Niwa.

Reviewed by Ryosuke Niwa.

Source/WebCore:

Adds a new method setSelectionOffsets to Editor. This selects between
the two integer offsets provided in the node currently being edited,
assuming the offsets are given relative to the rootEditableElement.
If no node or field is currently being edited, the method returns false.

Test: a new test has been added to the chromium port's WebViewTest that
calls this via WebViewImpl::setSelectionEditableOffsets.

* editing/Editor.cpp:
(WebCore::Editor::setSelectionOffsets):
(WebCore):
* editing/Editor.h:
(Editor):

Source/WebKit/chromium:

This adds a new method WebViewImpl::setEditableSelectionOffsets, which
can be used to select between two character positions in the node
currently beign edited.

The offsets are assumed to be relative to the rootEditableElement.

This can be used for IME features that require the ability to manipulate
the selection, for example on Android where the method InputConnection#setSelection
is used.

This method calls a new method Editor::setSelectionOffsets.

The method works for inputs/textareas (i.e. text form controls) and
contenteditable nodes, and the new test in WebViewTest tests both these cases.

* public/WebView.h:
(WebView):
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::setEditableSelectionOffsets):
(WebKit):
* src/WebViewImpl.h:
(WebViewImpl):
* tests/WebViewTest.cpp:
(WebKit::TEST_F):
(WebKit):
* tests/data/content_editable_populated.html: Added.
* tests/data/input_field_populated.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp
Source/WebCore/editing/Editor.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebView.h
Source/WebKit/chromium/src/WebViewImpl.cpp
Source/WebKit/chromium/src/WebViewImpl.h
Source/WebKit/chromium/tests/WebViewTest.cpp
Source/WebKit/chromium/tests/data/content_editable_populated.html [new file with mode: 0644]
Source/WebKit/chromium/tests/data/input_field_populated.html [new file with mode: 0644]