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

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: comments Created 9 years, 7 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
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 char* kRenderWidgetHVWPropStr = "RWHVW_P";
vangelis 2011/05/26 19:21:53 A quick look through the code indicates that we do
jbates 2011/05/26 20:14:47 Done.
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 RenderWidgetHost* widget) { 216 RenderWidgetHost* widget) {
215 return new RenderWidgetHostViewWin(widget); 217 return new RenderWidgetHostViewWin(widget);
216 } 218 }
217 219
218 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
219 // RenderWidgetHostViewWin, public: 221 // RenderWidgetHostViewWin, public:
220 222
221 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) 223 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
222 : render_widget_host_(widget), 224 : render_widget_host_(widget),
223 compositor_host_window_(NULL), 225 compositor_host_window_(NULL),
226 was_compositing_just_scheduled_(false),
224 hide_compositor_window_at_next_paint_(false), 227 hide_compositor_window_at_next_paint_(false),
225 track_mouse_leave_(false), 228 track_mouse_leave_(false),
226 ime_notification_(false), 229 ime_notification_(false),
227 capture_enter_key_(false), 230 capture_enter_key_(false),
228 is_hidden_(false), 231 is_hidden_(false),
229 about_to_validate_and_paint_(false), 232 about_to_validate_and_paint_(false),
230 close_on_deactivate_(false), 233 close_on_deactivate_(false),
231 being_destroyed_(false), 234 being_destroyed_(false),
232 tooltip_hwnd_(NULL), 235 tooltip_hwnd_(NULL),
233 tooltip_showing_(false), 236 tooltip_showing_(false),
234 shutdown_factory_(this), 237 shutdown_factory_(this),
238 method_factory_(this),
235 parent_hwnd_(NULL), 239 parent_hwnd_(NULL),
236 is_loading_(false), 240 is_loading_(false),
237 overlay_color_(0), 241 overlay_color_(0),
238 text_input_type_(WebKit::WebTextInputTypeNone) { 242 text_input_type_(WebKit::WebTextInputTypeNone) {
239 render_widget_host_->set_view(this); 243 render_widget_host_->set_view(this);
240 registrar_.Add(this, 244 registrar_.Add(this,
241 NotificationType::RENDERER_PROCESS_TERMINATED, 245 NotificationType::RENDERER_PROCESS_TERMINATED,
242 NotificationService::AllSources()); 246 NotificationService::AllSources());
243 } 247 }
244 248
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { 836 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) {
833 DCHECK(render_widget_host_->process()->HasConnection()); 837 DCHECK(render_widget_host_->process()->HasConnection());
834 838
835 // If the GPU process is rendering directly into the View, 839 // If the GPU process is rendering directly into the View,
836 // call the compositor directly. 840 // call the compositor directly.
837 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); 841 RenderWidgetHost* render_widget_host = GetRenderWidgetHost();
838 if (render_widget_host->is_accelerated_compositing_active()) { 842 if (render_widget_host->is_accelerated_compositing_active()) {
839 // We initialize paint_dc here so that BeginPaint()/EndPaint() 843 // We initialize paint_dc here so that BeginPaint()/EndPaint()
840 // get called to validate the region. 844 // get called to validate the region.
841 CPaintDC paint_dc(m_hWnd); 845 CPaintDC paint_dc(m_hWnd);
842 render_widget_host_->ScheduleComposite(); 846 ScheduleCompositeIfNeeded();
843 return; 847 return;
844 } 848 }
845 849
846 about_to_validate_and_paint_ = true; 850 about_to_validate_and_paint_ = true;
847 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>( 851 BackingStoreWin* backing_store = static_cast<BackingStoreWin*>(
848 render_widget_host_->GetBackingStore(true)); 852 render_widget_host_->GetBackingStore(true));
849 853
850 // We initialize |paint_dc| (and thus call BeginPaint()) after calling 854 // We initialize |paint_dc| (and thus call BeginPaint()) after calling
851 // GetBackingStore(), so that if it updates the invalid rect we'll catch the 855 // GetBackingStore(), so that if it updates the invalid rect we'll catch the
852 // changes and repaint them. 856 // changes and repaint them.
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 // If it was our RenderProcessHost that posted the notification, 1474 // If it was our RenderProcessHost that posted the notification,
1471 // clear the BrowserAccessibilityManager, because the renderer is 1475 // clear the BrowserAccessibilityManager, because the renderer is
1472 // dead and any accessibility information we have is now stale. 1476 // dead and any accessibility information we have is now stale.
1473 browser_accessibility_manager_.reset(NULL); 1477 browser_accessibility_manager_.reset(NULL);
1474 } 1478 }
1475 1479
1476 static void PaintCompositorHostWindow(HWND hWnd) { 1480 static void PaintCompositorHostWindow(HWND hWnd) {
1477 PAINTSTRUCT paint; 1481 PAINTSTRUCT paint;
1478 BeginPaint(hWnd, &paint); 1482 BeginPaint(hWnd, &paint);
1479 1483
1484 RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>(
1485 GetPropA(hWnd, kRenderWidgetHVWPropStr));
1486 // May block unless parent window already did this.
1487 win->ScheduleCompositeIfNeeded();
1488
1480 EndPaint(hWnd, &paint); 1489 EndPaint(hWnd, &paint);
1481 } 1490 }
1482 1491
1483 // WndProc for the compositor host window. We use this instead of Default so 1492 // WndProc for the compositor host window. We use this instead of Default so
1484 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor. 1493 // we can drop WM_PAINT and WM_ERASEBKGD messages on the floor.
1485 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, 1494 static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message,
1486 WPARAM wParam, LPARAM lParam) { 1495 WPARAM wParam, LPARAM lParam) {
1487 switch (message) { 1496 switch (message) {
1488 case WM_ERASEBKGND: 1497 case WM_ERASEBKGND:
1489 return 0; 1498 return 0;
1490 case WM_DESTROY: 1499 case WM_DESTROY:
1500 RemovePropA(hWnd, kRenderWidgetHVWPropStr);
1491 return 0; 1501 return 0;
1492 case WM_PAINT: 1502 case WM_PAINT:
1493 PaintCompositorHostWindow(hWnd); 1503 PaintCompositorHostWindow(hWnd);
1494 return 0; 1504 return 0;
1495 default: 1505 default:
1496 return DefWindowProc(hWnd, message, wParam, lParam); 1506 return DefWindowProc(hWnd, message, wParam, lParam);
1497 } 1507 }
1498 } 1508 }
1499 1509
1510 void RenderWidgetHostViewWin::ScheduleCompositeIfNeeded() {
1511 // Call ScheduleComposite unless it has already occured during this set of
1512 // Windows events.
1513 if (!was_compositing_just_scheduled_) {
1514 was_compositing_just_scheduled_ = true;
1515 render_widget_host_->ScheduleComposite();
1516 MessageLoop::current()->PostTask(FROM_HERE,
1517 method_factory_.NewRunnableMethod(
1518 &RenderWidgetHostViewWin::ResetWasCompositingJustCompleted));
1519 }
1520 }
1521
1522 void RenderWidgetHostViewWin::ResetWasCompositingJustCompleted() {
vangelis 2011/05/26 19:21:53 Should be renamed to *JustScheduled for consistenc
jbates 2011/05/26 20:14:47 Done.
1523 was_compositing_just_scheduled_ = false;
1524 }
1525
1500 // Creates a HWND within the RenderWidgetHostView that will serve as a host 1526 // Creates a HWND within the RenderWidgetHostView that will serve as a host
1501 // for a HWND that the GPU process will create. The host window is used 1527 // for a HWND that the GPU process will create. The host window is used
1502 // to Z-position the GPU's window relative to other plugin windows. 1528 // to Z-position the GPU's window relative to other plugin windows.
1503 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { 1529 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() {
1504 // If the window has been created, don't recreate it a second time 1530 // If the window has been created, don't recreate it a second time
1505 if (compositor_host_window_) 1531 if (compositor_host_window_)
1506 return compositor_host_window_; 1532 return compositor_host_window_;
1507 1533
1508 static ATOM window_class = 0; 1534 static ATOM window_class = 0;
1509 if (!window_class) { 1535 if (!window_class) {
(...skipping 20 matching lines...) Expand all
1530 int width = currentRect.right - currentRect.left; 1556 int width = currentRect.right - currentRect.left;
1531 int height = currentRect.bottom - currentRect.top; 1557 int height = currentRect.bottom - currentRect.top;
1532 1558
1533 compositor_host_window_ = CreateWindowEx( 1559 compositor_host_window_ = CreateWindowEx(
1534 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, 1560 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
1535 MAKEINTATOM(window_class), 0, 1561 MAKEINTATOM(window_class), 0,
1536 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, 1562 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED,
1537 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); 1563 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0);
1538 ui::CheckWindowCreated(compositor_host_window_); 1564 ui::CheckWindowCreated(compositor_host_window_);
1539 1565
1566 SetPropA(compositor_host_window_, kRenderWidgetHVWPropStr, this);
1567
1540 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); 1568 return static_cast<gfx::PluginWindowHandle>(compositor_host_window_);
1541 } 1569 }
1542 1570
1543 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) { 1571 void RenderWidgetHostViewWin::ShowCompositorHostWindow(bool show) {
1544 // When we first create the compositor, we will get a show request from 1572 // When we first create the compositor, we will get a show request from
1545 // the renderer before we have gotten the create request from the GPU. In this 1573 // the renderer before we have gotten the create request from the GPU. In this
1546 // case, simply ignore the show request. 1574 // case, simply ignore the show request.
1547 if (compositor_host_window_ == NULL) 1575 if (compositor_host_window_ == NULL)
1548 return; 1576 return;
1549 1577
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1774 } 1802 }
1775 1803
1776 // static 1804 // static
1777 RenderWidgetHostView* 1805 RenderWidgetHostView*
1778 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( 1806 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView(
1779 gfx::NativeView native_view) { 1807 gfx::NativeView native_view) {
1780 return ::IsWindow(native_view) ? 1808 return ::IsWindow(native_view) ?
1781 reinterpret_cast<RenderWidgetHostView*>( 1809 reinterpret_cast<RenderWidgetHostView*>(
1782 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; 1810 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL;
1783 } 1811 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698