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

Unified Diff: content/renderer/text_input_client_observer.cc

Issue 2537363002: Handling firstRectForCharacterRange when range argument has invalid range (Mac) (Closed)
Patch Set: Using isNull() instead of comparing agains -1 Created 4 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/text_input_client_observer.cc
diff --git a/content/renderer/text_input_client_observer.cc b/content/renderer/text_input_client_observer.cc
index eb9ef89d1ae4281e23b73bfbcc50cb7d78e43f61..fd8d5d723ff588b27950d0f8c832e9713f12affb 100644
--- a/content/renderer/text_input_client_observer.cc
+++ b/content/renderer/text_input_client_observer.cc
@@ -26,6 +26,13 @@
namespace content {
+namespace {
+uint32_t GetCurrentCursorPositionInFrame(blink::WebLocalFrame* localFrame) {
+ blink::WebRange range = localFrame->selectionRange();
+ return range.isNull() ? 0U : static_cast<uint32_t>(range.startOffset());
+}
+}
+
TextInputClientObserver::TextInputClientObserver(RenderWidget* render_widget)
: render_widget_(render_widget) {}
@@ -133,8 +140,11 @@ void TextInputClientObserver::OnFirstRectForCharacterRange(gfx::Range range) {
// See crbug.com/304341
if (frame) {
blink::WebRect web_rect;
- frame->firstRectForCharacterRange(range.start(), range.length(),
- web_rect);
+ // When request range is invalid we will try to obtain it from current
+ // frame selection. The fallback value will be 0.
+ uint32_t start = range.IsValid() ? range.start()
+ : GetCurrentCursorPositionInFrame(frame);
+ frame->firstRectForCharacterRange(start, range.length(), web_rect);
rect = web_rect;
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698