OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "app/l10n_util_win.h" | 9 #include "app/l10n_util_win.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/histogram.h" | 12 #include "base/histogram.h" |
| 13 #include "base/i18n/rtl.h" |
13 #include "base/process_util.h" | 14 #include "base/process_util.h" |
14 #include "base/thread.h" | 15 #include "base/thread.h" |
15 #include "base/win_util.h" | 16 #include "base/win_util.h" |
16 #include "chrome/browser/browser_accessibility_manager.h" | 17 #include "chrome/browser/browser_accessibility_manager.h" |
17 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/browser_trial.h" | 19 #include "chrome/browser/browser_trial.h" |
19 #include "chrome/browser/chrome_thread.h" | 20 #include "chrome/browser/chrome_thread.h" |
20 #include "chrome/browser/plugin_process_host.h" | 21 #include "chrome/browser/plugin_process_host.h" |
21 #include "chrome/browser/renderer_host/backing_store.h" | 22 #include "chrome/browser/renderer_host/backing_store.h" |
22 #include "chrome/browser/renderer_host/backing_store_win.h" | 23 #include "chrome/browser/renderer_host/backing_store_win.h" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 static HINSTANCE module_handle = | 552 static HINSTANCE module_handle = |
552 GetModuleHandle(chrome::kBrowserResourcesDll); | 553 GetModuleHandle(chrome::kBrowserResourcesDll); |
553 | 554 |
554 // If the mouse is over our HWND, then update the cursor state immediately. | 555 // If the mouse is over our HWND, then update the cursor state immediately. |
555 CPoint pt; | 556 CPoint pt; |
556 GetCursorPos(&pt); | 557 GetCursorPos(&pt); |
557 if (WindowFromPoint(pt) == m_hWnd) { | 558 if (WindowFromPoint(pt) == m_hWnd) { |
558 BOOL result = ::ScreenToClient(m_hWnd, &pt); | 559 BOOL result = ::ScreenToClient(m_hWnd, &pt); |
559 DCHECK(result); | 560 DCHECK(result); |
560 if (render_widget_host_->GetRootWindowResizerRect().Contains(pt.x, pt.y)) { | 561 if (render_widget_host_->GetRootWindowResizerRect().Contains(pt.x, pt.y)) { |
561 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 562 if (base::i18n::IsRTL()) |
562 SetCursor(kCursorResizeLeft); | 563 SetCursor(kCursorResizeLeft); |
563 else | 564 else |
564 SetCursor(kCursorResizeRight); | 565 SetCursor(kCursorResizeRight); |
565 } else { | 566 } else { |
566 // We cannot pass in NULL as the module handle as this would only work for | 567 // We cannot pass in NULL as the module handle as this would only work for |
567 // standard win32 cursors. We can also receive cursor types which are | 568 // standard win32 cursors. We can also receive cursor types which are |
568 // defined as webkit resources. We need to specify the module handle of | 569 // defined as webkit resources. We need to specify the module handle of |
569 // chrome.dll while loading these cursors. | 570 // chrome.dll while loading these cursors. |
570 HCURSOR display_cursor = current_cursor_.GetCursor(module_handle); | 571 HCURSOR display_cursor = current_cursor_.GetCursor(module_handle); |
571 | 572 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 HDC dc) { | 645 HDC dc) { |
645 gfx::Rect resize_corner_rect = | 646 gfx::Rect resize_corner_rect = |
646 render_widget_host_->GetRootWindowResizerRect(); | 647 render_widget_host_->GetRootWindowResizerRect(); |
647 if (!paint_rect.Intersect(resize_corner_rect).IsEmpty()) { | 648 if (!paint_rect.Intersect(resize_corner_rect).IsEmpty()) { |
648 SkBitmap* bitmap = ResourceBundle::GetSharedInstance(). | 649 SkBitmap* bitmap = ResourceBundle::GetSharedInstance(). |
649 GetBitmapNamed(IDR_TEXTAREA_RESIZER); | 650 GetBitmapNamed(IDR_TEXTAREA_RESIZER); |
650 gfx::Canvas canvas(bitmap->width(), bitmap->height(), false); | 651 gfx::Canvas canvas(bitmap->width(), bitmap->height(), false); |
651 canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); | 652 canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0); |
652 int x = resize_corner_rect.x() + resize_corner_rect.width() - | 653 int x = resize_corner_rect.x() + resize_corner_rect.width() - |
653 bitmap->width(); | 654 bitmap->width(); |
654 bool rtl_dir = (l10n_util::GetTextDirection() == | 655 bool rtl_dir = base::i18n::IsRTL(); |
655 l10n_util::RIGHT_TO_LEFT); | |
656 if (rtl_dir) { | 656 if (rtl_dir) { |
657 canvas.TranslateInt(bitmap->width(), 0); | 657 canvas.TranslateInt(bitmap->width(), 0); |
658 canvas.ScaleInt(-1, 1); | 658 canvas.ScaleInt(-1, 1); |
659 canvas.save(); | 659 canvas.save(); |
660 x = 0; | 660 x = 0; |
661 } | 661 } |
662 canvas.DrawBitmapInt(*bitmap, 0, 0); | 662 canvas.DrawBitmapInt(*bitmap, 0, 0); |
663 canvas.getTopPlatformDevice().drawToHDC(dc, x, | 663 canvas.getTopPlatformDevice().drawToHDC(dc, x, |
664 resize_corner_rect.y() + resize_corner_rect.height() - | 664 resize_corner_rect.y() + resize_corner_rect.height() - |
665 bitmap->height(), NULL); | 665 bitmap->height(), NULL); |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1228 // RenderViewHostHWND as there is no way to retrieve it from the HWND. | 1228 // RenderViewHostHWND as there is no way to retrieve it from the HWND. |
1229 if (!close_on_deactivate_) { // Don't forward if the container is a popup. | 1229 if (!close_on_deactivate_) { // Don't forward if the container is a popup. |
1230 if (message == WM_LBUTTONDOWN) { | 1230 if (message == WM_LBUTTONDOWN) { |
1231 // If we get clicked on, where the resize corner is drawn, we delegate the | 1231 // If we get clicked on, where the resize corner is drawn, we delegate the |
1232 // message to the root window, with the proper HTBOTTOMXXX wparam so that | 1232 // message to the root window, with the proper HTBOTTOMXXX wparam so that |
1233 // Windows can take care of the resizing for us. | 1233 // Windows can take care of the resizing for us. |
1234 if (render_widget_host_ && | 1234 if (render_widget_host_ && |
1235 render_widget_host_->GetRootWindowResizerRect(). | 1235 render_widget_host_->GetRootWindowResizerRect(). |
1236 Contains(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam))) { | 1236 Contains(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam))) { |
1237 WPARAM wparam = HTBOTTOMRIGHT; | 1237 WPARAM wparam = HTBOTTOMRIGHT; |
1238 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 1238 if (base::i18n::IsRTL()) |
1239 wparam = HTBOTTOMLEFT; | 1239 wparam = HTBOTTOMLEFT; |
1240 HWND root_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); | 1240 HWND root_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); |
1241 if (SendMessage(root_hwnd, WM_NCLBUTTONDOWN, wparam, lparam) == 0) | 1241 if (SendMessage(root_hwnd, WM_NCLBUTTONDOWN, wparam, lparam) == 0) |
1242 return 0; | 1242 return 0; |
1243 } | 1243 } |
1244 } | 1244 } |
1245 switch (message) { | 1245 switch (message) { |
1246 case WM_LBUTTONDOWN: | 1246 case WM_LBUTTONDOWN: |
1247 case WM_MBUTTONDOWN: | 1247 case WM_MBUTTONDOWN: |
1248 case WM_MOUSEMOVE: | 1248 case WM_MOUSEMOVE: |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1599 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1600 gfx::NativeView native_view) { | 1600 gfx::NativeView native_view) { |
1601 if (::IsWindow(native_view)) { | 1601 if (::IsWindow(native_view)) { |
1602 HANDLE raw_render_host_view = ::GetProp(native_view, | 1602 HANDLE raw_render_host_view = ::GetProp(native_view, |
1603 kRenderWidgetHostViewKey); | 1603 kRenderWidgetHostViewKey); |
1604 if (raw_render_host_view) | 1604 if (raw_render_host_view) |
1605 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); | 1605 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); |
1606 } | 1606 } |
1607 return NULL; | 1607 return NULL; |
1608 } | 1608 } |
OLD | NEW |