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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 506013: Combine ViewHostMsg_{Paint,Scroll}Rect into one IPC.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years 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
OLDNEW
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 "chrome/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #import "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // origin is the upper-left corner of this view. On the other hand, Cocoa 268 // origin is the upper-left corner of this view. On the other hand, Cocoa
269 // uses a coordinate system whose origin is the lower-left corner of this 269 // uses a coordinate system whose origin is the lower-left corner of this
270 // view. So, we convert the cursor rectangle and save it. 270 // view. So, we convert the cursor rectangle and save it.
271 NSRect view_rect = [cocoa_view_ bounds]; 271 NSRect view_rect = [cocoa_view_ bounds];
272 const int y_offset = static_cast<int>(view_rect.size.height); 272 const int y_offset = static_cast<int>(view_rect.size.height);
273 im_caret_rect_ = NSMakeRect(caret_rect.x(), 273 im_caret_rect_ = NSMakeRect(caret_rect.x(),
274 y_offset - caret_rect.y() - caret_rect.height(), 274 y_offset - caret_rect.y() - caret_rect.height(),
275 caret_rect.width(), caret_rect.height()); 275 caret_rect.width(), caret_rect.height());
276 } 276 }
277 277
278 void RenderWidgetHostViewMac::DidPaintRect(const gfx::Rect& rect) { 278 void RenderWidgetHostViewMac::DidPaintBackingStoreRects(
279 const std::vector<gfx::Rect>& rects) {
279 if (is_hidden_) 280 if (is_hidden_)
280 return; 281 return;
281 282
282 NSRect ns_rect = [cocoa_view_ RectToNSRect:rect]; 283 for (size_t i = 0; i < rects.size(); ++i) {
284 NSRect ns_rect = [cocoa_view_ RectToNSRect:rects[i]];
283 285
284 if (about_to_validate_and_paint_) { 286 if (about_to_validate_and_paint_) {
285 // As much as we'd like to use -setNeedsDisplayInRect: here, we can't. We're 287 // As much as we'd like to use -setNeedsDisplayInRect: here, we can't.
286 // in the middle of executing a -drawRect:, and as soon as it returns Cocoa 288 // We're in the middle of executing a -drawRect:, and as soon as it
287 // will clear its record of what needs display. If we want to handle the 289 // returns Cocoa will clear its record of what needs display. If we want
288 // recursive drawing, we need to do it ourselves. 290 // to handle the recursive drawing, we need to do it ourselves.
289 invalid_rect_ = NSUnionRect(invalid_rect_, ns_rect); 291 invalid_rect_ = NSUnionRect(invalid_rect_, ns_rect);
290 } else { 292 } else {
291 [cocoa_view_ setNeedsDisplayInRect:ns_rect]; 293 [cocoa_view_ setNeedsDisplayInRect:ns_rect];
294 }
295 }
296
297 if (!about_to_validate_and_paint_)
292 [cocoa_view_ displayIfNeeded]; 298 [cocoa_view_ displayIfNeeded];
293 }
294 } 299 }
295 300
296 void RenderWidgetHostViewMac::DidScrollRect( 301 void RenderWidgetHostViewMac::DidScrollBackingStoreRect(const gfx::Rect& rect,
297 const gfx::Rect& rect, int dx, int dy) { 302 int dx, int dy) {
298 if (is_hidden_) 303 if (is_hidden_)
299 return; 304 return;
300 305
301 // We've already modified the BackingStore to reflect the scroll, so 306 // We've already modified the BackingStore to reflect the scroll, so
302 // simply ask the RWHVCocoa to redraw itself based on the new 307 // simply ask the RWHVCocoa to redraw itself based on the new
303 // pixels. We cannot use -[NSView scrollRect:by:] here because the 308 // pixels. We cannot use -[NSView scrollRect:by:] here because the
304 // findbar and blocked popups will leave trails behind. 309 // findbar and blocked popups will leave trails behind.
305 // TODO(rohitrao): Evaluate how slow this full redraw is. If it 310 // TODO(rohitrao): Evaluate how slow this full redraw is. If it
306 // turns out to be a problem, consider scrolling only a portion of 311 // turns out to be a problem, consider scrolling only a portion of
307 // the view, based on where the findbar and blocked popups are. 312 // the view, based on where the findbar and blocked popups are.
308 DidPaintRect(rect); 313 DidPaintBackingStoreRects(std::vector<gfx::Rect>(1, rect));
309 } 314 }
310 315
311 void RenderWidgetHostViewMac::RenderViewGone() { 316 void RenderWidgetHostViewMac::RenderViewGone() {
312 // TODO(darin): keep this around, and draw sad-tab into it. 317 // TODO(darin): keep this around, and draw sad-tab into it.
313 UpdateCursorIfOverSelf(); 318 UpdateCursorIfOverSelf();
314 Destroy(); 319 Destroy();
315 } 320 }
316 321
317 void RenderWidgetHostViewMac::Destroy() { 322 void RenderWidgetHostViewMac::Destroy() {
318 // On Windows, popups are implemented with a popup window style, so that when 323 // On Windows, popups are implemented with a popup window style, so that when
(...skipping 1062 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 event.skip_in_browser = true; 1386 event.skip_in_browser = true;
1382 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); 1387 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event);
1383 } else { 1388 } else {
1384 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( 1389 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition(
1385 UTF8ToUTF16([im_text UTF8String])); 1390 UTF8ToUTF16([im_text UTF8String]));
1386 } 1391 }
1387 renderWidgetHostView_->im_composing_ = false; 1392 renderWidgetHostView_->im_composing_ = false;
1388 } 1393 }
1389 1394
1390 @end 1395 @end
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/renderer_host/render_widget_host_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698