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

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

Issue 7068029: Fix residue left over from find bar when using accelerated compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 using WebKit::WebInputEvent; 63 using WebKit::WebInputEvent;
64 using WebKit::WebInputEventFactory; 64 using WebKit::WebInputEventFactory;
65 using WebKit::WebMouseEvent; 65 using WebKit::WebMouseEvent;
66 using WebKit::WebTextDirection; 66 using WebKit::WebTextDirection;
67 using webkit::npapi::WebPluginGeometry; 67 using webkit::npapi::WebPluginGeometry;
68 68
69 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; 69 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND";
70 70
71 namespace { 71 namespace {
72 72
73 const TCHAR* kRenderWidgetHVWPropStr = _T("RWHVW_P");
74
73 // Tooltips will wrap after this width. Yes, wrap. Imagine that! 75 // Tooltips will wrap after this width. Yes, wrap. Imagine that!
74 const int kTooltipMaxWidthPixels = 300; 76 const int kTooltipMaxWidthPixels = 300;
75 77
76 // Maximum number of characters we allow in a tooltip. 78 // Maximum number of characters we allow in a tooltip.
77 const int kMaxTooltipLength = 1024; 79 const int kMaxTooltipLength = 1024;
78 80
79 // A custom MSAA object id used to determine if a screen reader is actively 81 // A custom MSAA object id used to determine if a screen reader is actively
80 // listening for MSAA events. 82 // listening for MSAA events.
81 const int kIdCustom = 1; 83 const int kIdCustom = 1;
82 84
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 829
828 CleanupCompositorWindow(); 830 CleanupCompositorWindow();
829 831
830 ResetTooltip(); 832 ResetTooltip();
831 TrackMouseLeave(false); 833 TrackMouseLeave(false);
832 } 834 }
833 835
834 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { 836 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) {
835 DCHECK(render_widget_host_->process()->HasConnection()); 837 DCHECK(render_widget_host_->process()->HasConnection());
836 838
837 // If the GPU process is rendering directly into the View, 839 // If the GPU process is rendering directly into the View, compositing is
838 // call the compositor directly. 840 // already triggered by damage to compositor_host_window_, so all we need to
839 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); 841 // do here is clear borders during resize.
840 if (render_widget_host->is_accelerated_compositing_active()) { 842 if (render_widget_host_ &&
843 render_widget_host_->is_accelerated_compositing_active()) {
841 // We initialize paint_dc here so that BeginPaint()/EndPaint() 844 // We initialize paint_dc here so that BeginPaint()/EndPaint()
842 // get called to validate the region. 845 // get called to validate the region.
843 CPaintDC paint_dc(m_hWnd); 846 CPaintDC paint_dc(m_hWnd);
844 render_widget_host_->ScheduleComposite(); 847 RECT host_rect, child_rect;
848 GetClientRect(&host_rect);
849 if (::GetClientRect(compositor_host_window_, &child_rect) &&
850 (child_rect.right < host_rect.right ||
851 child_rect.bottom < host_rect.bottom)) {
852 paint_dc.FillRect(&host_rect,
853 reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)));
854 }
845 return; 855 return;
846 } 856 }
847 857
848 about_to_validate_and_paint_ = true; 858 about_to_validate_and_paint_ = true;
849 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( 859 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>(
850 render_widget_host_->GetBackingStore(true)); 860 render_widget_host_->GetBackingStore(true));
851 861
852 // We initialize |paint_dc| (and thus call BeginPaint()) after calling 862 // We initialize |paint_dc| (and thus call BeginPaint()) after calling
853 // GetBackingStore(), so that if it updates the invalid rect we'll catch the 863 // GetBackingStore(), so that if it updates the invalid rect we'll catch the
854 // changes and repaint them. 864 // changes and repaint them.
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 // If it was our RenderProcessHost that posted the notification, 1482 // If it was our RenderProcessHost that posted the notification,
1473 // clear the BrowserAccessibilityManager, because the renderer is 1483 // clear the BrowserAccessibilityManager, because the renderer is
1474 // dead and any accessibility information we have is now stale. 1484 // dead and any accessibility information we have is now stale.
1475 browser_accessibility_manager_.reset(NULL); 1485 browser_accessibility_manager_.reset(NULL);
1476 } 1486 }
1477 1487
1478 static void PaintCompositorHostWindow(HWND hWnd) { 1488 static void PaintCompositorHostWindow(HWND hWnd) {
1479 PAINTSTRUCT paint; 1489 PAINTSTRUCT paint;
1480 BeginPaint(hWnd, &paint); 1490 BeginPaint(hWnd, &paint);
1481 1491
1492 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>(
1493 GetProp(hWnd, kRenderWidgetHVWPropStr));
1494 // Trigger composite to rerender window.
1495 win->ScheduleComposite();
1496
1482 EndPaint(hWnd, &paint); 1497 EndPaint(hWnd, &paint);
1483 } 1498 }
1484 1499
1485 // WndProc for the compositor host window. We use this instead of Default so 1500 // WndProc for the compositor host window. We use this instead of Default so
1486 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor. 1501 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor.
1487 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, 1502 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message,
1488 WPARAM wParam, LPARAM lParam) { 1503 WPARAM wParam, LPARAM lParam) {
1489 switch (message) { 1504 switch (message) {
1490 case WM_ERASEBKGND: 1505 case WM_ERASEBKGND:
1491 return 0; 1506 return 0;
1492 case WM_DESTROY: 1507 case WM_DESTROY:
1508 RemoveProp(hWnd, kRenderWidgetHVWPropStr);
1493 return 0; 1509 return 0;
1494 case WM_PAINT: 1510 case WM_PAINT:
1495 PaintCompositorHostWindow(hWnd); 1511 PaintCompositorHostWindow(hWnd);
1496 return 0; 1512 return 0;
1497 default: 1513 default:
1498 return DefWindowProc(hWnd, message, wParam, lParam); 1514 return DefWindowProc(hWnd, message, wParam, lParam);
1499 } 1515 }
1500 } 1516 }
1501 1517
1518 void RenderWidgetHostViewWin::ScheduleComposite() {
1519 if (render_widget_host_)
1520 render_widget_host_->ScheduleComposite();
1521 }
1522
1502 // Creates a HWND within the RenderWidgetHostView that will serve as a host 1523 // Creates a HWND within the RenderWidgetHostView that will serve as a host
1503 // for a HWND that the GPU process will create. The host window is used 1524 // for a HWND that the GPU process will create. The host window is used
1504 // to Z-position the GPU's window relative to other plugin windows. 1525 // to Z-position the GPU's window relative to other plugin windows.
1505 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { 1526 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() {
1506 // If the window has been created, don't recreate it a second time 1527 // If the window has been created, don't recreate it a second time
1507 if (compositor_host_window_) 1528 if (compositor_host_window_)
1508 return compositor_host_window_; 1529 return compositor_host_window_;
1509 1530
1510 static ATOM window_class = 0; 1531 static ATOM window_class = 0;
1511 if (!window_class) { 1532 if (!window_class) {
(...skipping 20 matching lines...) Expand all
1532 int width = currentRect.right - currentRect.left; 1553 int width = currentRect.right - currentRect.left;
1533 int height = currentRect.bottom - currentRect.top; 1554 int height = currentRect.bottom - currentRect.top;
1534 1555
1535 compositor_host_window_ = CreateWindowEx( 1556 compositor_host_window_ = CreateWindowEx(
1536 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, 1557 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
1537 MAKEINTATOM(window_class), 0, 1558 MAKEINTATOM(window_class), 0,
1538 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, 1559 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED,
1539 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); 1560 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0);
1540 ui::CheckWindowCreated(compositor_host_window_); 1561 ui::CheckWindowCreated(compositor_host_window_);
1541 1562
1563 SetProp(compositor_host_window_, kRenderWidgetHVWPropStr, this);
Ben Goodger (Google) 2011/05/27 17:56:18 SetProp() can be problematic, and can lead to stra
jbates 2011/05/27 18:18:55 User data sounds good to me. You mean SetWindowLon
Ben Goodger (Google) 2011/05/27 18:20:15 Yes. There should be a win_util in base somewhere
jbates 2011/05/27 18:27:33 I don't see anything like that in win_util or base
Ben Goodger (Google) 2011/05/27 18:44:17 Ah it got migrated to src/ui. But you're in src/ch
jbates 2011/05/27 19:10:37 Done.
1564
1542 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); 1565 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_);
1543 } 1566 }
1544 1567
1545 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) { 1568 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) {
1546 // When we first create the compositor, we will get a show request from 1569 // When we first create the compositor, we will get a show request from
1547 // the renderer before we have gotten the create request from the GPU. In this 1570 // the renderer before we have gotten the create request from the GPU. In this
1548 // case, simply ignore the show request. 1571 // case, simply ignore the show request.
1549 if (compositor_host_window_ == NULL) 1572 if (compositor_host_window_ == NULL)
1550 return; 1573 return;
1551 1574
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 } 1799 }
1777 1800
1778 // static 1801 // static
1779 RenderWidgetHostView* 1802 RenderWidgetHostView*
1780 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 1803 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
1781 gfx::NativeView native_view) { 1804 gfx::NativeView native_view) {
1782 return ::IsWindow(native_view) ? 1805 return ::IsWindow(native_view) ?
1783 reinterpret_cast<RenderWidgetHostView*>( 1806 reinterpret_cast<RenderWidgetHostView*>(
1784 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; 1807 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL;
1785 } 1808 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698