Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1449)

Unified Diff: third_party/WebKit/Source/web/WebViewImpl.cpp

Issue 2306643003: WebRange-ify WebWidget::compositionRange. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebWidget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/WebViewImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp
index 6a5ae67d63ad9cf36e1ec62914937b6fcaa3acf6..a7df922c3e92c4a387717d1ea0d7aa0bf8a8d1cc 100644
--- a/third_party/WebKit/Source/web/WebViewImpl.cpp
+++ b/third_party/WebKit/Source/web/WebViewImpl.cpp
@@ -2387,24 +2387,19 @@ bool WebViewImpl::confirmComposition(const WebString& text, ConfirmCompositionBe
return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : InputMethodController::DoNotKeepSelection);
}
-bool WebViewImpl::compositionRange(size_t* location, size_t* length)
+WebRange WebViewImpl::compositionRange()
{
LocalFrame* focused = focusedLocalFrameAvailableForIme();
if (!focused)
- return false;
+ return WebRange();
const EphemeralRange range = focused->inputMethodController().compositionEphemeralRange();
if (range.isNull())
- return false;
+ return WebRange();
Element* editable = focused->selection().rootEditableElementOrDocumentElement();
DCHECK(editable);
- PlainTextRange plainTextRange(PlainTextRange::create(*editable, range));
- if (plainTextRange.isNull())
- return false;
- *location = plainTextRange.start();
- *length = plainTextRange.length();
- return true;
+ return PlainTextRange::create(*editable, range);
}
WebTextInputInfo WebViewImpl::textInputInfo()
@@ -2812,12 +2807,11 @@ void WebViewImpl::didChangeWindowResizerRect()
bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds)
{
- size_t offset = 0;
- size_t characterCount = 0;
- if (!compositionRange(&offset, &characterCount))
+ WebRange range = compositionRange();
+ if (range.isNull())
return false;
- if (characterCount == 0)
+ if (range.length() == 0)
esprehn 2016/09/02 21:24:34 isEmpty() would be idiomatic.
return false;
WebLocalFrame* frame = focusedFrame();
@@ -2828,6 +2822,8 @@ bool WebViewImpl::getCompositionCharacterBounds(WebVector<WebRect>& bounds)
if (frame->localRoot() != mainFrameImpl())
return false;
+ size_t characterCount = range.length();
+ size_t offset = range.startOffset();
WebVector<WebRect> result(characterCount);
WebRect webrect;
for (size_t i = 0; i < characterCount; ++i) {
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebWidget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698