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

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: Fixed Compile Errors 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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 1041 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
1042 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 1042 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
1043 clipboard_writer.WriteText(text.substr(pos, n)); 1043 clipboard_writer.WriteText(text.substr(pos, n));
1044 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 1044 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
1045 } 1045 }
1046 1046
1047 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 1047 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
1048 return delegated_frame_host_->GetRequestedRendererSize(); 1048 return delegated_frame_host_->GetRequestedRendererSize();
1049 } 1049 }
1050 1050
1051 void RenderWidgetHostViewAura::SelectionBoundsChanged(
1052 const ViewHostMsg_SelectionBounds_Params& params) {
1053 gfx::SelectionBound anchor_bound, focus_bound;
1054 anchor_bound.SetEdge(gfx::PointF(params.anchor_rect.origin()),
1055 gfx::PointF(params.anchor_rect.bottom_left()));
1056 focus_bound.SetEdge(gfx::PointF(params.focus_rect.origin()),
1057 gfx::PointF(params.focus_rect.bottom_left()));
1058
1059 if (params.anchor_rect == params.focus_rect) {
1060 anchor_bound.set_type(gfx::SelectionBound::CENTER);
1061 focus_bound.set_type(gfx::SelectionBound::CENTER);
1062 } else {
1063 // Whether text is LTR at the anchor handle.
1064 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
1065 // Whether text is LTR at the focus handle.
1066 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
1067
1068 if ((params.is_anchor_first && anchor_LTR) ||
1069 (!params.is_anchor_first && !anchor_LTR)) {
1070 anchor_bound.set_type(gfx::SelectionBound::LEFT);
1071 } else {
1072 anchor_bound.set_type(gfx::SelectionBound::RIGHT);
1073 }
1074 if ((params.is_anchor_first && focus_LTR) ||
1075 (!params.is_anchor_first && !focus_LTR)) {
1076 focus_bound.set_type(gfx::SelectionBound::RIGHT);
1077 } else {
1078 focus_bound.set_type(gfx::SelectionBound::LEFT);
1079 }
1080 }
1081
1082 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1083 return;
1084
1085 selection_anchor_ = anchor_bound;
1086 selection_focus_ = focus_bound;
1087 if (GetInputMethod())
1088 GetInputMethod()->OnCaretBoundsChanged(this);
1089 }
1090
1091 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1051 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1092 const gfx::Rect& src_subrect, 1052 const gfx::Rect& src_subrect,
1093 const gfx::Size& dst_size, 1053 const gfx::Size& dst_size,
1094 const ReadbackRequestCallback& callback, 1054 const ReadbackRequestCallback& callback,
1095 const SkColorType preferred_color_type) { 1055 const SkColorType preferred_color_type) {
1096 delegated_frame_host_->CopyFromCompositingSurface( 1056 delegated_frame_host_->CopyFromCompositingSurface(
1097 src_subrect, dst_size, callback, preferred_color_type); 1057 src_subrect, dst_size, callback, preferred_color_type);
1098 } 1058 }
1099 1059
1100 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1060 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 return gfx::Rect(origin.x(), 1524 return gfx::Rect(origin.x(),
1565 origin.y(), 1525 origin.y(),
1566 end.x() - origin.x(), 1526 end.x() - origin.x(),
1567 end.y() - origin.y()); 1527 end.y() - origin.y());
1568 } 1528 }
1569 1529
1570 return rect; 1530 return rect;
1571 } 1531 }
1572 1532
1573 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1533 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1574 return ConvertRectToScreen( 1534 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1575 gfx::RectBetweenSelectionBounds(selection_anchor_, selection_focus_)); 1535 return gfx::Rect();
1536 return ConvertRectToScreen(text_input_manager_->GetSelectionBoundsRect());
1576 } 1537 }
1577 1538
1578 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1539 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1579 uint32_t index, 1540 uint32_t index,
1580 gfx::Rect* rect) const { 1541 gfx::Rect* rect) const {
1581 DCHECK(rect); 1542 DCHECK(rect);
1582 if (index >= composition_character_bounds_.size()) 1543 if (index >= composition_character_bounds_.size())
1583 return false; 1544 return false;
1584 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1545 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1585 return true; 1546 return true;
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3023 if (did_update_state) 2984 if (did_update_state)
3024 GetInputMethod()->OnTextInputTypeChanged(this); 2985 GetInputMethod()->OnTextInputTypeChanged(this);
3025 2986
3026 const TextInputState* state = text_input_manager_->GetTextInputState(); 2987 const TextInputState* state = text_input_manager_->GetTextInputState();
3027 2988
3028 if (state && state->show_ime_if_needed && 2989 if (state && state->show_ime_if_needed &&
3029 state->type != ui::TEXT_INPUT_TYPE_NONE) 2990 state->type != ui::TEXT_INPUT_TYPE_NONE)
3030 GetInputMethod()->ShowImeIfNeeded(); 2991 GetInputMethod()->ShowImeIfNeeded();
3031 } 2992 }
3032 2993
2994 void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
2995 TextInputManager* text_input_manager,
2996 RenderWidgetHostViewBase* updated_view) {
2997 if (GetInputMethod())
2998 GetInputMethod()->OnCaretBoundsChanged(this);
2999 }
3000
3033 //////////////////////////////////////////////////////////////////////////////// 3001 ////////////////////////////////////////////////////////////////////////////////
3034 // RenderWidgetHostViewBase, public: 3002 // RenderWidgetHostViewBase, public:
3035 3003
3036 // static 3004 // static
3037 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3005 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3038 GetScreenInfoForWindow(results, NULL); 3006 GetScreenInfoForWindow(results, NULL);
3039 } 3007 }
3040 3008
3041 } // namespace content 3009 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698