Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: Source/core/frame/FrameView.cpp

Issue 191693002: Delay scrollContents until the next paint (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: fixed typos Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 return false; 1252 return false;
1253 } 1253 }
1254 1254
1255 bool FrameView::useSlowRepaintsIfNotOverlapped() const 1255 bool FrameView::useSlowRepaintsIfNotOverlapped() const
1256 { 1256 {
1257 return useSlowRepaints(false); 1257 return useSlowRepaints(false);
1258 } 1258 }
1259 1259
1260 bool FrameView::shouldAttemptToScrollUsingFastPath() const 1260 bool FrameView::shouldAttemptToScrollUsingFastPath() const
1261 { 1261 {
1262 // FIXME: useSlowRepaints reads compositing state in parent frames. Composit ing state on the parent
1263 // frames is not necessarily up to date.
1264 // https://code.google.com/p/chromium/issues/detail?id=343766
1265 DisableCompositingQueryAsserts disabler;
1266 return !useSlowRepaints(); 1262 return !useSlowRepaints();
1267 } 1263 }
1268 1264
1269 bool FrameView::contentsInCompositedLayer() const 1265 bool FrameView::contentsInCompositedLayer() const
1270 { 1266 {
1271 RenderView* renderView = this->renderView(); 1267 RenderView* renderView = this->renderView();
1272 if (renderView && renderView->compositingState() == PaintsIntoOwnBacking) { 1268 if (renderView && renderView->compositingState() == PaintsIntoOwnBacking) {
1273 GraphicsLayer* layer = renderView->layer()->compositedLayerMapping()->ma inGraphicsLayer(); 1269 GraphicsLayer* layer = renderView->layer()->compositedLayerMapping()->ma inGraphicsLayer();
1274 if (layer && layer->drawsContent()) 1270 if (layer && layer->drawsContent())
1275 return true; 1271 return true;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 { 1391 {
1396 return m_frame->eventHandler().lastKnownMousePosition(); 1392 return m_frame->eventHandler().lastKnownMousePosition();
1397 } 1393 }
1398 1394
1399 bool FrameView::shouldSetCursor() const 1395 bool FrameView::shouldSetCursor() const
1400 { 1396 {
1401 Page* page = frame().page(); 1397 Page* page = frame().page();
1402 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive(); 1398 return page && page->visibilityState() != PageVisibilityStateHidden && page- >focusController().isActive();
1403 } 1399 }
1404 1400
1401 void FrameView::scrollContentsIfNeededRecursive()
1402 {
1403 scrollContentsIfNeeded();
1404
1405 for (LocalFrame* child = m_frame->tree().firstChild(); child; child = child- >tree().nextSibling()) {
1406 if (FrameView* view = child->view())
1407 view->scrollContentsIfNeededRecursive();
1408 }
1409 }
1410
1411 void FrameView::scrollContentsIfNeeded()
1412 {
1413 bool didScroll = !pendingScrollDelta().isZero();
1414 ScrollView::scrollContentsIfNeeded();
1415 if (didScroll)
1416 updateFixedElementRepaintRectsAfterScroll();
1417 }
1418
1405 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect & rectToScroll, const IntRect& clipRect) 1419 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect & rectToScroll, const IntRect& clipRect)
1406 { 1420 {
1407 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) { 1421 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty() ) {
1408 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); 1422 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
1409 return true; 1423 return true;
1410 } 1424 }
1411 1425
1412 // https://code.google.com/p/chromium/issues/detail?id=343767
1413 DisableCompositingQueryAsserts disabler;
1414 const bool isCompositedContentLayer = contentsInCompositedLayer(); 1426 const bool isCompositedContentLayer = contentsInCompositedLayer();
1415 1427
1416 // Get the rects of the fixed objects visible in the rectToScroll 1428 // Get the rects of the fixed objects visible in the rectToScroll
1417 Region regionToUpdate; 1429 Region regionToUpdate;
1418 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end(); 1430 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
1419 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) { 1431 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
1420 RenderObject* renderer = *it; 1432 RenderObject* renderer = *it;
1421 if (!renderer->style()->hasViewportConstrainedPosition()) 1433 if (!renderer->style()->hasViewportConstrainedPosition())
1422 continue; 1434 continue;
1423 1435
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1478
1467 // 1) scroll 1479 // 1) scroll
1468 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect); 1480 hostWindow()->scroll(scrollDelta, rectToScroll, clipRect);
1469 1481
1470 // 2) update the area of fixed objects that has been invalidated 1482 // 2) update the area of fixed objects that has been invalidated
1471 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects(); 1483 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects();
1472 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size(); 1484 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size();
1473 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) { 1485 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) {
1474 IntRect updateRect = subRectsToUpdate[i]; 1486 IntRect updateRect = subRectsToUpdate[i];
1475 IntRect scrolledRect = updateRect; 1487 IntRect scrolledRect = updateRect;
1476 scrolledRect.move(scrollDelta); 1488 scrolledRect.move(-scrollDelta);
1477 updateRect.unite(scrolledRect); 1489 updateRect.unite(scrolledRect);
1478 if (isCompositedContentLayer) { 1490 if (isCompositedContentLayer) {
1479 updateRect = rootViewToContents(updateRect); 1491 updateRect = rootViewToContents(updateRect);
1480 ASSERT(renderView()); 1492 ASSERT(renderView());
1481 renderView()->layer()->repainter().setBackingNeedsRepaintInRect(upda teRect); 1493 renderView()->layer()->repainter().setBackingNeedsRepaintInRect(upda teRect);
1482 continue; 1494 continue;
1483 } 1495 }
1484 if (clipsRepaints()) 1496 if (clipsRepaints())
1485 updateRect.intersect(rectToScroll); 1497 updateRect.intersect(rectToScroll);
1486 hostWindow()->invalidateContentsAndRootView(updateRect); 1498 hostWindow()->invalidateContentsAndRootView(updateRect);
1487 } 1499 }
1488 1500
1489 return true; 1501 return true;
1490 } 1502 }
1491 1503
1492 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) 1504 void FrameView::scrollContentsSlowPath(const IntRect& updateRect)
1493 { 1505 {
1494 // FIXME: This is called when JS calls scrollTo, at which point there's no g uarantee that
1495 // compositing state is up to date.
1496 // https://code.google.com/p/chromium/issues/detail?id=343767
1497 DisableCompositingQueryAsserts disabler;
1498
1499 if (contentsInCompositedLayer()) { 1506 if (contentsInCompositedLayer()) {
1500 IntRect updateRect = visibleContentRect(); 1507 IntRect updateRect = visibleContentRect();
1501 ASSERT(renderView()); 1508 ASSERT(renderView());
1502 renderView()->layer()->repainter().setBackingNeedsRepaintInRect(updateRe ct); 1509 renderView()->layer()->repainter().setBackingNeedsRepaintInRect(updateRe ct);
1503 } 1510 }
1504 if (RenderPart* frameRenderer = m_frame->ownerRenderer()) { 1511 if (RenderPart* frameRenderer = m_frame->ownerRenderer()) {
1505 if (isEnclosedInCompositingLayer()) { 1512 if (isEnclosedInCompositingLayer()) {
1506 LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->padding Left(), 1513 LayoutRect rect(frameRenderer->borderLeft() + frameRenderer->padding Left(),
1507 frameRenderer->borderTop() + frameRenderer->paddingT op(), 1514 frameRenderer->borderTop() + frameRenderer->paddingT op(),
1508 visibleWidth(), visibleHeight()); 1515 visibleWidth(), visibleHeight());
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 frame().loader().saveScrollState(); 1684 frame().loader().saveScrollState();
1678 } 1685 }
1679 1686
1680 void FrameView::didScrollTimerFired(Timer<FrameView>*) 1687 void FrameView::didScrollTimerFired(Timer<FrameView>*)
1681 { 1688 {
1682 if (m_frame->document() && m_frame->document()->renderer()) { 1689 if (m_frame->document() && m_frame->document()->renderer()) {
1683 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAl lImageResourcePriorities(); 1690 ResourceLoadPriorityOptimizer::resourceLoadPriorityOptimizer()->updateAl lImageResourcePriorities();
1684 } 1691 }
1685 } 1692 }
1686 1693
1687 void FrameView::repaintFixedElementsAfterScrolling() 1694 void FrameView::updateLayersAndCompositingAfterScrollIfNeeded()
1688 { 1695 {
1696 // Nothing to do after scrolling if there are no fixed position elements.
1697 if (!hasViewportConstrainedObjects())
1698 return;
1699
1689 RefPtr<FrameView> protect(this); 1700 RefPtr<FrameView> protect(this);
1690 // For fixed position elements, update widget positions and compositing laye rs after scrolling, 1701
1691 // but only if we're not inside of layout. 1702 // If there fixed position elements, scrolling may cause compositing layers to change.
1692 if (!m_nestedLayoutCount && hasViewportConstrainedObjects()) { 1703 // Update widget and layer positions after scrolling, but only if we're not inside of
1704 // layout.
1705 if (!m_nestedLayoutCount) {
1693 updateWidgetPositions(); 1706 updateWidgetPositions();
1694 if (RenderView* renderView = this->renderView()) 1707 if (RenderView* renderView = this->renderView())
1695 renderView->layer()->updateLayerPositionsAfterDocumentScroll(); 1708 renderView->layer()->updateLayerPositionsAfterDocumentScroll();
1696 } 1709 }
1710
1711 // Compositing layers may change after scrolling.
1712 // FIXME: Maybe no longer needed after we land squashing and kill overlap te sting?
1713 if (m_nestedLayoutCount <= 1) {
1714 if (RenderView* renderView = this->renderView())
1715 renderView->compositor()->setNeedsCompositingUpdate(CompositingUpdat eOnScroll);
1716 }
1697 } 1717 }
1698 1718
1699 void FrameView::updateFixedElementsAfterScrolling() 1719 void FrameView::updateFixedElementRepaintRectsAfterScroll()
1700 { 1720 {
1701 if (m_nestedLayoutCount <= 1 && hasViewportConstrainedObjects()) { 1721 if (!hasViewportConstrainedObjects())
1702 if (RenderView* renderView = this->renderView()) 1722 return;
1703 renderView->compositor()->setNeedsCompositingUpdate(CompositingUpdat eOnScroll); 1723
1724 // Update the repaint rects for fixed elements after scrolling and invalidat ion to reflect
1725 // the new scroll position.
1726 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje cts->end();
1727 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained Objects->begin(); it != end; ++it) {
1728 RenderObject* renderer = *it;
1729 if (!renderer->style()->hasViewportConstrainedPosition())
esprehn 2014/03/25 02:37:44 It seems really weird that m_viewportConstrainedOb
ykyyip 2014/03/25 23:02:00 I don't know why this check is here either. m_view
1730 continue;
1731
1732 // Fixed items should always have layers.
1733 ASSERT(renderer->hasLayer());
1734
1735 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer();
1736
1737 // Don't need to do this for composited fixed items.
1738 if (layer->compositingState() == PaintsIntoOwnBacking)
esprehn 2014/03/25 02:37:44 Fixed position elements are always composited now,
ykyyip 2014/03/25 23:02:00 Really, that code still gets run when there are fi
1739 continue;
1740
1741 // Also don't need to do this for invisible items.
1742 if (layer->viewportConstrainedNotCompositedReason() == RenderLayer::NotC ompositedForBoundsOutOfView
1743 || layer->viewportConstrainedNotCompositedReason() == RenderLayer::N otCompositedForNoVisibleContent)
1744 continue;
1745
1746 layer->repainter().computeRepaintRects(renderer->containerForRepaint());
1704 } 1747 }
1705 } 1748 }
1706 1749
1707 bool FrameView::shouldRubberBandInDirection(ScrollDirection direction) const 1750 bool FrameView::shouldRubberBandInDirection(ScrollDirection direction) const
1708 { 1751 {
1709 Page* page = frame().page(); 1752 Page* page = frame().page();
1710 if (!page) 1753 if (!page)
1711 return ScrollView::shouldRubberBandInDirection(direction); 1754 return ScrollView::shouldRubberBandInDirection(direction);
1712 return page->chrome().client().shouldRubberBandInDirection(direction); 1755 return page->chrome().client().shouldRubberBandInDirection(direction);
1713 } 1756 }
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 bool FrameView::isActive() const 2345 bool FrameView::isActive() const
2303 { 2346 {
2304 Page* page = frame().page(); 2347 Page* page = frame().page();
2305 return page && page->focusController().isActive(); 2348 return page && page->focusController().isActive();
2306 } 2349 }
2307 2350
2308 void FrameView::scrollTo(const IntSize& newOffset) 2351 void FrameView::scrollTo(const IntSize& newOffset)
2309 { 2352 {
2310 LayoutSize offset = scrollOffset(); 2353 LayoutSize offset = scrollOffset();
2311 ScrollView::scrollTo(newOffset); 2354 ScrollView::scrollTo(newOffset);
2312 if (offset != scrollOffset()) 2355 if (offset != scrollOffset()) {
2356 updateLayersAndCompositingAfterScrollIfNeeded();
2313 scrollPositionChanged(); 2357 scrollPositionChanged();
2358 }
2314 frame().loader().client()->didChangeScrollOffset(); 2359 frame().loader().client()->didChangeScrollOffset();
2315 } 2360 }
2316 2361
2317 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec t) 2362 void FrameView::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rec t)
2318 { 2363 {
2319 // Add in our offset within the FrameView. 2364 // Add in our offset within the FrameView.
2320 IntRect dirtyRect = rect; 2365 IntRect dirtyRect = rect;
2321 dirtyRect.moveBy(scrollbar->location()); 2366 dirtyRect.moveBy(scrollbar->location());
2322 2367
2323 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && isInPerformLayout ()) { 2368 if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled() && isInPerformLayout ()) {
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
2781 2826
2782 ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOver hangArea, dirtyRect); 2827 ScrollView::paintOverhangAreas(context, horizontalOverhangArea, verticalOver hangArea, dirtyRect);
2783 } 2828 }
2784 2829
2785 void FrameView::updateLayoutAndStyleForPainting() 2830 void FrameView::updateLayoutAndStyleForPainting()
2786 { 2831 {
2787 // Updating layout can run script, which can tear down the FrameView. 2832 // Updating layout can run script, which can tear down the FrameView.
2788 RefPtr<FrameView> protector(this); 2833 RefPtr<FrameView> protector(this);
2789 2834
2790 updateLayoutAndStyleIfNeededRecursive(); 2835 updateLayoutAndStyleIfNeededRecursive();
2836
2791 if (RenderView* view = renderView()) 2837 if (RenderView* view = renderView())
2792 view->compositor()->updateCompositingLayers(); 2838 view->compositor()->updateCompositingLayers();
2839
2840 scrollContentsIfNeededRecursive();
2793 } 2841 }
2794 2842
2795 void FrameView::updateLayoutAndStyleIfNeededRecursive() 2843 void FrameView::updateLayoutAndStyleIfNeededRecursive()
2796 { 2844 {
2797 // We have to crawl our entire tree looking for any FrameViews that need 2845 // We have to crawl our entire tree looking for any FrameViews that need
2798 // layout and make sure they are up to date. 2846 // layout and make sure they are up to date.
2799 // Mac actually tests for intersection with the dirty region and tries not t o 2847 // Mac actually tests for intersection with the dirty region and tries not t o
2800 // update layout for frames that are outside the dirty region. Not only doe s this seem 2848 // update layout for frames that are outside the dirty region. Not only doe s this seem
2801 // pointless (since those frames will have set a zero timer to layout anyway ), but 2849 // pointless (since those frames will have set a zero timer to layout anyway ), but
2802 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty 2850 // it is also incorrect, since if two frames overlap, the first could be exc luded from the dirty
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
3216 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation) 3264 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o rientation)
3217 { 3265 {
3218 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); 3266 ScrollableArea::willRemoveScrollbar(scrollbar, orientation);
3219 if (AXObjectCache* cache = axObjectCache()) { 3267 if (AXObjectCache* cache = axObjectCache()) {
3220 cache->remove(scrollbar); 3268 cache->remove(scrollbar);
3221 cache->handleScrollbarUpdate(this); 3269 cache->handleScrollbarUpdate(this);
3222 } 3270 }
3223 } 3271 }
3224 3272
3225 } // namespace WebCore 3273 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698