| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 } | 316 } |
| 317 | 317 |
| 318 WebWidgetHost::~WebWidgetHost() { | 318 WebWidgetHost::~WebWidgetHost() { |
| 319 g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL); | 319 g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL); |
| 320 webwidget_->close(); | 320 webwidget_->close(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void WebWidgetHost::Resize(const gfx::Size &newsize) { | 323 void WebWidgetHost::Resize(const gfx::Size &newsize) { |
| 324 // The pixel buffer backing us is now the wrong size | 324 // The pixel buffer backing us is now the wrong size |
| 325 canvas_.reset(); | 325 canvas_.reset(); |
| 326 | 326 logical_size_ = newsize; |
| 327 webwidget_->resize(newsize); | 327 webwidget_->resize(newsize); |
| 328 } | 328 } |
| 329 | 329 |
| 330 void WebWidgetHost::Paint() { | 330 void WebWidgetHost::Paint() { |
| 331 int width = view_->allocation.width; | 331 int width = logical_size_.width(); |
| 332 int height = view_->allocation.height; | 332 int height = logical_size_.height(); |
| 333 gfx::Rect client_rect(width, height); | 333 gfx::Rect client_rect(width, height); |
| 334 | 334 |
| 335 // Allocate a canvas if necessary | 335 // Allocate a canvas if necessary |
| 336 if (!canvas_.get()) { | 336 if (!canvas_.get()) { |
| 337 ResetScrollRect(); | 337 ResetScrollRect(); |
| 338 paint_rect_ = client_rect; | 338 paint_rect_ = client_rect; |
| 339 canvas_.reset(new skia::PlatformCanvas(width, height, true)); | 339 canvas_.reset(new skia::PlatformCanvas(width, height, true)); |
| 340 if (!canvas_.get()) { | 340 if (!canvas_.get()) { |
| 341 // memory allocation failed, we can't paint. | 341 // memory allocation failed, we can't paint. |
| 342 LOG(ERROR) << "Failed to allocate memory for " << width << "x" << height; | 342 LOG(ERROR) << "Failed to allocate memory for " << width << "x" << height; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 403 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |
| 404 set_painting(true); | 404 set_painting(true); |
| 405 webwidget_->paint(canvas_.get(), rect); | 405 webwidget_->paint(canvas_.get(), rect); |
| 406 set_painting(false); | 406 set_painting(false); |
| 407 } | 407 } |
| 408 | 408 |
| 409 void WebWidgetHost::WindowDestroyed() { | 409 void WebWidgetHost::WindowDestroyed() { |
| 410 delete this; | 410 delete this; |
| 411 } | 411 } |
| OLD | NEW |