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 void FrameView::maybeRecordLoadReason() { | |
ojan
2016/11/08 21:27:06
Nit: I have a pet peeve around putting "maybe" in
esprehn
2016/11/08 22:18:35
Yeah... the code this is calling is already called
| |
4443 FrameView* parent = parentFrameView(); | 4462 FrameView* parent = parentFrameView(); |
4444 if (frame().document()->frame()) { | 4463 if (frame().document()->frame()) { |
4445 if (!parent) { | 4464 if (!parent) { |
4446 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); | 4465 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); |
4447 if (!element) | 4466 if (!element) |
4448 frame().document()->maybeRecordLoadReason(WouldLoadOutOfProcess); | 4467 frame().document()->maybeRecordLoadReason(WouldLoadOutOfProcess); |
4449 // Having no layout object means the frame is not drawn. | 4468 // Having no layout object means the frame is not drawn. |
4450 else if (!element->layoutObject()) | 4469 else if (!element->layoutObject()) |
4451 frame().document()->maybeRecordLoadReason(WouldLoadDisplayNone); | 4470 frame().document()->maybeRecordLoadReason(WouldLoadDisplayNone); |
4452 } else { | 4471 } else { |
(...skipping 10 matching lines...) Expand all Loading... | |
4463 frame().document()->maybeRecordLoadReason(WouldLoadAboveAndLeft); | 4482 frame().document()->maybeRecordLoadReason(WouldLoadAboveAndLeft); |
4464 else if (frameRect().maxY() < 0) | 4483 else if (frameRect().maxY() < 0) |
4465 frame().document()->maybeRecordLoadReason(WouldLoadAbove); | 4484 frame().document()->maybeRecordLoadReason(WouldLoadAbove); |
4466 else if (frameRect().maxX() < 0) | 4485 else if (frameRect().maxX() < 0) |
4467 frame().document()->maybeRecordLoadReason(WouldLoadLeft); | 4486 frame().document()->maybeRecordLoadReason(WouldLoadLeft); |
4468 else if (!m_hiddenForThrottling) | 4487 else if (!m_hiddenForThrottling) |
4469 frame().document()->maybeRecordLoadReason(WouldLoadVisible); | 4488 frame().document()->maybeRecordLoadReason(WouldLoadVisible); |
4470 } | 4489 } |
4471 } | 4490 } |
4472 } | 4491 } |
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 } | 4492 } |
4482 | 4493 |
4483 bool FrameView::shouldThrottleRendering() const { | 4494 bool FrameView::shouldThrottleRendering() const { |
4484 return canThrottleRendering() && lifecycle().throttlingAllowed(); | 4495 return canThrottleRendering() && lifecycle().throttlingAllowed(); |
4485 } | 4496 } |
4486 | 4497 |
4487 bool FrameView::canThrottleRendering() const { | 4498 bool FrameView::canThrottleRendering() const { |
4499 if (m_lifecycleUpdatesThrottled) | |
4500 return true; | |
4488 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) | 4501 if (!RuntimeEnabledFeatures::renderingPipelineThrottlingEnabled()) |
4489 return false; | 4502 return false; |
4490 // We only throttle the rendering pipeline in cross-origin frames. This is | 4503 if (m_subtreeThrottled) |
4491 // to avoid a situation where an ancestor frame directly depends on the | 4504 return true; |
4492 // pipeline timing of a descendant and breaks as a result of throttling. | 4505 // 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 | 4506 // 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 | 4507 // descendant and breaks as a result of throttling. The rationale is that |
4495 // receiving replies from a throttled peer. | 4508 // cross-origin frames must already communicate with asynchronous messages, |
4496 return m_subtreeThrottled || | 4509 // so they should be able to tolerate some delay in receiving replies from a |
4497 (m_hiddenForThrottling && m_frame->isCrossOriginSubframe()); | 4510 // throttled peer. |
4511 return m_hiddenForThrottling && m_frame->isCrossOriginSubframe(); | |
4512 } | |
4513 | |
4514 void FrameView::beginLifecycleUpdates() { | |
4515 // Avoid pumping frames for the initially empty document. | |
4516 if (!frame().loader().stateMachine()->committedFirstRealDocumentLoad()) | |
4517 return; | |
4518 m_lifecycleUpdatesThrottled = false; | |
4519 setupRenderThrottling(); | |
4520 updateRenderThrottlingStatus(m_hiddenForThrottling, m_subtreeThrottled); | |
4521 // The compositor will "defer commits" for the main frame until we | |
4522 // explicitly request them. | |
4523 if (frame().isMainFrame()) | |
4524 frame().host()->chromeClient().beginLifecycleUpdates(); | |
4498 } | 4525 } |
4499 | 4526 |
4500 void FrameView::setInitialViewportSize(const IntSize& viewportSize) { | 4527 void FrameView::setInitialViewportSize(const IntSize& viewportSize) { |
4501 if (viewportSize == m_initialViewportSize) | 4528 if (viewportSize == m_initialViewportSize) |
4502 return; | 4529 return; |
4503 | 4530 |
4504 m_initialViewportSize = viewportSize; | 4531 m_initialViewportSize = viewportSize; |
4505 if (Document* document = m_frame->document()) | 4532 if (Document* document = m_frame->document()) |
4506 document->styleEngine().initialViewportChanged(); | 4533 document->styleEngine().initialViewportChanged(); |
4507 } | 4534 } |
4508 | 4535 |
4509 int FrameView::initialViewportWidth() const { | 4536 int FrameView::initialViewportWidth() const { |
4510 DCHECK(m_frame->isMainFrame()); | 4537 DCHECK(m_frame->isMainFrame()); |
4511 return m_initialViewportSize.width(); | 4538 return m_initialViewportSize.width(); |
4512 } | 4539 } |
4513 | 4540 |
4514 int FrameView::initialViewportHeight() const { | 4541 int FrameView::initialViewportHeight() const { |
4515 DCHECK(m_frame->isMainFrame()); | 4542 DCHECK(m_frame->isMainFrame()); |
4516 return m_initialViewportSize.height(); | 4543 return m_initialViewportSize.height(); |
4517 } | 4544 } |
4518 | 4545 |
4519 } // namespace blink | 4546 } // namespace blink |
OLD | NEW |