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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 9265018: Change grow box computation back to a method on BrowserWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cros build Created 8 years, 11 months 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 | Annotate | Revision Log
OLDNEW
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_win.h" 5 #include "content/browser/renderer_host/render_widget_host_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <peninputpanel_i.c> 8 #include <peninputpanel_i.c>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 GetWindowRect(&window_rect); 675 GetWindowRect(&window_rect);
676 return gfx::Rect(window_rect); 676 return gfx::Rect(window_rect);
677 } 677 }
678 678
679 void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) { 679 void RenderWidgetHostViewWin::UpdateCursor(const WebCursor& cursor) {
680 current_cursor_ = cursor; 680 current_cursor_ = cursor;
681 UpdateCursorIfOverSelf(); 681 UpdateCursorIfOverSelf();
682 } 682 }
683 683
684 void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() { 684 void RenderWidgetHostViewWin::UpdateCursorIfOverSelf() {
685 static HCURSOR kCursorResizeRight = LoadCursor(NULL, IDC_SIZENWSE);
686 static HCURSOR kCursorResizeLeft = LoadCursor(NULL, IDC_SIZENESW);
685 static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW); 687 static HCURSOR kCursorArrow = LoadCursor(NULL, IDC_ARROW);
686 static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING); 688 static HCURSOR kCursorAppStarting = LoadCursor(NULL, IDC_APPSTARTING);
687 static HINSTANCE module_handle = GetModuleHandle( 689 static HINSTANCE module_handle = GetModuleHandle(
688 content::GetContentClient()->browser()->GetResourceDllName()); 690 content::GetContentClient()->browser()->GetResourceDllName());
689 691
690 // If the mouse is over our HWND, then update the cursor state immediately. 692 // If the mouse is over our HWND, then update the cursor state immediately.
691 CPoint pt; 693 CPoint pt;
692 GetCursorPos(&pt); 694 GetCursorPos(&pt);
693 if (WindowFromPoint(pt) == m_hWnd) { 695 if (WindowFromPoint(pt) == m_hWnd) {
694 // We cannot pass in NULL as the module handle as this would only work for 696 BOOL result = ::ScreenToClient(m_hWnd, &pt);
695 // standard win32 cursors. We can also receive cursor types which are 697 DCHECK(result);
696 // defined as webkit resources. We need to specify the module handle of 698 if (render_widget_host_->GetRootWindowResizerRect().Contains(pt.x, pt.y)) {
697 // chrome.dll while loading these cursors. 699 SetCursor(base::i18n::IsRTL() ? kCursorResizeLeft : kCursorResizeRight);
698 HCURSOR display_cursor = current_cursor_.GetCursor(module_handle); 700 } else {
701 // We cannot pass in NULL as the module handle as this would only work for
702 // standard win32 cursors. We can also receive cursor types which are
703 // defined as webkit resources. We need to specify the module handle of
704 // chrome.dll while loading these cursors.
705 HCURSOR display_cursor = current_cursor_.GetCursor(module_handle);
699 706
700 // If a page is in the loading state, we want to show the Arrow+Hourglass 707 // If a page is in the loading state, we want to show the Arrow+Hourglass
701 // cursor only when the current cursor is the ARROW cursor. In all other 708 // cursor only when the current cursor is the ARROW cursor. In all other
702 // cases we should continue to display the current cursor. 709 // cases we should continue to display the current cursor.
703 if (is_loading_ && display_cursor == kCursorArrow) 710 if (is_loading_ && display_cursor == kCursorArrow)
704 display_cursor = kCursorAppStarting; 711 display_cursor = kCursorAppStarting;
705 712
706 SetCursor(display_cursor); 713 SetCursor(display_cursor);
714 }
707 } 715 }
708 } 716 }
709 717
710 void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) { 718 void RenderWidgetHostViewWin::SetIsLoading(bool is_loading) {
711 is_loading_ = is_loading; 719 is_loading_ = is_loading;
712 UpdateCursorIfOverSelf(); 720 UpdateCursorIfOverSelf();
713 } 721 }
714 722
715 void RenderWidgetHostViewWin::TextInputStateChanged( 723 void RenderWidgetHostViewWin::TextInputStateChanged(
716 ui::TextInputType type, 724 ui::TextInputType type,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 795
788 // Send the invalid rect in screen coordinates. 796 // Send the invalid rect in screen coordinates.
789 gfx::Rect screen_rect = GetViewBounds(); 797 gfx::Rect screen_rect = GetViewBounds();
790 gfx::Rect invalid_screen_rect(damage_bounds); 798 gfx::Rect invalid_screen_rect(damage_bounds);
791 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); 799 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
792 800
793 LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect); 801 LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect);
794 EnumChildWindows(m_hWnd, EnumChildProc, lparam); 802 EnumChildWindows(m_hWnd, EnumChildProc, lparam);
795 } 803 }
796 804
805 void RenderWidgetHostViewWin::DrawResizeCorner(const gfx::Rect& paint_rect,
806 HDC dc) {
807 gfx::Rect resize_corner_rect =
808 render_widget_host_->GetRootWindowResizerRect();
809 if (!paint_rect.Intersect(resize_corner_rect).IsEmpty()) {
810 SkBitmap* bitmap = ResourceBundle::GetSharedInstance().
811 GetBitmapNamed(IDR_TEXTAREA_RESIZER);
812 gfx::CanvasSkia canvas(bitmap->width(), bitmap->height(), false);
813 canvas.getDevice()->accessBitmap(true).eraseARGB(0, 0, 0, 0);
814 int x = resize_corner_rect.x() + resize_corner_rect.width() -
815 bitmap->width();
816 canvas.save();
817 if (base::i18n::IsRTL()) {
818 canvas.TranslateInt(bitmap->width(), 0);
819 canvas.ScaleInt(-1, 1);
820 x = 0;
821 }
822 canvas.DrawBitmapInt(*bitmap, 0, 0);
823 canvas.getTopPlatformDevice().drawToHDC(dc, x,
824 resize_corner_rect.y() + resize_corner_rect.height() -
825 bitmap->height(), NULL);
826 canvas.restore();
827 }
828 }
829
797 void RenderWidgetHostViewWin::DidUpdateBackingStore( 830 void RenderWidgetHostViewWin::DidUpdateBackingStore(
798 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy, 831 const gfx::Rect& scroll_rect, int scroll_dx, int scroll_dy,
799 const std::vector<gfx::Rect>& copy_rects) { 832 const std::vector<gfx::Rect>& copy_rects) {
800 if (is_hidden_) 833 if (is_hidden_)
801 return; 834 return;
802 835
803 // Schedule invalidations first so that the ScrollWindowEx call is closer to 836 // Schedule invalidations first so that the ScrollWindowEx call is closer to
804 // Redraw. That minimizes chances of "flicker" resulting if the screen 837 // Redraw. That minimizes chances of "flicker" resulting if the screen
805 // refreshes before we have a chance to paint the exposed area. Somewhat 838 // refreshes before we have a chance to paint the exposed area. Somewhat
806 // surprisingly, this ordering matters. 839 // surprisingly, this ordering matters.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 // Blit only the damaged regions from the backing store. 1058 // Blit only the damaged regions from the backing store.
1026 DWORD data_size = GetRegionData(damage_region, 0, NULL); 1059 DWORD data_size = GetRegionData(damage_region, 0, NULL);
1027 scoped_array<char> region_data_buf(new char[data_size]); 1060 scoped_array<char> region_data_buf(new char[data_size]);
1028 RGNDATA* region_data = reinterpret_cast<RGNDATA*>(region_data_buf.get()); 1061 RGNDATA* region_data = reinterpret_cast<RGNDATA*>(region_data_buf.get());
1029 GetRegionData(damage_region, data_size, region_data); 1062 GetRegionData(damage_region, data_size, region_data);
1030 1063
1031 RECT* region_rects = reinterpret_cast<RECT*>(region_data->Buffer); 1064 RECT* region_rects = reinterpret_cast<RECT*>(region_data->Buffer);
1032 for (DWORD i = 0; i < region_data->rdh.nCount; ++i) { 1065 for (DWORD i = 0; i < region_data->rdh.nCount; ++i) {
1033 gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i])); 1066 gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i]));
1034 if (!paint_rect.IsEmpty()) { 1067 if (!paint_rect.IsEmpty()) {
1068 DrawResizeCorner(paint_rect, backing_store->hdc());
1035 BitBlt(paint_dc.m_hDC, 1069 BitBlt(paint_dc.m_hDC,
1036 paint_rect.x(), 1070 paint_rect.x(),
1037 paint_rect.y(), 1071 paint_rect.y(),
1038 paint_rect.width(), 1072 paint_rect.width(),
1039 paint_rect.height(), 1073 paint_rect.height(),
1040 backing_store->hdc(), 1074 backing_store->hdc(),
1041 paint_rect.x(), 1075 paint_rect.x(),
1042 paint_rect.y(), 1076 paint_rect.y(),
1043 SRCCOPY); 1077 SRCCOPY);
1044 } 1078 }
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 // window coordinates. For now we don't forward the message in that case to 1452 // window coordinates. For now we don't forward the message in that case to
1419 // address bug #907474. 1453 // address bug #907474.
1420 // Note: GetParent() on popup windows returns the top window and not the 1454 // Note: GetParent() on popup windows returns the top window and not the
1421 // parent the window was created with (the parent and the owner of the popup 1455 // parent the window was created with (the parent and the owner of the popup
1422 // is the first non-child view of the view that was specified to the create 1456 // is the first non-child view of the view that was specified to the create
1423 // call). So the TabContents window would have to be specified to the 1457 // call). So the TabContents window would have to be specified to the
1424 // RenderViewHostHWND as there is no way to retrieve it from the HWND. 1458 // RenderViewHostHWND as there is no way to retrieve it from the HWND.
1425 1459
1426 // Don't forward if the container is a popup or fullscreen widget. 1460 // Don't forward if the container is a popup or fullscreen widget.
1427 if (!is_fullscreen_ && !close_on_deactivate_) { 1461 if (!is_fullscreen_ && !close_on_deactivate_) {
1462 if (message == WM_LBUTTONDOWN) {
1463 // If we get clicked on, where the resize corner is drawn, we delegate the
1464 // message to the root window, with the proper HTBOTTOMXXX wparam so that
1465 // Windows can take care of the resizing for us.
1466 if (render_widget_host_ &&
1467 render_widget_host_->GetRootWindowResizerRect().
1468 Contains(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam))) {
1469 WPARAM wparam = HTBOTTOMRIGHT;
1470 if (base::i18n::IsRTL())
1471 wparam = HTBOTTOMLEFT;
1472 HWND root_hwnd = ::GetAncestor(m_hWnd, GA_ROOT);
1473 if (SendMessage(root_hwnd, WM_NCLBUTTONDOWN, wparam, lparam) == 0)
1474 return 0;
1475 }
1476 }
1428 switch (message) { 1477 switch (message) {
1429 case WM_LBUTTONDOWN: 1478 case WM_LBUTTONDOWN:
1430 case WM_MBUTTONDOWN: 1479 case WM_MBUTTONDOWN:
1431 case WM_RBUTTONDOWN: 1480 case WM_RBUTTONDOWN:
1432 // Finish the ongoing composition whenever a mouse click happens. 1481 // Finish the ongoing composition whenever a mouse click happens.
1433 // It matches IE's behavior. 1482 // It matches IE's behavior.
1434 ime_input_.CleanupComposition(m_hWnd); 1483 ime_input_.CleanupComposition(m_hWnd);
1435 // Fall through. 1484 // Fall through.
1436 case WM_MOUSEMOVE: 1485 case WM_MOUSEMOVE:
1437 case WM_MOUSELEAVE: { 1486 case WM_MOUSELEAVE: {
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 void RenderWidgetHostViewWin::ResetPointerDownContext() { 2618 void RenderWidgetHostViewWin::ResetPointerDownContext() {
2570 // If the default focus on the page is on an edit field and we did not 2619 // If the default focus on the page is on an edit field and we did not
2571 // receive a focus change in the context of a pointer down message, it means 2620 // receive a focus change in the context of a pointer down message, it means
2572 // that the pointer down message occurred on the edit field and we should 2621 // that the pointer down message occurred on the edit field and we should
2573 // display the on screen keyboard 2622 // display the on screen keyboard
2574 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 2623 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
2575 DisplayOnScreenKeyboardIfNeeded(); 2624 DisplayOnScreenKeyboardIfNeeded();
2576 received_focus_change_after_pointer_down_ = false; 2625 received_focus_change_after_pointer_down_ = false;
2577 pointer_down_context_ = false; 2626 pointer_down_context_ = false;
2578 } 2627 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698