OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 if (!scrollbar) | 2346 if (!scrollbar) |
2347 return; | 2347 return; |
2348 | 2348 |
2349 const IntRect& scrollbarRect = scrollbar->frameRect(); | 2349 const IntRect& scrollbarRect = scrollbar->frameRect(); |
2350 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); | 2350 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr
anslation(-scrollbarRect.x(), -scrollbarRect.y())); |
2351 IntRect transformedClip = clip; | 2351 IntRect transformedClip = clip; |
2352 transformedClip.moveBy(scrollbarRect.location()); | 2352 transformedClip.moveBy(scrollbarRect.location()); |
2353 scrollbar->paint(context, CullRect(transformedClip)); | 2353 scrollbar->paint(context, CullRect(transformedClip)); |
2354 } | 2354 } |
2355 | 2355 |
| 2356 // TODO(eseckler): Make recording distance configurable, e.g. for use in |
| 2357 // headless, where we would like to record an exact area (distance = 0). |
2356 static const int kPixelDistanceToRecord = 4000; | 2358 static const int kPixelDistanceToRecord = 4000; |
2357 | 2359 |
2358 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const | 2360 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph
icsLayer) const |
2359 { | 2361 { |
2360 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); | 2362 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); |
2361 | 2363 |
2362 IntSize offsetFromAnchorLayoutObject; | 2364 IntSize offsetFromAnchorLayoutObject; |
2363 const LayoutBoxModelObject* anchorLayoutObject; | 2365 const LayoutBoxModelObject* anchorLayoutObject; |
2364 if (graphicsLayer == m_squashingLayer.get()) { | 2366 if (graphicsLayer == m_squashingLayer.get()) { |
2365 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that | 2367 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev
er, it should never be the case that |
2366 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. | 2368 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must
be a bug elsewhere. |
2367 if (m_squashedLayers.size() == 0) | 2369 if (m_squashedLayers.size() == 0) |
2368 return IntRect(); | 2370 return IntRect(); |
2369 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's | 2371 // All squashed layers have the same clip and transform space, so we can
use the first squashed layer's |
2370 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject | 2372 // layoutObject to map the squashing layer's bounds into viewport space,
with offsetFromAnchorLayoutObject |
2371 // to translate squashing layer's bounds into the first squashed layer's
space. | 2373 // to translate squashing layer's bounds into the first squashed layer's
space. |
2372 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); | 2374 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); |
2373 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; | 2375 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec
t; |
2374 } else { | 2376 } else { |
2375 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro
llingContentsLayer.get()); | 2377 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro
llingContentsLayer.get()); |
2376 anchorLayoutObject = m_owningLayer.layoutObject(); | 2378 anchorLayoutObject = m_owningLayer.layoutObject(); |
2377 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); | 2379 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); |
2378 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); | 2380 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject
); |
2379 } | 2381 } |
2380 | 2382 |
2381 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. | 2383 // Start with the bounds of the graphics layer in the space of the anchor La
youtObject. |
2382 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); | 2384 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); |
2383 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); | 2385 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); |
2384 | 2386 |
2385 // Now map the bounds to its visible content rect in screen space, including
applying clips along the way. | 2387 // Now map the bounds to its visible content rect in root view space, includ
ing applying clips along the way. |
2386 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); | 2388 LayoutRect graphicsLayerBoundsInRootViewSpace(graphicsLayerBoundsInObjectSpa
ce); |
2387 LayoutView* rootView = anchorLayoutObject->view(); | 2389 LayoutView* rootView = anchorLayoutObject->view(); |
2388 while (!rootView->frame()->ownerLayoutItem().isNull()) | 2390 while (!rootView->frame()->ownerLayoutItem().isNull()) |
2389 rootView = LayoutAPIShim::layoutObjectFrom(rootView->frame()->ownerLayou
tItem())->view(); | 2391 rootView = LayoutAPIShim::layoutObjectFrom(rootView->frame()->ownerLayou
tItem())->view(); |
2390 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, visibleContentR
ect); | 2392 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, graphicsLayerBo
undsInRootViewSpace); |
2391 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten
tRect())); | 2393 FloatRect visibleContentRect(graphicsLayerBoundsInRootViewSpace); |
| 2394 rootView->frameView()->clipPaintRect(&visibleContentRect); |
2392 | 2395 |
2393 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds)); | 2396 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds)); |
2394 | 2397 |
2395 // Map the visible content rect from screen space to local graphics layer sp
ace. | 2398 // Map the visible content rect from root view space to local graphics layer
space. |
2396 IntRect localInterestRect; | 2399 IntRect localInterestRect; |
2397 // If the visible content rect is empty, then it makes no sense to map it ba
ck since there is nothing to map. | 2400 // If the visible content rect is empty, then it makes no sense to map it ba
ck since there is nothing to map. |
2398 if (!visibleContentRect.isEmpty()) { | 2401 if (!visibleContentRect.isEmpty()) { |
2399 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(FloatRect(vi
sibleContentRect), UseTransforms | TraverseDocumentBoundaries).enclosingBounding
Box(); | 2402 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(visibleConte
ntRect, UseTransforms | TraverseDocumentBoundaries).enclosingBoundingBox(); |
2400 localInterestRect.move(-offsetFromAnchorLayoutObject); | 2403 localInterestRect.move(-offsetFromAnchorLayoutObject); |
2401 // TODO(chrishtr): the code below is a heuristic, instead we should dete
ct and return whether the mapping failed. | 2404 // TODO(chrishtr): the code below is a heuristic, instead we should dete
ct and return whether the mapping failed. |
2402 // In some cases, absoluteToLocalQuad can fail to map back to the local
space, due to passing through | 2405 // In some cases, absoluteToLocalQuad can fail to map back to the local
space, due to passing through |
2403 // non-invertible transforms or floating-point accuracy issues. Examples
include rotation near 90 degrees | 2406 // non-invertible transforms or floating-point accuracy issues. Examples
include rotation near 90 degrees |
2404 // or perspective. In such cases, fall back to painting the first kPixel
DistanceToRecord pixels in each direction. | 2407 // or perspective. In such cases, fall back to painting the first kPixel
DistanceToRecord pixels in each direction. |
2405 localInterestRect.intersect(enclosingGraphicsLayerBounds); | 2408 localInterestRect.intersect(enclosingGraphicsLayerBounds); |
2406 } | 2409 } |
2407 // Expand by interest rect padding amount. | 2410 // Expand by interest rect padding amount. |
2408 localInterestRect.inflate(kPixelDistanceToRecord); | 2411 localInterestRect.inflate(kPixelDistanceToRecord); |
2409 localInterestRect.intersect(enclosingGraphicsLayerBounds); | 2412 localInterestRect.intersect(enclosingGraphicsLayerBounds); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2444 return false; | 2447 return false; |
2445 } | 2448 } |
2446 | 2449 |
2447 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const | 2450 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic
sLayer, const IntRect& previousInterestRect) const |
2448 { | 2451 { |
2449 // Use the previous interest rect if it covers the whole layer. | 2452 // Use the previous interest rect if it covers the whole layer. |
2450 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); | 2453 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer->
size())); |
2451 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) | 2454 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) |
2452 return previousInterestRect; | 2455 return previousInterestRect; |
2453 | 2456 |
2454 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W
ebPreferences::record_whole_document is true. | 2457 if (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashingLa
yer.get() && graphicsLayer != m_scrollingContentsLayer.get()) |
2455 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin
gs()->mainFrameClipsContent(); | |
2456 if (shouldPaintWholePage | |
2457 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi
ngLayer.get() && graphicsLayer != m_scrollingContentsLayer.get())) | |
2458 return wholeLayerRect; | 2458 return wholeLayerRect; |
2459 | 2459 |
2460 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); | 2460 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); |
2461 if (needsRepaint(*graphicsLayer) || interestRectChangedEnoughToRepaint(previ
ousInterestRect, newInterestRect, expandedIntSize(graphicsLayer->size()))) | 2461 if (needsRepaint(*graphicsLayer) || interestRectChangedEnoughToRepaint(previ
ousInterestRect, newInterestRect, expandedIntSize(graphicsLayer->size()))) |
2462 return newInterestRect; | 2462 return newInterestRect; |
2463 return previousInterestRect; | 2463 return previousInterestRect; |
2464 } | 2464 } |
2465 | 2465 |
2466 LayoutSize CompositedLayerMapping::subpixelAccumulation() const | 2466 LayoutSize CompositedLayerMapping::subpixelAccumulation() const |
2467 { | 2467 { |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { | 2751 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { |
2752 name = "Scrolling Contents Layer"; | 2752 name = "Scrolling Contents Layer"; |
2753 } else { | 2753 } else { |
2754 ASSERT_NOT_REACHED(); | 2754 ASSERT_NOT_REACHED(); |
2755 } | 2755 } |
2756 | 2756 |
2757 return name; | 2757 return name; |
2758 } | 2758 } |
2759 | 2759 |
2760 } // namespace blink | 2760 } // namespace blink |
OLD | NEW |