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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2057803002: Tracking SelectionBounds for all RenderWidgets on the Browser Side (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed |selection_anchor_| and |selection_focus_| from RenderWidgetHostViewAura. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 1035 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
1036 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 1036 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
1037 clipboard_writer.WriteText(text.substr(pos, n)); 1037 clipboard_writer.WriteText(text.substr(pos, n));
1038 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 1038 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
1039 } 1039 }
1040 1040
1041 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 1041 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
1042 return delegated_frame_host_->GetRequestedRendererSize(); 1042 return delegated_frame_host_->GetRequestedRendererSize();
1043 } 1043 }
1044 1044
1045 void RenderWidgetHostViewAura::SelectionBoundsChanged(
1046 const ViewHostMsg_SelectionBounds_Params& params) {
1047 gfx::SelectionBound anchor_bound, focus_bound;
1048 anchor_bound.SetEdge(gfx::PointF(params.anchor_rect.origin()),
1049 gfx::PointF(params.anchor_rect.bottom_left()));
1050 focus_bound.SetEdge(gfx::PointF(params.focus_rect.origin()),
1051 gfx::PointF(params.focus_rect.bottom_left()));
1052
1053 if (params.anchor_rect == params.focus_rect) {
1054 anchor_bound.set_type(gfx::SelectionBound::CENTER);
1055 focus_bound.set_type(gfx::SelectionBound::CENTER);
1056 } else {
1057 // Whether text is LTR at the anchor handle.
1058 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
1059 // Whether text is LTR at the focus handle.
1060 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
1061
1062 if ((params.is_anchor_first && anchor_LTR) ||
1063 (!params.is_anchor_first && !anchor_LTR)) {
1064 anchor_bound.set_type(gfx::SelectionBound::LEFT);
1065 } else {
1066 anchor_bound.set_type(gfx::SelectionBound::RIGHT);
1067 }
1068 if ((params.is_anchor_first && focus_LTR) ||
1069 (!params.is_anchor_first && !focus_LTR)) {
1070 focus_bound.set_type(gfx::SelectionBound::RIGHT);
1071 } else {
1072 focus_bound.set_type(gfx::SelectionBound::LEFT);
1073 }
1074 }
1075
1076 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1077 return;
1078
1079 selection_anchor_ = anchor_bound;
1080 selection_focus_ = focus_bound;
1081 if (GetInputMethod())
1082 GetInputMethod()->OnCaretBoundsChanged(this);
1083 }
1084
1085 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1045 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1086 const gfx::Rect& src_subrect, 1046 const gfx::Rect& src_subrect,
1087 const gfx::Size& dst_size, 1047 const gfx::Size& dst_size,
1088 const ReadbackRequestCallback& callback, 1048 const ReadbackRequestCallback& callback,
1089 const SkColorType preferred_color_type) { 1049 const SkColorType preferred_color_type) {
1090 delegated_frame_host_->CopyFromCompositingSurface( 1050 delegated_frame_host_->CopyFromCompositingSurface(
1091 src_subrect, dst_size, callback, preferred_color_type); 1051 src_subrect, dst_size, callback, preferred_color_type);
1092 } 1052 }
1093 1053
1094 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1054 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 return gfx::Rect(origin.x(), 1518 return gfx::Rect(origin.x(),
1559 origin.y(), 1519 origin.y(),
1560 end.x() - origin.x(), 1520 end.x() - origin.x(),
1561 end.y() - origin.y()); 1521 end.y() - origin.y());
1562 } 1522 }
1563 1523
1564 return rect; 1524 return rect;
1565 } 1525 }
1566 1526
1567 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1527 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1568 return ConvertRectToScreen( 1528 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1569 gfx::RectBetweenSelectionBounds(selection_anchor_, selection_focus_)); 1529 return gfx::Rect();
1530 return ConvertRectToScreen(text_input_manager_->GetSelectionBoundsRect());
1570 } 1531 }
1571 1532
1572 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1533 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1573 uint32_t index, 1534 uint32_t index,
1574 gfx::Rect* rect) const { 1535 gfx::Rect* rect) const {
1575 DCHECK(rect); 1536 DCHECK(rect);
1576 if (index >= composition_character_bounds_.size()) 1537 if (index >= composition_character_bounds_.size())
1577 return false; 1538 return false;
1578 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1539 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1579 return true; 1540 return true;
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 RenderWidgetHostViewBase* view) { 2990 RenderWidgetHostViewBase* view) {
3030 // |view| is not necessarily the one corresponding to 2991 // |view| is not necessarily the one corresponding to
3031 // TextInputManager::GetActiveWidget() as RenderWidgetHostViewAura can call 2992 // TextInputManager::GetActiveWidget() as RenderWidgetHostViewAura can call
3032 // this method to finish any ongoing composition in response to a mouse down 2993 // this method to finish any ongoing composition in response to a mouse down
3033 // event. 2994 // event.
3034 if (GetInputMethod()) 2995 if (GetInputMethod())
3035 GetInputMethod()->CancelComposition(this); 2996 GetInputMethod()->CancelComposition(this);
3036 has_composition_text_ = false; 2997 has_composition_text_ = false;
3037 } 2998 }
3038 2999
3000 void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
3001 TextInputManager* text_input_manager,
3002 RenderWidgetHostViewBase* updated_view) {
3003 if (GetInputMethod())
3004 GetInputMethod()->OnCaretBoundsChanged(this);
3005 }
3006
3039 //////////////////////////////////////////////////////////////////////////////// 3007 ////////////////////////////////////////////////////////////////////////////////
3040 // RenderWidgetHostViewBase, public: 3008 // RenderWidgetHostViewBase, public:
3041 3009
3042 // static 3010 // static
3043 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3011 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3044 GetScreenInfoForWindow(results, NULL); 3012 GetScreenInfoForWindow(results, NULL);
3045 } 3013 }
3046 3014
3047 } // namespace content 3015 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698