| 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 "chrome/renderer/render_widget.h" | 5 #include "chrome/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "app/surface/transport_dib.h" | 7 #include "app/surface/transport_dib.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 DCHECK(opener_id != MSG_ROUTING_NONE); | 96 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 97 scoped_refptr<RenderWidget> widget(new RenderWidget(render_thread, | 97 scoped_refptr<RenderWidget> widget(new RenderWidget(render_thread, |
| 98 popup_type)); | 98 popup_type)); |
| 99 widget->Init(opener_id); // adds reference | 99 widget->Init(opener_id); // adds reference |
| 100 return widget; | 100 return widget; |
| 101 } | 101 } |
| 102 | 102 |
| 103 // static | 103 // static |
| 104 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 104 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
| 105 switch (render_widget->popup_type_) { | 105 switch (render_widget->popup_type_) { |
| 106 case WebKit::WebPopupTypeNone: // Nothing to create. | 106 case WebKit::WebPopupTypeNone: // Nothing to create. |
| 107 break; | 107 break; |
| 108 case WebKit::WebPopupTypeSelect: | 108 case WebKit::WebPopupTypeSelect: |
| 109 case WebKit::WebPopupTypeSuggestion: | 109 case WebKit::WebPopupTypeSuggestion: |
| 110 return WebPopupMenu::create(render_widget); | 110 return WebPopupMenu::create(render_widget); |
| 111 default: | 111 default: |
| 112 NOTREACHED(); | 112 NOTREACHED(); |
| 113 } | 113 } |
| 114 return NULL; | 114 return NULL; |
| 115 } | 115 } |
| 116 | 116 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 // Balances the AddRef taken when we called AddRoute. | 225 // Balances the AddRef taken when we called AddRoute. |
| 226 Release(); | 226 Release(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void RenderWidget::OnResize(const gfx::Size& new_size, | 229 void RenderWidget::OnResize(const gfx::Size& new_size, |
| 230 const gfx::Rect& resizer_rect) { | 230 const gfx::Rect& resizer_rect) { |
| 231 // During shutdown we can just ignore this message. | 231 // During shutdown we can just ignore this message. |
| 232 if (!webwidget_) | 232 if (!webwidget_) |
| 233 return; | 233 return; |
| 234 | 234 |
| 235 // We shouldn't be asked to resize to our current size. |
| 236 DCHECK(size_ != new_size || resizer_rect_ != resizer_rect); |
| 237 |
| 235 // Remember the rect where the resize corner will be drawn. | 238 // Remember the rect where the resize corner will be drawn. |
| 236 resizer_rect_ = resizer_rect; | 239 resizer_rect_ = resizer_rect; |
| 237 | 240 |
| 241 if (size_ == new_size) |
| 242 return; |
| 243 |
| 238 // TODO(darin): We should not need to reset this here. | 244 // TODO(darin): We should not need to reset this here. |
| 239 SetHidden(false); | 245 SetHidden(false); |
| 240 needs_repainting_on_restore_ = false; | 246 needs_repainting_on_restore_ = false; |
| 241 | 247 |
| 242 // We shouldn't be asked to resize to our current size. | |
| 243 DCHECK(size_ != new_size); | |
| 244 size_ = new_size; | 248 size_ = new_size; |
| 245 | 249 |
| 246 // We should not be sent a Resize message if we have not ACK'd the previous | 250 // We should not be sent a Resize message if we have not ACK'd the previous |
| 247 DCHECK(!next_paint_is_resize_ack()); | 251 DCHECK(!next_paint_is_resize_ack()); |
| 248 | 252 |
| 249 paint_aggregator_.ClearPendingUpdate(); | 253 paint_aggregator_.ClearPendingUpdate(); |
| 250 | 254 |
| 251 // When resizing, we want to wait to paint before ACK'ing the resize. This | 255 // When resizing, we want to wait to paint before ACK'ing the resize. This |
| 252 // ensures that we only resize as fast as we can paint. We only need to send | 256 // ensures that we only resize as fast as we can paint. We only need to send |
| 253 // an ACK if we are resized to a non-empty rect. | 257 // an ACK if we are resized to a non-empty rect. |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (is_gpu_rendering_active_) { | 562 if (is_gpu_rendering_active_) { |
| 559 // If painting is done via the gpu process then we clear out all damage | 563 // If painting is done via the gpu process then we clear out all damage |
| 560 // rects to save the browser process from doing unecessary work. | 564 // rects to save the browser process from doing unecessary work. |
| 561 params.scroll_rect = gfx::Rect(); | 565 params.scroll_rect = gfx::Rect(); |
| 562 params.copy_rects.clear(); | 566 params.copy_rects.clear(); |
| 563 } else { | 567 } else { |
| 564 params.scroll_rect = update.scroll_rect; | 568 params.scroll_rect = update.scroll_rect; |
| 565 params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds? | 569 params.copy_rects.swap(copy_rects); // TODO(darin): clip to bounds? |
| 566 } | 570 } |
| 567 params.view_size = size_; | 571 params.view_size = size_; |
| 572 params.resizer_rect = resizer_rect_; |
| 568 params.plugin_window_moves.swap(plugin_window_moves_); | 573 params.plugin_window_moves.swap(plugin_window_moves_); |
| 569 params.flags = next_paint_flags_; | 574 params.flags = next_paint_flags_; |
| 570 | 575 |
| 571 update_reply_pending_ = true; | 576 update_reply_pending_ = true; |
| 572 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 577 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
| 573 next_paint_flags_ = 0; | 578 next_paint_flags_ = 0; |
| 574 | 579 |
| 575 UpdateInputMethod(); | 580 UpdateInputMethod(); |
| 576 | 581 |
| 577 // Let derived classes know we've painted. | 582 // Let derived classes know we've painted. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 this, &RenderWidget::CallDoDeferredUpdate)); | 659 this, &RenderWidget::CallDoDeferredUpdate)); |
| 655 } | 660 } |
| 656 | 661 |
| 657 void RenderWidget::scheduleComposite() { | 662 void RenderWidget::scheduleComposite() { |
| 658 // TODO(nduca): replace with something a little less hacky. The reason this | 663 // TODO(nduca): replace with something a little less hacky. The reason this |
| 659 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 664 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
| 660 // contains a lot of host-renderer synchronization logic that is still | 665 // contains a lot of host-renderer synchronization logic that is still |
| 661 // important for the accelerated compositing case. The option of simply | 666 // important for the accelerated compositing case. The option of simply |
| 662 // duplicating all that code is less desirable than "faking out" the | 667 // duplicating all that code is less desirable than "faking out" the |
| 663 // invalidation path using a magical damage rect. | 668 // invalidation path using a magical damage rect. |
| 664 didInvalidateRect(WebRect(0,0,1,1)); | 669 didInvalidateRect(WebRect(0, 0, 1, 1)); |
| 665 } | 670 } |
| 666 | 671 |
| 667 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { | 672 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { |
| 668 // TODO(darin): Eliminate this temporary. | 673 // TODO(darin): Eliminate this temporary. |
| 669 WebCursor cursor(cursor_info); | 674 WebCursor cursor(cursor_info); |
| 670 | 675 |
| 671 // Only send a SetCursor message if we need to make a change. | 676 // Only send a SetCursor message if we need to make a change. |
| 672 if (!current_cursor_.IsEqual(cursor)) { | 677 if (!current_cursor_.IsEqual(cursor)) { |
| 673 current_cursor_ = cursor; | 678 current_cursor_ = cursor; |
| 674 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); | 679 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 | 1014 |
| 1010 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { | 1015 void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { |
| 1011 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); | 1016 for (WebPluginGeometryVector::iterator i = plugin_window_moves_.begin(); |
| 1012 i != plugin_window_moves_.end(); ++i) { | 1017 i != plugin_window_moves_.end(); ++i) { |
| 1013 if (i->window == window) { | 1018 if (i->window == window) { |
| 1014 plugin_window_moves_.erase(i); | 1019 plugin_window_moves_.erase(i); |
| 1015 break; | 1020 break; |
| 1016 } | 1021 } |
| 1017 } | 1022 } |
| 1018 } | 1023 } |
| OLD | NEW |