summaryrefslogtreecommitdiff
path: root/chromium/ui/views/widget/native_widget_win.cc
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2013-12-11 21:33:03 +0100
committerAndras Becsi <andras.becsi@digia.com>2013-12-13 12:34:07 +0100
commitf2a33ff9cbc6d19943f1c7fbddd1f23d23975577 (patch)
tree0586a32aa390ade8557dfd6b4897f43a07449578 /chromium/ui/views/widget/native_widget_win.cc
parent5362912cdb5eea702b68ebe23702468d17c3017a (diff)
downloadqtwebengine-chromium-f2a33ff9cbc6d19943f1c7fbddd1f23d23975577.tar.gz
Update Chromium to branch 1650 (31.0.1650.63)
Change-Id: I57d8c832eaec1eb2364e0a8e7352a6dd354db99f Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'chromium/ui/views/widget/native_widget_win.cc')
-rw-r--r--chromium/ui/views/widget/native_widget_win.cc88
1 files changed, 54 insertions, 34 deletions
diff --git a/chromium/ui/views/widget/native_widget_win.cc b/chromium/ui/views/widget/native_widget_win.cc
index d6ebdd6d664..53aed93a29a 100644
--- a/chromium/ui/views/widget/native_widget_win.cc
+++ b/chromium/ui/views/widget/native_widget_win.cc
@@ -18,22 +18,22 @@
#include "ui/base/dragdrop/drag_source_win.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_win.h"
-#include "ui/base/events/event.h"
#include "ui/base/ime/input_method_factory.h"
-#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/theme_provider.h"
#include "ui/base/view_prop.h"
-#include "ui/base/win/dpi.h"
-#include "ui/base/win/hwnd_util.h"
#include "ui/base/win/mouse_wheel_util.h"
#include "ui/base/win/shell.h"
+#include "ui/events/event.h"
+#include "ui/events/keycodes/keyboard_code_conversion_win.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/canvas_skia_paint.h"
#include "ui/gfx/path.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/screen.h"
#include "ui/gfx/size_conversions.h"
+#include "ui/gfx/win/dpi.h"
+#include "ui/gfx/win/hwnd_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/controls/native_control_win.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -61,9 +61,10 @@ namespace views {
namespace {
-// Enumeration callback for NativeWidget::GetAllChildWidgets(). Called for each
-// child HWND beneath the original HWND.
-BOOL CALLBACK EnumerateChildWindowsForNativeWidgets(HWND hwnd, LPARAM l_param) {
+// Enumeration callback for NativeWidget::GetAllChildWidgets() and
+// NativeWidget::GetAllOwnedWidgets. Adds any HWNDs that correspond to
+// Widgets to a set.
+BOOL CALLBACK EnumerateNativeWidgets(HWND hwnd, LPARAM l_param) {
Widget* widget = Widget::GetWidgetForNativeView(hwnd);
if (widget) {
Widget::Widgets* widgets = reinterpret_cast<Widget::Widgets*>(l_param);
@@ -116,7 +117,7 @@ void NativeWidgetWin::Show(int show_state) {
// NativeWidgetWin, NativeWidget implementation:
void NativeWidgetWin::InitNativeWidget(const Widget::InitParams& params) {
- gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(params.bounds);
+ gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(params.bounds);
Widget::InitParams params_in_pixel(params);
params_in_pixel.bounds = pixel_bounds;
SetInitParams(params_in_pixel);
@@ -220,7 +221,7 @@ internal::InputMethodDelegate* NativeWidgetWin::GetInputMethodDelegate() {
}
void NativeWidgetWin::CenterWindow(const gfx::Size& size) {
- gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size);
+ gfx::Size size_in_pixels = gfx::win::DIPToScreenSize(size);
message_handler_->CenterWindow(size_in_pixels);
}
@@ -228,7 +229,7 @@ void NativeWidgetWin::GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const {
message_handler_->GetWindowPlacement(bounds, show_state);
- *bounds = ui::win::ScreenToDIPRect(*bounds);
+ *bounds = gfx::win::ScreenToDIPRect(*bounds);
}
void NativeWidgetWin::SetWindowTitle(const string16& title) {
@@ -246,21 +247,21 @@ void NativeWidgetWin::InitModalType(ui::ModalType modal_type) {
gfx::Rect NativeWidgetWin::GetWindowBoundsInScreen() const {
gfx::Rect bounds_in_pixels = message_handler_->GetWindowBoundsInScreen();
- return ui::win::ScreenToDIPRect(bounds_in_pixels);
+ return gfx::win::ScreenToDIPRect(bounds_in_pixels);
}
gfx::Rect NativeWidgetWin::GetClientAreaBoundsInScreen() const {
gfx::Rect bounds_in_pixels = message_handler_->GetClientAreaBoundsInScreen();
- return ui::win::ScreenToDIPRect(bounds_in_pixels);
+ return gfx::win::ScreenToDIPRect(bounds_in_pixels);
}
gfx::Rect NativeWidgetWin::GetRestoredBounds() const {
gfx::Rect bounds_in_pixels = message_handler_->GetRestoredBounds();
- return ui::win::ScreenToDIPRect(bounds_in_pixels);
+ return gfx::win::ScreenToDIPRect(bounds_in_pixels);
}
void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) {
- float scale = ui::win::GetDeviceScaleFactor();
+ float scale = gfx::win::GetDeviceScaleFactor();
gfx::Rect bounds_in_pixels(
gfx::ToCeiledPoint(gfx::ScalePoint(bounds.origin(), scale)),
gfx::ToFlooredSize(gfx::ScaleSize(bounds.size(), scale)));
@@ -305,7 +306,7 @@ void NativeWidgetWin::Hide() {
void NativeWidgetWin::ShowMaximizedWithBounds(
const gfx::Rect& restored_bounds) {
- gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(restored_bounds);
+ gfx::Rect pixel_bounds = gfx::win::DIPToScreenRect(restored_bounds);
message_handler_->ShowMaximizedWithBounds(pixel_bounds);
}
@@ -412,7 +413,7 @@ void NativeWidgetWin::RunShellDrag(View* view,
}
void NativeWidgetWin::SchedulePaintInRect(const gfx::Rect& rect) {
- gfx::Rect pixel_rect = ui::win::DIPToScreenRect(rect);
+ gfx::Rect pixel_rect = gfx::win::DIPToScreenRect(rect);
message_handler_->SchedulePaintInRect(pixel_rect);
}
@@ -429,7 +430,7 @@ void NativeWidgetWin::ClearNativeFocus() {
}
gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const {
- return ui::win::ScreenToDIPRect(
+ return gfx::win::ScreenToDIPRect(
gfx::Screen::GetNativeScreen()->GetDisplayNearestWindow(
GetNativeView()).work_area());
}
@@ -456,6 +457,9 @@ ui::NativeTheme* NativeWidgetWin::GetNativeTheme() const {
return ui::NativeTheme::instance();
}
+void NativeWidgetWin::OnRootViewLayout() const {
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, NativeWidget implementation:
@@ -566,7 +570,7 @@ bool NativeWidgetWin::WillProcessWorkAreaChange() const {
}
int NativeWidgetWin::GetNonClientComponent(const gfx::Point& point) const {
- gfx::Point point_in_dip = ui::win::ScreenToDIPPoint(point);
+ gfx::Point point_in_dip = gfx::win::ScreenToDIPPoint(point);
return delegate_->GetNonClientComponent(point_in_dip);
}
@@ -581,13 +585,13 @@ bool NativeWidgetWin::GetClientAreaInsets(gfx::Insets* insets) const {
void NativeWidgetWin::GetMinMaxSize(gfx::Size* min_size,
gfx::Size* max_size) const {
- *min_size = ui::win::ScreenToDIPSize(delegate_->GetMinimumSize());
- *max_size = ui::win::ScreenToDIPSize(delegate_->GetMaximumSize());
+ *min_size = gfx::win::ScreenToDIPSize(delegate_->GetMinimumSize());
+ *max_size = gfx::win::ScreenToDIPSize(delegate_->GetMaximumSize());
}
gfx::Size NativeWidgetWin::GetRootViewSize() const {
gfx::Size pixel_size = GetWidget()->GetRootView()->size();
- return ui::win::ScreenToDIPSize(pixel_size);
+ return gfx::win::ScreenToDIPSize(pixel_size);
}
void NativeWidgetWin::ResetWindowControls() {
@@ -717,12 +721,16 @@ void NativeWidgetWin::HandleWorkAreaChanged() {
GetWidget()->widget_delegate()->OnWorkAreaChanged();
}
+void NativeWidgetWin::HandleVisibilityChanging(bool visible) {
+ delegate_->OnNativeWidgetVisibilityChanging(visible);
+}
+
void NativeWidgetWin::HandleVisibilityChanged(bool visible) {
delegate_->OnNativeWidgetVisibilityChanged(visible);
}
void NativeWidgetWin::HandleClientSizeChanged(const gfx::Size& new_size) {
- gfx::Size size_in_dip = ui::win::ScreenToDIPSize(new_size);
+ gfx::Size size_in_dip = gfx::win::ScreenToDIPSize(new_size);
delegate_->OnNativeWidgetSizeChanged(size_in_dip);
}
@@ -747,8 +755,8 @@ void NativeWidgetWin::HandleNativeBlur(HWND focused_window) {
bool NativeWidgetWin::HandleMouseEvent(const ui::MouseEvent& event) {
static gfx::Transform scale_transform(
- 1/ui::win::GetDeviceScaleFactor(), 0.0,
- 0.0, 1/ui::win::GetDeviceScaleFactor(),
+ 1/gfx::win::GetDeviceScaleFactor(), 0.0,
+ 0.0, 1/gfx::win::GetDeviceScaleFactor(),
0.0, 0.0);
if (event.IsMouseWheelEvent()) {
ui::MouseWheelEvent dpi_event(
@@ -780,9 +788,8 @@ bool NativeWidgetWin::HandleUntranslatedKeyEvent(const ui::KeyEvent& event) {
return !!input_method;
}
-bool NativeWidgetWin::HandleTouchEvent(const ui::TouchEvent& event) {
+void NativeWidgetWin::HandleTouchEvent(const ui::TouchEvent& event) {
NOTREACHED() << "Touch events are not supported";
- return false;
}
bool NativeWidgetWin::HandleIMEMessage(UINT message,
@@ -812,7 +819,7 @@ void NativeWidgetWin::HandleInputLanguageChange(DWORD character_set,
}
bool NativeWidgetWin::HandlePaintAccelerated(const gfx::Rect& invalid_rect) {
- gfx::Rect dpi_rect = ui::win::ScreenToDIPRect(invalid_rect);
+ gfx::Rect dpi_rect = gfx::win::ScreenToDIPRect(invalid_rect);
return delegate_->OnNativeWidgetPaintAccelerated(dpi_rect);
}
@@ -902,11 +909,11 @@ bool Widget::ConvertRect(const Widget* source,
if (source_hwnd == target_hwnd)
return true;
- RECT win_rect = ui::win::DIPToScreenRect(*rect).ToRECT();
+ RECT win_rect = gfx::win::DIPToScreenRect(*rect).ToRECT();
if (::MapWindowPoints(source_hwnd, target_hwnd,
reinterpret_cast<LPPOINT>(&win_rect),
sizeof(RECT)/sizeof(POINT))) {
- *rect = ui::win::ScreenToDIPRect(gfx::Rect(win_rect));
+ *rect = gfx::win::ScreenToDIPRect(gfx::Rect(win_rect));
return true;
}
return false;
@@ -984,11 +991,26 @@ void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
Widget* widget = Widget::GetWidgetForNativeView(native_view);
if (widget)
children->insert(widget);
- EnumChildWindows(native_view, EnumerateChildWindowsForNativeWidgets,
+ EnumChildWindows(native_view, EnumerateNativeWidgets,
reinterpret_cast<LPARAM>(children));
}
// static
+void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view,
+ Widget::Widgets* owned) {
+ if (!native_view)
+ return;
+
+ Widget::Widgets all;
+ EnumWindows(EnumerateNativeWidgets, reinterpret_cast<LPARAM>(&all));
+ for (Widget::Widgets::const_iterator iter = all.begin();
+ iter != all.end(); ++iter) {
+ if (native_view == GetWindow((*iter)->GetNativeView(), GW_OWNER))
+ owned->insert(*iter);
+ }
+}
+
+// static
void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
gfx::NativeView new_parent) {
if (!native_view)
@@ -1005,9 +1027,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
// from their previous parent.
for (Widget::Widgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
- // TODO(beng): Rename this notification to NotifyNativeViewChanging()
- // and eliminate the bool parameter.
- (*it)->NotifyNativeViewHierarchyChanged(false, previous_parent);
+ (*it)->NotifyNativeViewHierarchyWillChange();
}
::SetParent(native_view, new_parent);
@@ -1015,7 +1035,7 @@ void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
// And now, notify them that they have a brand new parent.
for (Widget::Widgets::iterator it = widgets.begin();
it != widgets.end(); ++it) {
- (*it)->NotifyNativeViewHierarchyChanged(true, new_parent);
+ (*it)->NotifyNativeViewHierarchyChanged();
}
}