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