OLD | NEW |
---|---|
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 Loading... | |
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 anchor_bound.type = | |
946 params.is_anchor_first ^ anchor_LTR ? ui::SelectionBound::RIGHT | |
947 : ui::SelectionBound::LEFT; | |
948 focus_bound.type = | |
949 params.is_anchor_first ^ focus_LTR ? ui::SelectionBound::LEFT | |
950 : ui::SelectionBound::RIGHT; | |
951 } | |
952 | |
953 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) | |
934 return; | 954 return; |
935 | 955 |
936 selection_anchor_rect_ = params.anchor_rect; | 956 selection_anchor_ = anchor_bound; |
937 selection_focus_rect_ = params.focus_rect; | 957 selection_focus_ = focus_bound; |
938 | |
939 if (GetInputMethod()) | 958 if (GetInputMethod()) |
940 GetInputMethod()->OnCaretBoundsChanged(this); | 959 GetInputMethod()->OnCaretBoundsChanged(this); |
941 | 960 |
942 if (touch_editing_client_) { | 961 if (touch_editing_client_) |
943 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, | 962 touch_editing_client_->OnSelectionOrCursorChanged( |
944 selection_focus_rect_); | 963 anchor_bound, focus_bound); |
mohsen
2014/11/10 22:25:59
nit: Curly braces for multi-line block.
mfomitchev
2014/11/10 23:07:29
Acknowledged.
mfomitchev
2014/11/12 18:32:49
Done.
| |
945 } | |
946 } | 964 } |
947 | 965 |
948 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 966 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
949 const gfx::Rect& src_subrect, | 967 const gfx::Rect& src_subrect, |
950 const gfx::Size& dst_size, | 968 const gfx::Size& dst_size, |
951 CopyFromCompositingSurfaceCallback& callback, | 969 CopyFromCompositingSurfaceCallback& callback, |
952 const SkColorType color_type) { | 970 const SkColorType color_type) { |
953 delegated_frame_host_->CopyFromCompositingSurface( | 971 delegated_frame_host_->CopyFromCompositingSurface( |
954 src_subrect, dst_size, callback, color_type); | 972 src_subrect, dst_size, callback, color_type); |
955 } | 973 } |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 return gfx::Rect(origin.x(), | 1504 return gfx::Rect(origin.x(), |
1487 origin.y(), | 1505 origin.y(), |
1488 end.x() - origin.x(), | 1506 end.x() - origin.x(), |
1489 end.y() - origin.y()); | 1507 end.y() - origin.y()); |
1490 } | 1508 } |
1491 | 1509 |
1492 return rect; | 1510 return rect; |
1493 } | 1511 } |
1494 | 1512 |
1495 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { | 1513 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { |
1496 const gfx::Rect rect = | 1514 gfx::Rect rect = |
1497 gfx::UnionRects(selection_anchor_rect_, selection_focus_rect_); | 1515 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); |
1498 return ConvertRectToScreen(rect); | 1516 return ConvertRectToScreen(rect); |
1499 } | 1517 } |
1500 | 1518 |
1501 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( | 1519 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( |
1502 uint32 index, | 1520 uint32 index, |
1503 gfx::Rect* rect) const { | 1521 gfx::Rect* rect) const { |
1504 DCHECK(rect); | 1522 DCHECK(rect); |
1505 if (index >= composition_character_bounds_.size()) | 1523 if (index >= composition_character_bounds_.size()) |
1506 return false; | 1524 return false; |
1507 *rect = ConvertRectToScreen(composition_character_bounds_[index]); | 1525 *rect = ConvertRectToScreen(composition_character_bounds_[index]); |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2381 host_->InvalidateScreenInfo(); | 2399 host_->InvalidateScreenInfo(); |
2382 | 2400 |
2383 SnapToPhysicalPixelBoundary(); | 2401 SnapToPhysicalPixelBoundary(); |
2384 // Don't recursively call SetBounds if this bounds update is the result of | 2402 // Don't recursively call SetBounds if this bounds update is the result of |
2385 // a Window::SetBoundsInternal call. | 2403 // a Window::SetBoundsInternal call. |
2386 if (!in_bounds_changed_) | 2404 if (!in_bounds_changed_) |
2387 window_->SetBounds(rect); | 2405 window_->SetBounds(rect); |
2388 host_->WasResized(); | 2406 host_->WasResized(); |
2389 delegated_frame_host_->WasResized(); | 2407 delegated_frame_host_->WasResized(); |
2390 if (touch_editing_client_) { | 2408 if (touch_editing_client_) { |
2391 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_rect_, | 2409 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, |
2392 selection_focus_rect_); | 2410 selection_focus_); |
2393 } | 2411 } |
2394 #if defined(OS_WIN) | 2412 #if defined(OS_WIN) |
2395 if (mouse_locked_) | 2413 if (mouse_locked_) |
2396 UpdateMouseLockRegion(); | 2414 UpdateMouseLockRegion(); |
2397 #endif | 2415 #endif |
2398 } | 2416 } |
2399 | 2417 |
2400 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( | 2418 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( |
2401 const gfx::Rect& rect, | 2419 const gfx::Rect& rect, |
2402 const gfx::Rect& clip) { | 2420 const gfx::Rect& clip) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2540 | 2558 |
2541 //////////////////////////////////////////////////////////////////////////////// | 2559 //////////////////////////////////////////////////////////////////////////////// |
2542 // RenderWidgetHostViewBase, public: | 2560 // RenderWidgetHostViewBase, public: |
2543 | 2561 |
2544 // static | 2562 // static |
2545 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2563 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2546 GetScreenInfoForWindow(results, NULL); | 2564 GetScreenInfoForWindow(results, NULL); |
2547 } | 2565 } |
2548 | 2566 |
2549 } // namespace content | 2567 } // namespace content |
OLD | NEW |