RESOLVED FIXED 89098
Add methods to select between offsets in an editable field.
https://bugs.webkit.org/show_bug.cgi?id=89098
Summary Add methods to select between offsets in an editable field.
Oli Lan
Reported 2012-06-14 07:15:08 PDT
Add a method to select between offsets in an editable field.
Attachments
Patch (5.90 KB, patch)
2012-06-14 07:26 PDT, Oli Lan
no flags
Patch (6.71 KB, patch)
2012-06-14 07:43 PDT, Oli Lan
no flags
Patch (8.80 KB, patch)
2012-06-15 09:26 PDT, Oli Lan
no flags
Patch for landing (8.91 KB, patch)
2012-06-21 13:43 PDT, Adam Barth
no flags
Oli Lan
Comment 1 2012-06-14 07:26:05 PDT
WebKit Review Bot
Comment 2 2012-06-14 07:29:47 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Oli Lan
Comment 3 2012-06-14 07:32:42 PDT
Hmm, it looks like the new html files in tests/data haven't been picked up in the patch.
Oli Lan
Comment 4 2012-06-14 07:43:10 PDT
Oli Lan
Comment 5 2012-06-14 07:44:19 PDT
Patch 2 has the new test html files.
Adam Barth
Comment 6 2012-06-14 08:51:43 PDT
@rniwa: Would you be willing to review this patch?
Ryosuke Niwa
Comment 7 2012-06-14 10:38:04 PDT
Comment on attachment 147588 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=147588&action=review > Source/WebKit/chromium/ChangeLog:15 > + Reviewed by NOBODY (OOPS!). This line should appear before the long description bug after the bug url. > Source/WebKit/chromium/src/WebViewImpl.cpp:2098 > + Node* node = focusedWebCoreNode(); > + if (node && node->isElementNode()) { > + Element* elementNode = toElement(node); > + if (elementNode->isTextFormControl()) { > + HTMLTextFormControlElement* formElement = toTextFormControl(elementNode); > + formElement->setSelectionRange(start, end); > + return; > + } > + } This code is redundant. > Source/WebKit/chromium/src/WebViewImpl.cpp:2102 > + // For contenteditable nodes the focusedWebCoreNode may not be what we want (the editable > + // node may not be focused even during editing). Also, we need to go to the ancestor node > + // to apply the offsets. This comment is redundant for anyone who understands editing code. I'd suggest we move all of this code to Editor.cpp so that we don't have to add this comment. > Source/WebKit/chromium/src/WebViewImpl.cpp:2106 > + node = frame->selection()->start().containerNode(); Why do you want to use start's container node here? That sounds completely arbitrary except when both start & end are in the same node. > Source/WebKit/chromium/src/WebViewImpl.cpp:2107 > + if (node && node->shouldUseInputMethod()) { If anything, what you want to do is to obtain the root editable element and use TextIterator's static functions to obtain range given start & length offsets from the beginning of the element. > Source/WebKit/chromium/src/WebViewImpl.cpp:2110 > + Position startPosition(node, start, Position::PositionIsOffsetInAnchor); > + Position endPosition(node, end, Position::PositionIsOffsetInAnchor); What guarantees that start and end are in the same node? If this is specific to composition, then the method name should reflect that. Also, I'd prefer moving this code to Editor.h/cpp next to getCompositionSelection.
Oli Lan
Comment 8 2012-06-15 08:18:54 PDT
Thanks for the review. I'll rework this to take into account all your comments.
Oli Lan
Comment 9 2012-06-15 09:26:41 PDT
Adam Barth
Comment 10 2012-06-18 15:44:38 PDT
@rniwa: Are you happy with this patch now?
Ryosuke Niwa
Comment 11 2012-06-18 16:02:47 PDT
Comment on attachment 147835 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=147835&action=review r=me provided the following nits are addressed. > Source/WebCore/editing/Editor.cpp:2352 > + Element* rootEditable = m_frame->selection()->rootEditableElement(); Nit: root editable what? "editable" is an adjective, not a noun. I'd prefer spelling out rootEditableElement. Element is fine as well. > Source/WebCore/editing/Editor.cpp:2360 > + return m_frame->selection()->setSelectedRange(range.get(), WebCore::VP_DEFAULT_AFFINITY, false); Nit: No need for WebCore::
Adam Barth
Comment 12 2012-06-21 13:43:38 PDT
Created attachment 148878 [details] Patch for landing
WebKit Review Bot
Comment 13 2012-06-21 17:49:42 PDT
Comment on attachment 148878 [details] Patch for landing Clearing flags on attachment: 148878 Committed r120985: <http://trac.webkit.org/changeset/120985>
WebKit Review Bot
Comment 14 2012-06-21 17:49:48 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.