| 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 <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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "ui/aura/client/screen_position_client.h" | 64 #include "ui/aura/client/screen_position_client.h" |
| 65 #include "ui/aura/client/window_tree_client.h" | 65 #include "ui/aura/client/window_tree_client.h" |
| 66 #include "ui/aura/env.h" | 66 #include "ui/aura/env.h" |
| 67 #include "ui/aura/window.h" | 67 #include "ui/aura/window.h" |
| 68 #include "ui/aura/window_event_dispatcher.h" | 68 #include "ui/aura/window_event_dispatcher.h" |
| 69 #include "ui/aura/window_observer.h" | 69 #include "ui/aura/window_observer.h" |
| 70 #include "ui/aura/window_tree_host.h" | 70 #include "ui/aura/window_tree_host.h" |
| 71 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 71 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 72 #include "ui/base/hit_test.h" | 72 #include "ui/base/hit_test.h" |
| 73 #include "ui/base/ime/input_method.h" | 73 #include "ui/base/ime/input_method.h" |
| 74 #include "ui/base/ui_base_switches.h" |
| 74 #include "ui/base/ui_base_types.h" | 75 #include "ui/base/ui_base_types.h" |
| 75 #include "ui/compositor/compositor_vsync_manager.h" | 76 #include "ui/compositor/compositor_vsync_manager.h" |
| 76 #include "ui/compositor/dip_util.h" | 77 #include "ui/compositor/dip_util.h" |
| 77 #include "ui/display/display.h" | 78 #include "ui/display/display.h" |
| 78 #include "ui/display/screen.h" | 79 #include "ui/display/screen.h" |
| 79 #include "ui/events/blink/blink_event_util.h" | 80 #include "ui/events/blink/blink_event_util.h" |
| 80 #include "ui/events/blink/web_input_event.h" | 81 #include "ui/events/blink/web_input_event.h" |
| 81 #include "ui/events/event.h" | 82 #include "ui/events/event.h" |
| 82 #include "ui/events/event_utils.h" | 83 #include "ui/events/event_utils.h" |
| 83 #include "ui/events/gesture_detection/gesture_configuration.h" | 84 #include "ui/events/gesture_detection/gesture_configuration.h" |
| (...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 } | 1614 } |
| 1614 | 1615 |
| 1615 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( | 1616 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( |
| 1616 size_t before, size_t after) { | 1617 size_t before, size_t after) { |
| 1617 RenderFrameHostImpl* rfh = GetFocusedFrame(); | 1618 RenderFrameHostImpl* rfh = GetFocusedFrame(); |
| 1618 if (rfh) | 1619 if (rfh) |
| 1619 rfh->ExtendSelectionAndDelete(before, after); | 1620 rfh->ExtendSelectionAndDelete(before, after); |
| 1620 } | 1621 } |
| 1621 | 1622 |
| 1622 void RenderWidgetHostViewAura::EnsureCaretInRect(const gfx::Rect& rect) { | 1623 void RenderWidgetHostViewAura::EnsureCaretInRect(const gfx::Rect& rect) { |
| 1624 // Perform overscroll. |
| 1623 gfx::Rect intersected_rect( | 1625 gfx::Rect intersected_rect( |
| 1624 gfx::IntersectRects(rect, window_->GetBoundsInScreen())); | 1626 gfx::IntersectRects(rect, window_->GetBoundsInScreen())); |
| 1627 if (!intersected_rect.IsEmpty()) |
| 1628 host_->ScrollFocusedEditableNodeIntoRect( |
| 1629 ConvertRectFromScreen(intersected_rect)); |
| 1625 | 1630 |
| 1626 if (intersected_rect.IsEmpty()) | 1631 #if defined(OS_CHROMEOS) |
| 1632 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1633 ::switches::kUseNewVirtualKeyboardBehavior)) |
| 1627 return; | 1634 return; |
| 1628 | 1635 |
| 1629 host_->ScrollFocusedEditableNodeIntoRect( | 1636 // Only windows in primary display should be moved by virtual keyboard. |
| 1630 ConvertRectFromScreen(intersected_rect)); | 1637 display::Screen* screen = display::Screen::GetScreen(); |
| 1638 if (screen->GetPrimaryDisplay().id() != |
| 1639 screen->GetDisplayNearestWindow(window_).id()) |
| 1640 return; |
| 1641 |
| 1642 aura::Window* top_level_window = window_->GetToplevelWindow(); |
| 1643 if (rect != screen->GetPrimaryDisplay().bounds()) { |
| 1644 // Calculate vertical window shift. |
| 1645 gfx::Rect window_bounds = top_level_window->GetBoundsInRootWindow(); |
| 1646 int vertical_displacement = |
| 1647 std::max(0, window_bounds.bottom() - rect.bottom()); |
| 1648 int shift = std::min(vertical_displacement, window_bounds.y()); |
| 1649 |
| 1650 // Set restore bounds and move window. |
| 1651 if (shift > 0) { |
| 1652 gfx::Point origin(window_bounds.x(), window_bounds.y() - shift); |
| 1653 top_level_window->SetProperty( |
| 1654 aura::client::kVirtualKeyboardRestoreBoundsKey, |
| 1655 new gfx::Rect(window_bounds)); |
| 1656 top_level_window->SetBounds(gfx::Rect(origin, window_bounds.size())); |
| 1657 } |
| 1658 } else { |
| 1659 // Restore if necessary |
| 1660 OnClientFocusLost(); |
| 1661 } |
| 1662 #endif |
| 1663 } |
| 1664 |
| 1665 void RenderWidgetHostViewAura::OnClientFocusLost() { |
| 1666 #if defined(OS_CHROMEOS) |
| 1667 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1668 ::switches::kUseNewVirtualKeyboardBehavior)) |
| 1669 return; |
| 1670 |
| 1671 // Only windows in primary display should be moved by virtual keyboard. |
| 1672 display::Screen* screen = display::Screen::GetScreen(); |
| 1673 if (screen->GetPrimaryDisplay().id() != |
| 1674 screen->GetDisplayNearestWindow(window_).id()) |
| 1675 return; |
| 1676 |
| 1677 // Get restore bounds of window. |
| 1678 aura::Window* top_level_window = window_->GetToplevelWindow(); |
| 1679 gfx::Rect* vk_restore_bounds = top_level_window->GetProperty( |
| 1680 aura::client::kVirtualKeyboardRestoreBoundsKey); |
| 1681 |
| 1682 if (vk_restore_bounds) { |
| 1683 // Restore window. |
| 1684 top_level_window->SetBounds(*vk_restore_bounds); |
| 1685 top_level_window->ClearProperty( |
| 1686 aura::client::kVirtualKeyboardRestoreBoundsKey); |
| 1687 } |
| 1688 #endif |
| 1631 } | 1689 } |
| 1632 | 1690 |
| 1633 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( | 1691 bool RenderWidgetHostViewAura::IsTextEditCommandEnabled( |
| 1634 ui::TextEditCommand command) const { | 1692 ui::TextEditCommand command) const { |
| 1635 return false; | 1693 return false; |
| 1636 } | 1694 } |
| 1637 | 1695 |
| 1638 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( | 1696 void RenderWidgetHostViewAura::SetTextEditCommandForNextKeyEvent( |
| 1639 ui::TextEditCommand command) {} | 1697 ui::TextEditCommand command) {} |
| 1640 | 1698 |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3055 ->GetTextSelection(focused_view) | 3113 ->GetTextSelection(focused_view) |
| 3056 ->GetSelectedText(&selected_text)) { | 3114 ->GetSelectedText(&selected_text)) { |
| 3057 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 3115 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
| 3058 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 3116 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
| 3059 clipboard_writer.WriteText(selected_text); | 3117 clipboard_writer.WriteText(selected_text); |
| 3060 } | 3118 } |
| 3061 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 3119 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) |
| 3062 } | 3120 } |
| 3063 | 3121 |
| 3064 } // namespace content | 3122 } // namespace content |
| OLD | NEW |