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

Unified Diff: third_party/WebKit/Source/web/WebFrameWidgetImpl.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
Index: third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
diff --git a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
index 86c93cfd5d6b182744b968eb9c2cdc3f249a90ae..1c48812bf9783a3d80a39c620844ed59d26b50c6 100644
--- a/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
+++ b/third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp
@@ -569,24 +569,19 @@ bool WebFrameWidgetImpl::confirmComposition(const WebString& text, ConfirmCompos
return focused->inputMethodController().confirmCompositionOrInsertText(text, selectionBehavior == KeepSelection ? InputMethodController::KeepSelection : InputMethodController::DoNotKeepSelection);
}
-bool WebFrameWidgetImpl::compositionRange(size_t* location, size_t* length)
+WebRange WebFrameWidgetImpl::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 WebFrameWidgetImpl::textInputInfo()
@@ -853,12 +848,11 @@ void WebFrameWidgetImpl::didLosePointerLock()
bool WebFrameWidgetImpl::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)
return false;
LocalFrame* frame = focusedLocalFrameInWidget();
@@ -866,6 +860,8 @@ bool WebFrameWidgetImpl::getCompositionCharacterBounds(WebVector<WebRect>& bound
return false;
WebLocalFrameImpl* webLocalFrame = WebLocalFrameImpl::fromFrame(frame);
+ size_t characterCount = range.length();
+ size_t offset = range.startOffset();
WebVector<WebRect> result(characterCount);
WebRect webrect;
for (size_t i = 0; i < characterCount; ++i) {
@@ -875,6 +871,7 @@ bool WebFrameWidgetImpl::getCompositionCharacterBounds(WebVector<WebRect>& bound
}
result[i] = webrect;
}
+
bounds.swap(result);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698