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 "webkit/tools/test_shell/webwidget_host.h" | 5 #include "webkit/tools/test_shell/webwidget_host.h" |
6 | 6 |
7 #include "app/win/hwnd_util.h" | 7 #include "app/win/hwnd_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "gfx/rect.h" | 9 #include "gfx/rect.h" |
10 #include "skia/ext/platform_canvas.h" | 10 #include "skia/ext/platform_canvas.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 void WebWidgetHost::DiscardBackingStore() { | 194 void WebWidgetHost::DiscardBackingStore() { |
195 canvas_.reset(); | 195 canvas_.reset(); |
196 } | 196 } |
197 | 197 |
198 WebWidgetHost::WebWidgetHost() | 198 WebWidgetHost::WebWidgetHost() |
199 : view_(NULL), | 199 : view_(NULL), |
200 webwidget_(NULL), | 200 webwidget_(NULL), |
201 track_mouse_leave_(false), | 201 track_mouse_leave_(false), |
202 scroll_dx_(0), | 202 scroll_dx_(0), |
203 scroll_dy_(0) { | 203 scroll_dy_(0), |
| 204 ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) { |
204 set_painting(false); | 205 set_painting(false); |
205 } | 206 } |
206 | 207 |
207 WebWidgetHost::~WebWidgetHost() { | 208 WebWidgetHost::~WebWidgetHost() { |
208 app::win::SetWindowUserData(view_, 0); | 209 app::win::SetWindowUserData(view_, 0); |
209 | 210 |
210 TrackMouseLeave(false); | 211 TrackMouseLeave(false); |
211 | 212 |
212 webwidget_->close(); | 213 webwidget_->close(); |
213 } | 214 } |
(...skipping 21 matching lines...) Expand all Loading... |
235 gfx::Rect client_rect(r); | 236 gfx::Rect client_rect(r); |
236 | 237 |
237 // Allocate a canvas if necessary | 238 // Allocate a canvas if necessary |
238 if (!canvas_.get()) { | 239 if (!canvas_.get()) { |
239 ResetScrollRect(); | 240 ResetScrollRect(); |
240 paint_rect_ = client_rect; | 241 paint_rect_ = client_rect; |
241 canvas_.reset(new skia::PlatformCanvas( | 242 canvas_.reset(new skia::PlatformCanvas( |
242 paint_rect_.width(), paint_rect_.height(), true)); | 243 paint_rect_.width(), paint_rect_.height(), true)); |
243 } | 244 } |
244 | 245 |
| 246 webwidget_->animate(); |
| 247 |
245 // This may result in more invalidation | 248 // This may result in more invalidation |
246 webwidget_->layout(); | 249 webwidget_->layout(); |
247 | 250 |
248 // Scroll the canvas if necessary | 251 // Scroll the canvas if necessary |
249 scroll_rect_ = client_rect.Intersect(scroll_rect_); | 252 scroll_rect_ = client_rect.Intersect(scroll_rect_); |
250 if (!scroll_rect_.IsEmpty()) { | 253 if (!scroll_rect_.IsEmpty()) { |
251 HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC(); | 254 HDC hdc = canvas_->getTopPlatformDevice().getBitmapDC(); |
252 | 255 |
253 RECT damaged_rect, r = scroll_rect_.ToRECT(); | 256 RECT damaged_rect, r = scroll_rect_.ToRECT(); |
254 ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect); | 257 ScrollDC(hdc, scroll_dx_, scroll_dy_, NULL, &r, NULL, &damaged_rect); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 374 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
372 #ifndef NDEBUG | 375 #ifndef NDEBUG |
373 DCHECK(!painting_); | 376 DCHECK(!painting_); |
374 #endif | 377 #endif |
375 DCHECK(canvas_.get()); | 378 DCHECK(canvas_.get()); |
376 | 379 |
377 set_painting(true); | 380 set_painting(true); |
378 webwidget_->paint(canvas_.get(), rect); | 381 webwidget_->paint(canvas_.get(), rect); |
379 set_painting(false); | 382 set_painting(false); |
380 } | 383 } |
OLD | NEW |