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

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

Issue 700563002: Implementing directional text selection handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_assets_text
Patch Set: Removing the SelectionBound test from Android, since touch_editing_controller not included in Andro… Created 6 years, 1 month 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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 clipboard_writer.WriteText(text.substr(pos, n)); 922 clipboard_writer.WriteText(text.substr(pos, n));
923 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 923 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
924 } 924 }
925 925
926 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 926 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
927 return delegated_frame_host_->GetRequestedRendererSize(); 927 return delegated_frame_host_->GetRequestedRendererSize();
928 } 928 }
929 929
930 void RenderWidgetHostViewAura::SelectionBoundsChanged( 930 void RenderWidgetHostViewAura::SelectionBoundsChanged(
931 const ViewHostMsg_SelectionBounds_Params& params) { 931 const ViewHostMsg_SelectionBounds_Params& params) {
932 if (selection_anchor_rect_ == params.anchor_rect && 932 ui::SelectionBound anchor_bound, focus_bound;
933 selection_focus_rect_ == params.focus_rect) 933 anchor_bound.edge_top = params.anchor_rect.origin();
934 anchor_bound.edge_bottom = params.anchor_rect.bottom_left();
935 focus_bound.edge_top = params.focus_rect.origin();
936 focus_bound.edge_bottom = params.focus_rect.bottom_left();
937
938 if (params.anchor_rect == params.focus_rect) {
939 anchor_bound.type = focus_bound.type = ui::SelectionBound::CENTER;
940 } else {
941 // Whether text is LTR at the anchor handle.
942 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
943 // Whether text is LTR at the focus handle.
944 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
945
946 if ((params.is_anchor_first && anchor_LTR) ||
947 (!params.is_anchor_first && !anchor_LTR)) {
948 anchor_bound.type = ui::SelectionBound::LEFT;
949 } else {
950 anchor_bound.type = ui::SelectionBound::RIGHT;
951 }
952 if ((params.is_anchor_first && focus_LTR) ||
953 (!params.is_anchor_first && !focus_LTR)) {
954 focus_bound.type = ui::SelectionBound::RIGHT;
955 } else {
956 focus_bound.type = ui::SelectionBound::LEFT;
957 }
958 }
959
960 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
934 return; 961 return;
935 962
936 selection_anchor_rect_ = params.anchor_rect; 963 selection_anchor_ = anchor_bound;
937 selection_focus_rect_ = params.focus_rect; 964 selection_focus_ = focus_bound;
938
939 if (GetInputMethod()) 965 if (GetInputMethod())
940 GetInputMethod()->OnCaretBoundsChanged(this); 966 GetInputMethod()->OnCaretBoundsChanged(this);
941 967
942 if (touch_editing_client_) { 968 if (touch_editing_client_) {
943 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 969 touch_editing_client_->OnSelectionOrCursorChanged(
944 selection_focus_rect_); 970 anchor_bound, focus_bound);
945 } 971 }
946 } 972 }
947 973
948 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 974 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
949 const gfx::Rect& src_subrect, 975 const gfx::Rect& src_subrect,
950 const gfx::Size& dst_size, 976 const gfx::Size& dst_size,
951 CopyFromCompositingSurfaceCallback& callback, 977 CopyFromCompositingSurfaceCallback& callback,
952 const SkColorType color_type) { 978 const SkColorType color_type) {
953 delegated_frame_host_->CopyFromCompositingSurface( 979 delegated_frame_host_->CopyFromCompositingSurface(
954 src_subrect, dst_size, callback, color_type); 980 src_subrect, dst_size, callback, color_type);
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 return gfx::Rect(origin.x(), 1512 return gfx::Rect(origin.x(),
1487 origin.y(), 1513 origin.y(),
1488 end.x() - origin.x(), 1514 end.x() - origin.x(),
1489 end.y() - origin.y()); 1515 end.y() - origin.y());
1490 } 1516 }
1491 1517
1492 return rect; 1518 return rect;
1493 } 1519 }
1494 1520
1495 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1521 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1496 const gfx::Rect rect = 1522 gfx::Rect rect =
1497 gfx::UnionRects(selection_anchor_rect_, selection_focus_rect_); 1523 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_);
1498 return ConvertRectToScreen(rect); 1524 return ConvertRectToScreen(rect);
1499 } 1525 }
1500 1526
1501 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1527 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1502 uint32 index, 1528 uint32 index,
1503 gfx::Rect* rect) const { 1529 gfx::Rect* rect) const {
1504 DCHECK(rect); 1530 DCHECK(rect);
1505 if (index >= composition_character_bounds_.size()) 1531 if (index >= composition_character_bounds_.size())
1506 return false; 1532 return false;
1507 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1533 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 host_->InvalidateScreenInfo(); 2407 host_->InvalidateScreenInfo();
2382 2408
2383 SnapToPhysicalPixelBoundary(); 2409 SnapToPhysicalPixelBoundary();
2384 // Don't recursively call SetBounds if this bounds update is the result of 2410 // Don't recursively call SetBounds if this bounds update is the result of
2385 // a Window::SetBoundsInternal call. 2411 // a Window::SetBoundsInternal call.
2386 if (!in_bounds_changed_) 2412 if (!in_bounds_changed_)
2387 window_->SetBounds(rect); 2413 window_->SetBounds(rect);
2388 host_->WasResized(); 2414 host_->WasResized();
2389 delegated_frame_host_->WasResized(); 2415 delegated_frame_host_->WasResized();
2390 if (touch_editing_client_) { 2416 if (touch_editing_client_) {
2391 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 2417 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2392 selection_focus_rect_); 2418 selection_focus_);
2393 } 2419 }
2394 #if defined(OS_WIN) 2420 #if defined(OS_WIN)
2395 if (mouse_locked_) 2421 if (mouse_locked_)
2396 UpdateMouseLockRegion(); 2422 UpdateMouseLockRegion();
2397 #endif 2423 #endif
2398 } 2424 }
2399 2425
2400 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( 2426 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip(
2401 const gfx::Rect& rect, 2427 const gfx::Rect& rect,
2402 const gfx::Rect& clip) { 2428 const gfx::Rect& clip) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 2566
2541 //////////////////////////////////////////////////////////////////////////////// 2567 ////////////////////////////////////////////////////////////////////////////////
2542 // RenderWidgetHostViewBase, public: 2568 // RenderWidgetHostViewBase, public:
2543 2569
2544 // static 2570 // static
2545 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2571 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2546 GetScreenInfoForWindow(results, NULL); 2572 GetScreenInfoForWindow(results, NULL);
2547 } 2573 }
2548 2574
2549 } // namespace content 2575 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/web_contents/touch_editable_impl_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698