| OLD | NEW | 
|    1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2008-2009 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 #import <Cocoa/Cocoa.h> |    5 #import <Cocoa/Cocoa.h> | 
|    6  |    6  | 
|    7 #include "webkit/tools/test_shell/webwidget_host.h" |    7 #include "webkit/tools/test_shell/webwidget_host.h" | 
|    8  |    8  | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "gfx/rect.h" |   10 #include "gfx/rect.h" | 
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  142 // } |  142 // } | 
|  143  |  143  | 
|  144 void WebWidgetHost::DiscardBackingStore() { |  144 void WebWidgetHost::DiscardBackingStore() { | 
|  145   canvas_.reset(); |  145   canvas_.reset(); | 
|  146 } |  146 } | 
|  147  |  147  | 
|  148 WebWidgetHost::WebWidgetHost() |  148 WebWidgetHost::WebWidgetHost() | 
|  149     : view_(NULL), |  149     : view_(NULL), | 
|  150       webwidget_(NULL), |  150       webwidget_(NULL), | 
|  151       scroll_dx_(0), |  151       scroll_dx_(0), | 
|  152       scroll_dy_(0) { |  152       scroll_dy_(0), | 
 |  153       ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) { | 
|  153   set_painting(false); |  154   set_painting(false); | 
|  154 } |  155 } | 
|  155  |  156  | 
|  156 WebWidgetHost::~WebWidgetHost() { |  157 WebWidgetHost::~WebWidgetHost() { | 
|  157   // app::win::SetWindowUserData(hwnd_, 0); |  158   // app::win::SetWindowUserData(hwnd_, 0); | 
|  158  |  159  | 
|  159   webwidget_->close(); |  160   webwidget_->close(); | 
|  160 } |  161 } | 
|  161  |  162  | 
|  162 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { |  163 void WebWidgetHost::UpdatePaintRect(const gfx::Rect& rect) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
|  176         paint_rect_.width(), paint_rect_.height(), true)); |  177         paint_rect_.width(), paint_rect_.height(), true)); | 
|  177   } |  178   } | 
|  178  |  179  | 
|  179   // make sure webkit draws into our bitmap, not the window |  180   // make sure webkit draws into our bitmap, not the window | 
|  180   CGContextRef bitmap_context = |  181   CGContextRef bitmap_context = | 
|  181       canvas_->getTopPlatformDevice().GetBitmapContext(); |  182       canvas_->getTopPlatformDevice().GetBitmapContext(); | 
|  182   [NSGraphicsContext setCurrentContext: |  183   [NSGraphicsContext setCurrentContext: | 
|  183       [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context |  184       [NSGraphicsContext graphicsContextWithGraphicsPort:bitmap_context | 
|  184                                                  flipped:YES]]; |  185                                                  flipped:YES]]; | 
|  185  |  186  | 
 |  187   webwidget_->animate(); | 
 |  188  | 
|  186   // This may result in more invalidation |  189   // This may result in more invalidation | 
|  187   webwidget_->layout(); |  190   webwidget_->layout(); | 
|  188  |  191  | 
|  189   // Scroll the canvas if necessary |  192   // Scroll the canvas if necessary | 
|  190   scroll_rect_ = client_rect.Intersect(scroll_rect_); |  193   scroll_rect_ = client_rect.Intersect(scroll_rect_); | 
|  191   if (!scroll_rect_.IsEmpty()) { |  194   if (!scroll_rect_.IsEmpty()) { | 
|  192     // add to invalidate rect, since there's no equivalent of ScrollDC. |  195     // add to invalidate rect, since there's no equivalent of ScrollDC. | 
|  193     paint_rect_ = paint_rect_.Union(scroll_rect_); |  196     paint_rect_ = paint_rect_.Union(scroll_rect_); | 
|  194   } |  197   } | 
|  195   ResetScrollRect(); |  198   ResetScrollRect(); | 
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  274 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { |  277 void WebWidgetHost::PaintRect(const gfx::Rect& rect) { | 
|  275 #ifndef NDEBUG |  278 #ifndef NDEBUG | 
|  276   DCHECK(!painting_); |  279   DCHECK(!painting_); | 
|  277 #endif |  280 #endif | 
|  278   DCHECK(canvas_.get()); |  281   DCHECK(canvas_.get()); | 
|  279  |  282  | 
|  280   set_painting(true); |  283   set_painting(true); | 
|  281   webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); |  284   webwidget_->paint(webkit_glue::ToWebCanvas(canvas_.get()), rect); | 
|  282   set_painting(false); |  285   set_painting(false); | 
|  283 } |  286 } | 
| OLD | NEW |