OLD | NEW |
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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 HWND parent = | 135 HWND parent = |
136 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); | 136 widget->GetNativeView()->GetRootWindow()->GetAcceleratedWidget(); |
137 SetParent(window, parent); | 137 SetParent(window, parent); |
138 } | 138 } |
139 return TRUE; | 139 return TRUE; |
140 } | 140 } |
141 | 141 |
142 struct CutoutRectsParams { | 142 struct CutoutRectsParams { |
143 RenderWidgetHostViewAura* widget; | 143 RenderWidgetHostViewAura* widget; |
144 std::vector<gfx::Rect> cutout_rects; | 144 std::vector<gfx::Rect> cutout_rects; |
145 std::map<HWND, webkit::npapi::WebPluginGeometry>* geometry; | 145 std::map<HWND, WebPluginGeometry>* geometry; |
146 }; | 146 }; |
147 | 147 |
148 // Used to update the region for the windowed plugin to draw in. We start with | 148 // Used to update the region for the windowed plugin to draw in. We start with |
149 // the clip rect from the renderer, then remove the cutout rects from the | 149 // the clip rect from the renderer, then remove the cutout rects from the |
150 // renderer, and then remove the transient windows from the root window and the | 150 // renderer, and then remove the transient windows from the root window and the |
151 // constrained windows from the parent window. | 151 // constrained windows from the parent window. |
152 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) { | 152 BOOL CALLBACK SetCutoutRectsCallback(HWND window, LPARAM param) { |
153 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param); | 153 CutoutRectsParams* params = reinterpret_cast<CutoutRectsParams*>(param); |
154 | 154 |
155 if (GetProp(window, kWidgetOwnerProperty) == params->widget) { | 155 if (GetProp(window, kWidgetOwnerProperty) == params->widget) { |
156 // First calculate the offset of this plugin from the root window, since | 156 // First calculate the offset of this plugin from the root window, since |
157 // the cutouts are relative to the root window. | 157 // the cutouts are relative to the root window. |
158 HWND parent = params->widget->GetNativeView()->GetRootWindow()-> | 158 HWND parent = params->widget->GetNativeView()->GetRootWindow()-> |
159 GetAcceleratedWidget(); | 159 GetAcceleratedWidget(); |
160 POINT offset; | 160 POINT offset; |
161 offset.x = offset.y = 0; | 161 offset.x = offset.y = 0; |
162 MapWindowPoints(window, parent, &offset, 1); | 162 MapWindowPoints(window, parent, &offset, 1); |
163 | 163 |
164 // Now get the cached clip rect and cutouts for this plugin window that came | 164 // Now get the cached clip rect and cutouts for this plugin window that came |
165 // from the renderer. | 165 // from the renderer. |
166 std::map<HWND, webkit::npapi::WebPluginGeometry>::iterator i = | 166 std::map<HWND, WebPluginGeometry>::iterator i = params->geometry->begin(); |
167 params->geometry->begin(); | |
168 while (i != params->geometry->end() && | 167 while (i != params->geometry->end() && |
169 i->second.window != window && | 168 i->second.window != window && |
170 GetParent(i->second.window) != window) { | 169 GetParent(i->second.window) != window) { |
171 ++i; | 170 ++i; |
172 } | 171 } |
173 | 172 |
174 if (i == params->geometry->end()) { | 173 if (i == params->geometry->end()) { |
175 NOTREACHED(); | 174 NOTREACHED(); |
176 return TRUE; | 175 return TRUE; |
177 } | 176 } |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 #else | 868 #else |
870 manager = BrowserAccessibilityManager::Create(AccessibilityNodeData(), this); | 869 manager = BrowserAccessibilityManager::Create(AccessibilityNodeData(), this); |
871 #endif | 870 #endif |
872 | 871 |
873 SetBrowserAccessibilityManager(manager); | 872 SetBrowserAccessibilityManager(manager); |
874 return manager; | 873 return manager; |
875 } | 874 } |
876 | 875 |
877 void RenderWidgetHostViewAura::MovePluginWindows( | 876 void RenderWidgetHostViewAura::MovePluginWindows( |
878 const gfx::Vector2d& scroll_offset, | 877 const gfx::Vector2d& scroll_offset, |
879 const std::vector<webkit::npapi::WebPluginGeometry>& plugin_window_moves) { | 878 const std::vector<WebPluginGeometry>& plugin_window_moves) { |
880 #if defined(OS_WIN) | 879 #if defined(OS_WIN) |
881 // We need to clip the rectangle to the tab's viewport, otherwise we will draw | 880 // We need to clip the rectangle to the tab's viewport, otherwise we will draw |
882 // over the browser UI. | 881 // over the browser UI. |
883 if (!window_->GetRootWindow()) { | 882 if (!window_->GetRootWindow()) { |
884 DCHECK(plugin_window_moves.empty()); | 883 DCHECK(plugin_window_moves.empty()); |
885 return; | 884 return; |
886 } | 885 } |
887 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); | 886 HWND parent = window_->GetRootWindow()->GetAcceleratedWidget(); |
888 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); | 887 gfx::Rect view_bounds = window_->GetBoundsInRootWindow(); |
889 std::vector<webkit::npapi::WebPluginGeometry> moves = plugin_window_moves; | 888 std::vector<WebPluginGeometry> moves = plugin_window_moves; |
890 | 889 |
891 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), | 890 gfx::Rect view_port(scroll_offset.x(), scroll_offset.y(), view_bounds.width(), |
892 view_bounds.height()); | 891 view_bounds.height()); |
893 | 892 |
894 for (size_t i = 0; i < moves.size(); ++i) { | 893 for (size_t i = 0; i < moves.size(); ++i) { |
895 gfx::Rect clip(moves[i].clip_rect); | 894 gfx::Rect clip(moves[i].clip_rect); |
896 gfx::Vector2d view_port_offset( | 895 gfx::Vector2d view_port_offset( |
897 moves[i].window_rect.OffsetFromOrigin() + scroll_offset); | 896 moves[i].window_rect.OffsetFromOrigin() + scroll_offset); |
898 clip.Offset(view_port_offset); | 897 clip.Offset(view_port_offset); |
899 clip.Intersect(view_port); | 898 clip.Intersect(view_port); |
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 RenderWidgetHost* widget) { | 3113 RenderWidgetHost* widget) { |
3115 return new RenderWidgetHostViewAura(widget); | 3114 return new RenderWidgetHostViewAura(widget); |
3116 } | 3115 } |
3117 | 3116 |
3118 // static | 3117 // static |
3119 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3118 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3120 GetScreenInfoForWindow(results, NULL); | 3119 GetScreenInfoForWindow(results, NULL); |
3121 } | 3120 } |
3122 | 3121 |
3123 } // namespace content | 3122 } // namespace content |
OLD | NEW |