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

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 1513053002: WIP - Gutterless resize on Windows Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 5 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/mac/foundation_util.h" 10 #import "base/mac/foundation_util.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #import "base/mac/sdk_forward_declarations.h" 12 #import "base/mac/sdk_forward_declarations.h"
13 #include "base/thread_task_runner_handle.h" 13 #include "base/thread_task_runner_handle.h"
14 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h"
15 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" 14 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h"
16 #include "ui/base/hit_test.h" 15 #include "ui/base/hit_test.h"
17 #include "ui/base/ime/input_method.h" 16 #include "ui/base/ime/input_method.h"
18 #include "ui/base/ime/input_method_factory.h" 17 #include "ui/base/ime/input_method_factory.h"
18 #include "ui/base/window_resize_helper.h"
19 #include "ui/gfx/display.h" 19 #include "ui/gfx/display.h"
20 #include "ui/gfx/geometry/dip_util.h" 20 #include "ui/gfx/geometry/dip_util.h"
21 #import "ui/gfx/mac/coordinate_conversion.h" 21 #import "ui/gfx/mac/coordinate_conversion.h"
22 #import "ui/gfx/mac/nswindow_frame_controls.h" 22 #import "ui/gfx/mac/nswindow_frame_controls.h"
23 #include "ui/gfx/screen.h" 23 #include "ui/gfx/screen.h"
24 #import "ui/views/cocoa/bridged_content_view.h" 24 #import "ui/views/cocoa/bridged_content_view.h"
25 #import "ui/views/cocoa/cocoa_mouse_capture.h" 25 #import "ui/views/cocoa/cocoa_mouse_capture.h"
26 #include "ui/views/cocoa/tooltip_manager_mac.h" 26 #include "ui/views/cocoa/tooltip_manager_mac.h"
27 #import "ui/views/cocoa/views_nswindow_delegate.h" 27 #import "ui/views/cocoa/views_nswindow_delegate.h"
28 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h" 28 #import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 // Returns a task runner for creating a ui::Compositor. This allows compositor 217 // Returns a task runner for creating a ui::Compositor. This allows compositor
218 // tasks to be funneled through ui::WindowResizeHelper's task runner to allow 218 // tasks to be funneled through ui::WindowResizeHelper's task runner to allow
219 // resize operations to coordinate with frames provided by the GPU process. 219 // resize operations to coordinate with frames provided by the GPU process.
220 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() { 220 scoped_refptr<base::SingleThreadTaskRunner> GetCompositorTaskRunner() {
221 // If the WindowResizeHelper's pumpable task runner is set, it means the GPU 221 // If the WindowResizeHelper's pumpable task runner is set, it means the GPU
222 // process is directing messages there, and the compositor can synchronize 222 // process is directing messages there, and the compositor can synchronize
223 // with it. Otherwise, just use the UI thread. 223 // with it. Otherwise, just use the UI thread.
224 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 224 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
225 ui::WindowResizeHelperMac::Get()->task_runner(); 225 ui::WindowResizeHelper::Get()->task_runner();
226 return task_runner ? task_runner : base::ThreadTaskRunnerHandle::Get(); 226 return task_runner ? task_runner : base::ThreadTaskRunnerHandle::Get();
227 } 227 }
228 228
229 } // namespace 229 } // namespace
230 230
231 namespace views { 231 namespace views {
232 232
233 // static 233 // static
234 gfx::Size BridgedNativeWidget::GetWindowSizeForClientSize( 234 gfx::Size BridgedNativeWidget::GetWindowSizeForClientSize(
235 NSWindow* window, 235 NSWindow* window,
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1116
1117 void BridgedNativeWidget::MaybeWaitForFrame(const gfx::Size& size_in_dip) { 1117 void BridgedNativeWidget::MaybeWaitForFrame(const gfx::Size& size_in_dip) {
1118 if (!layer()->IsDrawn() || compositor_widget_->HasFrameOfSize(size_in_dip)) 1118 if (!layer()->IsDrawn() || compositor_widget_->HasFrameOfSize(size_in_dip))
1119 return; 1119 return;
1120 1120
1121 const int kPaintMsgTimeoutMS = 50; 1121 const int kPaintMsgTimeoutMS = 50;
1122 const base::TimeTicks start_time = base::TimeTicks::Now(); 1122 const base::TimeTicks start_time = base::TimeTicks::Now();
1123 const base::TimeTicks timeout_time = 1123 const base::TimeTicks timeout_time =
1124 start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS); 1124 start_time + base::TimeDelta::FromMilliseconds(kPaintMsgTimeoutMS);
1125 1125
1126 ui::WindowResizeHelperMac* resize_helper = ui::WindowResizeHelperMac::Get(); 1126 ui::WindowResizeHelper* resize_helper = ui::WindowResizeHelper::Get();
1127 for (base::TimeTicks now = start_time; now < timeout_time; 1127 for (base::TimeTicks now = start_time; now < timeout_time;
1128 now = base::TimeTicks::Now()) { 1128 now = base::TimeTicks::Now()) {
1129 if (!resize_helper->WaitForSingleTaskToRun(timeout_time - now)) 1129 if (!resize_helper->WaitForSingleTaskToRun(timeout_time - now))
1130 return; // Timeout. 1130 return; // Timeout.
1131 1131
1132 // Since the UI thread is blocked, the size shouldn't change. 1132 // Since the UI thread is blocked, the size shouldn't change.
1133 DCHECK(size_in_dip == GetClientAreaSize()); 1133 DCHECK(size_in_dip == GetClientAreaSize());
1134 if (compositor_widget_->HasFrameOfSize(size_in_dip)) 1134 if (compositor_widget_->HasFrameOfSize(size_in_dip))
1135 return; // Frame arrived. 1135 return; // Frame arrived.
1136 } 1136 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 [bridged_view_ setMouseDownCanMoveWindow:draggable]; 1170 [bridged_view_ setMouseDownCanMoveWindow:draggable];
1171 // AppKit will not update its cache of mouseDownCanMoveWindow unless something 1171 // AppKit will not update its cache of mouseDownCanMoveWindow unless something
1172 // changes. Previously we tried adding an NSView and removing it, but for some 1172 // changes. Previously we tried adding an NSView and removing it, but for some
1173 // reason it required reposting the mouse-down event, and didn't always work. 1173 // reason it required reposting the mouse-down event, and didn't always work.
1174 // Calling the below seems to be an effective solution. 1174 // Calling the below seems to be an effective solution.
1175 [window_ setMovableByWindowBackground:NO]; 1175 [window_ setMovableByWindowBackground:NO];
1176 [window_ setMovableByWindowBackground:YES]; 1176 [window_ setMovableByWindowBackground:YES];
1177 } 1177 }
1178 1178
1179 } // namespace views 1179 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698