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

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: Created 4 years, 6 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 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 1039 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
1040 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 1040 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
1041 clipboard_writer.WriteText(text.substr(pos, n)); 1041 clipboard_writer.WriteText(text.substr(pos, n));
1042 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 1042 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
1043 } 1043 }
1044 1044
1045 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 1045 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
1046 return delegated_frame_host_->GetRequestedRendererSize(); 1046 return delegated_frame_host_->GetRequestedRendererSize();
1047 } 1047 }
1048 1048
1049 void RenderWidgetHostViewAura::SelectionBoundsChanged(
1050 const ViewHostMsg_SelectionBounds_Params& params) {
1051 gfx::SelectionBound anchor_bound, focus_bound;
1052 anchor_bound.SetEdge(gfx::PointF(params.anchor_rect.origin()),
1053 gfx::PointF(params.anchor_rect.bottom_left()));
1054 focus_bound.SetEdge(gfx::PointF(params.focus_rect.origin()),
1055 gfx::PointF(params.focus_rect.bottom_left()));
1056
1057 if (params.anchor_rect == params.focus_rect) {
1058 anchor_bound.set_type(gfx::SelectionBound::CENTER);
1059 focus_bound.set_type(gfx::SelectionBound::CENTER);
1060 } else {
1061 // Whether text is LTR at the anchor handle.
1062 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
1063 // Whether text is LTR at the focus handle.
1064 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
1065
1066 if ((params.is_anchor_first && anchor_LTR) ||
1067 (!params.is_anchor_first && !anchor_LTR)) {
1068 anchor_bound.set_type(gfx::SelectionBound::LEFT);
1069 } else {
1070 anchor_bound.set_type(gfx::SelectionBound::RIGHT);
1071 }
1072 if ((params.is_anchor_first && focus_LTR) ||
1073 (!params.is_anchor_first && !focus_LTR)) {
1074 focus_bound.set_type(gfx::SelectionBound::RIGHT);
1075 } else {
1076 focus_bound.set_type(gfx::SelectionBound::LEFT);
1077 }
1078 }
1079
1080 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1081 return;
1082
1083 selection_anchor_ = anchor_bound;
1084 selection_focus_ = focus_bound;
1085 if (GetInputMethod())
1086 GetInputMethod()->OnCaretBoundsChanged(this);
1087 }
1088
1089 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1049 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1090 const gfx::Rect& src_subrect, 1050 const gfx::Rect& src_subrect,
1091 const gfx::Size& dst_size, 1051 const gfx::Size& dst_size,
1092 const ReadbackRequestCallback& callback, 1052 const ReadbackRequestCallback& callback,
1093 const SkColorType preferred_color_type) { 1053 const SkColorType preferred_color_type) {
1094 delegated_frame_host_->CopyFromCompositingSurface( 1054 delegated_frame_host_->CopyFromCompositingSurface(
1095 src_subrect, dst_size, callback, preferred_color_type); 1055 src_subrect, dst_size, callback, preferred_color_type);
1096 } 1056 }
1097 1057
1098 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 1058 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 return gfx::Rect(origin.x(), 1525 return gfx::Rect(origin.x(),
1566 origin.y(), 1526 origin.y(),
1567 end.x() - origin.x(), 1527 end.x() - origin.x(),
1568 end.y() - origin.y()); 1528 end.y() - origin.y());
1569 } 1529 }
1570 1530
1571 return rect; 1531 return rect;
1572 } 1532 }
1573 1533
1574 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1534 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1575 return ConvertRectToScreen( 1535 if (!text_input_manager_ || !text_input_manager_->GetActiveView())
1576 gfx::RectBetweenSelectionBounds(selection_anchor_, selection_focus_)); 1536 return gfx::Rect();
1537 return ConvertRectToScreen(text_input_manager_->GetSelectionBoundsRect());
1577 } 1538 }
1578 1539
1579 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1540 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1580 uint32_t index, 1541 uint32_t index,
1581 gfx::Rect* rect) const { 1542 gfx::Rect* rect) const {
1582 DCHECK(rect); 1543 DCHECK(rect);
1583 if (index >= composition_character_bounds_.size()) 1544 if (index >= composition_character_bounds_.size())
1584 return false; 1545 return false;
1585 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1546 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1586 return true; 1547 return true;
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3007 if (did_update_state) 2968 if (did_update_state)
3008 GetInputMethod()->OnTextInputTypeChanged(this); 2969 GetInputMethod()->OnTextInputTypeChanged(this);
3009 2970
3010 const TextInputState* state = text_input_manager_->GetTextInputState(); 2971 const TextInputState* state = text_input_manager_->GetTextInputState();
3011 2972
3012 if (state && state->show_ime_if_needed && 2973 if (state && state->show_ime_if_needed &&
3013 state->type != ui::TEXT_INPUT_TYPE_NONE) 2974 state->type != ui::TEXT_INPUT_TYPE_NONE)
3014 GetInputMethod()->ShowImeIfNeeded(); 2975 GetInputMethod()->ShowImeIfNeeded();
3015 } 2976 }
3016 2977
2978 void RenderWidgetHostViewAura::OnSelectionBoundsChanged(
2979 TextInputManager* text_input_manager,
2980 RenderWidgetHostViewBase* updated_view) {
2981 if (GetInputMethod())
2982 GetInputMethod()->OnCaretBoundsChanged(this);
2983 }
2984
3017 //////////////////////////////////////////////////////////////////////////////// 2985 ////////////////////////////////////////////////////////////////////////////////
3018 // RenderWidgetHostViewBase, public: 2986 // RenderWidgetHostViewBase, public:
3019 2987
3020 // static 2988 // static
3021 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2989 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3022 GetScreenInfoForWindow(results, NULL); 2990 GetScreenInfoForWindow(results, NULL);
3023 } 2991 }
3024 2992
3025 } // namespace content 2993 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698