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

Side by Side Diff: webkit/plugins/webview_plugin.cc

Issue 12218122: Revert pagescale from plugin placeholder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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 | « webkit/plugins/webview_plugin.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) 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 "skia/ext/platform_canvas.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebSize.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return false; 120 return false;
121 } 121 }
122 122
123 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) { 123 void WebViewPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
124 gfx::Rect paint_rect = gfx::IntersectRects(rect_, rect); 124 gfx::Rect paint_rect = gfx::IntersectRects(rect_, rect);
125 if (paint_rect.IsEmpty()) 125 if (paint_rect.IsEmpty())
126 return; 126 return;
127 127
128 paint_rect.Offset(-rect_.x(), -rect_.y()); 128 paint_rect.Offset(-rect_.x(), -rect_.y());
129 129
130 float content_scale = 1.0f / GetPageScaleFactor();
131 paint_rect.SetRect(
132 ceil(content_scale * paint_rect.x()),
133 ceil(content_scale * paint_rect.y()),
134 ceil(content_scale * paint_rect.width()),
135 ceil(content_scale * paint_rect.height()));
136
137 canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y())); 130 canvas->translate(SkIntToScalar(rect_.x()), SkIntToScalar(rect_.y()));
138 canvas->save(); 131 canvas->save();
139 132
140 web_view_->layout(); 133 web_view_->layout();
141 web_view_->paint(canvas, paint_rect); 134 web_view_->paint(canvas, paint_rect);
142 135
143 canvas->restore(); 136 canvas->restore();
144 } 137 }
145 138
146 // Coordinates are relative to the containing window. 139 // Coordinates are relative to the containing window.
147 void WebViewPlugin::updateGeometry( 140 void WebViewPlugin::updateGeometry(
148 const WebRect& frame_rect, const WebRect& clip_rect, 141 const WebRect& frame_rect, const WebRect& clip_rect,
149 const WebVector<WebRect>& cut_out_rects, bool is_visible) { 142 const WebVector<WebRect>& cut_out_rects, bool is_visible) {
150 if (static_cast<gfx::Rect>(frame_rect) != rect_) { 143 if (static_cast<gfx::Rect>(frame_rect) != rect_)
151 rect_ = frame_rect; 144 rect_ = frame_rect;
152
153 float content_scale = 1.0f / GetPageScaleFactor();
154 web_view_->resize(WebSize(content_scale * frame_rect.width,
155 content_scale * frame_rect.height));
156 }
157 } 145 }
158 146
159 bool WebViewPlugin::acceptsInputEvents() { 147 bool WebViewPlugin::acceptsInputEvents() {
160 return true; 148 return true;
161 } 149 }
162 150
163 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event, 151 bool WebViewPlugin::handleInputEvent(const WebInputEvent& event,
164 WebCursorInfo& cursor) { 152 WebCursorInfo& cursor) {
165 // For tap events, don't handle them. They will be converted to 153 // For tap events, don't handle them. They will be converted to
166 // mouse events later and passed to here. 154 // mouse events later and passed to here.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 error.unreachableURL = request.url(); 237 error.unreachableURL = request.url();
250 return error; 238 return error;
251 } 239 }
252 240
253 void WebViewPlugin::didReceiveResponse(WebFrame* frame, 241 void WebViewPlugin::didReceiveResponse(WebFrame* frame,
254 unsigned identifier, 242 unsigned identifier,
255 const WebURLResponse& response) { 243 const WebURLResponse& response) {
256 WebFrameClient::didReceiveResponse(frame, identifier, response); 244 WebFrameClient::didReceiveResponse(frame, identifier, response);
257 } 245 }
258 246
259 float WebViewPlugin::GetPageScaleFactor() {
260 if (container_) {
261 WebFrame* frame = container_->element().document().frame();
262 WebView* top_view = frame->top()->view();
263 return top_view->pageScaleFactor();
264 }
265 return 1.0f;
266 }
267
268 } // namespace webkit 247 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/webview_plugin.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698