| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 OverscrollMode current_mode_; | 147 OverscrollMode current_mode_; |
| 148 OverscrollMode completed_mode_; | 148 OverscrollMode completed_mode_; |
| 149 float delta_x_; | 149 float delta_x_; |
| 150 float delta_y_; | 150 float delta_y_; |
| 151 | 151 |
| 152 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); | 152 DISALLOW_COPY_AND_ASSIGN(TestOverscrollDelegate); |
| 153 }; | 153 }; |
| 154 | 154 |
| 155 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 155 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 156 public: | 156 public: |
| 157 MockRenderWidgetHostDelegate() : rwh_(nullptr) {} | 157 MockRenderWidgetHostDelegate() : rwh_(nullptr), is_fullscreen_(false) {} |
| 158 ~MockRenderWidgetHostDelegate() override {} | 158 ~MockRenderWidgetHostDelegate() override {} |
| 159 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } | 159 const NativeWebKeyboardEvent* last_event() const { return last_event_.get(); } |
| 160 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } | 160 void set_widget_host(RenderWidgetHostImpl* rwh) { rwh_ = rwh; } |
| 161 void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; } |
| 161 | 162 |
| 162 protected: | 163 protected: |
| 163 // RenderWidgetHostDelegate: | 164 // RenderWidgetHostDelegate: |
| 164 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 165 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 165 bool* is_keyboard_shortcut) override { | 166 bool* is_keyboard_shortcut) override { |
| 166 last_event_.reset(new NativeWebKeyboardEvent(event)); | 167 last_event_.reset(new NativeWebKeyboardEvent(event)); |
| 167 return true; | 168 return true; |
| 168 } | 169 } |
| 169 void Cut() override {} | 170 void Cut() override {} |
| 170 void Copy() override {} | 171 void Copy() override {} |
| 171 void Paste() override {} | 172 void Paste() override {} |
| 172 void SelectAll() override {} | 173 void SelectAll() override {} |
| 173 void SendScreenRects() override { | 174 void SendScreenRects() override { |
| 174 if (rwh_) | 175 if (rwh_) |
| 175 rwh_->SendScreenRects(); | 176 rwh_->SendScreenRects(); |
| 176 } | 177 } |
| 178 bool IsFullscreenForCurrentTab( |
| 179 RenderWidgetHostImpl* render_widget_host) const override { |
| 180 return is_fullscreen_; |
| 181 } |
| 177 | 182 |
| 178 private: | 183 private: |
| 179 std::unique_ptr<NativeWebKeyboardEvent> last_event_; | 184 std::unique_ptr<NativeWebKeyboardEvent> last_event_; |
| 180 RenderWidgetHostImpl* rwh_; | 185 RenderWidgetHostImpl* rwh_; |
| 186 bool is_fullscreen_; |
| 181 | 187 |
| 182 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); | 188 DISALLOW_COPY_AND_ASSIGN(MockRenderWidgetHostDelegate); |
| 183 }; | 189 }; |
| 184 | 190 |
| 185 // Simple observer that keeps track of changes to a window for tests. | 191 // Simple observer that keeps track of changes to a window for tests. |
| 186 class TestWindowObserver : public aura::WindowObserver { | 192 class TestWindowObserver : public aura::WindowObserver { |
| 187 public: | 193 public: |
| 188 explicit TestWindowObserver(aura::Window* window_to_observe) | 194 explicit TestWindowObserver(aura::Window* window_to_observe) |
| 189 : window_(window_to_observe) { | 195 : window_(window_to_observe) { |
| 190 window_->AddObserver(this); | 196 window_->AddObserver(this); |
| (...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 view_->OnSwapCompositorFrame(0, std::move(frame)); | 1720 view_->OnSwapCompositorFrame(0, std::move(frame)); |
| 1715 | 1721 |
| 1716 ui::Layer* parent_layer = view_->GetNativeView()->layer(); | 1722 ui::Layer* parent_layer = view_->GetNativeView()->layer(); |
| 1717 | 1723 |
| 1718 ASSERT_EQ(2u, parent_layer->children().size()); | 1724 ASSERT_EQ(2u, parent_layer->children().size()); |
| 1719 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds()); | 1725 EXPECT_EQ(gfx::Rect(40, 0, 60, 100), parent_layer->children()[0]->bounds()); |
| 1720 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color()); | 1726 EXPECT_EQ(SK_ColorRED, parent_layer->children()[0]->background_color()); |
| 1721 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds()); | 1727 EXPECT_EQ(gfx::Rect(0, 45, 40, 55), parent_layer->children()[1]->bounds()); |
| 1722 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color()); | 1728 EXPECT_EQ(SK_ColorRED, parent_layer->children()[1]->background_color()); |
| 1723 | 1729 |
| 1730 delegates_.back()->set_is_fullscreen(true); |
| 1724 view_->SetSize(medium_size); | 1731 view_->SetSize(medium_size); |
| 1725 | 1732 |
| 1726 // Right gutter is unnecessary. | 1733 // Right gutter is unnecessary. |
| 1727 ASSERT_EQ(1u, parent_layer->children().size()); | 1734 ASSERT_EQ(1u, parent_layer->children().size()); |
| 1728 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds()); | 1735 EXPECT_EQ(gfx::Rect(0, 45, 40, 50), parent_layer->children()[0]->bounds()); |
| 1729 | 1736 |
| 1737 // RWH is fullscreen, so gutters should be black. |
| 1738 EXPECT_EQ(SK_ColorBLACK, parent_layer->children()[0]->background_color()); |
| 1739 |
| 1730 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size)); | 1740 frame = MakeDelegatedFrame(1.f, medium_size, gfx::Rect(medium_size)); |
| 1731 view_->OnSwapCompositorFrame(0, std::move(frame)); | 1741 view_->OnSwapCompositorFrame(0, std::move(frame)); |
| 1732 EXPECT_EQ(0u, parent_layer->children().size()); | 1742 EXPECT_EQ(0u, parent_layer->children().size()); |
| 1733 | 1743 |
| 1734 view_->SetSize(large_size); | 1744 view_->SetSize(large_size); |
| 1735 ASSERT_EQ(2u, parent_layer->children().size()); | 1745 ASSERT_EQ(2u, parent_layer->children().size()); |
| 1736 | 1746 |
| 1737 // This should evict the frame and remove the gutter layers. | 1747 // This should evict the frame and remove the gutter layers. |
| 1738 view_->Hide(); | 1748 view_->Hide(); |
| 1739 view_->SetSize(small_size); | 1749 view_->SetSize(small_size); |
| (...skipping 2735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4475 view()->OnGestureEvent(&gesture_event); | 4485 view()->OnGestureEvent(&gesture_event); |
| 4476 | 4486 |
| 4477 EXPECT_TRUE(delegate->context_menu_request_received()); | 4487 EXPECT_TRUE(delegate->context_menu_request_received()); |
| 4478 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); | 4488 EXPECT_EQ(delegate->context_menu_source_type(), ui::MENU_SOURCE_TOUCH); |
| 4479 #endif | 4489 #endif |
| 4480 | 4490 |
| 4481 RenderViewHostFactory::set_is_real_render_view_host(false); | 4491 RenderViewHostFactory::set_is_real_render_view_host(false); |
| 4482 } | 4492 } |
| 4483 | 4493 |
| 4484 } // namespace content | 4494 } // namespace content |
| OLD | NEW |