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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2213503002: Tracking SelectionBounds for all RenderWidgets on the Browser Side (Mac) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a crash Created 4 years, 4 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: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index adc93fa634f9c05bb268f9854f7223026df5a19a..d2019443d49c2f352d4d6d0c40bfb33a7a3ba740 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -568,10 +568,21 @@ cc::SurfaceId RenderWidgetHostViewMac::SurfaceIdForTesting() const {
return browser_compositor_->GetDelegatedFrameHost()->SurfaceIdForTesting();
}
+RenderWidgetHostImpl* RenderWidgetHostViewMac::GetActiveWidget() {
+ if (GetTextInputManager() && GetTextInputManager()->GetActiveWidget())
+ return GetTextInputManager()->GetActiveWidget();
+ return render_widget_host_;
+}
+
ui::TextInputType RenderWidgetHostViewMac::GetTextInputType() {
- if (!GetTextInputManager() || !GetTextInputManager()->GetActiveWidget())
+ const TextInputState* text_input_state =
+ GetTextInputManager() ? GetTextInputManager()->GetTextInputState()
+ : nullptr;
+
+ if (!text_input_state)
return ui::TEXT_INPUT_TYPE_NONE;
- return GetTextInputManager()->GetTextInputState()->type;
+
+ return text_input_state->type;
}
///////////////////////////////////////////////////////////////////////////////
@@ -1062,13 +1073,6 @@ void RenderWidgetHostViewMac::SelectionChanged(const base::string16& text,
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
}
-void RenderWidgetHostViewMac::SelectionBoundsChanged(
- const ViewHostMsg_SelectionBounds_Params& params) {
- if (params.anchor_rect == params.focus_rect)
- caret_rect_ = params.anchor_rect;
- first_selection_rect_ = params.anchor_rect;
-}
-
void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) {
RenderWidgetHostViewBase::SetShowingContextMenu(showing);
@@ -1264,7 +1268,8 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(
if (selection_range_.is_empty() && requested_range == selection_range_) {
if (actual_range)
*actual_range = range;
- *rect = NSRectFromCGRect(caret_rect_.ToCGRect());
+ *rect = NSRectFromCGRect(
+ GetTextInputManager()->GetCaretRect(GetActiveWidget())->ToCGRect());
return true;
}
@@ -1273,7 +1278,9 @@ bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange(
return false;
if (actual_range)
*actual_range = selection_range_.ToNSRange();
- *rect = NSRectFromCGRect(first_selection_rect_.ToCGRect());
+ *rect = NSRectFromCGRect(GetTextInputManager()
+ ->GetFirstSelectionRect(GetActiveWidget())
+ ->ToCGRect());
return true;
}
@@ -2826,7 +2833,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
&rect,
actualRange)) {
rect = TextInputClientMac::GetInstance()->GetFirstRectForRange(
- renderWidgetHostView_->render_widget_host_, theRange);
+ renderWidgetHostView_->GetActiveWidget(), theRange);
// TODO(thakis): Pipe |actualRange| through TextInputClientMac machinery.
if (actualRange)
@@ -2844,7 +2851,7 @@ extern NSString *NSTextInputReplacementRangeAttributeName;
actualRange:(NSRangePointer)actualRange {
// During tab closure, events can arrive after RenderWidgetHostViewMac::
// Destroy() is called, which will have set |render_widget_host_| to null.
- if (!renderWidgetHostView_->render_widget_host_) {
+ if (!renderWidgetHostView_->GetActiveWidget()) {
[self cancelComposition];
return NSZeroRect;
}

Powered by Google App Engine
This is Rietveld 408576698