| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // During shutdown we can just ignore this message. | 265 // During shutdown we can just ignore this message. |
| 266 if (!webwidget_) | 266 if (!webwidget_) |
| 267 return; | 267 return; |
| 268 | 268 |
| 269 // We shouldn't be asked to resize to our current size. | 269 // We shouldn't be asked to resize to our current size. |
| 270 DCHECK(size_ != new_size || resizer_rect_ != resizer_rect); | 270 DCHECK(size_ != new_size || resizer_rect_ != resizer_rect); |
| 271 | 271 |
| 272 // Remember the rect where the resize corner will be drawn. | 272 // Remember the rect where the resize corner will be drawn. |
| 273 resizer_rect_ = resizer_rect; | 273 resizer_rect_ = resizer_rect; |
| 274 | 274 |
| 275 if (size_ == new_size) | 275 // NOTE: We may have entered fullscreen mode without changing our size. |
| 276 return; | 276 bool fullscreen_change = is_fullscreen_ != is_fullscreen; |
| 277 | 277 if (fullscreen_change) |
| 278 // TODO(darin): We should not need to reset this here. | 278 WillToggleFullscreen(); |
| 279 SetHidden(false); | |
| 280 needs_repainting_on_restore_ = false; | |
| 281 | |
| 282 size_ = new_size; | |
| 283 is_fullscreen_ = is_fullscreen; | 279 is_fullscreen_ = is_fullscreen; |
| 284 | 280 |
| 285 // We should not be sent a Resize message if we have not ACK'd the previous | 281 if (size_ != new_size) { |
| 286 DCHECK(!next_paint_is_resize_ack()); | 282 // TODO(darin): We should not need to reset this here. |
| 283 SetHidden(false); |
| 284 needs_repainting_on_restore_ = false; |
| 287 | 285 |
| 288 paint_aggregator_.ClearPendingUpdate(); | 286 size_ = new_size; |
| 289 | 287 |
| 290 // When resizing, we want to wait to paint before ACK'ing the resize. This | 288 // We should not be sent a Resize message if we have not ACK'd the previous |
| 291 // ensures that we only resize as fast as we can paint. We only need to send | 289 DCHECK(!next_paint_is_resize_ack()); |
| 292 // an ACK if we are resized to a non-empty rect. | 290 |
| 293 webwidget_->resize(new_size); | 291 paint_aggregator_.ClearPendingUpdate(); |
| 294 if (!new_size.IsEmpty()) { | 292 |
| 295 if (!is_accelerated_compositing_active_) { | 293 // When resizing, we want to wait to paint before ACK'ing the resize. This |
| 296 // Resize should have caused an invalidation of the entire view. | 294 // ensures that we only resize as fast as we can paint. We only need to |
| 297 DCHECK(paint_aggregator_.HasPendingUpdate()); | 295 // send an ACK if we are resized to a non-empty rect. |
| 296 webwidget_->resize(new_size); |
| 297 if (!new_size.IsEmpty()) { |
| 298 if (!is_accelerated_compositing_active_) { |
| 299 // Resize should have caused an invalidation of the entire view. |
| 300 DCHECK(paint_aggregator_.HasPendingUpdate()); |
| 301 } |
| 302 |
| 303 // We will send the Resize_ACK flag once we paint again. |
| 304 set_next_paint_is_resize_ack(); |
| 298 } | 305 } |
| 306 } |
| 299 | 307 |
| 300 // We will send the Resize_ACK flag once we paint again. | 308 if (fullscreen_change) |
| 301 set_next_paint_is_resize_ack(); | 309 DidToggleFullscreen(); |
| 302 } | |
| 303 } | 310 } |
| 304 | 311 |
| 305 void RenderWidget::OnWasHidden() { | 312 void RenderWidget::OnWasHidden() { |
| 306 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); | 313 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
| 307 // Go into a mode where we stop generating paint and scrolling events. | 314 // Go into a mode where we stop generating paint and scrolling events. |
| 308 SetHidden(true); | 315 SetHidden(true); |
| 309 } | 316 } |
| 310 | 317 |
| 311 void RenderWidget::OnWasRestored(bool needs_repainting) { | 318 void RenderWidget::OnWasRestored(bool needs_repainting) { |
| 312 TRACE_EVENT0("renderer", "RenderWidget::OnWasRestored"); | 319 TRACE_EVENT0("renderer", "RenderWidget::OnWasRestored"); |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 return; | 1269 return; |
| 1263 | 1270 |
| 1264 // The status has changed. Tell the RenderThread about it. | 1271 // The status has changed. Tell the RenderThread about it. |
| 1265 is_hidden_ = hidden; | 1272 is_hidden_ = hidden; |
| 1266 if (is_hidden_) | 1273 if (is_hidden_) |
| 1267 RenderThread::Get()->WidgetHidden(); | 1274 RenderThread::Get()->WidgetHidden(); |
| 1268 else | 1275 else |
| 1269 RenderThread::Get()->WidgetRestored(); | 1276 RenderThread::Get()->WidgetRestored(); |
| 1270 } | 1277 } |
| 1271 | 1278 |
| 1279 void RenderWidget::WillToggleFullscreen() { |
| 1280 #ifdef WEBKIT_HAS_NEW_FULLSCREEN_API |
| 1281 if (!webwidget_) |
| 1282 return; |
| 1283 |
| 1284 if (is_fullscreen_) { |
| 1285 webwidget_->willExitFullScreen(); |
| 1286 } else { |
| 1287 webwidget_->willEnterFullScreen(); |
| 1288 } |
| 1289 #endif |
| 1290 } |
| 1291 |
| 1292 void RenderWidget::DidToggleFullscreen() { |
| 1293 #ifdef WEBKIT_HAS_NEW_FULLSCREEN_API |
| 1294 if (!webwidget_) |
| 1295 return; |
| 1296 |
| 1297 if (is_fullscreen_) { |
| 1298 webwidget_->didEnterFullScreen(); |
| 1299 } else { |
| 1300 webwidget_->didExitFullScreen(); |
| 1301 } |
| 1302 #endif |
| 1303 } |
| 1304 |
| 1272 void RenderWidget::SetBackground(const SkBitmap& background) { | 1305 void RenderWidget::SetBackground(const SkBitmap& background) { |
| 1273 background_ = background; | 1306 background_ = background; |
| 1274 | 1307 |
| 1275 // Generate a full repaint. | 1308 // Generate a full repaint. |
| 1276 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 1309 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
| 1277 } | 1310 } |
| 1278 | 1311 |
| 1279 bool RenderWidget::next_paint_is_resize_ack() const { | 1312 bool RenderWidget::next_paint_is_resize_ack() const { |
| 1280 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); | 1313 return ViewHostMsg_UpdateRect_Flags::is_resize_ack(next_paint_flags_); |
| 1281 } | 1314 } |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 } | 1461 } |
| 1429 } | 1462 } |
| 1430 | 1463 |
| 1431 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1464 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1432 return false; | 1465 return false; |
| 1433 } | 1466 } |
| 1434 | 1467 |
| 1435 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1468 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1436 return false; | 1469 return false; |
| 1437 } | 1470 } |
| OLD | NEW |