| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 #include "platform/scroll/ScrollAnimatorBase.h" | 118 #include "platform/scroll/ScrollAnimatorBase.h" |
| 119 #include "platform/scroll/ScrollbarTheme.h" | 119 #include "platform/scroll/ScrollbarTheme.h" |
| 120 #include "platform/text/TextStream.h" | 120 #include "platform/text/TextStream.h" |
| 121 #include "platform/tracing/TraceEvent.h" | 121 #include "platform/tracing/TraceEvent.h" |
| 122 #include "platform/tracing/TracedValue.h" | 122 #include "platform/tracing/TracedValue.h" |
| 123 #include "public/platform/WebDisplayItemList.h" | 123 #include "public/platform/WebDisplayItemList.h" |
| 124 #include "public/platform/WebFrameScheduler.h" | 124 #include "public/platform/WebFrameScheduler.h" |
| 125 #include "wtf/CurrentTime.h" | 125 #include "wtf/CurrentTime.h" |
| 126 #include "wtf/PtrUtil.h" | 126 #include "wtf/PtrUtil.h" |
| 127 #include "wtf/StdLibExtras.h" | 127 #include "wtf/StdLibExtras.h" |
| 128 #include <algorithm> |
| 128 #include <memory> | 129 #include <memory> |
| 129 | 130 |
| 130 // Used to check for dirty layouts violating document lifecycle rules. | 131 // Used to check for dirty layouts violating document lifecycle rules. |
| 131 // If arg evaluates to true, the program will continue. If arg evaluates to | 132 // If arg evaluates to true, the program will continue. If arg evaluates to |
| 132 // false, program will crash if DCHECK_IS_ON() or return false from the current | 133 // false, program will crash if DCHECK_IS_ON() or return false from the current |
| 133 // function. | 134 // function. |
| 134 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ | 135 #define CHECK_FOR_DIRTY_LAYOUT(arg) \ |
| 135 do { \ | 136 do { \ |
| 136 if (!(arg)) { \ | 137 if (!(arg)) { \ |
| 137 NOTREACHED(); \ | 138 NOTREACHED(); \ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 166 m_baseBackgroundColor(Color::white), | 167 m_baseBackgroundColor(Color::white), |
| 167 m_mediaType(MediaTypeNames::screen), | 168 m_mediaType(MediaTypeNames::screen), |
| 168 m_safeToPropagateScrollToParent(true), | 169 m_safeToPropagateScrollToParent(true), |
| 169 m_scrollCorner(nullptr), | 170 m_scrollCorner(nullptr), |
| 170 m_stickyPositionObjectCount(0), | 171 m_stickyPositionObjectCount(0), |
| 171 m_inputEventsScaleFactorForEmulation(1), | 172 m_inputEventsScaleFactorForEmulation(1), |
| 172 m_layoutSizeFixedToFrameSize(true), | 173 m_layoutSizeFixedToFrameSize(true), |
| 173 m_didScrollTimer(this, &FrameView::didScrollTimerFired), | 174 m_didScrollTimer(this, &FrameView::didScrollTimerFired), |
| 174 m_browserControlsViewportAdjustment(0), | 175 m_browserControlsViewportAdjustment(0), |
| 175 m_needsUpdateWidgetGeometries(false), | 176 m_needsUpdateWidgetGeometries(false), |
| 176 m_needsUpdateViewportIntersection(true), | |
| 177 #if ENABLE(ASSERT) | 177 #if ENABLE(ASSERT) |
| 178 m_hasBeenDisposed(false), | 178 m_hasBeenDisposed(false), |
| 179 #endif | 179 #endif |
| 180 m_horizontalScrollbarMode(ScrollbarAuto), | 180 m_horizontalScrollbarMode(ScrollbarAuto), |
| 181 m_verticalScrollbarMode(ScrollbarAuto), | 181 m_verticalScrollbarMode(ScrollbarAuto), |
| 182 m_horizontalScrollbarLock(false), | 182 m_horizontalScrollbarLock(false), |
| 183 m_verticalScrollbarLock(false), | 183 m_verticalScrollbarLock(false), |
| 184 m_scrollbarsSuppressed(false), | 184 m_scrollbarsSuppressed(false), |
| 185 m_inUpdateScrollbars(false), | 185 m_inUpdateScrollbars(false), |
| 186 m_frameTimingRequestsDirty(true), | 186 m_frameTimingRequestsDirty(true), |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 // frames whose owner element is remote. | 304 // frames whose owner element is remote. |
| 305 Element* targetElement = frame().deprecatedLocalOwner(); | 305 Element* targetElement = frame().deprecatedLocalOwner(); |
| 306 if (!targetElement) | 306 if (!targetElement) |
| 307 return; | 307 return; |
| 308 | 308 |
| 309 m_visibilityObserver = new ElementVisibilityObserver( | 309 m_visibilityObserver = new ElementVisibilityObserver( |
| 310 targetElement, WTF::bind( | 310 targetElement, WTF::bind( |
| 311 [](FrameView* frameView, bool isVisible) { | 311 [](FrameView* frameView, bool isVisible) { |
| 312 frameView->updateRenderThrottlingStatus( | 312 frameView->updateRenderThrottlingStatus( |
| 313 !isVisible, frameView->m_subtreeThrottled); | 313 !isVisible, frameView->m_subtreeThrottled); |
| 314 frameView->maybeRecordLoadReason(); | 314 frameView->recordDeferredLoadingStats(); |
| 315 }, | 315 }, |
| 316 wrapWeakPersistent(this))); | 316 wrapWeakPersistent(this))); |
| 317 m_visibilityObserver->start(); | 317 m_visibilityObserver->start(); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void FrameView::dispose() { | 320 void FrameView::dispose() { |
| 321 RELEASE_ASSERT(!isInPerformLayout()); | 321 RELEASE_ASSERT(!isInPerformLayout()); |
| 322 | 322 |
| 323 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) | 323 if (ScrollAnimatorBase* scrollAnimator = existingScrollAnimator()) |
| 324 scrollAnimator->cancelAnimation(); | 324 scrollAnimator->cancelAnimation(); |
| (...skipping 4078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4403 } | 4403 } |
| 4404 | 4404 |
| 4405 void FrameView::setNeedsUpdateViewportIntersection() { | 4405 void FrameView::setNeedsUpdateViewportIntersection() { |
| 4406 for (FrameView* parent = parentFrameView(); parent; | 4406 for (FrameView* parent = parentFrameView(); parent; |
| 4407 parent = parent->parentFrameView()) | 4407 parent = parent->parentFrameView()) |
| 4408 parent->m_needsUpdateViewportIntersectionInSubtree = true; | 4408 parent->m_needsUpdateViewportIntersectionInSubtree = true; |
| 4409 } | 4409 } |
| 4410 | 4410 |
| 4411 void FrameView::updateViewportIntersectionsForSubtree( | 4411 void FrameView::updateViewportIntersectionsForSubtree( |
| 4412 DocumentLifecycle::LifecycleState targetState) { | 4412 DocumentLifecycle::LifecycleState targetState) { |
| 4413 // Notify javascript IntersectionObservers | 4413 if (targetState == DocumentLifecycle::PaintClean) { |
| 4414 if (targetState == DocumentLifecycle::PaintClean && | 4414 recordDeferredLoadingStats(); |
| 4415 frame().document()->intersectionObserverController()) | 4415 // Notify javascript IntersectionObservers |
| 4416 frame() | 4416 if (frame().document()->intersectionObserverController()) { |
| 4417 .document() | 4417 frame() |
| 4418 ->intersectionObserverController() | 4418 .document() |
| 4419 ->computeTrackedIntersectionObservations(); | 4419 ->intersectionObserverController() |
| 4420 ->computeTrackedIntersectionObservations(); |
| 4421 } |
| 4422 } |
| 4420 | 4423 |
| 4421 if (!m_needsUpdateViewportIntersectionInSubtree) | 4424 if (!m_needsUpdateViewportIntersectionInSubtree) |
| 4422 return; | 4425 return; |
| 4423 m_needsUpdateViewportIntersectionInSubtree = false; | 4426 m_needsUpdateViewportIntersectionInSubtree = false; |
| 4424 | 4427 |
| 4425 for (Frame* child = m_frame->tree().firstChild(); child; | 4428 for (Frame* child = m_frame->tree().firstChild(); child; |
| 4426 child = child->tree().nextSibling()) { | 4429 child = child->tree().nextSibling()) { |
| 4427 if (!child->isLocalFrame()) | 4430 if (!child->isLocalFrame()) |
| 4428 continue; | 4431 continue; |
| 4429 if (FrameView* view = toLocalFrame(child)->view()) | 4432 if (FrameView* view = toLocalFrame(child)->view()) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4497 #if DCHECK_IS_ON() | 4500 #if DCHECK_IS_ON() |
| 4498 // Make sure we never have an unthrottled frame inside a throttled one. | 4501 // Make sure we never have an unthrottled frame inside a throttled one. |
| 4499 FrameView* parent = parentFrameView(); | 4502 FrameView* parent = parentFrameView(); |
| 4500 while (parent) { | 4503 while (parent) { |
| 4501 DCHECK(canThrottleRendering() || !parent->canThrottleRendering()); | 4504 DCHECK(canThrottleRendering() || !parent->canThrottleRendering()); |
| 4502 parent = parent->parentFrameView(); | 4505 parent = parent->parentFrameView(); |
| 4503 } | 4506 } |
| 4504 #endif | 4507 #endif |
| 4505 } | 4508 } |
| 4506 | 4509 |
| 4507 // TODO(esprehn): Rename this and the method on Document to | 4510 void FrameView::recordDeferredLoadingStats() { |
| 4508 // recordDeferredLoadReason(). | 4511 if (!frame().document()->frame() || !frame().isCrossOriginSubframe()) |
| 4509 void FrameView::maybeRecordLoadReason() { | 4512 return; |
| 4510 FrameView* parent = parentFrameView(); | 4513 FrameView* parent = parentFrameView(); |
| 4511 if (frame().document()->frame()) { | 4514 if (!parent) { |
| 4512 if (!parent) { | 4515 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); |
| 4513 HTMLFrameOwnerElement* element = frame().deprecatedLocalOwner(); | 4516 // We would fall into an else block on some teardowns and other weird cases. |
| 4514 if (!element) | 4517 if (!element || !element->layoutObject()) |
| 4515 frame().document()->maybeRecordLoadReason(WouldLoadOutOfProcess); | 4518 frame().document()->recordDeferredLoadReason(WouldLoadNoParent); |
| 4516 // Having no layout object means the frame is not drawn. | 4519 return; |
| 4517 else if (!element->layoutObject()) | 4520 } |
| 4518 frame().document()->maybeRecordLoadReason(WouldLoadDisplayNone); | 4521 // Small inaccuracy: frames with origins that match the top level might be |
| 4519 } else { | 4522 // nested in a cross-origin frame. To keep code simpler, count such frames as |
| 4520 // Assume the main frame has always loaded since we don't track its | 4523 // WouldLoadVisible, even when their parent is offscreen. |
| 4521 // visibility. | 4524 WouldLoadReason whyParentLoaded = WouldLoadVisible; |
| 4522 bool parentLoaded = | 4525 if (parent->parentFrameView() && parent->frame().isCrossOriginSubframe()) |
| 4523 !parent->parentFrameView() || | 4526 whyParentLoaded = parent->frame().document()->deferredLoadReason(); |
| 4524 parent->frame().document()->wouldLoadReason() > Created; | 4527 |
| 4525 // If the parent wasn't loaded, the children won't be either. | 4528 // If the parent wasn't loaded, the children won't be either. |
| 4526 if (parentLoaded) { | 4529 if (whyParentLoaded == Created) |
| 4527 if (frameRect().isEmpty()) | 4530 return; |
| 4528 frame().document()->maybeRecordLoadReason(WouldLoadZeroByZero); | 4531 if (frameRect().isEmpty() || frameRect().maxY() < 0 || |
| 4529 else if (frameRect().maxY() < 0 && frameRect().maxX() < 0) | 4532 frameRect().maxX() < 0) { |
| 4530 frame().document()->maybeRecordLoadReason(WouldLoadAboveAndLeft); | 4533 frame().document()->recordDeferredLoadReason(whyParentLoaded); |
| 4531 else if (frameRect().maxY() < 0) | 4534 return; |
| 4532 frame().document()->maybeRecordLoadReason(WouldLoadAbove); | 4535 } |
| 4533 else if (frameRect().maxX() < 0) | 4536 IntRect parentRect = parent->frameRect(); |
| 4534 frame().document()->maybeRecordLoadReason(WouldLoadLeft); | 4537 if (FrameView* grandParent = parent->parentFrameView()) |
| 4535 else if (!m_hiddenForThrottling) | 4538 parentRect = grandParent->contentsToRootFrame(parentRect); |
| 4536 frame().document()->maybeRecordLoadReason(WouldLoadVisible); | 4539 const IntRect childRect = parent->contentsToRootFrame(frameRect()); |
| 4540 // Optimization opportunity: Do some arithmetic instead of looping over each |
| 4541 // of the repositioned viewports. |
| 4542 for (int i = 0; i <= 3; ++i) { |
| 4543 for (int j = 0; j <= (3 - i); ++j) { |
| 4544 IntRect expandedParentRect(parentRect); |
| 4545 expandedParentRect.expand(i * parentRect.width(), |
| 4546 j * parentRect.height()); |
| 4547 if (expandedParentRect.intersects(childRect)) { |
| 4548 frame().document()->recordDeferredLoadReason( |
| 4549 static_cast<WouldLoadReason>(std::min( |
| 4550 static_cast<int>(whyParentLoaded), WouldLoadVisible - i - j))); |
| 4551 return; |
| 4537 } | 4552 } |
| 4538 } | 4553 } |
| 4539 } | 4554 } |
| 4540 } | 4555 } |
| 4541 | 4556 |
| 4542 bool FrameView::shouldThrottleRendering() const { | 4557 bool FrameView::shouldThrottleRendering() const { |
| 4543 return canThrottleRendering() && lifecycle().throttlingAllowed(); | 4558 return canThrottleRendering() && lifecycle().throttlingAllowed(); |
| 4544 } | 4559 } |
| 4545 | 4560 |
| 4546 bool FrameView::canThrottleRendering() const { | 4561 bool FrameView::canThrottleRendering() const { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4585 DCHECK(m_frame->isMainFrame()); | 4600 DCHECK(m_frame->isMainFrame()); |
| 4586 return m_initialViewportSize.width(); | 4601 return m_initialViewportSize.width(); |
| 4587 } | 4602 } |
| 4588 | 4603 |
| 4589 int FrameView::initialViewportHeight() const { | 4604 int FrameView::initialViewportHeight() const { |
| 4590 DCHECK(m_frame->isMainFrame()); | 4605 DCHECK(m_frame->isMainFrame()); |
| 4591 return m_initialViewportSize.height(); | 4606 return m_initialViewportSize.height(); |
| 4592 } | 4607 } |
| 4593 | 4608 |
| 4594 } // namespace blink | 4609 } // namespace blink |
| OLD | NEW |