| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/gfx/point.h" | 8 #include "base/gfx/point.h" |
| 9 #include "base/gfx/size.h" | 9 #include "base/gfx/size.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 using WebKit::WebSize; | 43 using WebKit::WebSize; |
| 44 using WebKit::WebTextDirection; | 44 using WebKit::WebTextDirection; |
| 45 | 45 |
| 46 RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) | 46 RenderWidget::RenderWidget(RenderThreadBase* render_thread, bool activatable) |
| 47 : routing_id_(MSG_ROUTING_NONE), | 47 : routing_id_(MSG_ROUTING_NONE), |
| 48 webwidget_(NULL), | 48 webwidget_(NULL), |
| 49 opener_id_(MSG_ROUTING_NONE), | 49 opener_id_(MSG_ROUTING_NONE), |
| 50 render_thread_(render_thread), | 50 render_thread_(render_thread), |
| 51 host_window_(0), | 51 host_window_(0), |
| 52 current_paint_buf_(NULL), | 52 current_paint_buf_(NULL), |
| 53 current_scroll_buf_(NULL), | |
| 54 next_paint_flags_(0), | 53 next_paint_flags_(0), |
| 55 paint_reply_pending_(false), | 54 update_reply_pending_(false), |
| 56 did_show_(false), | 55 did_show_(false), |
| 57 is_hidden_(false), | 56 is_hidden_(false), |
| 58 needs_repainting_on_restore_(false), | 57 needs_repainting_on_restore_(false), |
| 59 has_focus_(false), | 58 has_focus_(false), |
| 60 handling_input_event_(false), | 59 handling_input_event_(false), |
| 61 closing_(false), | 60 closing_(false), |
| 62 ime_is_active_(false), | 61 ime_is_active_(false), |
| 63 ime_control_enable_ime_(true), | 62 ime_control_enable_ime_(true), |
| 64 ime_control_x_(-1), | 63 ime_control_x_(-1), |
| 65 ime_control_y_(-1), | 64 ime_control_y_(-1), |
| 66 ime_control_new_state_(false), | 65 ime_control_new_state_(false), |
| 67 ime_control_updated_(false), | 66 ime_control_updated_(false), |
| 68 ime_control_busy_(false), | 67 ime_control_busy_(false), |
| 69 activatable_(activatable), | 68 activatable_(activatable), |
| 70 pending_window_rect_count_(0), | 69 pending_window_rect_count_(0), |
| 71 suppress_next_char_events_(false) { | 70 suppress_next_char_events_(false) { |
| 72 RenderProcess::current()->AddRefProcess(); | 71 RenderProcess::current()->AddRefProcess(); |
| 73 DCHECK(render_thread_); | 72 DCHECK(render_thread_); |
| 74 } | 73 } |
| 75 | 74 |
| 76 RenderWidget::~RenderWidget() { | 75 RenderWidget::~RenderWidget() { |
| 77 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 76 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 78 if (current_paint_buf_) { | 77 if (current_paint_buf_) { |
| 79 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 78 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
| 80 current_paint_buf_ = NULL; | 79 current_paint_buf_ = NULL; |
| 81 } | 80 } |
| 82 if (current_scroll_buf_) { | |
| 83 RenderProcess::current()->ReleaseTransportDIB(current_scroll_buf_); | |
| 84 current_scroll_buf_ = NULL; | |
| 85 } | |
| 86 RenderProcess::current()->ReleaseProcess(); | 81 RenderProcess::current()->ReleaseProcess(); |
| 87 } | 82 } |
| 88 | 83 |
| 89 /*static*/ | 84 /*static*/ |
| 90 RenderWidget* RenderWidget::Create(int32 opener_id, | 85 RenderWidget* RenderWidget::Create(int32 opener_id, |
| 91 RenderThreadBase* render_thread, | 86 RenderThreadBase* render_thread, |
| 92 bool activatable) { | 87 bool activatable) { |
| 93 DCHECK(opener_id != MSG_ROUTING_NONE); | 88 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 94 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, | 89 scoped_refptr<RenderWidget> widget = new RenderWidget(render_thread, |
| 95 activatable); | 90 activatable); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 130 |
| 136 Send(new ViewHostMsg_RenderViewReady(routing_id_)); | 131 Send(new ViewHostMsg_RenderViewReady(routing_id_)); |
| 137 } | 132 } |
| 138 | 133 |
| 139 IPC_DEFINE_MESSAGE_MAP(RenderWidget) | 134 IPC_DEFINE_MESSAGE_MAP(RenderWidget) |
| 140 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 135 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 141 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 136 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
| 142 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 137 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 143 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 138 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 144 IPC_MESSAGE_HANDLER(ViewMsg_WasRestored, OnWasRestored) | 139 IPC_MESSAGE_HANDLER(ViewMsg_WasRestored, OnWasRestored) |
| 145 IPC_MESSAGE_HANDLER(ViewMsg_PaintRect_ACK, OnPaintRectAck) | 140 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) |
| 146 IPC_MESSAGE_HANDLER(ViewMsg_ScrollRect_ACK, OnScrollRectAck) | |
| 147 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent) | 141 IPC_MESSAGE_HANDLER(ViewMsg_HandleInputEvent, OnHandleInputEvent) |
| 148 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost) | 142 IPC_MESSAGE_HANDLER(ViewMsg_MouseCaptureLost, OnMouseCaptureLost) |
| 149 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus) | 143 IPC_MESSAGE_HANDLER(ViewMsg_SetFocus, OnSetFocus) |
| 150 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetInputMode, OnImeSetInputMode) | 144 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetInputMode, OnImeSetInputMode) |
| 151 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) | 145 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) |
| 152 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint) | 146 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint) |
| 153 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 147 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 154 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 148 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 155 IPC_MESSAGE_UNHANDLED_ERROR() | 149 IPC_MESSAGE_UNHANDLED_ERROR() |
| 156 IPC_END_MESSAGE_MAP() | 150 IPC_END_MESSAGE_MAP() |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 needs_repainting_on_restore_ = false; | 245 needs_repainting_on_restore_ = false; |
| 252 | 246 |
| 253 // Tag the next paint as a restore ack, which is picked up by DoDeferredUpdate | 247 // Tag the next paint as a restore ack, which is picked up by DoDeferredUpdate |
| 254 // when it sends out the next PaintRect message. | 248 // when it sends out the next PaintRect message. |
| 255 set_next_paint_is_restore_ack(); | 249 set_next_paint_is_restore_ack(); |
| 256 | 250 |
| 257 // Generate a full repaint. | 251 // Generate a full repaint. |
| 258 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 252 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
| 259 } | 253 } |
| 260 | 254 |
| 261 void RenderWidget::OnPaintRectAck() { | 255 void RenderWidget::OnRequestMoveAck() { |
| 262 DCHECK(paint_reply_pending()); | 256 DCHECK(pending_window_rect_count_); |
| 263 paint_reply_pending_ = false; | 257 pending_window_rect_count_--; |
| 264 // If we sent a PaintRect message with a zero-sized bitmap, then | 258 } |
| 265 // we should have no current paint buf. | 259 |
| 260 void RenderWidget::OnUpdateRectAck() { |
| 261 DCHECK(update_reply_pending()); |
| 262 update_reply_pending_ = false; |
| 263 |
| 264 // If we sent an UpdateRect message with a zero-sized bitmap, then we should |
| 265 // have no current update buf. |
| 266 if (current_paint_buf_) { | 266 if (current_paint_buf_) { |
| 267 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); | 267 RenderProcess::current()->ReleaseTransportDIB(current_paint_buf_); |
| 268 current_paint_buf_ = NULL; | 268 current_paint_buf_ = NULL; |
| 269 } | 269 } |
| 270 | 270 |
| 271 // Notify subclasses | 271 // Notify subclasses |
| 272 DidPaint(); | 272 DidPaint(); |
| 273 | 273 |
| 274 // Continue painting if necessary... | 274 // Continue painting if necessary... |
| 275 CallDoDeferredUpdate(); | 275 CallDoDeferredUpdate(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void RenderWidget::OnRequestMoveAck() { | |
| 279 DCHECK(pending_window_rect_count_); | |
| 280 pending_window_rect_count_--; | |
| 281 } | |
| 282 | |
| 283 void RenderWidget::OnScrollRectAck() { | |
| 284 DCHECK(scroll_reply_pending()); | |
| 285 | |
| 286 if (current_scroll_buf_) { | |
| 287 RenderProcess::current()->ReleaseTransportDIB(current_scroll_buf_); | |
| 288 current_scroll_buf_ = NULL; | |
| 289 } | |
| 290 | |
| 291 // Continue scrolling if necessary... | |
| 292 CallDoDeferredUpdate(); | |
| 293 } | |
| 294 | |
| 295 void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { | 278 void RenderWidget::OnHandleInputEvent(const IPC::Message& message) { |
| 296 void* iter = NULL; | 279 void* iter = NULL; |
| 297 | 280 |
| 298 const char* data; | 281 const char* data; |
| 299 int data_length; | 282 int data_length; |
| 300 handling_input_event_ = true; | 283 handling_input_event_ = true; |
| 301 if (!message.ReadData(&iter, &data, &data_length)) { | 284 if (!message.ReadData(&iter, &data, &data_length)) { |
| 302 handling_input_event_ = false; | 285 handling_input_event_ = false; |
| 303 return; | 286 return; |
| 304 } | 287 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 canvas->restore(); | 381 canvas->restore(); |
| 399 } | 382 } |
| 400 | 383 |
| 401 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, | 384 void RenderWidget::PaintDebugBorder(const gfx::Rect& rect, |
| 402 skia::PlatformCanvas* canvas) { | 385 skia::PlatformCanvas* canvas) { |
| 403 static bool kPaintBorder = | 386 static bool kPaintBorder = |
| 404 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); | 387 CommandLine::ForCurrentProcess()->HasSwitch(switches::kShowPaintRects); |
| 405 if (!kPaintBorder) | 388 if (!kPaintBorder) |
| 406 return; | 389 return; |
| 407 | 390 |
| 391 // Cycle through these colors to help distinguish new paint rects. |
| 392 const SkColor colors[] = { |
| 393 SkColorSetARGB(0x3F, 0xFF, 0, 0), |
| 394 SkColorSetARGB(0x3F, 0xFF, 0, 0xFF), |
| 395 SkColorSetARGB(0x3F, 0, 0, 0xFF), |
| 396 }; |
| 397 static int color_selector = 0; |
| 398 |
| 408 SkPaint paint; | 399 SkPaint paint; |
| 409 paint.setStyle(SkPaint::kStroke_Style); | 400 paint.setStyle(SkPaint::kStroke_Style); |
| 410 paint.setColor(SkColorSetARGB(0x3F, 0xFF, 0, 0)); | 401 paint.setColor(colors[color_selector++ % arraysize(colors)]); |
| 411 paint.setStrokeWidth(1); | 402 paint.setStrokeWidth(1); |
| 412 | 403 |
| 413 SkIRect irect; | 404 SkIRect irect; |
| 414 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); | 405 irect.set(rect.x(), rect.y(), rect.right() - 1, rect.bottom() - 1); |
| 415 canvas->drawIRect(irect, paint); | 406 canvas->drawIRect(irect, paint); |
| 416 } | 407 } |
| 417 | 408 |
| 418 void RenderWidget::CallDoDeferredUpdate() { | 409 void RenderWidget::CallDoDeferredUpdate() { |
| 419 DoDeferredUpdate(); | 410 DoDeferredUpdate(); |
| 420 | 411 |
| 421 if (pending_input_event_ack_.get()) { | 412 if (pending_input_event_ack_.get()) { |
| 422 Send(pending_input_event_ack_.get()); | 413 Send(pending_input_event_ack_.get()); |
| 423 pending_input_event_ack_.release(); | 414 pending_input_event_ack_.release(); |
| 424 } | 415 } |
| 425 } | 416 } |
| 426 | 417 |
| 427 void RenderWidget::DoDeferredUpdate() { | 418 void RenderWidget::DoDeferredUpdate() { |
| 428 if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() || | 419 if (!webwidget_ || !paint_aggregator_.HasPendingUpdate() || |
| 429 paint_reply_pending() || scroll_reply_pending()) | 420 update_reply_pending()) |
| 430 return; | 421 return; |
| 431 | 422 |
| 432 // Suppress updating when we are hidden. | 423 // Suppress updating when we are hidden. |
| 433 if (is_hidden_ || size_.IsEmpty()) { | 424 if (is_hidden_ || size_.IsEmpty()) { |
| 434 paint_aggregator_.ClearPendingUpdate(); | 425 paint_aggregator_.ClearPendingUpdate(); |
| 435 needs_repainting_on_restore_ = true; | 426 needs_repainting_on_restore_ = true; |
| 436 return; | 427 return; |
| 437 } | 428 } |
| 438 | 429 |
| 439 // Layout may generate more invalidation. | 430 // Layout may generate more invalidation. |
| 440 webwidget_->layout(); | 431 webwidget_->layout(); |
| 441 | 432 |
| 442 // OK, save the pending update to a local since painting may cause more | 433 // OK, save the pending update to a local since painting may cause more |
| 443 // invalidation. Some WebCore rendering objects only layout when painted. | 434 // invalidation. Some WebCore rendering objects only layout when painted. |
| 444 PaintAggregator::PendingUpdate update = paint_aggregator_.GetPendingUpdate(); | 435 PaintAggregator::PendingUpdate update = paint_aggregator_.GetPendingUpdate(); |
| 445 paint_aggregator_.ClearPendingUpdate(); | 436 paint_aggregator_.ClearPendingUpdate(); |
| 446 | 437 |
| 447 if (!update.scroll_rect.IsEmpty()) { | 438 gfx::Rect scroll_damage = update.GetScrollDamage(); |
| 448 // Optmized scrolling | 439 gfx::Rect bounds = update.GetPaintBounds().Union(scroll_damage); |
| 449 | 440 |
| 450 // Compute the region we will expose by scrolling, and paint that into a | 441 // Compute a buffer for painting and cache it. |
| 451 // shared memory section. | 442 scoped_ptr<skia::PlatformCanvas> canvas( |
| 452 gfx::Rect damaged_rect = update.GetScrollDamage(); | 443 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, bounds)); |
| 453 | 444 if (!canvas.get()) { |
| 454 scoped_ptr<skia::PlatformCanvas> canvas( | 445 NOTREACHED(); |
| 455 RenderProcess::current()->GetDrawingCanvas(¤t_scroll_buf_, | 446 return; |
| 456 damaged_rect)); | |
| 457 if (!canvas.get()) { | |
| 458 NOTREACHED(); | |
| 459 return; | |
| 460 } | |
| 461 | |
| 462 // We may get back a smaller canvas than we asked for. | |
| 463 damaged_rect.set_width(canvas->getDevice()->width()); | |
| 464 damaged_rect.set_height(canvas->getDevice()->height()); | |
| 465 | |
| 466 // Set these parameters before calling Paint, since that could result in | |
| 467 // further invalidates (uncommon). | |
| 468 ViewHostMsg_ScrollRect_Params params; | |
| 469 params.bitmap_rect = damaged_rect; | |
| 470 params.dx = update.scroll_delta.x(); | |
| 471 params.dy = update.scroll_delta.y(); | |
| 472 params.clip_rect = update.scroll_rect; | |
| 473 params.view_size = size_; | |
| 474 params.plugin_window_moves = plugin_window_moves_; | |
| 475 params.bitmap = current_scroll_buf_->id(); | |
| 476 | |
| 477 plugin_window_moves_.clear(); | |
| 478 | |
| 479 PaintRect(damaged_rect, damaged_rect.origin(), canvas.get()); | |
| 480 Send(new ViewHostMsg_ScrollRect(routing_id_, params)); | |
| 481 } | 447 } |
| 482 | 448 |
| 483 if (!update.paint_rects.empty()) { | 449 // We may get back a smaller canvas than we asked for. |
| 484 // Normal painting | 450 // TODO(darin): This seems like it could cause painting problems! |
| 451 DCHECK_EQ(bounds.width(), canvas->getDevice()->width()); |
| 452 DCHECK_EQ(bounds.height(), canvas->getDevice()->height()); |
| 453 bounds.set_width(canvas->getDevice()->width()); |
| 454 bounds.set_height(canvas->getDevice()->height()); |
| 485 | 455 |
| 486 gfx::Rect bounds = update.GetPaintBounds(); | 456 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size()); |
| 487 | 457 |
| 488 // Compute a buffer for painting and cache it. | 458 // The scroll damage is just another rectangle to paint and copy. |
| 489 scoped_ptr<skia::PlatformCanvas> canvas( | 459 std::vector<gfx::Rect> copy_rects; |
| 490 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 460 copy_rects.swap(update.paint_rects); |
| 491 bounds)); | 461 if (!scroll_damage.IsEmpty()) |
| 492 if (!canvas.get()) { | 462 copy_rects.push_back(scroll_damage); |
| 493 NOTREACHED(); | |
| 494 return; | |
| 495 } | |
| 496 | 463 |
| 497 // We may get back a smaller canvas than we asked for. | 464 // TODO(darin): Re-enable painting multiple damage rects once the |
| 498 bounds.set_width(canvas->getDevice()->width()); | 465 // page-cycler regressions are resolved. See bug 29589. |
| 499 bounds.set_height(canvas->getDevice()->height()); | 466 if (update.scroll_rect.IsEmpty()) { |
| 467 update.paint_rects.clear(); |
| 468 update.paint_rects.push_back(bounds); |
| 469 } |
| 500 | 470 |
| 501 HISTOGRAM_COUNTS_100("MPArch.RW_PaintRectCount", update.paint_rects.size()); | 471 for (size_t i = 0; i < copy_rects.size(); ++i) |
| 472 PaintRect(copy_rects[i], bounds.origin(), canvas.get()); |
| 502 | 473 |
| 503 // TODO(darin): Re-enable painting multiple damage rects once the | 474 ViewHostMsg_UpdateRect_Params params; |
| 504 // page-cycler regressions are resolved. See bug 29589. | 475 params.bitmap = current_paint_buf_->id(); |
| 505 if (update.scroll_rect.IsEmpty()) { | 476 params.bitmap_rect = bounds; |
| 506 update.paint_rects.clear(); | 477 params.dx = update.scroll_delta.x(); |
| 507 update.paint_rects.push_back(bounds); | 478 params.dy = update.scroll_delta.y(); |
| 508 } | 479 params.scroll_rect = update.scroll_rect; |
| 480 params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds? |
| 481 params.view_size = size_; |
| 482 params.plugin_window_moves.swap(plugin_window_moves_); |
| 483 params.flags = next_paint_flags_; |
| 509 | 484 |
| 510 for (size_t i = 0; i < update.paint_rects.size(); ++i) | 485 update_reply_pending_ = true; |
| 511 PaintRect(update.paint_rects[i], bounds.origin(), canvas.get()); | 486 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
| 512 | 487 next_paint_flags_ = 0; |
| 513 ViewHostMsg_PaintRect_Params params; | |
| 514 params.bitmap_rect = bounds; | |
| 515 params.update_rects = update.paint_rects; // TODO(darin): clip to bounds? | |
| 516 params.view_size = size_; | |
| 517 params.plugin_window_moves = plugin_window_moves_; | |
| 518 params.flags = next_paint_flags_; | |
| 519 params.bitmap = current_paint_buf_->id(); | |
| 520 | |
| 521 plugin_window_moves_.clear(); | |
| 522 | |
| 523 paint_reply_pending_ = true; | |
| 524 Send(new ViewHostMsg_PaintRect(routing_id_, params)); | |
| 525 next_paint_flags_ = 0; | |
| 526 } | |
| 527 | 488 |
| 528 UpdateIME(); | 489 UpdateIME(); |
| 529 } | 490 } |
| 530 | 491 |
| 531 /////////////////////////////////////////////////////////////////////////////// | 492 /////////////////////////////////////////////////////////////////////////////// |
| 532 // WebWidgetDelegate | 493 // WebWidgetDelegate |
| 533 | 494 |
| 534 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 495 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
| 535 // We only want one pending DoDeferredUpdate call at any time... | 496 // We only want one pending DoDeferredUpdate call at any time... |
| 536 bool update_pending = paint_aggregator_.HasPendingUpdate(); | 497 bool update_pending = paint_aggregator_.HasPendingUpdate(); |
| 537 | 498 |
| 538 // The invalidated rect might be outside the bounds of the view. | 499 // The invalidated rect might be outside the bounds of the view. |
| 539 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); | 500 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); |
| 540 gfx::Rect damaged_rect = view_rect.Intersect(rect); | 501 gfx::Rect damaged_rect = view_rect.Intersect(rect); |
| 541 if (damaged_rect.IsEmpty()) | 502 if (damaged_rect.IsEmpty()) |
| 542 return; | 503 return; |
| 543 | 504 |
| 544 paint_aggregator_.InvalidateRect(damaged_rect); | 505 paint_aggregator_.InvalidateRect(damaged_rect); |
| 545 | 506 |
| 546 // We may not need to schedule another call to DoDeferredUpdate. | 507 // We may not need to schedule another call to DoDeferredUpdate. |
| 547 if (update_pending) | 508 if (update_pending) |
| 548 return; | 509 return; |
| 549 if (!paint_aggregator_.HasPendingUpdate()) | 510 if (!paint_aggregator_.HasPendingUpdate()) |
| 550 return; | 511 return; |
| 551 if (paint_reply_pending() || scroll_reply_pending()) | 512 if (update_reply_pending()) |
| 552 return; | 513 return; |
| 553 | 514 |
| 554 // Perform updating asynchronously. This serves two purposes: | 515 // Perform updating asynchronously. This serves two purposes: |
| 555 // 1) Ensures that we call WebView::Paint without a bunch of other junk | 516 // 1) Ensures that we call WebView::Paint without a bunch of other junk |
| 556 // on the call stack. | 517 // on the call stack. |
| 557 // 2) Allows us to collect more damage rects before painting to help coalesce | 518 // 2) Allows us to collect more damage rects before painting to help coalesce |
| 558 // the work that we will need to do. | 519 // the work that we will need to do. |
| 559 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 520 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| 560 this, &RenderWidget::CallDoDeferredUpdate)); | 521 this, &RenderWidget::CallDoDeferredUpdate)); |
| 561 } | 522 } |
| 562 | 523 |
| 563 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { | 524 void RenderWidget::didScrollRect(int dx, int dy, const WebRect& clip_rect) { |
| 564 // We only want one pending DoDeferredUpdate call at any time... | 525 // We only want one pending DoDeferredUpdate call at any time... |
| 565 bool update_pending = paint_aggregator_.HasPendingUpdate(); | 526 bool update_pending = paint_aggregator_.HasPendingUpdate(); |
| 566 | 527 |
| 567 // The scrolled rect might be outside the bounds of the view. | 528 // The scrolled rect might be outside the bounds of the view. |
| 568 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); | 529 gfx::Rect view_rect(0, 0, size_.width(), size_.height()); |
| 569 gfx::Rect damaged_rect = view_rect.Intersect(clip_rect); | 530 gfx::Rect damaged_rect = view_rect.Intersect(clip_rect); |
| 570 if (damaged_rect.IsEmpty()) | 531 if (damaged_rect.IsEmpty()) |
| 571 return; | 532 return; |
| 572 | 533 |
| 573 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); | 534 paint_aggregator_.ScrollRect(dx, dy, damaged_rect); |
| 574 | 535 |
| 575 // We may not need to schedule another call to DoDeferredUpdate. | 536 // We may not need to schedule another call to DoDeferredUpdate. |
| 576 if (update_pending) | 537 if (update_pending) |
| 577 return; | 538 return; |
| 578 if (!paint_aggregator_.HasPendingUpdate()) | 539 if (!paint_aggregator_.HasPendingUpdate()) |
| 579 return; | 540 return; |
| 580 if (paint_reply_pending() || scroll_reply_pending()) | 541 if (update_reply_pending()) |
| 581 return; | 542 return; |
| 582 | 543 |
| 583 // Perform updating asynchronously. This serves two purposes: | 544 // Perform updating asynchronously. This serves two purposes: |
| 584 // 1) Ensures that we call WebView::Paint without a bunch of other junk | 545 // 1) Ensures that we call WebView::Paint without a bunch of other junk |
| 585 // on the call stack. | 546 // on the call stack. |
| 586 // 2) Allows us to collect more damage rects before painting to help coalesce | 547 // 2) Allows us to collect more damage rects before painting to help coalesce |
| 587 // the work that we will need to do. | 548 // the work that we will need to do. |
| 588 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 549 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| 589 this, &RenderWidget::CallDoDeferredUpdate)); | 550 this, &RenderWidget::CallDoDeferredUpdate)); |
| 590 } | 551 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 render_thread_->WidgetRestored(); | 727 render_thread_->WidgetRestored(); |
| 767 } | 728 } |
| 768 | 729 |
| 769 void RenderWidget::SetBackground(const SkBitmap& background) { | 730 void RenderWidget::SetBackground(const SkBitmap& background) { |
| 770 background_ = background; | 731 background_ = background; |
| 771 // Generate a full repaint. | 732 // Generate a full repaint. |
| 772 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 733 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
| 773 } | 734 } |
| 774 | 735 |
| 775 bool RenderWidget::next_paint_is_resize_ack() const { | 736 bool RenderWidget::next_paint_is_resize_ack() const { |
| 776 return ViewHostMsg_PaintRect_Flags::is_resize_ack(next_paint_flags_); | 737 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); |
| 777 } | 738 } |
| 778 | 739 |
| 779 bool RenderWidget::next_paint_is_restore_ack() const { | 740 bool RenderWidget::next_paint_is_restore_ack() const { |
| 780 return ViewHostMsg_PaintRect_Flags::is_restore_ack(next_paint_flags_); | 741 return ViewHostMsg_UpdateRect_Flags::is_restore_ack(next_paint_flags_); |
| 781 } | 742 } |
| 782 | 743 |
| 783 void RenderWidget::set_next_paint_is_resize_ack() { | 744 void RenderWidget::set_next_paint_is_resize_ack() { |
| 784 next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK; | 745 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESIZE_ACK; |
| 785 } | 746 } |
| 786 | 747 |
| 787 void RenderWidget::set_next_paint_is_restore_ack() { | 748 void RenderWidget::set_next_paint_is_restore_ack() { |
| 788 next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_RESTORE_ACK; | 749 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_RESTORE_ACK; |
| 789 } | 750 } |
| 790 | 751 |
| 791 void RenderWidget::set_next_paint_is_repaint_ack() { | 752 void RenderWidget::set_next_paint_is_repaint_ack() { |
| 792 next_paint_flags_ |= ViewHostMsg_PaintRect_Flags::IS_REPAINT_ACK; | 753 next_paint_flags_ |= ViewHostMsg_UpdateRect_Flags::IS_REPAINT_ACK; |
| 793 } | 754 } |
| 794 | 755 |
| 795 void RenderWidget::UpdateIME() { | 756 void RenderWidget::UpdateIME() { |
| 796 // If a browser process does not have IMEs, its IMEs are not active, or there | 757 // If a browser process does not have IMEs, its IMEs are not active, or there |
| 797 // are not any attached widgets. | 758 // are not any attached widgets. |
| 798 // a renderer process does not have to retrieve information of the focused | 759 // a renderer process does not have to retrieve information of the focused |
| 799 // control or send notification messages to a browser process. | 760 // control or send notification messages to a browser process. |
| 800 if (!ime_is_active_) { | 761 if (!ime_is_active_) { |
| 801 return; | 762 return; |
| 802 } | 763 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 850 |
| 890 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 851 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
| 891 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 852 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
| 892 i != plugin_window_moves_.end(); ++i) { | 853 i != plugin_window_moves_.end(); ++i) { |
| 893 if (i->window == window) { | 854 if (i->window == window) { |
| 894 plugin_window_moves_.erase(i); | 855 plugin_window_moves_.erase(i); |
| 895 break; | 856 break; |
| 896 } | 857 } |
| 897 } | 858 } |
| 898 } | 859 } |
| OLD | NEW |