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 1206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1217 scrollContentsIfNeeded(); | 1217 scrollContentsIfNeeded(); |
1218 | 1218 |
1219 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { | 1219 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().nextSibling()) { |
1220 if (!child->isLocalFrame()) | 1220 if (!child->isLocalFrame()) |
1221 continue; | 1221 continue; |
1222 if (FrameView* view = toLocalFrame(child)->view()) | 1222 if (FrameView* view = toLocalFrame(child)->view()) |
1223 view->scrollContentsIfNeededRecursive(); | 1223 view->scrollContentsIfNeededRecursive(); |
1224 } | 1224 } |
1225 } | 1225 } |
1226 | 1226 |
1227 void FrameView::scrollContentsIfNeeded() | 1227 // FIXME: If we had a flag to force invalidations in a whole subtree, we could g
et rid of this function (crbug.com/410097). |
| 1228 static void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(c
onst RenderLayer* layer) |
1228 { | 1229 { |
1229 bool didScroll = !pendingScrollDelta().isZero(); | 1230 layer->renderer()->setShouldDoFullPaintInvalidation(true); |
1230 ScrollView::scrollContentsIfNeeded(); | 1231 |
1231 if (didScroll) | 1232 for (RenderLayer* child = layer->firstChild(); child; child = child->nextSib
ling()) { |
1232 updateFixedElementPaintInvalidationRectsAfterScroll(); | 1233 // Don't include paint invalidation rects for composited child layers; t
hey will paint themselves and have a different origin. |
| 1234 if (child->isPaintInvalidationContainer()) |
| 1235 continue; |
| 1236 |
| 1237 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(child
); |
| 1238 } |
1233 } | 1239 } |
1234 | 1240 |
1235 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) | 1241 bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta) |
1236 { | 1242 { |
1237 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) | 1243 if (!contentsInCompositedLayer() || hasSlowRepaintObjects()) |
1238 return false; | 1244 return false; |
1239 | 1245 |
1240 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { | 1246 if (!m_viewportConstrainedObjects || m_viewportConstrainedObjects->isEmpty()
) { |
1241 InspectorInstrumentation::didScroll(page()); | 1247 InspectorInstrumentation::didScroll(page()); |
1242 return true; | 1248 return true; |
1243 } | 1249 } |
1244 | 1250 |
1245 Region regionToUpdate; | |
1246 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); | 1251 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); |
1247 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { | 1252 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { |
1248 RenderObject* renderer = *it; | 1253 RenderObject* renderer = *it; |
1249 ASSERT(renderer->style()->hasViewportConstrainedPosition()); | 1254 ASSERT(renderer->style()->hasViewportConstrainedPosition()); |
1250 ASSERT(renderer->hasLayer()); | 1255 ASSERT(renderer->hasLayer()); |
1251 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | 1256 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); |
1252 | 1257 |
1253 CompositingState state = layer->compositingState(); | 1258 if (layer->isPaintInvalidationContainer()) |
1254 if (state == PaintsIntoOwnBacking || state == PaintsIntoGroupedBacking) | |
1255 continue; | 1259 continue; |
1256 | 1260 |
1257 if (layer->subtreeIsInvisible()) | 1261 if (layer->subtreeIsInvisible()) |
1258 continue; | 1262 continue; |
1259 | 1263 |
1260 // If the fixed layer has a blur/drop-shadow filter applied on at least
one of its parents, we cannot | 1264 // If the fixed layer has a blur/drop-shadow filter applied on at least
one of its parents, we cannot |
1261 // scroll using the fast path, otherwise the outsets of the filter will
be moved around the page. | 1265 // scroll using the fast path, otherwise the outsets of the filter will
be moved around the page. |
1262 if (layer->hasAncestorWithFilterOutsets()) | 1266 if (layer->hasAncestorWithFilterOutsets()) |
1263 return false; | 1267 return false; |
1264 | 1268 |
1265 IntRect updateRect = pixelSnappedIntRect(layer->paintInvalidator().paint
InvalidationRectIncludingNonCompositingDescendants()); | 1269 setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(layer
); |
1266 | |
1267 const RenderLayerModelObject* repaintContainer = layer->renderer()->cont
ainerForPaintInvalidation(); | |
1268 if (repaintContainer && !repaintContainer->isRenderView()) { | |
1269 // Invalidate the old and new locations of fixed position elements t
hat are not drawn into the RenderView. | |
1270 updateRect.moveBy(scrollPosition()); | |
1271 IntRect previousRect = updateRect; | |
1272 previousRect.move(scrollDelta); | |
1273 // FIXME: Rather than uniting the rects, we should just issue both i
nvalidations. | |
1274 updateRect.unite(previousRect); | |
1275 layer->renderer()->invalidatePaintUsingContainer(repaintContainer, u
pdateRect, InvalidationScroll); | |
1276 } else { | |
1277 // Coalesce the paint invalidations that will be issued to the rende
rView. | |
1278 updateRect = contentsToRootView(updateRect); | |
1279 if (!updateRect.isEmpty()) | |
1280 regionToUpdate.unite(updateRect); | |
1281 } | |
1282 } | 1270 } |
1283 | 1271 |
1284 InspectorInstrumentation::didScroll(page()); | 1272 InspectorInstrumentation::didScroll(page()); |
1285 | |
1286 // Invalidate the old and new locations of fixed position elements that are
drawn into the RenderView. | |
1287 Vector<IntRect> subRectsToUpdate = regionToUpdate.rects(); | |
1288 size_t viewportConstrainedObjectsCount = subRectsToUpdate.size(); | |
1289 for (size_t i = 0; i < viewportConstrainedObjectsCount; ++i) { | |
1290 IntRect updateRect = subRectsToUpdate[i]; | |
1291 IntRect scrolledRect = updateRect; | |
1292 scrolledRect.move(-scrollDelta); | |
1293 updateRect.unite(scrolledRect); | |
1294 // FIXME: We should be able to issue these invalidations separately and
before we actually scroll. | |
1295 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(rootViewToContents(updateRect)); | |
1296 } | |
1297 | |
1298 return true; | 1273 return true; |
1299 } | 1274 } |
1300 | 1275 |
1301 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) | 1276 void FrameView::scrollContentsSlowPath(const IntRect& updateRect) |
1302 { | 1277 { |
1303 if (contentsInCompositedLayer()) { | 1278 if (contentsInCompositedLayer()) { |
1304 IntRect updateRect = visibleContentRect(); | 1279 IntRect updateRect = visibleContentRect(); |
1305 ASSERT(renderView()); | 1280 ASSERT(renderView()); |
1306 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(updateRect); | 1281 renderView()->layer()->paintInvalidator().setBackingNeedsPaintInvalidati
onInRect(updateRect); |
1307 } | 1282 } |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 // If there fixed position elements, scrolling may cause compositing layers
to change. | 1492 // If there fixed position elements, scrolling may cause compositing layers
to change. |
1518 // Update widget and layer positions after scrolling, but only if we're not
inside of | 1493 // Update widget and layer positions after scrolling, but only if we're not
inside of |
1519 // layout. | 1494 // layout. |
1520 if (!m_nestedLayoutCount) { | 1495 if (!m_nestedLayoutCount) { |
1521 updateWidgetPositions(); | 1496 updateWidgetPositions(); |
1522 if (RenderView* renderView = this->renderView()) | 1497 if (RenderView* renderView = this->renderView()) |
1523 renderView->layer()->setNeedsCompositingInputsUpdate(); | 1498 renderView->layer()->setNeedsCompositingInputsUpdate(); |
1524 } | 1499 } |
1525 } | 1500 } |
1526 | 1501 |
1527 void FrameView::updateFixedElementPaintInvalidationRectsAfterScroll() | |
1528 { | |
1529 if (!hasViewportConstrainedObjects()) | |
1530 return; | |
1531 | |
1532 // Update the paint invalidation rects for fixed elements after scrolling an
d invalidation to reflect | |
1533 // the new scroll position. | |
1534 ViewportConstrainedObjectSet::const_iterator end = m_viewportConstrainedObje
cts->end(); | |
1535 for (ViewportConstrainedObjectSet::const_iterator it = m_viewportConstrained
Objects->begin(); it != end; ++it) { | |
1536 RenderObject* renderer = *it; | |
1537 // m_viewportConstrainedObjects should not contain non-viewport constrai
ned objects. | |
1538 ASSERT(renderer->style()->hasViewportConstrainedPosition()); | |
1539 | |
1540 // Fixed items should always have layers. | |
1541 ASSERT(renderer->hasLayer()); | |
1542 | |
1543 RenderLayer* layer = toRenderBoxModelObject(renderer)->layer(); | |
1544 | |
1545 // Don't need to do this for composited fixed items. | |
1546 if (layer->compositingState() == PaintsIntoOwnBacking) | |
1547 continue; | |
1548 | |
1549 layer->paintInvalidator().computePaintInvalidationRectsIncludingNonCompo
sitingDescendants(); | |
1550 } | |
1551 } | |
1552 | |
1553 void FrameView::updateCompositedSelectionBoundsIfNeeded() | 1502 void FrameView::updateCompositedSelectionBoundsIfNeeded() |
1554 { | 1503 { |
1555 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) | 1504 if (!RuntimeEnabledFeatures::compositedSelectionUpdatesEnabled()) |
1556 return; | 1505 return; |
1557 | 1506 |
1558 Page* page = frame().page(); | 1507 Page* page = frame().page(); |
1559 ASSERT(page); | 1508 ASSERT(page); |
1560 | 1509 |
1561 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame(
)); | 1510 LocalFrame* frame = toLocalFrame(page->focusController().focusedOrMainFrame(
)); |
1562 if (!frame || !frame->selection().isCaretOrRange()) { | 1511 if (!frame || !frame->selection().isCaretOrRange()) { |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 | 2485 |
2537 void FrameView::updateLayoutAndStyleForPainting() | 2486 void FrameView::updateLayoutAndStyleForPainting() |
2538 { | 2487 { |
2539 // Updating layout can run script, which can tear down the FrameView. | 2488 // Updating layout can run script, which can tear down the FrameView. |
2540 RefPtr<FrameView> protector(this); | 2489 RefPtr<FrameView> protector(this); |
2541 | 2490 |
2542 updateLayoutAndStyleIfNeededRecursive(); | 2491 updateLayoutAndStyleIfNeededRecursive(); |
2543 | 2492 |
2544 updateWidgetPositionsIfNeeded(); | 2493 updateWidgetPositionsIfNeeded(); |
2545 | 2494 |
2546 if (RenderView* view = renderView()) { | 2495 RenderView* view = renderView(); |
| 2496 if (view) { |
2547 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateLayerTree", "frame", m_frame.get()); | 2497 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Up
dateLayerTree", "frame", m_frame.get()); |
2548 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. | 2498 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti
meline migrates to tracing. |
2549 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); | 2499 InspectorInstrumentation::willUpdateLayerTree(m_frame.get()); |
2550 | 2500 |
2551 view->compositor()->updateIfNeededRecursive(); | 2501 view->compositor()->updateIfNeededRecursive(); |
2552 | 2502 |
2553 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) | 2503 if (view->compositor()->inCompositingMode() && m_frame->isLocalRoot()) |
2554 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang
eIfNeeded(); | 2504 m_frame->page()->scrollingCoordinator()->updateAfterCompositingChang
eIfNeeded(); |
2555 | 2505 |
2556 updateCompositedSelectionBoundsIfNeeded(); | 2506 updateCompositedSelectionBoundsIfNeeded(); |
2557 | 2507 |
2558 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); | 2508 InspectorInstrumentation::didUpdateLayerTree(m_frame.get()); |
2559 | |
2560 invalidateTreeIfNeededRecursive(); | |
2561 } | 2509 } |
2562 | 2510 |
2563 scrollContentsIfNeededRecursive(); | 2511 scrollContentsIfNeededRecursive(); |
| 2512 |
| 2513 if (view) |
| 2514 invalidateTreeIfNeededRecursive(); |
| 2515 |
2564 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); | 2516 ASSERT(lifecycle().state() == DocumentLifecycle::PaintInvalidationClean); |
2565 } | 2517 } |
2566 | 2518 |
2567 void FrameView::updateLayoutAndStyleIfNeededRecursive() | 2519 void FrameView::updateLayoutAndStyleIfNeededRecursive() |
2568 { | 2520 { |
2569 // We have to crawl our entire tree looking for any FrameViews that need | 2521 // We have to crawl our entire tree looking for any FrameViews that need |
2570 // layout and make sure they are up to date. | 2522 // layout and make sure they are up to date. |
2571 // Mac actually tests for intersection with the dirty region and tries not t
o | 2523 // Mac actually tests for intersection with the dirty region and tries not t
o |
2572 // update layout for frames that are outside the dirty region. Not only doe
s this seem | 2524 // update layout for frames that are outside the dirty region. Not only doe
s this seem |
2573 // pointless (since those frames will have set a zero timer to layout anyway
), but | 2525 // 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... |
3000 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) | 2952 void FrameView::willRemoveScrollbar(Scrollbar* scrollbar, ScrollbarOrientation o
rientation) |
3001 { | 2953 { |
3002 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); | 2954 ScrollableArea::willRemoveScrollbar(scrollbar, orientation); |
3003 if (AXObjectCache* cache = axObjectCache()) { | 2955 if (AXObjectCache* cache = axObjectCache()) { |
3004 cache->remove(scrollbar); | 2956 cache->remove(scrollbar); |
3005 cache->handleScrollbarUpdate(this); | 2957 cache->handleScrollbarUpdate(this); |
3006 } | 2958 } |
3007 } | 2959 } |
3008 | 2960 |
3009 } // namespace blink | 2961 } // namespace blink |
OLD | NEW |