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

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: Addressing creis@'s comments 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 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 1034 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
1035 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 1035 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
1036 clipboard_writer.WriteText(text.substr(pos, n)); 1036 clipboard_writer.WriteText(text.substr(pos, n));
1037 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 1037 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
1038 } 1038 }
1039 1039
1040 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 1040 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
1041 return delegated_frame_host_->GetRequestedRendererSize(); 1041 return delegated_frame_host_->GetRequestedRendererSize();
1042 } 1042 }
1043 1043
1044 void RenderWidgetHostViewAura::SelectionBoundsChanged(
1045 const ViewHostMsg_SelectionBounds_Params& params) {
1046 gfx::SelectionBound anchor_bound, focus_bound;
1047 anchor_bound.SetEdge(gfx::PointF(params.anchor_rect.origin()),
1048 gfx::PointF(params.anchor_rect.bottom_left()));
1049 focus_bound.SetEdge(gfx::PointF(params.focus_rect.origin()),
1050 gfx::PointF(params.focus_rect.bottom_left()));
1051
1052 if (params.anchor_rect == params.focus_rect) {
1053 anchor_bound.set_type(gfx::SelectionBound::CENTER);
1054 focus_bound.set_type(gfx::SelectionBound::CENTER);
1055 } else {
1056 // Whether text is LTR at the anchor handle.
1057 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
1058 // Whether text is LTR at the focus handle.
1059 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
1060
1061 if ((params.is_anchor_first && anchor_LTR) ||
1062 (!params.is_anchor_first && !anchor_LTR)) {
1063 anchor_bound.set_type(gfx::SelectionBound::LEFT);
1064 } else {
1065 anchor_bound.set_type(gfx::SelectionBound::RIGHT);
1066 }
1067 if ((params.is_anchor_first && focus_LTR) ||
1068 (!params.is_anchor_first && !focus_LTR)) {
1069 focus_bound.set_type(gfx::SelectionBound::RIGHT);
1070 } else {
1071 focus_bound.set_type(gfx::SelectionBound::LEFT);
1072 }
1073 }
1074
1075 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1076 return;
1077
1078 selection_anchor_ = anchor_bound;
1079 selection_focus_ = focus_bound;
1080 if (GetInputMethod())
1081 GetInputMethod()->OnCaretBoundsChanged(this);
1082 }
1083
1084 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1044 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1085 const gfx::Rect& src_subrect, 1045 const gfx::Rect& src_subrect,
1086 const gfx::Size& dst_size, 1046 const gfx::Size& dst_size,
1087 const ReadbackRequestCallback& callback, 1047 const ReadbackRequestCallback& callback,
1088 const SkColorType preferred_color_type) { 1048 const SkColorType preferred_color_type) {
1089 delegated_frame_host_->CopyFromCompositingSurface( 1049 delegated_frame_host_->CopyFromCompositingSurface(
1090 src_subrect, dst_size, callback, preferred_color_type); 1050 src_subrect, dst_size, callback, preferred_color_type);
1091 } 1051 }
1092 1052
1093 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1053 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 return gfx::Rect(origin.x(), 1517 return gfx::Rect(origin.x(),
1558 origin.y(), 1518 origin.y(),
1559 end.x() - origin.x(), 1519 end.x() - origin.x(),
1560 end.y() - origin.y()); 1520 end.y() - origin.y());
1561 } 1521 }
1562 1522
1563 return rect; 1523 return rect;
1564 } 1524 }
1565 1525
1566 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1526 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1567 return ConvertRectToScreen( 1527 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1568 gfx::RectBetweenSelectionBounds(selection_anchor_, selection_focus_)); 1528 return gfx::Rect();
1529 return ConvertRectToScreen(text_input_manager_->GetSelectionBoundsRect());
1569 } 1530 }
1570 1531
1571 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1532 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1572 uint32_t index, 1533 uint32_t index,
1573 gfx::Rect* rect) const { 1534 gfx::Rect* rect) const {
1574 DCHECK(rect); 1535 DCHECK(rect);
1575 if (index >= composition_character_bounds_.size()) 1536 if (index >= composition_character_bounds_.size())
1576 return false; 1537 return false;
1577 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1538 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1578 return true; 1539 return true;
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3028 RenderWidgetHostViewBase* view) { 2989 RenderWidgetHostViewBase* view) {
3029 // |view| is not necessarily the one corresponding to 2990 // |view| is not necessarily the one corresponding to
3030 // TextInputManager::GetActiveWidget() as RenderWidgetHostViewAura can call 2991 // TextInputManager::GetActiveWidget() as RenderWidgetHostViewAura can call
3031 // this method to finish any ongoing composition in response to a mouse down 2992 // this method to finish any ongoing composition in response to a mouse down
3032 // event. 2993 // event.
3033 if (GetInputMethod()) 2994 if (GetInputMethod())
3034 GetInputMethod()->CancelComposition(this); 2995 GetInputMethod()->CancelComposition(this);
3035 has_composition_text_ = false; 2996 has_composition_text_ = false;
3036 } 2997 }
3037 2998
2999 void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
3000 TextInputManager* text_input_manager,
3001 RenderWidgetHostViewBase* updated_view) {
3002 if (GetInputMethod())
3003 GetInputMethod()->OnCaretBoundsChanged(this);
3004 }
3005
3038 //////////////////////////////////////////////////////////////////////////////// 3006 ////////////////////////////////////////////////////////////////////////////////
3039 // RenderWidgetHostViewBase, public: 3007 // RenderWidgetHostViewBase, public:
3040 3008
3041 // static 3009 // static
3042 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3010 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3043 GetScreenInfoForWindow(results, NULL); 3011 GetScreenInfoForWindow(results, NULL);
3044 } 3012 }
3045 3013
3046 } // namespace content 3014 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698