OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Dirk Mueller <mueller@kde.org> | 5 * 2000 Dirk Mueller <mueller@kde.org> |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) | 7 * (C) 2006 Graham Dennis (graham.dennis@gmail.com) |
8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) | 8 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) |
9 * Copyright (C) 2009 Google Inc. All rights reserved. | 9 * Copyright (C) 2009 Google Inc. All rights reserved. |
10 * | 10 * |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 #endif | 173 #endif |
174 m_horizontalScrollbarMode(ScrollbarAuto), | 174 m_horizontalScrollbarMode(ScrollbarAuto), |
175 m_verticalScrollbarMode(ScrollbarAuto), | 175 m_verticalScrollbarMode(ScrollbarAuto), |
176 m_horizontalScrollbarLock(false), | 176 m_horizontalScrollbarLock(false), |
177 m_verticalScrollbarLock(false), | 177 m_verticalScrollbarLock(false), |
178 m_scrollbarsSuppressed(false), | 178 m_scrollbarsSuppressed(false), |
179 m_inUpdateScrollbars(false), | 179 m_inUpdateScrollbars(false), |
180 m_frameTimingRequestsDirty(true), | 180 m_frameTimingRequestsDirty(true), |
181 m_hiddenForThrottling(false), | 181 m_hiddenForThrottling(false), |
182 m_subtreeThrottled(false), | 182 m_subtreeThrottled(false), |
| 183 m_lifecycleUpdatesThrottled(false), |
183 m_currentUpdateLifecyclePhasesTargetState( | 184 m_currentUpdateLifecyclePhasesTargetState( |
184 DocumentLifecycle::Uninitialized), | 185 DocumentLifecycle::Uninitialized), |
185 m_scrollAnchor(this), | 186 m_scrollAnchor(this), |
186 m_scrollbarManager(*this), | 187 m_scrollbarManager(*this), |
187 m_needsScrollbarsUpdate(false), | 188 m_needsScrollbarsUpdate(false), |
188 m_suppressAdjustViewSize(false), | 189 m_suppressAdjustViewSize(false), |
189 m_allowsLayoutInvalidationAfterLayoutClean(true) { | 190 m_allowsLayoutInvalidationAfterLayoutClean(true) { |
190 ASSERT(m_frame); | 191 ASSERT(m_frame); |
191 init(); | 192 init(); |
192 } | 193 } |
(...skipping 27 matching lines...) Expand all Loading... |
220 visitor->trace(m_viewportScrollableArea); | 221 visitor->trace(m_viewportScrollableArea); |
221 visitor->trace(m_visibilityObserver); | 222 visitor->trace(m_visibilityObserver); |
222 visitor->trace(m_scrollAnchor); | 223 visitor->trace(m_scrollAnchor); |
223 visitor->trace(m_anchoringAdjustmentQueue); | 224 visitor->trace(m_anchoringAdjustmentQueue); |
224 visitor->trace(m_scrollbarManager); | 225 visitor->trace(m_scrollbarManager); |
225 Widget::trace(visitor); | 226 Widget::trace(visitor); |
226 ScrollableArea::trace(visitor); | 227 ScrollableArea::trace(visitor); |
227 } | 228 } |
228 | 229 |
229 void FrameView::reset() { | 230 void FrameView::reset() { |
| 231 // The compositor throttles the main frame using deferred commits, we can't |
| 232 // throttle it here or it seems the root compositor doesn't get setup |
| 233 // properly. |
| 234 if (RuntimeEnabledFeatures:: |
| 235 renderingPipelineThrottlingLoadingIframesEnabled()) |
| 236 m_lifecycleUpdatesThrottled = !frame().isMainFrame(); |
230 m_hasPendingLayout = false; | 237 m_hasPendingLayout = false; |
231 m_layoutSchedulingEnabled = true; | 238 m_layoutSchedulingEnabled = true; |
232 m_inSynchronousPostLayout = false; | 239 m_inSynchronousPostLayout = false; |
233 m_layoutCount = 0; | 240 m_layoutCount = 0; |
234 m_nestedLayoutCount = 0; | 241 m_nestedLayoutCount = 0; |
235 m_postLayoutTasksTimer.stop(); | 242 m_postLayoutTasksTimer.stop(); |
236 m_updateWidgetsTimer.stop(); | 243 m_updateWidgetsTimer.stop(); |
237 m_firstLayout = true; | 244 m_firstLayout = true; |
238 m_safeToPropagateScrollToParent = true; | 245 m_safeToPropagateScrollToParent = true; |
239 m_lastViewportSize = IntSize(); | 246 m_lastViewportSize = IntSize(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // frames whose owner element is remote. | 298 // frames whose owner element is remote. |
292 Element* targetElement = frame().deprecatedLocalOwner(); | 299 Element* targetElement = frame().deprecatedLocalOwner(); |
293 if (!targetElement) | 300 if (!targetElement) |
294 return; | 301 return; |
295 | 302 |
296 m_visibilityObserver = new ElementVisibilityObserver( | 303 m_visibilityObserver = new ElementVisibilityObserver( |
297 targetElement, WTF::bind( | 304 targetElement, WTF::bind( |
298 [](FrameView* frameView, bool isVisible) { | 305 [](FrameView* frameView, bool isVisible) { |
299 frameView->updateRenderThrottlingStatus( | 306 frameView->updateRenderThrottlingStatus( |
300 !isVisible, frameView->m_subtreeThrottled); | 307 !isVisible, frameView->m_subtreeThrottled); |
| 308 frameView->maybeRecordLoadReason(); |
301 }, | 309 }, |
302 wrapWeakPersistent(this))); | 310 wrapWeakPersistent(this))); |
303 m_visibilityObserver->start(); | 311 m_visibilityObserver->start(); |
304 } | 312 } |
305 | 313 |
306 void FrameView::dispose() { | 314 void FrameView::dispose() { |
307 RELEASE_ASSERT(!isInPerformLayout()); | 315 RELEASE_ASSERT(!isInPerformLayout()); |
308 | 316 |
309 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 317 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
310 scrollAnimator->cancelAnimation(); | 318 scrollAnimator->cancelAnimation(); |
(...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4433 layoutViewItem.invalidatePaintForViewAndCompositedLayers(); | 4441 layoutViewItem.invalidatePaintForViewAndCompositedLayers(); |
4434 } | 4442 } |
4435 | 4443 |
4436 bool hasHandlers = m_frame->host() && | 4444 bool hasHandlers = m_frame->host() && |
4437 m_frame->host()->eventHandlerRegistry().hasEventHandlers( | 4445 m_frame->host()->eventHandlerRegistry().hasEventHandlers( |
4438 EventHandlerRegistry::TouchStartOrMoveEventBlocking); | 4446 EventHandlerRegistry::TouchStartOrMoveEventBlocking); |
4439 if (wasThrottled != canThrottleRendering() && scrollingCoordinator && | 4447 if (wasThrottled != canThrottleRendering() && scrollingCoordinator && |
4440 hasHandlers) | 4448 hasHandlers) |
4441 scrollingCoordinator->touchEventTargetRectsDidChange(); | 4449 scrollingCoordinator->touchEventTargetRectsDidChange(); |
4442 | 4450 |
| 4451 #if DCHECK_IS_ON() |
| 4452 // Make sure we never have an unthrottled frame inside a throttled one. |
| 4453 FrameView* parent = parentFrameView(); |
| 4454 while (parent) { |
| 4455 DCHECK(canThrottleRendering() || !parent->canThrottleRendering()); |
| 4456 parent = parent->parentFrameView(); |
| 4457 } |
| 4458 #endif |
| 4459 } |
| 4460 |
| 4461 // TODO(esprehn): Rename this and the method on Document to |
| 4462 // recordDeferredLoadReason(). |
| 4463 void FrameView::maybeRecordLoadReason() { |
4443 FrameView* parent = parentFrameView(); | 4464 FrameView* parent = parentFrameView(); |
4444 if (frame().document()->frame()) { | 4465 if (frame().document()->frame()) { |
4445 if (!parent) { | 4466 if (!parent) { |
4446 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); | 4467 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); |
4447 if (!element) | 4468 if (!element) |
4448 frame().document()->maybeRecordLoadReason(WouldLoadOutOfProcess); | 4469 frame().document()->maybeRecordLoadReason(WouldLoadOutOfProcess); |
4449 // Having no layout object means the frame is not drawn. | 4470 // Having no layout object means the frame is not drawn. |
4450 else if (!element->layoutObject()) | 4471 else if (!element->layoutObject()) |
4451 frame().document()->maybeRecordLoadReason(WouldLoadDisplayNone); | 4472 frame().document()->maybeRecordLoadReason(WouldLoadDisplayNone); |
4452 } else { | 4473 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
4463 frame().document()->maybeRecordLoadReason(WouldLoadAboveAndLeft); | 4484 frame().document()->maybeRecordLoadReason(WouldLoadAboveAndLeft); |
4464 else if (frameRect().maxY() < 0) | 4485 else if (frameRect().maxY() < 0) |
4465 frame().document()->maybeRecordLoadReason(WouldLoadAbove); | 4486 frame().document()->maybeRecordLoadReason(WouldLoadAbove); |
4466 else if (frameRect().maxX() < 0) | 4487 else if (frameRect().maxX() < 0) |
4467 frame().document()->maybeRecordLoadReason(WouldLoadLeft); | 4488 frame().document()->maybeRecordLoadReason(WouldLoadLeft); |
4468 else if (!m_hiddenForThrottling) | 4489 else if (!m_hiddenForThrottling) |
4469 frame().document()->maybeRecordLoadReason(WouldLoadVisible); | 4490 frame().document()->maybeRecordLoadReason(WouldLoadVisible); |
4470 } | 4491 } |
4471 } | 4492 } |
4472 } | 4493 } |
4473 | |
4474 #if DCHECK_IS_ON() | |
4475 // Make sure we never have an unthrottled frame inside a throttled one. | |
4476 while (parent) { | |
4477 DCHECK(canThrottleRendering() || !parent->canThrottleRendering()); | |
4478 parent = parent->parentFrameView(); | |
4479 } | |
4480 #endif | |
4481 } | 4494 } |
4482 | 4495 |
4483 bool FrameView::shouldThrottleRendering() const { | 4496 bool FrameView::shouldThrottleRendering() const { |
4484 return canThrottleRendering() && lifecycle().throttlingAllowed(); | 4497 return canThrottleRendering() && lifecycle().throttlingAllowed(); |
4485 } | 4498 } |
4486 | 4499 |
4487 bool FrameView::canThrottleRendering() const { | 4500 bool FrameView::canThrottleRendering() const { |
| 4501 if (m_lifecycleUpdatesThrottled) |
| 4502 return true; |
4488 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4503 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
4489 return false; | 4504 return false; |
4490 // We only throttle the rendering pipeline in cross-origin frames. This is | 4505 if (m_subtreeThrottled) |
4491 // to avoid a situation where an ancestor frame directly depends on the | 4506 return true; |
4492 // pipeline timing of a descendant and breaks as a result of throttling. | 4507 // We only throttle hidden cross-origin frames. This is to avoid a situation |
4493 // The rationale is that cross-origin frames must already communicate with | 4508 // where an ancestor frame directly depends on the pipeline timing of a |
4494 // asynchronous messages, so they should be able to tolerate some delay in | 4509 // descendant and breaks as a result of throttling. The rationale is that |
4495 // receiving replies from a throttled peer. | 4510 // cross-origin frames must already communicate with asynchronous messages, |
4496 return m_subtreeThrottled || | 4511 // so they should be able to tolerate some delay in receiving replies from a |
4497 (m_hiddenForThrottling && m_frame->isCrossOriginSubframe()); | 4512 // throttled peer. |
| 4513 return m_hiddenForThrottling && m_frame->isCrossOriginSubframe(); |
| 4514 } |
| 4515 |
| 4516 void FrameView::beginLifecycleUpdates() { |
| 4517 // Avoid pumping frames for the initially empty document. |
| 4518 if (!frame().loader().stateMachine()->committedFirstRealDocumentLoad()) |
| 4519 return; |
| 4520 m_lifecycleUpdatesThrottled = false; |
| 4521 setupRenderThrottling(); |
| 4522 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled); |
| 4523 // The compositor will "defer commits" for the main frame until we |
| 4524 // explicitly request them. |
| 4525 if (frame().isMainFrame()) |
| 4526 frame().host()->chromeClient().beginLifecycleUpdates(); |
4498 } | 4527 } |
4499 | 4528 |
4500 void FrameView::setInitialViewportSize(const IntSize& viewportSize) { | 4529 void FrameView::setInitialViewportSize(const IntSize& viewportSize) { |
4501 if (viewportSize == m_initialViewportSize) | 4530 if (viewportSize == m_initialViewportSize) |
4502 return; | 4531 return; |
4503 | 4532 |
4504 m_initialViewportSize = viewportSize; | 4533 m_initialViewportSize = viewportSize; |
4505 if (Document* document = m_frame->document()) | 4534 if (Document* document = m_frame->document()) |
4506 document->styleEngine().initialViewportChanged(); | 4535 document->styleEngine().initialViewportChanged(); |
4507 } | 4536 } |
4508 | 4537 |
4509 int FrameView::initialViewportWidth() const { | 4538 int FrameView::initialViewportWidth() const { |
4510 DCHECK(m_frame->isMainFrame()); | 4539 DCHECK(m_frame->isMainFrame()); |
4511 return m_initialViewportSize.width(); | 4540 return m_initialViewportSize.width(); |
4512 } | 4541 } |
4513 | 4542 |
4514 int FrameView::initialViewportHeight() const { | 4543 int FrameView::initialViewportHeight() const { |
4515 DCHECK(m_frame->isMainFrame()); | 4544 DCHECK(m_frame->isMainFrame()); |
4516 return m_initialViewportSize.height(); | 4545 return m_initialViewportSize.height(); |
4517 } | 4546 } |
4518 | 4547 |
4519 } // namespace blink | 4548 } // namespace blink |
OLD | NEW |