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 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 scrollContentsIfNeeded(); | 1234 scrollContentsIfNeeded(); |
1235 | 1235 |
1236 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 1236 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
1237 if (!child->isLocalFrame()) | 1237 if (!child->isLocalFrame()) |
1238 continue; | 1238 continue; |
1239 if (FrameView* view = toLocalFrame(child)->view()) | 1239 if (FrameView* view = toLocalFrame(child)->view()) |
1240 view->scrollContentsIfNeededRecursive(); | 1240 view->scrollContentsIfNeededRecursive(); |
1241 } | 1241 } |
1242 } | 1242 } |
1243 | 1243 |
1244 void FrameView::scrollContentsIfNeeded() | 1244 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g
et rid of this function (crbug.com/410097). |
| 1245 static void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(c
onst RenderLayer* layer) |
1245 { | 1246 { |
1246 bool didScroll = !pendingScrollDelta().isZero(); | 1247 layer->renderer()->setShouldDoFullPaintInvalidation(true); |
1247 ScrollView::scrollContentsIfNeeded(); | 1248 |
1248 if (didScroll) | 1249 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib
ling()) { |
1249 updateFixedElementPaintInvalidationRectsAfterScroll(); | 1250 // Don't include paint invalidation rects for composited child layers; t
hey will paint themselves and have a different origin. |
| 1251 if (child->isPaintInvalidationContainer()) |
| 1252 continue; |
| 1253 |
| 1254 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(child
); |
| 1255 } |
1250 } | 1256 } |
1251 | 1257 |
1252 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) | 1258 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
1253 { | 1259 { |
1254 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) | 1260 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) |
1255 return false; | 1261 return false; |
1256 | 1262 |
1257 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { | 1263 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { |
1258 InspectorInstrumentation::didScroll(page()); | 1264 InspectorInstrumentation::didScroll(page()); |
1259 return true; | 1265 return true; |
1260 } | 1266 } |
1261 | 1267 |
1262 Region regionToUpdate; | |
1263 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); | 1268 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); |
1264 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { | 1269 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { |
1265 RenderObject* renderer = *it; | 1270 RenderObject* renderer = *it; |
1266 ASSERT(renderer->style()->hasViewportConstrainedPosition()); | 1271 ASSERT(renderer->style()->hasViewportConstrainedPosition()); |
1267 ASSERT(renderer->hasLayer()); | 1272 ASSERT(renderer->hasLayer()); |
1268 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 1273 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
1269 | 1274 |
1270 CompositingState state = layer->compositingState(); | 1275 if (layer->isPaintInvalidationContainer()) |
1271 if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking) | |
1272 continue; | 1276 continue; |
1273 | 1277 |
1274 if (layer->subtreeIsInvisible()) | 1278 if (layer->subtreeIsInvisible()) |
1275 continue; | 1279 continue; |
1276 | 1280 |
1277 // If the fixed layer has a blur/drop-shadow filter applied on at least
one of its parents, we cannot | 1281 // If the fixed layer has a blur/drop-shadow filter applied on at least
one of its parents, we cannot |
1278 // scroll using the fast path, otherwise the outsets of the filter will
be moved around the page. | 1282 // scroll using the fast path, otherwise the outsets of the filter will
be moved around the page. |
1279 if (layer->hasAncestorWithFilterOutsets()) | 1283 if (layer->hasAncestorWithFilterOutsets()) |
1280 return false; | 1284 return false; |
1281 | 1285 |
1282 IntRect updateRect = pixelSnappedIntRect(layer->paintInvalidator().paint
InvalidationRectIncludingNonCompositingDescendants()); | 1286 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(layer
); |
1283 | |
1284 const RenderLayerModelObject* repaintContainer = layer->renderer()->cont
ainerForPaintInvalidation(); | |
1285 if (repaintContainer && !repaintContainer->isRenderView()) { | |
1286 // Invalidate the old and new locations of fixed position elements t
hat are not drawn into the RenderView. | |
1287 updateRect.moveBy(scrollPosition()); | |
1288 IntRect previousRect = updateRect; | |
1289 previousRect.move(scrollDelta); | |
1290 // FIXME: Rather than uniting the rects, we should just issue both i
nvalidations. | |
1291 updateRect.unite(previousRect); | |
1292 layer->renderer()->invalidatePaintUsingContainer(repaintContainer, u
pdateRect, InvalidationScroll); | |
1293 } else { | |
1294 // Coalesce the paint invalidations that will be issued to the rende
rView. | |
1295 updateRect = contentsToRootView(updateRect); | |
1296 if (!updateRect.isEmpty()) | |
1297 regionToUpdate.unite(updateRect); | |
1298 } | |
1299 } | 1287 } |
1300 | 1288 |
1301 InspectorInstrumentation::didScroll(page()); | 1289 InspectorInstrumentation::didScroll(page()); |
1302 | |
1303 // Invalidate the old and new locations of fixed position elements that are
drawn into the RenderView. | |
1304 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects(); | |
1305 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size(); | |
1306 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) { | |
1307 IntRect updateRect = subRectsToUpdate[i]; | |
1308 IntRect scrolledRect = updateRect; | |
1309 scrolledRect.move(-scrollDelta); | |
1310 updateRect.unite(scrolledRect); | |
1311 // FIXME: We should be able to issue these invalidations separately and
before we actually scroll. | |
1312 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(rootViewToContents(updateRect)); | |
1313 } | |
1314 | |
1315 return true; | 1290 return true; |
1316 } | 1291 } |
1317 | 1292 |
1318 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) | 1293 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) |
1319 { | 1294 { |
1320 if (contentsInCompositedLayer()) { | 1295 if (contentsInCompositedLayer()) { |
1321 IntRect updateRect = visibleContentRect(); | 1296 IntRect updateRect = visibleContentRect(); |
1322 ASSERT(renderView()); | 1297 ASSERT(renderView()); |
1323 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(updateRect); | 1298 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(updateRect); |
1324 } | 1299 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 // If there fixed position elements, scrolling may cause compositing layers
to change. | 1509 // If there fixed position elements, scrolling may cause compositing layers
to change. |
1535 // Update widget and layer positions after scrolling, but only if we're not
inside of | 1510 // Update widget and layer positions after scrolling, but only if we're not
inside of |
1536 // layout. | 1511 // layout. |
1537 if (!m_nestedLayoutCount) { | 1512 if (!m_nestedLayoutCount) { |
1538 updateWidgetPositions(); | 1513 updateWidgetPositions(); |
1539 if (RenderView* renderView = this->renderView()) | 1514 if (RenderView* renderView = this->renderView()) |
1540 renderView->layer()->setNeedsCompositingInputsUpdate(); | 1515 renderView->layer()->setNeedsCompositingInputsUpdate(); |
1541 } | 1516 } |
1542 } | 1517 } |
1543 | 1518 |
1544 void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll() | |
1545 { | |
1546 if (!hasViewportConstrainedObjects()) | |
1547 return; | |
1548 | |
1549 // Update the paint invalidation rects for fixed elements after scrolling an
d invalidation to reflect | |
1550 // the new scroll position. | |
1551 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); | |
1552 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { | |
1553 RenderObject* renderer = *it; | |
1554 // m_viewportConstrainedObjects should not contain non-viewport constrai
ned objects. | |
1555 ASSERT(renderer->style()->hasViewportConstrainedPosition()); | |
1556 | |
1557 // Fixed items should always have layers. | |
1558 ASSERT(renderer->hasLayer()); | |
1559 | |
1560 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | |
1561 | |
1562 // Don't need to do this for composited fixed items. | |
1563 if (layer->compositingState() == PaintsIntoOwnBacking) | |
1564 continue; | |
1565 | |
1566 layer->paintInvalidator().computePaintInvalidationRectsIncludingNonCompo
sitingDescendants(); | |
1567 } | |
1568 } | |
1569 | |
1570 void FrameView::updateCompositedSelectionBoundsIfNeeded() | 1519 void FrameView::updateCompositedSelectionBoundsIfNeeded() |
1571 { | 1520 { |
1572 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) | 1521 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) |
1573 return; | 1522 return; |
1574 | 1523 |
1575 Page* page = frame().page(); | 1524 Page* page = frame().page(); |
1576 ASSERT(page); | 1525 ASSERT(page); |
1577 | 1526 |
1578 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame(
)); | 1527 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame(
)); |
1579 if (!frame || !frame->selection().isCaretOrRange()) { | 1528 if (!frame || !frame->selection().isCaretOrRange()) { |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2553 | 2502 |
2554 void FrameView::updateLayoutAndStyleForPainting() | 2503 void FrameView::updateLayoutAndStyleForPainting() |
2555 { | 2504 { |
2556 // Updating layout can run script, which can tear down the FrameView. | 2505 // Updating layout can run script, which can tear down the FrameView. |
2557 RefPtr<FrameView> protector(this); | 2506 RefPtr<FrameView> protector(this); |
2558 | 2507 |
2559 updateLayoutAndStyleIfNeededRecursive(); | 2508 updateLayoutAndStyleIfNeededRecursive(); |
2560 | 2509 |
2561 updateWidgetPositionsIfNeeded(); | 2510 updateWidgetPositionsIfNeeded(); |
2562 | 2511 |
2563 if (RenderView* view = renderView()) { | 2512 RenderView* view = renderView(); |
| 2513 if (view) { |
2564 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateLayerTree", "frame", m_frame.get()); | 2514 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateLayerTree", "frame", m_frame.get()); |
2565 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. | 2515 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. |
2566 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); | 2516 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); |
2567 | 2517 |
2568 view->compositor()->updateIfNeededRecursive(); | 2518 view->compositor()->updateIfNeededRecursive(); |
2569 | 2519 |
2570 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) | 2520 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) |
2571 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang
eIfNeeded(); | 2521 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang
eIfNeeded(); |
2572 | 2522 |
2573 updateCompositedSelectionBoundsIfNeeded(); | 2523 updateCompositedSelectionBoundsIfNeeded(); |
2574 | 2524 |
2575 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); | 2525 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); |
2576 | |
2577 invalidateTreeIfNeededRecursive(); | |
2578 } | 2526 } |
2579 | 2527 |
2580 scrollContentsIfNeededRecursive(); | 2528 scrollContentsIfNeededRecursive(); |
| 2529 |
| 2530 if (view) |
| 2531 invalidateTreeIfNeededRecursive(); |
| 2532 |
2581 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); | 2533 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); |
2582 } | 2534 } |
2583 | 2535 |
2584 void FrameView::updateLayoutAndStyleIfNeededRecursive() | 2536 void FrameView::updateLayoutAndStyleIfNeededRecursive() |
2585 { | 2537 { |
2586 // We have to crawl our entire tree looking for any FrameViews that need | 2538 // We have to crawl our entire tree looking for any FrameViews that need |
2587 // layout and make sure they are up to date. | 2539 // layout and make sure they are up to date. |
2588 // Mac actually tests for intersection with the dirty region and tries not t
o | 2540 // Mac actually tests for intersection with the dirty region and tries not t
o |
2589 // update layout for frames that are outside the dirty region. Not only doe
s this seem | 2541 // update layout for frames that are outside the dirty region. Not only doe
s this seem |
2590 // pointless (since those frames will have set a zero timer to layout anyway
), but | 2542 // pointless (since those frames will have set a zero timer to layout anyway
), but |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) | 2969 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) |
3018 { | 2970 { |
3019 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 2971 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); |
3020 if (AXObjectCache* cache = axObjectCache()) { | 2972 if (AXObjectCache* cache = axObjectCache()) { |
3021 cache->remove(scrollbar); | 2973 cache->remove(scrollbar); |
3022 cache->handleScrollbarUpdate(this); | 2974 cache->handleScrollbarUpdate(this); |
3023 } | 2975 } |
3024 } | 2976 } |
3025 | 2977 |
3026 } // namespace blink | 2978 } // namespace blink |
OLD | NEW |