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

Side by Side Diff: third_party/WebKit/Source/core/layout/compositing/CompositedLayerMapping.cpp

Issue 2237433004: Adds DevTools commands for forced viewport override. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Dmitry's comments + sync. Created 4 years, 3 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
OLDNEW
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 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 if (!scrollbar) 2294 if (!scrollbar)
2295 return; 2295 return;
2296 2296
2297 const IntRect& scrollbarRect = scrollbar->frameRect(); 2297 const IntRect& scrollbarRect = scrollbar->frameRect();
2298 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y())); 2298 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y()));
2299 IntRect transformedClip = clip; 2299 IntRect transformedClip = clip;
2300 transformedClip.moveBy(scrollbarRect.location()); 2300 transformedClip.moveBy(scrollbarRect.location());
2301 scrollbar->paint(context, CullRect(transformedClip)); 2301 scrollbar->paint(context, CullRect(transformedClip));
2302 } 2302 }
2303 2303
2304 // TODO(eseckler): Make recording distance configurable, e.g. for use in
2305 // headless, where we would like to record an exact area (distance = 0).
2304 static const int kPixelDistanceToRecord = 4000; 2306 static const int kPixelDistanceToRecord = 4000;
2305 2307
2306 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph icsLayer) const 2308 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph icsLayer) const
2307 { 2309 {
2308 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); 2310 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size());
2309 2311
2310 IntSize offsetFromAnchorLayoutObject; 2312 IntSize offsetFromAnchorLayoutObject;
2311 const LayoutBoxModelObject* anchorLayoutObject; 2313 const LayoutBoxModelObject* anchorLayoutObject;
2312 if (graphicsLayer == m_squashingLayer.get()) { 2314 if (graphicsLayer == m_squashingLayer.get()) {
2313 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev er, it should never be the case that 2315 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev er, it should never be the case that
2314 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must be a bug elsewhere. 2316 // m_squashingLayer exists yet m_squashedLayers.size() == 0. There must be a bug elsewhere.
2315 if (m_squashedLayers.size() == 0) 2317 if (m_squashedLayers.size() == 0)
2316 return IntRect(); 2318 return IntRect();
2317 // All squashed layers have the same clip and transform space, so we can use the first squashed layer's 2319 // All squashed layers have the same clip and transform space, so we can use the first squashed layer's
2318 // layoutObject to map the squashing layer's bounds into viewport space, with offsetFromAnchorLayoutObject 2320 // layoutObject to map the squashing layer's bounds into viewport space, with offsetFromAnchorLayoutObject
2319 // to translate squashing layer's bounds into the first squashed layer's space. 2321 // to translate squashing layer's bounds into the first squashed layer's space.
2320 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject(); 2322 anchorLayoutObject = m_squashedLayers[0].paintLayer->layoutObject();
2321 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec t; 2323 offsetFromAnchorLayoutObject = m_squashedLayers[0].offsetFromLayoutObjec t;
2322 } else { 2324 } else {
2323 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro llingContentsLayer.get()); 2325 ASSERT(graphicsLayer == m_graphicsLayer.get() || graphicsLayer == m_scro llingContentsLayer.get());
2324 anchorLayoutObject = m_owningLayer.layoutObject(); 2326 anchorLayoutObject = m_owningLayer.layoutObject();
2325 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); 2327 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject();
2326 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject ); 2328 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject );
2327 } 2329 }
2328 2330
2329 // Start with the bounds of the graphics layer in the space of the anchor La youtObject. 2331 // Start with the bounds of the graphics layer in the space of the anchor La youtObject.
2330 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); 2332 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds);
2331 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); 2333 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject);
2332 2334
2333 // Now map the bounds to its visible content rect in screen space, including applying clips along the way. 2335 // Now map the bounds to its visible content rect in root view space, includ ing applying clips along the way.
2334 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); 2336 LayoutRect graphicsLayerBoundsInRootViewSpace(graphicsLayerBoundsInObjectSpa ce);
2335 LayoutView* rootView = anchorLayoutObject->view(); 2337 LayoutView* rootView = anchorLayoutObject->view();
2336 while (!rootView->frame()->ownerLayoutItem().isNull()) 2338 while (!rootView->frame()->ownerLayoutItem().isNull())
2337 rootView = LayoutAPIShim::layoutObjectFrom(rootView->frame()->ownerLayou tItem())->view(); 2339 rootView = LayoutAPIShim::layoutObjectFrom(rootView->frame()->ownerLayou tItem())->view();
2338 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, visibleContentR ect); 2340 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, graphicsLayerBo undsInRootViewSpace);
2339 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten tRect())); 2341 FloatRect visibleContentRect(graphicsLayerBoundsInRootViewSpace);
2342 rootView->frameView()->clipPaintRect(&visibleContentRect);
2340 2343
2341 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds)); 2344 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds));
2342 2345
2343 // Map the visible content rect from screen space to local graphics layer sp ace. 2346 // Map the visible content rect from root view space to local graphics layer space.
2344 IntRect localInterestRect; 2347 IntRect localInterestRect;
2345 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map. 2348 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map.
2346 if (!visibleContentRect.isEmpty()) { 2349 if (!visibleContentRect.isEmpty()) {
2347 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms | TraverseDocumentBoundaries).enclosingBounding Box(); 2350 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(visibleConte ntRect, UseTransforms | TraverseDocumentBoundaries).enclosingBoundingBox();
2348 localInterestRect.move(-offsetFromAnchorLayoutObject); 2351 localInterestRect.move(-offsetFromAnchorLayoutObject);
2349 // TODO(chrishtr): the code below is a heuristic, instead we should dete ct and return whether the mapping failed. 2352 // TODO(chrishtr): the code below is a heuristic, instead we should dete ct and return whether the mapping failed.
2350 // In some cases, absoluteToLocalQuad can fail to map back to the local space, due to passing through 2353 // In some cases, absoluteToLocalQuad can fail to map back to the local space, due to passing through
2351 // non-invertible transforms or floating-point accuracy issues. Examples include rotation near 90 degrees 2354 // non-invertible transforms or floating-point accuracy issues. Examples include rotation near 90 degrees
2352 // or perspective. In such cases, fall back to painting the first kPixel DistanceToRecord pixels in each direction. 2355 // or perspective. In such cases, fall back to painting the first kPixel DistanceToRecord pixels in each direction.
2353 localInterestRect.intersect(enclosingGraphicsLayerBounds); 2356 localInterestRect.intersect(enclosingGraphicsLayerBounds);
2354 } 2357 }
2355 // Expand by interest rect padding amount. 2358 // Expand by interest rect padding amount.
2356 localInterestRect.inflate(kPixelDistanceToRecord); 2359 localInterestRect.inflate(kPixelDistanceToRecord);
2357 localInterestRect.intersect(enclosingGraphicsLayerBounds); 2360 localInterestRect.intersect(enclosingGraphicsLayerBounds);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 return false; 2395 return false;
2393 } 2396 }
2394 2397
2395 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, const IntRect& previousInterestRect) const 2398 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, const IntRect& previousInterestRect) const
2396 { 2399 {
2397 // Use the previous interest rect if it covers the whole layer. 2400 // Use the previous interest rect if it covers the whole layer.
2398 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer-> size())); 2401 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer-> size()));
2399 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) 2402 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect)
2400 return previousInterestRect; 2403 return previousInterestRect;
2401 2404
2402 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W ebPreferences::record_whole_document is true. 2405 if (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashingLa yer.get() && graphicsLayer != m_scrollingContentsLayer.get())
2403 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin gs()->mainFrameClipsContent();
2404 if (shouldPaintWholePage
2405 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi ngLayer.get() && graphicsLayer != m_scrollingContentsLayer.get()))
2406 return wholeLayerRect; 2406 return wholeLayerRect;
2407 2407
2408 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); 2408 IntRect newInterestRect = recomputeInterestRect(graphicsLayer);
2409 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect , expandedIntSize(graphicsLayer->size()))) 2409 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect , expandedIntSize(graphicsLayer->size())))
2410 return newInterestRect; 2410 return newInterestRect;
2411 return previousInterestRect; 2411 return previousInterestRect;
2412 } 2412 }
2413 2413
2414 LayoutSize CompositedLayerMapping::subpixelAccumulation() const 2414 LayoutSize CompositedLayerMapping::subpixelAccumulation() const
2415 { 2415 {
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2697 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2697 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2698 name = "Scrolling Contents Layer"; 2698 name = "Scrolling Contents Layer";
2699 } else { 2699 } else {
2700 ASSERT_NOT_REACHED(); 2700 ASSERT_NOT_REACHED();
2701 } 2701 }
2702 2702
2703 return name; 2703 return name;
2704 } 2704 }
2705 2705
2706 } // namespace blink 2706 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698