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

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: 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 gfx::Rect anchor_rect(params.anchor_rect);
934 gfx::Rect focus_rect(params.focus_rect);
mohsen 2014/11/07 16:52:26 I think the above copies are not needed and you ca
mfomitchev 2014/11/10 04:04:11 Done.
935
936 anchor_bound.edge_top = anchor_rect.origin();
937 anchor_bound.edge_bottom = anchor_rect.bottom_left();
938 focus_bound.edge_top = focus_rect.origin();
939 focus_bound.edge_bottom = focus_rect.bottom_left();
940
941 if (params.anchor_rect == params.focus_rect) {
942 if (params.anchor_rect.x() || params.anchor_rect.y())
mohsen 2014/11/07 16:52:26 What does this line exactly check? And, what happe
mfomitchev 2014/11/10 04:04:11 Got rid of this. I took this from the Clank code,
943 anchor_bound.type = focus_bound.type = ui::SelectionBound::CENTER;
944 } else {
945 // Whether text is LTR at the anchor handle.
946 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
947 // Whether text is LTR at the focus handle.
948 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
949 anchor_bound.type =
950 params.is_anchor_first ^ anchor_LTR ? ui::SelectionBound::RIGHT
951 : ui::SelectionBound::LEFT;
952 focus_bound.type =
953 params.is_anchor_first ^ focus_LTR ? ui::SelectionBound::LEFT
954 : ui::SelectionBound::RIGHT;
955 }
956
957 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
934 return; 958 return;
935 959
936 selection_anchor_rect_ = params.anchor_rect; 960 selection_anchor_ = anchor_bound;
937 selection_focus_rect_ = params.focus_rect; 961 selection_focus_ = focus_bound;
938
939 if (GetInputMethod()) 962 if (GetInputMethod())
940 GetInputMethod()->OnCaretBoundsChanged(this); 963 GetInputMethod()->OnCaretBoundsChanged(this);
941 964
942 if (touch_editing_client_) { 965 if (touch_editing_client_)
943 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 966 touch_editing_client_->OnSelectionOrCursorChanged(
944 selection_focus_rect_); 967 anchor_bound, focus_bound);
945 }
946 } 968 }
947 969
948 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 970 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
949 const gfx::Rect& src_subrect, 971 const gfx::Rect& src_subrect,
950 const gfx::Size& dst_size, 972 const gfx::Size& dst_size,
951 CopyFromCompositingSurfaceCallback& callback, 973 CopyFromCompositingSurfaceCallback& callback,
952 const SkColorType color_type) { 974 const SkColorType color_type) {
953 delegated_frame_host_->CopyFromCompositingSurface( 975 delegated_frame_host_->CopyFromCompositingSurface(
954 src_subrect, dst_size, callback, color_type); 976 src_subrect, dst_size, callback, color_type);
955 } 977 }
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 return gfx::Rect(origin.x(), 1508 return gfx::Rect(origin.x(),
1487 origin.y(), 1509 origin.y(),
1488 end.x() - origin.x(), 1510 end.x() - origin.x(),
1489 end.y() - origin.y()); 1511 end.y() - origin.y());
1490 } 1512 }
1491 1513
1492 return rect; 1514 return rect;
1493 } 1515 }
1494 1516
1495 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1517 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1496 const gfx::Rect rect = 1518 gfx::Rect rect =
1497 gfx::UnionRects(selection_anchor_rect_, selection_focus_rect_); 1519 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_);
1498 return ConvertRectToScreen(rect); 1520 return ConvertRectToScreen(rect);
1499 } 1521 }
1500 1522
1501 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1523 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1502 uint32 index, 1524 uint32 index,
1503 gfx::Rect* rect) const { 1525 gfx::Rect* rect) const {
1504 DCHECK(rect); 1526 DCHECK(rect);
1505 if (index >= composition_character_bounds_.size()) 1527 if (index >= composition_character_bounds_.size())
1506 return false; 1528 return false;
1507 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1529 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after
2381 host_->InvalidateScreenInfo(); 2403 host_->InvalidateScreenInfo();
2382 2404
2383 SnapToPhysicalPixelBoundary(); 2405 SnapToPhysicalPixelBoundary();
2384 // Don't recursively call SetBounds if this bounds update is the result of 2406 // Don't recursively call SetBounds if this bounds update is the result of
2385 // a Window::SetBoundsInternal call. 2407 // a Window::SetBoundsInternal call.
2386 if (!in_bounds_changed_) 2408 if (!in_bounds_changed_)
2387 window_->SetBounds(rect); 2409 window_->SetBounds(rect);
2388 host_->WasResized(); 2410 host_->WasResized();
2389 delegated_frame_host_->WasResized(); 2411 delegated_frame_host_->WasResized();
2390 if (touch_editing_client_) { 2412 if (touch_editing_client_) {
2391 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, 2413 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2392 selection_focus_rect_); 2414 selection_focus_);
2393 } 2415 }
2394 #if defined(OS_WIN) 2416 #if defined(OS_WIN)
2395 if (mouse_locked_) 2417 if (mouse_locked_)
2396 UpdateMouseLockRegion(); 2418 UpdateMouseLockRegion();
2397 #endif 2419 #endif
2398 } 2420 }
2399 2421
2400 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( 2422 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip(
2401 const gfx::Rect& rect, 2423 const gfx::Rect& rect,
2402 const gfx::Rect& clip) { 2424 const gfx::Rect& clip) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 2562
2541 //////////////////////////////////////////////////////////////////////////////// 2563 ////////////////////////////////////////////////////////////////////////////////
2542 // RenderWidgetHostViewBase, public: 2564 // RenderWidgetHostViewBase, public:
2543 2565
2544 // static 2566 // static
2545 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2567 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2546 GetScreenInfoForWindow(results, NULL); 2568 GetScreenInfoForWindow(results, NULL);
2547 } 2569 }
2548 2570
2549 } // namespace content 2571 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698