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 "webkit/plugins/webview_plugin.h" | 5 #include "webkit/plugins/webview_plugin.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "skia/ext/platform_canvas.h" |
9 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
19 #include "webkit/glue/webpreferences.h" | 20 #include "webkit/glue/webpreferences.h" |
20 | 21 |
21 #if WEBKIT_USING_CG | |
22 #include <CoreGraphics/CGContext.h> | |
23 #elif WEBKIT_USING_SKIA | |
24 #include "skia/ext/platform_canvas.h" | |
25 #endif | |
26 | |
27 using WebKit::WebCanvas; | 22 using WebKit::WebCanvas; |
28 using WebKit::WebCursorInfo; | 23 using WebKit::WebCursorInfo; |
29 using WebKit::WebDragData; | 24 using WebKit::WebDragData; |
30 using WebKit::WebDragOperationsMask; | 25 using WebKit::WebDragOperationsMask; |
31 using WebKit::WebFrame; | 26 using WebKit::WebFrame; |
32 using WebKit::WebImage; | 27 using WebKit::WebImage; |
33 using WebKit::WebInputEvent; | 28 using WebKit::WebInputEvent; |
34 using WebKit::WebMouseEvent; | 29 using WebKit::WebMouseEvent; |
35 using WebKit::WebPlugin; | 30 using WebKit::WebPlugin; |
36 using WebKit::WebPluginContainer; | 31 using WebKit::WebPluginContainer; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return false; | 115 return false; |
121 } | 116 } |
122 | 117 |
123 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 118 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
124 gfx::Rect paintRect(rect_.Intersect(rect)); | 119 gfx::Rect paintRect(rect_.Intersect(rect)); |
125 if (paintRect.IsEmpty()) | 120 if (paintRect.IsEmpty()) |
126 return; | 121 return; |
127 | 122 |
128 paintRect.Offset(-rect_.x(), -rect_.y()); | 123 paintRect.Offset(-rect_.x(), -rect_.y()); |
129 | 124 |
130 #if WEBKIT_USING_CG | |
131 CGContextRef context = canvas; | |
132 CGContextTranslateCTM(context, rect_.x(), rect_.y()); | |
133 CGContextSaveGState(context); | |
134 #elif WEBKIT_USING_SKIA | |
135 canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y())); | 125 canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y())); |
136 canvas->save(); | 126 canvas->save(); |
137 #endif | |
138 | 127 |
139 web_view_->layout(); | 128 web_view_->layout(); |
140 web_view_->paint(canvas, paintRect); | 129 web_view_->paint(canvas, paintRect); |
141 | 130 |
142 #if WEBKIT_USING_SKIA | |
143 canvas->restore(); | 131 canvas->restore(); |
144 #elif WEBKIT_USING_CG | |
145 CGContextRestoreGState(context); | |
146 #endif | |
147 } | 132 } |
148 | 133 |
149 // Coordinates are relative to the containing window. | 134 // Coordinates are relative to the containing window. |
150 void WebViewPlugin::updateGeometry( | 135 void WebViewPlugin::updateGeometry( |
151 const WebRect& frame_rect, const WebRect& clip_rect, | 136 const WebRect& frame_rect, const WebRect& clip_rect, |
152 const WebVector<WebRect>& cut_out_rects, bool is_visible) { | 137 const WebVector<WebRect>& cut_out_rects, bool is_visible) { |
153 if (frame_rect != rect_) { | 138 if (frame_rect != rect_) { |
154 rect_ = frame_rect; | 139 rect_ = frame_rect; |
155 web_view_->resize(WebSize(frame_rect.width, frame_rect.height)); | 140 web_view_->resize(WebSize(frame_rect.width, frame_rect.height)); |
156 } | 141 } |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 return error; | 228 return error; |
244 } | 229 } |
245 | 230 |
246 void WebViewPlugin::didReceiveResponse(WebFrame* frame, | 231 void WebViewPlugin::didReceiveResponse(WebFrame* frame, |
247 unsigned identifier, | 232 unsigned identifier, |
248 const WebURLResponse& response) { | 233 const WebURLResponse& response) { |
249 WebFrameClient::didReceiveResponse(frame, identifier, response); | 234 WebFrameClient::didReceiveResponse(frame, identifier, response); |
250 } | 235 } |
251 | 236 |
252 } // namespace webkit | 237 } // namespace webkit |
OLD | NEW |