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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window) && | 239 if (WebPluginDelegateImpl::IsPluginDelegateWindow(window) && |
240 !IsHungAppWindow(window)) { | 240 !IsHungAppWindow(window)) { |
241 ::ShowWindow(window, SW_HIDE); | 241 ::ShowWindow(window, SW_HIDE); |
242 SetParent(window, NULL); | 242 SetParent(window, NULL); |
243 } | 243 } |
244 return TRUE; | 244 return TRUE; |
245 } | 245 } |
246 | 246 |
247 // Draw the contents of |backing_store_dc| onto |paint_rect| with a 70% grey | 247 // Draw the contents of |backing_store_dc| onto |paint_rect| with a 70% grey |
248 // filter. | 248 // filter. |
249 void DrawDeemphasized(const gfx::Rect& paint_rect, | 249 void DrawDeemphasized(const SkColor& color, |
| 250 const gfx::Rect& paint_rect, |
250 HDC backing_store_dc, | 251 HDC backing_store_dc, |
251 HDC paint_dc) { | 252 HDC paint_dc) { |
252 gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true); | 253 gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true); |
253 HDC dc = canvas.beginPlatformPaint(); | 254 HDC dc = canvas.beginPlatformPaint(); |
254 BitBlt(dc, | 255 BitBlt(dc, |
255 0, | 256 0, |
256 0, | 257 0, |
257 paint_rect.width(), | 258 paint_rect.width(), |
258 paint_rect.height(), | 259 paint_rect.height(), |
259 backing_store_dc, | 260 backing_store_dc, |
260 paint_rect.x(), | 261 paint_rect.x(), |
261 paint_rect.y(), | 262 paint_rect.y(), |
262 SRCCOPY); | 263 SRCCOPY); |
263 canvas.endPlatformPaint(); | 264 canvas.endPlatformPaint(); |
264 // 178 is 70% grey. | 265 canvas.FillRectInt(color, 0, 0, paint_rect.width(), paint_rect.height()); |
265 canvas.FillRectInt(SkColorSetARGB(178, 0, 0, 0), 0, 0, | |
266 paint_rect.width(), paint_rect.height()); | |
267 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(), | 266 canvas.getTopPlatformDevice().drawToHDC(paint_dc, paint_rect.x(), |
268 paint_rect.y(), NULL); | 267 paint_rect.y(), NULL); |
269 } | 268 } |
270 | 269 |
271 } // namespace | 270 } // namespace |
272 | 271 |
273 // RenderWidgetHostView -------------------------------------------------------- | 272 // RenderWidgetHostView -------------------------------------------------------- |
274 | 273 |
275 // static | 274 // static |
276 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( | 275 RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
(...skipping 12 matching lines...) Expand all Loading... |
289 capture_enter_key_(false), | 288 capture_enter_key_(false), |
290 is_hidden_(false), | 289 is_hidden_(false), |
291 about_to_validate_and_paint_(false), | 290 about_to_validate_and_paint_(false), |
292 close_on_deactivate_(false), | 291 close_on_deactivate_(false), |
293 being_destroyed_(false), | 292 being_destroyed_(false), |
294 tooltip_hwnd_(NULL), | 293 tooltip_hwnd_(NULL), |
295 tooltip_showing_(false), | 294 tooltip_showing_(false), |
296 shutdown_factory_(this), | 295 shutdown_factory_(this), |
297 parent_hwnd_(NULL), | 296 parent_hwnd_(NULL), |
298 is_loading_(false), | 297 is_loading_(false), |
299 visually_deemphasized_(false), | 298 overlay_color_(0), |
300 text_input_type_(WebKit::WebTextInputTypeNone) { | 299 text_input_type_(WebKit::WebTextInputTypeNone) { |
301 render_widget_host_->set_view(this); | 300 render_widget_host_->set_view(this); |
302 registrar_.Add(this, | 301 registrar_.Add(this, |
303 NotificationType::RENDERER_PROCESS_TERMINATED, | 302 NotificationType::RENDERER_PROCESS_TERMINATED, |
304 NotificationService::AllSources()); | 303 NotificationService::AllSources()); |
305 } | 304 } |
306 | 305 |
307 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 306 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
308 ResetTooltip(); | 307 ResetTooltip(); |
309 } | 308 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 HWND parent_window = ::GetParent(native_view); | 800 HWND parent_window = ::GetParent(native_view); |
802 while (parent_window) { | 801 while (parent_window) { |
803 if (parent_window == m_hWnd) | 802 if (parent_window == m_hWnd) |
804 return true; | 803 return true; |
805 parent_window = ::GetParent(parent_window); | 804 parent_window = ::GetParent(parent_window); |
806 } | 805 } |
807 | 806 |
808 return false; | 807 return false; |
809 } | 808 } |
810 | 809 |
811 void RenderWidgetHostViewWin::SetVisuallyDeemphasized(bool deemphasized) { | 810 void RenderWidgetHostViewWin::SetVisuallyDeemphasized(const SkColor* color, |
812 if (visually_deemphasized_ == deemphasized) | 811 bool animate) { |
| 812 // |animate| is not yet implemented, and currently isn't used. |
| 813 CHECK(!animate); |
| 814 |
| 815 SkColor overlay_color = color ? *color : 0; |
| 816 if (overlay_color_ == overlay_color) |
813 return; | 817 return; |
| 818 overlay_color_ = overlay_color; |
814 | 819 |
815 visually_deemphasized_ = deemphasized; | |
816 InvalidateRect(NULL, FALSE); | 820 InvalidateRect(NULL, FALSE); |
817 } | 821 } |
818 | 822 |
819 /////////////////////////////////////////////////////////////////////////////// | 823 /////////////////////////////////////////////////////////////////////////////// |
820 // RenderWidgetHostViewWin, private: | 824 // RenderWidgetHostViewWin, private: |
821 | 825 |
822 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { | 826 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { |
823 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale | 827 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale |
824 // of a browser process. | 828 // of a browser process. |
825 OnInputLangChange(0, 0); | 829 OnInputLangChange(0, 0); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 // Blit only the damaged regions from the backing store. | 919 // Blit only the damaged regions from the backing store. |
916 DWORD data_size = GetRegionData(damage_region, 0, NULL); | 920 DWORD data_size = GetRegionData(damage_region, 0, NULL); |
917 scoped_array<char> region_data_buf(new char[data_size]); | 921 scoped_array<char> region_data_buf(new char[data_size]); |
918 RGNDATA* region_data = reinterpret_cast<RGNDATA*>(region_data_buf.get()); | 922 RGNDATA* region_data = reinterpret_cast<RGNDATA*>(region_data_buf.get()); |
919 GetRegionData(damage_region, data_size, region_data); | 923 GetRegionData(damage_region, data_size, region_data); |
920 | 924 |
921 RECT* region_rects = reinterpret_cast<RECT*>(region_data->Buffer); | 925 RECT* region_rects = reinterpret_cast<RECT*>(region_data->Buffer); |
922 for (DWORD i = 0; i < region_data->rdh.nCount; ++i) { | 926 for (DWORD i = 0; i < region_data->rdh.nCount; ++i) { |
923 gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i])); | 927 gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i])); |
924 if (!paint_rect.IsEmpty()) { | 928 if (!paint_rect.IsEmpty()) { |
925 if (visually_deemphasized_) { | 929 if (SkColorGetA(overlay_color_) > 0) { |
926 DrawDeemphasized(paint_rect, backing_store->hdc(), paint_dc.m_hDC); | 930 DrawDeemphasized(overlay_color_, |
| 931 paint_rect, |
| 932 backing_store->hdc(), |
| 933 paint_dc.m_hDC); |
927 } else { | 934 } else { |
928 BitBlt(paint_dc.m_hDC, | 935 BitBlt(paint_dc.m_hDC, |
929 paint_rect.x(), | 936 paint_rect.x(), |
930 paint_rect.y(), | 937 paint_rect.y(), |
931 paint_rect.width(), | 938 paint_rect.width(), |
932 paint_rect.height(), | 939 paint_rect.height(), |
933 backing_store->hdc(), | 940 backing_store->hdc(), |
934 paint_rect.x(), | 941 paint_rect.x(), |
935 paint_rect.y(), | 942 paint_rect.y(), |
936 SRCCOPY); | 943 SRCCOPY); |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 } | 1804 } |
1798 | 1805 |
1799 // static | 1806 // static |
1800 RenderWidgetHostView* | 1807 RenderWidgetHostView* |
1801 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1808 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1802 gfx::NativeView native_view) { | 1809 gfx::NativeView native_view) { |
1803 return ::IsWindow(native_view) ? | 1810 return ::IsWindow(native_view) ? |
1804 reinterpret_cast<RenderWidgetHostView*>( | 1811 reinterpret_cast<RenderWidgetHostView*>( |
1805 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; | 1812 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; |
1806 } | 1813 } |
OLD | NEW |