| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 } | 213 } |
| 214 | 214 |
| 215 FrameView* FrameView::create(LocalFrame& frame) { | 215 FrameView* FrameView::create(LocalFrame& frame) { |
| 216 FrameView* view = new FrameView(frame); | 216 FrameView* view = new FrameView(frame); |
| 217 view->show(); | 217 view->show(); |
| 218 return view; | 218 return view; |
| 219 } | 219 } |
| 220 | 220 |
| 221 FrameView* FrameView::create(LocalFrame& frame, const IntSize& initialSize) { | 221 FrameView* FrameView::create(LocalFrame& frame, const IntSize& initialSize) { |
| 222 FrameView* view = new FrameView(frame); | 222 FrameView* view = new FrameView(frame); |
| 223 view->Widget::setFrameRect(IntRect(view->location(), initialSize)); | 223 view->FrameViewBase::setFrameRect(IntRect(view->location(), initialSize)); |
| 224 view->setLayoutSizeInternal(initialSize); | 224 view->setLayoutSizeInternal(initialSize); |
| 225 | 225 |
| 226 view->show(); | 226 view->show(); |
| 227 return view; | 227 return view; |
| 228 } | 228 } |
| 229 | 229 |
| 230 FrameView::~FrameView() { | 230 FrameView::~FrameView() { |
| 231 ASSERT(m_hasBeenDisposed); | 231 ASSERT(m_hasBeenDisposed); |
| 232 } | 232 } |
| 233 | 233 |
| 234 DEFINE_TRACE(FrameView) { | 234 DEFINE_TRACE(FrameView) { |
| 235 visitor->trace(m_frame); | 235 visitor->trace(m_frame); |
| 236 visitor->trace(m_fragmentAnchor); | 236 visitor->trace(m_fragmentAnchor); |
| 237 visitor->trace(m_scrollableAreas); | 237 visitor->trace(m_scrollableAreas); |
| 238 visitor->trace(m_animatingScrollableAreas); | 238 visitor->trace(m_animatingScrollableAreas); |
| 239 visitor->trace(m_autoSizeInfo); | 239 visitor->trace(m_autoSizeInfo); |
| 240 visitor->trace(m_children); | 240 visitor->trace(m_children); |
| 241 visitor->trace(m_viewportScrollableArea); | 241 visitor->trace(m_viewportScrollableArea); |
| 242 visitor->trace(m_visibilityObserver); | 242 visitor->trace(m_visibilityObserver); |
| 243 visitor->trace(m_scrollAnchor); | 243 visitor->trace(m_scrollAnchor); |
| 244 visitor->trace(m_anchoringAdjustmentQueue); | 244 visitor->trace(m_anchoringAdjustmentQueue); |
| 245 visitor->trace(m_scrollbarManager); | 245 visitor->trace(m_scrollbarManager); |
| 246 visitor->trace(m_printContext); | 246 visitor->trace(m_printContext); |
| 247 Widget::trace(visitor); | 247 FrameViewBase::trace(visitor); |
| 248 ScrollableArea::trace(visitor); | 248 ScrollableArea::trace(visitor); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void FrameView::reset() { | 251 void FrameView::reset() { |
| 252 // The compositor throttles the main frame using deferred commits, we can't | 252 // The compositor throttles the main frame using deferred commits, we can't |
| 253 // throttle it here or it seems the root compositor doesn't get setup | 253 // throttle it here or it seems the root compositor doesn't get setup |
| 254 // properly. | 254 // properly. |
| 255 if (RuntimeEnabledFeatures:: | 255 if (RuntimeEnabledFeatures:: |
| 256 renderingPipelineThrottlingLoadingIframesEnabled()) | 256 renderingPipelineThrottlingLoadingIframesEnabled()) |
| 257 m_lifecycleUpdatesThrottled = !frame().isMainFrame(); | 257 m_lifecycleUpdatesThrottled = !frame().isMainFrame(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing | 364 // Destroy |m_autoSizeInfo| as early as possible, to avoid dereferencing |
| 365 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|. | 365 // partially destroyed |this| via |m_autoSizeInfo->m_frameView|. |
| 366 m_autoSizeInfo.clear(); | 366 m_autoSizeInfo.clear(); |
| 367 | 367 |
| 368 m_postLayoutTasksTimer.stop(); | 368 m_postLayoutTasksTimer.stop(); |
| 369 m_didScrollTimer.stop(); | 369 m_didScrollTimer.stop(); |
| 370 | 370 |
| 371 // FIXME: Do we need to do something here for OOPI? | 371 // FIXME: Do we need to do something here for OOPI? |
| 372 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); | 372 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); |
| 373 // TODO(dcheng): It seems buggy that we can have an owner element that points | 373 // TODO(dcheng): It seems buggy that we can have an owner element that points |
| 374 // to another Widget. This can happen when a plugin element loads a frame | 374 // to another FrameViewBase. This can happen when a plugin element loads a |
| 375 // (widget A of type FrameView) and then loads a plugin (widget B of type | 375 // frame (FrameViewBase A of type FrameView) and then loads a plugin |
| 376 // WebPluginContainerImpl). In this case, the frame's view is A and the frame | 376 // (FrameViewBase B of type WebPluginContainerImpl). In this case, the frame's |
| 377 // element's owned widget is B. See https://crbug.com/673170 for an example. | 377 // view is A and the frame element's owned FrameViewBase is B. See |
| 378 // https://crbug.com/673170 for an example. |
| 378 if (ownerElement && ownerElement->ownedWidget() == this) | 379 if (ownerElement && ownerElement->ownedWidget() == this) |
| 379 ownerElement->setWidget(nullptr); | 380 ownerElement->setWidget(nullptr); |
| 380 | 381 |
| 381 #if DCHECK_IS_ON() | 382 #if DCHECK_IS_ON() |
| 382 m_hasBeenDisposed = true; | 383 m_hasBeenDisposed = true; |
| 383 #endif | 384 #endif |
| 384 } | 385 } |
| 385 | 386 |
| 386 void FrameView::detachScrollbars() { | 387 void FrameView::detachScrollbars() { |
| 387 // Previously, we detached custom scrollbars as early as possible to prevent | 388 // Previously, we detached custom scrollbars as early as possible to prevent |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 updateScrollCorner(); | 484 updateScrollCorner(); |
| 484 positionScrollbarLayers(); | 485 positionScrollbarLayers(); |
| 485 } | 486 } |
| 486 } | 487 } |
| 487 | 488 |
| 488 void FrameView::invalidateAllCustomScrollbarsOnActiveChanged() { | 489 void FrameView::invalidateAllCustomScrollbarsOnActiveChanged() { |
| 489 bool usesWindowInactiveSelector = | 490 bool usesWindowInactiveSelector = |
| 490 m_frame->document()->styleEngine().usesWindowInactiveSelector(); | 491 m_frame->document()->styleEngine().usesWindowInactiveSelector(); |
| 491 | 492 |
| 492 const ChildrenWidgetSet* viewChildren = children(); | 493 const ChildrenWidgetSet* viewChildren = children(); |
| 493 for (const Member<Widget>& child : *viewChildren) { | 494 for (const Member<FrameViewBase>& child : *viewChildren) { |
| 494 Widget* widget = child.get(); | 495 FrameViewBase* frameViewBase = child.get(); |
| 495 if (widget->isFrameView()) | 496 if (frameViewBase->isFrameView()) { |
| 496 toFrameView(widget)->invalidateAllCustomScrollbarsOnActiveChanged(); | 497 toFrameView(frameViewBase) |
| 497 else if (usesWindowInactiveSelector && widget->isScrollbar() && | 498 ->invalidateAllCustomScrollbarsOnActiveChanged(); |
| 498 toScrollbar(widget)->isCustomScrollbar()) | 499 } else if (usesWindowInactiveSelector && frameViewBase->isScrollbar() && |
| 499 toScrollbar(widget)->styleChanged(); | 500 toScrollbar(frameViewBase)->isCustomScrollbar()) { |
| 501 toScrollbar(frameViewBase)->styleChanged(); |
| 502 } |
| 500 } | 503 } |
| 501 if (usesWindowInactiveSelector) | 504 if (usesWindowInactiveSelector) |
| 502 recalculateCustomScrollbarStyle(); | 505 recalculateCustomScrollbarStyle(); |
| 503 } | 506 } |
| 504 | 507 |
| 505 void FrameView::clear() { | 508 void FrameView::clear() { |
| 506 reset(); | 509 reset(); |
| 507 setScrollbarsSuppressed(true); | 510 setScrollbarsSuppressed(true); |
| 508 } | 511 } |
| 509 | 512 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 524 // state. crbug.com/457415 | 527 // state. crbug.com/457415 |
| 525 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; | 528 DisablePaintInvalidationStateAsserts paintInvalidationAssertDisabler; |
| 526 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); | 529 layoutItem.invalidatePaintRectangle(LayoutRect(paintInvalidationRect)); |
| 527 } | 530 } |
| 528 | 531 |
| 529 void FrameView::setFrameRect(const IntRect& newRect) { | 532 void FrameView::setFrameRect(const IntRect& newRect) { |
| 530 IntRect oldRect = frameRect(); | 533 IntRect oldRect = frameRect(); |
| 531 if (newRect == oldRect) | 534 if (newRect == oldRect) |
| 532 return; | 535 return; |
| 533 | 536 |
| 534 Widget::setFrameRect(newRect); | 537 FrameViewBase::setFrameRect(newRect); |
| 535 | 538 |
| 536 const bool frameSizeChanged = oldRect.size() != newRect.size(); | 539 const bool frameSizeChanged = oldRect.size() != newRect.size(); |
| 537 | 540 |
| 538 m_needsScrollbarsUpdate = frameSizeChanged; | 541 m_needsScrollbarsUpdate = frameSizeChanged; |
| 539 // TODO(wjmaclean): find out why scrollbars fail to resize for complex | 542 // TODO(wjmaclean): find out why scrollbars fail to resize for complex |
| 540 // subframes after changing the zoom level. For now always calling | 543 // subframes after changing the zoom level. For now always calling |
| 541 // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to | 544 // updateScrollbarsIfNeeded() here fixes the issue, but it would be good to |
| 542 // discover the deeper cause of this. http://crbug.com/607987. | 545 // discover the deeper cause of this. http://crbug.com/607987. |
| 543 updateScrollbarsIfNeeded(); | 546 updateScrollbarsIfNeeded(); |
| 544 | 547 |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 if (!m_inSynchronousPostLayout) { | 1136 if (!m_inSynchronousPostLayout) { |
| 1134 m_inSynchronousPostLayout = true; | 1137 m_inSynchronousPostLayout = true; |
| 1135 // Calls resumeScheduledEvents() | 1138 // Calls resumeScheduledEvents() |
| 1136 performPostLayoutTasks(); | 1139 performPostLayoutTasks(); |
| 1137 m_inSynchronousPostLayout = false; | 1140 m_inSynchronousPostLayout = false; |
| 1138 } | 1141 } |
| 1139 | 1142 |
| 1140 if (!m_postLayoutTasksTimer.isActive() && | 1143 if (!m_postLayoutTasksTimer.isActive() && |
| 1141 (needsLayout() || m_inSynchronousPostLayout)) { | 1144 (needsLayout() || m_inSynchronousPostLayout)) { |
| 1142 // If we need layout or are already in a synchronous call to | 1145 // If we need layout or are already in a synchronous call to |
| 1143 // postLayoutTasks(), defer widget updates and event dispatch until after we | 1146 // postLayoutTasks(), defer FrameViewBase updates and event dispatch until |
| 1144 // return. postLayoutTasks() can make us need to update again, and we can | 1147 // after we return. postLayoutTasks() can make us need to update again, and |
| 1145 // get stuck in a nasty cycle unless we call it through the timer here. | 1148 // we can get stuck in a nasty cycle unless we call it through the timer |
| 1149 // here. |
| 1146 m_postLayoutTasksTimer.startOneShot(0, BLINK_FROM_HERE); | 1150 m_postLayoutTasksTimer.startOneShot(0, BLINK_FROM_HERE); |
| 1147 if (needsLayout()) | 1151 if (needsLayout()) |
| 1148 layout(); | 1152 layout(); |
| 1149 } | 1153 } |
| 1150 } | 1154 } |
| 1151 | 1155 |
| 1152 void FrameView::layout() { | 1156 void FrameView::layout() { |
| 1153 // We should never layout a Document which is not in a LocalFrame. | 1157 // We should never layout a Document which is not in a LocalFrame. |
| 1154 ASSERT(m_frame); | 1158 ASSERT(m_frame); |
| 1155 ASSERT(m_frame->view() == this); | 1159 ASSERT(m_frame->view() == this); |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 void FrameView::updateWidgetGeometries() { | 1466 void FrameView::updateWidgetGeometries() { |
| 1463 Vector<RefPtr<LayoutPart>> parts; | 1467 Vector<RefPtr<LayoutPart>> parts; |
| 1464 copyToVector(m_parts, parts); | 1468 copyToVector(m_parts, parts); |
| 1465 | 1469 |
| 1466 for (auto part : parts) { | 1470 for (auto part : parts) { |
| 1467 // Script or plugins could detach the frame so abort processing if that | 1471 // Script or plugins could detach the frame so abort processing if that |
| 1468 // happens. | 1472 // happens. |
| 1469 if (layoutViewItem().isNull()) | 1473 if (layoutViewItem().isNull()) |
| 1470 break; | 1474 break; |
| 1471 | 1475 |
| 1472 if (Widget* widget = part->widget()) { | 1476 if (FrameViewBase* frameViewBase = part->widget()) { |
| 1473 if (widget->isFrameView()) { | 1477 if (frameViewBase->isFrameView()) { |
| 1474 FrameView* frameView = toFrameView(widget); | 1478 FrameView* frameView = toFrameView(frameViewBase); |
| 1475 bool didNeedLayout = frameView->needsLayout(); | 1479 bool didNeedLayout = frameView->needsLayout(); |
| 1476 part->updateWidgetGeometry(); | 1480 part->updateWidgetGeometry(); |
| 1477 if (!didNeedLayout && !frameView->shouldThrottleRendering()) | 1481 if (!didNeedLayout && !frameView->shouldThrottleRendering()) |
| 1478 frameView->checkDoesNotNeedLayout(); | 1482 frameView->checkDoesNotNeedLayout(); |
| 1479 } else { | 1483 } else { |
| 1480 part->updateWidgetGeometry(); | 1484 part->updateWidgetGeometry(); |
| 1481 } | 1485 } |
| 1482 } | 1486 } |
| 1483 } | 1487 } |
| 1484 } | 1488 } |
| 1485 | 1489 |
| 1486 void FrameView::addPartToUpdate(LayoutEmbeddedObject& object) { | 1490 void FrameView::addPartToUpdate(LayoutEmbeddedObject& object) { |
| 1487 ASSERT(isInPerformLayout()); | 1491 ASSERT(isInPerformLayout()); |
| 1488 // Tell the DOM element that it needs a widget update. | 1492 // Tell the DOM element that it needs a FrameViewBase update. |
| 1489 Node* node = object.node(); | 1493 Node* node = object.node(); |
| 1490 ASSERT(node); | 1494 ASSERT(node); |
| 1491 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) | 1495 if (isHTMLObjectElement(*node) || isHTMLEmbedElement(*node)) |
| 1492 toHTMLPlugInElement(node)->setNeedsWidgetUpdate(true); | 1496 toHTMLPlugInElement(node)->setNeedsWidgetUpdate(true); |
| 1493 | 1497 |
| 1494 m_partUpdateSet.insert(&object); | 1498 m_partUpdateSet.insert(&object); |
| 1495 } | 1499 } |
| 1496 | 1500 |
| 1497 void FrameView::setDisplayMode(WebDisplayMode mode) { | 1501 void FrameView::setDisplayMode(WebDisplayMode mode) { |
| 1498 if (mode == m_displayMode) | 1502 if (mode == m_displayMode) |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 !constraintsMap.at(layer).hasAncestorStickyElement()) { | 1992 !constraintsMap.at(layer).hasAncestorStickyElement()) { |
| 1989 // TODO(skobes): Resolve circular dependency between scroll offset and | 1993 // TODO(skobes): Resolve circular dependency between scroll offset and |
| 1990 // compositing state, and remove this disabler. https://crbug.com/420741 | 1994 // compositing state, and remove this disabler. https://crbug.com/420741 |
| 1991 DisableCompositingQueryAsserts disabler; | 1995 DisableCompositingQueryAsserts disabler; |
| 1992 layer->updateLayerPositionsAfterOverflowScroll(); | 1996 layer->updateLayerPositionsAfterOverflowScroll(); |
| 1993 layoutObject->setMayNeedPaintInvalidationSubtree(); | 1997 layoutObject->setMayNeedPaintInvalidationSubtree(); |
| 1994 } | 1998 } |
| 1995 } | 1999 } |
| 1996 | 2000 |
| 1997 // If there fixed position elements, scrolling may cause compositing layers to | 2001 // If there fixed position elements, scrolling may cause compositing layers to |
| 1998 // change. Update widget and layer positions after scrolling, but only if | 2002 // change. Update FrameViewBase and layer positions after scrolling, but only |
| 1999 // we're not inside of layout. | 2003 // if we're not inside of layout. |
| 2000 if (!m_nestedLayoutCount) { | 2004 if (!m_nestedLayoutCount) { |
| 2001 updateWidgetGeometries(); | 2005 updateWidgetGeometries(); |
| 2002 LayoutViewItem layoutViewItem = this->layoutViewItem(); | 2006 LayoutViewItem layoutViewItem = this->layoutViewItem(); |
| 2003 if (!layoutViewItem.isNull()) | 2007 if (!layoutViewItem.isNull()) |
| 2004 layoutViewItem.layer()->setNeedsCompositingInputsUpdate(); | 2008 layoutViewItem.layer()->setNeedsCompositingInputsUpdate(); |
| 2005 } | 2009 } |
| 2006 } | 2010 } |
| 2007 | 2011 |
| 2008 bool FrameView::computeCompositedSelection(LocalFrame& frame, | 2012 bool FrameView::computeCompositedSelection(LocalFrame& frame, |
| 2009 CompositedSelection& selection) { | 2013 CompositedSelection& selection) { |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2400 | 2404 |
| 2401 // The fragment anchor should only be maintained while the frame is still | 2405 // The fragment anchor should only be maintained while the frame is still |
| 2402 // loading. If the frame is done loading, clear the anchor now. Otherwise, | 2406 // loading. If the frame is done loading, clear the anchor now. Otherwise, |
| 2403 // restore it since it may have been cleared during scrollRectToVisible. | 2407 // restore it since it may have been cleared during scrollRectToVisible. |
| 2404 m_fragmentAnchor = | 2408 m_fragmentAnchor = |
| 2405 m_frame->document()->isLoadCompleted() ? nullptr : anchorNode; | 2409 m_frame->document()->isLoadCompleted() ? nullptr : anchorNode; |
| 2406 } | 2410 } |
| 2407 | 2411 |
| 2408 bool FrameView::updateWidgets() { | 2412 bool FrameView::updateWidgets() { |
| 2409 // This is always called from updateWidgetsTimerFired. | 2413 // This is always called from updateWidgetsTimerFired. |
| 2410 // m_updateWidgetsTimer should only be scheduled if we have widgets to update. | 2414 // m_updateWidgetsTimer should only be scheduled if we have FrameViewBases to |
| 2411 // Thus I believe we can stop checking isEmpty here, and just ASSERT isEmpty: | 2415 // update. Thus I believe we can stop checking isEmpty here, and just ASSERT |
| 2416 // isEmpty: |
| 2412 // FIXME: This assert has been temporarily removed due to | 2417 // FIXME: This assert has been temporarily removed due to |
| 2413 // https://crbug.com/430344 | 2418 // https://crbug.com/430344 |
| 2414 if (m_nestedLayoutCount > 1 || m_partUpdateSet.isEmpty()) | 2419 if (m_nestedLayoutCount > 1 || m_partUpdateSet.isEmpty()) |
| 2415 return true; | 2420 return true; |
| 2416 | 2421 |
| 2417 // Need to swap because script will run inside the below loop and invalidate | 2422 // Need to swap because script will run inside the below loop and invalidate |
| 2418 // the iterator. | 2423 // the iterator. |
| 2419 EmbeddedObjectSet objects; | 2424 EmbeddedObjectSet objects; |
| 2420 objects.swap(m_partUpdateSet); | 2425 objects.swap(m_partUpdateSet); |
| 2421 | 2426 |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3298 layout(); | 3303 layout(); |
| 3299 | 3304 |
| 3300 checkDoesNotNeedLayout(); | 3305 checkDoesNotNeedLayout(); |
| 3301 | 3306 |
| 3302 // WebView plugins need to update regardless of whether the | 3307 // WebView plugins need to update regardless of whether the |
| 3303 // LayoutEmbeddedObject that owns them needed layout. | 3308 // LayoutEmbeddedObject that owns them needed layout. |
| 3304 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. | 3309 // TODO(leviw): This currently runs the entire lifecycle on plugin WebViews. |
| 3305 // We should have a way to only run these other Documents to the same | 3310 // We should have a way to only run these other Documents to the same |
| 3306 // lifecycle stage as this frame. | 3311 // lifecycle stage as this frame. |
| 3307 const ChildrenWidgetSet* viewChildren = children(); | 3312 const ChildrenWidgetSet* viewChildren = children(); |
| 3308 for (const Member<Widget>& child : *viewChildren) { | 3313 for (const Member<FrameViewBase>& child : *viewChildren) { |
| 3309 if ((*child).isPluginContainer()) | 3314 if ((*child).isPluginContainer()) |
| 3310 toPluginView(child.get())->updateAllLifecyclePhases(); | 3315 toPluginView(child.get())->updateAllLifecyclePhases(); |
| 3311 } | 3316 } |
| 3312 checkDoesNotNeedLayout(); | 3317 checkDoesNotNeedLayout(); |
| 3313 | 3318 |
| 3314 // FIXME: Calling layout() shouldn't trigger script execution or have any | 3319 // FIXME: Calling layout() shouldn't trigger script execution or have any |
| 3315 // observable effects on the frame tree but we're not quite there yet. | 3320 // observable effects on the frame tree but we're not quite there yet. |
| 3316 HeapVector<Member<FrameView>> frameViews; | 3321 HeapVector<Member<FrameView>> frameViews; |
| 3317 for (Frame* child = m_frame->tree().firstChild(); child; | 3322 for (Frame* child = m_frame->tree().firstChild(); child; |
| 3318 child = child->tree().nextSibling()) { | 3323 child = child->tree().nextSibling()) { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3736 m_animatingScrollableAreas = new ScrollableAreaSet; | 3741 m_animatingScrollableAreas = new ScrollableAreaSet; |
| 3737 m_animatingScrollableAreas->insert(scrollableArea); | 3742 m_animatingScrollableAreas->insert(scrollableArea); |
| 3738 } | 3743 } |
| 3739 | 3744 |
| 3740 void FrameView::removeAnimatingScrollableArea(ScrollableArea* scrollableArea) { | 3745 void FrameView::removeAnimatingScrollableArea(ScrollableArea* scrollableArea) { |
| 3741 if (!m_animatingScrollableAreas) | 3746 if (!m_animatingScrollableAreas) |
| 3742 return; | 3747 return; |
| 3743 m_animatingScrollableAreas->erase(scrollableArea); | 3748 m_animatingScrollableAreas->erase(scrollableArea); |
| 3744 } | 3749 } |
| 3745 | 3750 |
| 3746 void FrameView::setParent(Widget* parentView) { | 3751 void FrameView::setParent(FrameViewBase* parentView) { |
| 3747 if (parentView == parent()) | 3752 if (parentView == parent()) |
| 3748 return; | 3753 return; |
| 3749 | 3754 |
| 3750 Widget::setParent(parentView); | 3755 FrameViewBase::setParent(parentView); |
| 3751 | 3756 |
| 3752 updateParentScrollableAreaSet(); | 3757 updateParentScrollableAreaSet(); |
| 3753 setupRenderThrottling(); | 3758 setupRenderThrottling(); |
| 3754 | 3759 |
| 3755 if (parentFrameView()) | 3760 if (parentFrameView()) |
| 3756 m_subtreeThrottled = parentFrameView()->canThrottleRendering(); | 3761 m_subtreeThrottled = parentFrameView()->canThrottleRendering(); |
| 3757 } | 3762 } |
| 3758 | 3763 |
| 3759 void FrameView::removeChild(Widget* child) { | 3764 void FrameView::removeChild(FrameViewBase* child) { |
| 3760 ASSERT(child->parent() == this); | 3765 ASSERT(child->parent() == this); |
| 3761 | 3766 |
| 3762 if (child->isFrameView() && | 3767 if (child->isFrameView() && |
| 3763 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 3768 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 3764 removeScrollableArea(toFrameView(child)); | 3769 removeScrollableArea(toFrameView(child)); |
| 3765 | 3770 |
| 3766 child->setParent(0); | 3771 child->setParent(0); |
| 3767 m_children.erase(child); | 3772 m_children.erase(child); |
| 3768 } | 3773 } |
| 3769 | 3774 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3845 TopDocumentRootScrollerController& controller = | 3850 TopDocumentRootScrollerController& controller = |
| 3846 host->globalRootScrollerController(); | 3851 host->globalRootScrollerController(); |
| 3847 if (layoutViewport == controller.rootScrollerArea()) | 3852 if (layoutViewport == controller.rootScrollerArea()) |
| 3848 visibleSize = controller.rootScrollerVisibleArea(); | 3853 visibleSize = controller.rootScrollerVisibleArea(); |
| 3849 | 3854 |
| 3850 IntSize maximumOffset = | 3855 IntSize maximumOffset = |
| 3851 toIntSize(-scrollOrigin() + (contentBounds - visibleSize)); | 3856 toIntSize(-scrollOrigin() + (contentBounds - visibleSize)); |
| 3852 return maximumOffset.expandedTo(minimumScrollOffsetInt()); | 3857 return maximumOffset.expandedTo(minimumScrollOffsetInt()); |
| 3853 } | 3858 } |
| 3854 | 3859 |
| 3855 void FrameView::addChild(Widget* child) { | 3860 void FrameView::addChild(FrameViewBase* child) { |
| 3856 ASSERT(child != this && !child->parent()); | 3861 ASSERT(child != this && !child->parent()); |
| 3857 child->setParent(this); | 3862 child->setParent(this); |
| 3858 m_children.insert(child); | 3863 m_children.insert(child); |
| 3859 } | 3864 } |
| 3860 | 3865 |
| 3861 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, | 3866 void FrameView::setScrollbarModes(ScrollbarMode horizontalMode, |
| 3862 ScrollbarMode verticalMode, | 3867 ScrollbarMode verticalMode, |
| 3863 bool horizontalLock, | 3868 bool horizontalLock, |
| 3864 bool verticalLock) { | 3869 bool verticalLock) { |
| 3865 bool needsUpdate = false; | 3870 bool needsUpdate = false; |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4300 | 4305 |
| 4301 if (!scrollContentsFastPath(-scrollDelta)) | 4306 if (!scrollContentsFastPath(-scrollDelta)) |
| 4302 scrollContentsSlowPath(); | 4307 scrollContentsSlowPath(); |
| 4303 | 4308 |
| 4304 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && | 4309 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && |
| 4305 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 4310 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 4306 // Need to update scroll translation property. | 4311 // Need to update scroll translation property. |
| 4307 setNeedsPaintPropertyUpdate(); | 4312 setNeedsPaintPropertyUpdate(); |
| 4308 } | 4313 } |
| 4309 | 4314 |
| 4310 // This call will move children with native widgets (plugins) and invalidate | 4315 // This call will move children with native FrameViewBases (plugins) and |
| 4311 // them as well. | 4316 // invalidate them as well. |
| 4312 frameRectsChanged(); | 4317 frameRectsChanged(); |
| 4313 } | 4318 } |
| 4314 | 4319 |
| 4315 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { | 4320 IntPoint FrameView::contentsToFrame(const IntPoint& pointInContentSpace) const { |
| 4316 return pointInContentSpace - scrollOffsetInt(); | 4321 return pointInContentSpace - scrollOffsetInt(); |
| 4317 } | 4322 } |
| 4318 | 4323 |
| 4319 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { | 4324 IntRect FrameView::contentsToFrame(const IntRect& rectInContentSpace) const { |
| 4320 return IntRect(contentsToFrame(rectInContentSpace.location()), | 4325 return IntRect(contentsToFrame(rectInContentSpace.location()), |
| 4321 rectInContentSpace.size()); | 4326 rectInContentSpace.size()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4467 ? m_horizontalScrollbarMode | 4472 ? m_horizontalScrollbarMode |
| 4468 : m_verticalScrollbarMode; | 4473 : m_verticalScrollbarMode; |
| 4469 | 4474 |
| 4470 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; | 4475 return mode == ScrollbarAuto || mode == ScrollbarAlwaysOn; |
| 4471 } | 4476 } |
| 4472 | 4477 |
| 4473 bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const { | 4478 bool FrameView::shouldPlaceVerticalScrollbarOnLeft() const { |
| 4474 return false; | 4479 return false; |
| 4475 } | 4480 } |
| 4476 | 4481 |
| 4477 Widget* FrameView::getWidget() { | 4482 FrameViewBase* FrameView::getWidget() { |
| 4478 return this; | 4483 return this; |
| 4479 } | 4484 } |
| 4480 | 4485 |
| 4481 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, | 4486 LayoutRect FrameView::scrollIntoView(const LayoutRect& rectInContent, |
| 4482 const ScrollAlignment& alignX, | 4487 const ScrollAlignment& alignX, |
| 4483 const ScrollAlignment& alignY, | 4488 const ScrollAlignment& alignY, |
| 4484 ScrollType scrollType) { | 4489 ScrollType scrollType) { |
| 4485 LayoutRect viewRect(visibleContentRect()); | 4490 LayoutRect viewRect(visibleContentRect()); |
| 4486 LayoutRect exposeRect = | 4491 LayoutRect exposeRect = |
| 4487 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); | 4492 ScrollAlignment::getRectToExpose(viewRect, rectInContent, alignX, alignY); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4635 } | 4640 } |
| 4636 | 4641 |
| 4637 void FrameView::setParentVisible(bool visible) { | 4642 void FrameView::setParentVisible(bool visible) { |
| 4638 if (isParentVisible() == visible) | 4643 if (isParentVisible() == visible) |
| 4639 return; | 4644 return; |
| 4640 | 4645 |
| 4641 // As parent visibility changes, we may need to recomposite this frame view | 4646 // As parent visibility changes, we may need to recomposite this frame view |
| 4642 // and potentially child frame views. | 4647 // and potentially child frame views. |
| 4643 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); | 4648 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); |
| 4644 | 4649 |
| 4645 Widget::setParentVisible(visible); | 4650 FrameViewBase::setParentVisible(visible); |
| 4646 | 4651 |
| 4647 if (!isSelfVisible()) | 4652 if (!isSelfVisible()) |
| 4648 return; | 4653 return; |
| 4649 | 4654 |
| 4650 for (const auto& child : m_children) | 4655 for (const auto& child : m_children) |
| 4651 child->setParentVisible(visible); | 4656 child->setParentVisible(visible); |
| 4652 } | 4657 } |
| 4653 | 4658 |
| 4654 void FrameView::show() { | 4659 void FrameView::show() { |
| 4655 if (!isSelfVisible()) { | 4660 if (!isSelfVisible()) { |
| 4656 setSelfVisible(true); | 4661 setSelfVisible(true); |
| 4657 if (ScrollingCoordinator* scrollingCoordinator = | 4662 if (ScrollingCoordinator* scrollingCoordinator = |
| 4658 this->scrollingCoordinator()) | 4663 this->scrollingCoordinator()) |
| 4659 scrollingCoordinator->frameViewVisibilityDidChange(); | 4664 scrollingCoordinator->frameViewVisibilityDidChange(); |
| 4660 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); | 4665 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); |
| 4661 updateParentScrollableAreaSet(); | 4666 updateParentScrollableAreaSet(); |
| 4662 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && | 4667 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && |
| 4663 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 4668 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 4664 // The existance of scrolling properties depends on visibility through | 4669 // The existance of scrolling properties depends on visibility through |
| 4665 // isScrollable() so ensure properties are updated if visibility changes. | 4670 // isScrollable() so ensure properties are updated if visibility changes. |
| 4666 setNeedsPaintPropertyUpdate(); | 4671 setNeedsPaintPropertyUpdate(); |
| 4667 } | 4672 } |
| 4668 if (isParentVisible()) { | 4673 if (isParentVisible()) { |
| 4669 for (const auto& child : m_children) | 4674 for (const auto& child : m_children) |
| 4670 child->setParentVisible(true); | 4675 child->setParentVisible(true); |
| 4671 } | 4676 } |
| 4672 } | 4677 } |
| 4673 | 4678 |
| 4674 Widget::show(); | 4679 FrameViewBase::show(); |
| 4675 } | 4680 } |
| 4676 | 4681 |
| 4677 void FrameView::hide() { | 4682 void FrameView::hide() { |
| 4678 if (isSelfVisible()) { | 4683 if (isSelfVisible()) { |
| 4679 if (isParentVisible()) { | 4684 if (isParentVisible()) { |
| 4680 for (const auto& child : m_children) | 4685 for (const auto& child : m_children) |
| 4681 child->setParentVisible(false); | 4686 child->setParentVisible(false); |
| 4682 } | 4687 } |
| 4683 setSelfVisible(false); | 4688 setSelfVisible(false); |
| 4684 if (ScrollingCoordinator* scrollingCoordinator = | 4689 if (ScrollingCoordinator* scrollingCoordinator = |
| 4685 this->scrollingCoordinator()) | 4690 this->scrollingCoordinator()) |
| 4686 scrollingCoordinator->frameViewVisibilityDidChange(); | 4691 scrollingCoordinator->frameViewVisibilityDidChange(); |
| 4687 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); | 4692 setNeedsCompositingUpdate(layoutViewItem(), CompositingUpdateRebuildTree); |
| 4688 updateParentScrollableAreaSet(); | 4693 updateParentScrollableAreaSet(); |
| 4689 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && | 4694 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled() && |
| 4690 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { | 4695 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { |
| 4691 // The existance of scrolling properties depends on visibility through | 4696 // The existance of scrolling properties depends on visibility through |
| 4692 // isScrollable() so ensure properties are updated if visibility changes. | 4697 // isScrollable() so ensure properties are updated if visibility changes. |
| 4693 setNeedsPaintPropertyUpdate(); | 4698 setNeedsPaintPropertyUpdate(); |
| 4694 } | 4699 } |
| 4695 } | 4700 } |
| 4696 | 4701 |
| 4697 Widget::hide(); | 4702 FrameViewBase::hide(); |
| 4698 } | 4703 } |
| 4699 | 4704 |
| 4700 int FrameView::viewportWidth() const { | 4705 int FrameView::viewportWidth() const { |
| 4701 int viewportWidth = layoutSize(IncludeScrollbars).width(); | 4706 int viewportWidth = layoutSize(IncludeScrollbars).width(); |
| 4702 return adjustForAbsoluteZoom(viewportWidth, layoutView()); | 4707 return adjustForAbsoluteZoom(viewportWidth, layoutView()); |
| 4703 } | 4708 } |
| 4704 | 4709 |
| 4705 ScrollableArea* FrameView::getScrollableArea() { | 4710 ScrollableArea* FrameView::getScrollableArea() { |
| 4706 if (m_viewportScrollableArea) | 4711 if (m_viewportScrollableArea) |
| 4707 return m_viewportScrollableArea.get(); | 4712 return m_viewportScrollableArea.get(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4738 return; | 4743 return; |
| 4739 | 4744 |
| 4740 layoutObject.addAnnotatedRegions(regions); | 4745 layoutObject.addAnnotatedRegions(regions); |
| 4741 for (LayoutObject* curr = layoutObject.slowFirstChild(); curr; | 4746 for (LayoutObject* curr = layoutObject.slowFirstChild(); curr; |
| 4742 curr = curr->nextSibling()) | 4747 curr = curr->nextSibling()) |
| 4743 collectAnnotatedRegions(*curr, regions); | 4748 collectAnnotatedRegions(*curr, regions); |
| 4744 } | 4749 } |
| 4745 | 4750 |
| 4746 void FrameView::updateViewportIntersectionsForSubtree( | 4751 void FrameView::updateViewportIntersectionsForSubtree( |
| 4747 DocumentLifecycle::LifecycleState targetState) { | 4752 DocumentLifecycle::LifecycleState targetState) { |
| 4748 // TODO(dcheng): Since widget tree updates are deferred, FrameViews might | 4753 // TODO(dcheng): Since FrameViewBase tree updates are deferred, FrameViews |
| 4749 // still be in the widget hierarchy even though the associated Document is | 4754 // might still be in the FrameViewBase hierarchy even though the associated |
| 4750 // already detached. Investigate if this check and a similar check in | 4755 // Document is already detached. Investigate if this check and a similar check |
| 4751 // lifecycle updates are still needed when there are no more deferred widget | 4756 // in lifecycle updates are still needed when there are no more deferred |
| 4752 // updates: https://crbug.com/561683 | 4757 // FrameViewBase updates: https://crbug.com/561683 |
| 4753 if (!frame().document()->isActive()) | 4758 if (!frame().document()->isActive()) |
| 4754 return; | 4759 return; |
| 4755 | 4760 |
| 4756 if (targetState == DocumentLifecycle::PaintClean) { | 4761 if (targetState == DocumentLifecycle::PaintClean) { |
| 4757 recordDeferredLoadingStats(); | 4762 recordDeferredLoadingStats(); |
| 4758 // Notify javascript IntersectionObservers | 4763 // Notify javascript IntersectionObservers |
| 4759 if (frame().document()->intersectionObserverController()) { | 4764 if (frame().document()->intersectionObserverController()) { |
| 4760 frame() | 4765 frame() |
| 4761 .document() | 4766 .document() |
| 4762 ->intersectionObserverController() | 4767 ->intersectionObserverController() |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4817 bool becameUnthrottled = wasThrottled && !isThrottled; | 4822 bool becameUnthrottled = wasThrottled && !isThrottled; |
| 4818 | 4823 |
| 4819 // If this FrameView became unthrottled or throttled, we must make sure all | 4824 // If this FrameView became unthrottled or throttled, we must make sure all |
| 4820 // its children are notified synchronously. Otherwise we 1) might attempt to | 4825 // its children are notified synchronously. Otherwise we 1) might attempt to |
| 4821 // paint one of the children with an out-of-date layout before | 4826 // paint one of the children with an out-of-date layout before |
| 4822 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to | 4827 // |updateRenderThrottlingStatus| has made it throttled or 2) fail to |
| 4823 // unthrottle a child whose parent is unthrottled by a later notification. | 4828 // unthrottle a child whose parent is unthrottled by a later notification. |
| 4824 if (notifyChildrenBehavior == NotifyChildren && | 4829 if (notifyChildrenBehavior == NotifyChildren && |
| 4825 (wasThrottled != isThrottled || | 4830 (wasThrottled != isThrottled || |
| 4826 forceThrottlingInvalidationBehavior == ForceThrottlingInvalidation)) { | 4831 forceThrottlingInvalidationBehavior == ForceThrottlingInvalidation)) { |
| 4827 for (const Member<Widget>& child : *children()) { | 4832 for (const Member<FrameViewBase>& child : *children()) { |
| 4828 if (child->isFrameView()) { | 4833 if (child->isFrameView()) { |
| 4829 FrameView* childView = toFrameView(child); | 4834 FrameView* childView = toFrameView(child); |
| 4830 childView->updateRenderThrottlingStatus( | 4835 childView->updateRenderThrottlingStatus( |
| 4831 childView->m_hiddenForThrottling, isThrottled); | 4836 childView->m_hiddenForThrottling, isThrottled); |
| 4832 } | 4837 } |
| 4833 } | 4838 } |
| 4834 } | 4839 } |
| 4835 | 4840 |
| 4836 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(); | 4841 ScrollingCoordinator* scrollingCoordinator = this->scrollingCoordinator(); |
| 4837 if (becameUnthrottled || | 4842 if (becameUnthrottled || |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5246 void FrameView::setAnimationHost( | 5251 void FrameView::setAnimationHost( |
| 5247 std::unique_ptr<CompositorAnimationHost> host) { | 5252 std::unique_ptr<CompositorAnimationHost> host) { |
| 5248 m_animationHost = std::move(host); | 5253 m_animationHost = std::move(host); |
| 5249 } | 5254 } |
| 5250 | 5255 |
| 5251 LayoutUnit FrameView::caretWidth() const { | 5256 LayoutUnit FrameView::caretWidth() const { |
| 5252 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); | 5257 return LayoutUnit(getHostWindow()->windowToViewportScalar(1)); |
| 5253 } | 5258 } |
| 5254 | 5259 |
| 5255 } // namespace blink | 5260 } // namespace blink |
| OLD | NEW |