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

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: remove offset/scale params, rename commands, clip by backing size. 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 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 if (!scrollbar) 2275 if (!scrollbar)
2276 return; 2276 return;
2277 2277
2278 const IntRect& scrollbarRect = scrollbar->frameRect(); 2278 const IntRect& scrollbarRect = scrollbar->frameRect();
2279 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y())); 2279 TransformRecorder transformRecorder(context, *scrollbar, AffineTransform::tr anslation(-scrollbarRect.x(), -scrollbarRect.y()));
2280 IntRect transformedClip = clip; 2280 IntRect transformedClip = clip;
2281 transformedClip.moveBy(scrollbarRect.location()); 2281 transformedClip.moveBy(scrollbarRect.location());
2282 scrollbar->paint(context, CullRect(transformedClip)); 2282 scrollbar->paint(context, CullRect(transformedClip));
2283 } 2283 }
2284 2284
2285 // TODO(eseckler): Make recording distance configurable, e.g. for use in
2286 // headless, where we would like to record an exact area (distance = 0).
2285 static const int kPixelDistanceToRecord = 4000; 2287 static const int kPixelDistanceToRecord = 4000;
2286 2288
2287 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph icsLayer) const 2289 IntRect CompositedLayerMapping::recomputeInterestRect(const GraphicsLayer* graph icsLayer) const
2288 { 2290 {
2289 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size()); 2291 FloatRect graphicsLayerBounds(FloatPoint(), graphicsLayer->size());
2290 2292
2291 IntSize offsetFromAnchorLayoutObject; 2293 IntSize offsetFromAnchorLayoutObject;
2292 const LayoutBoxModelObject* anchorLayoutObject; 2294 const LayoutBoxModelObject* anchorLayoutObject;
2293 if (graphicsLayer == m_squashingLayer.get()) { 2295 if (graphicsLayer == m_squashingLayer.get()) {
2294 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev er, it should never be the case that 2296 // TODO(chrishtr): this is a speculative fix for crbug.com/561306. Howev er, it should never be the case that
(...skipping 10 matching lines...) Expand all
2305 anchorLayoutObject = m_owningLayer.layoutObject(); 2307 anchorLayoutObject = m_owningLayer.layoutObject();
2306 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject(); 2308 offsetFromAnchorLayoutObject = graphicsLayer->offsetFromLayoutObject();
2307 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject ); 2309 adjustForCompositedScrolling(graphicsLayer, offsetFromAnchorLayoutObject );
2308 } 2310 }
2309 2311
2310 // Start with the bounds of the graphics layer in the space of the anchor La youtObject. 2312 // Start with the bounds of the graphics layer in the space of the anchor La youtObject.
2311 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds); 2313 FloatRect graphicsLayerBoundsInObjectSpace(graphicsLayerBounds);
2312 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject); 2314 graphicsLayerBoundsInObjectSpace.move(offsetFromAnchorLayoutObject);
2313 2315
2314 // Now map the bounds to its visible content rect in screen space, including applying clips along the way. 2316 // Now map the bounds to its visible content rect in screen space, including applying clips along the way.
2315 LayoutRect visibleContentRect(graphicsLayerBoundsInObjectSpace); 2317 LayoutRect graphicsLayerBoundsInScreenSpace(graphicsLayerBoundsInObjectSpace );
chrishtr 2016/08/22 22:00:42 It's not screen space, it's the space of the root
Eric Seckler 2016/08/23 09:32:19 Makes sense, updated the comments as well.
2316 LayoutView* rootView = anchorLayoutObject->view(); 2318 LayoutView* rootView = anchorLayoutObject->view();
2317 while (rootView->frame()->ownerLayoutObject()) 2319 while (rootView->frame()->ownerLayoutObject())
2318 rootView = rootView->frame()->ownerLayoutObject()->view(); 2320 rootView = rootView->frame()->ownerLayoutObject()->view();
2319 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, visibleContentR ect); 2321 anchorLayoutObject->mapToVisualRectInAncestorSpace(rootView, graphicsLayerBo undsInScreenSpace);
2320 visibleContentRect.intersect(LayoutRect(rootView->frameView()->visibleConten tRect())); 2322 FloatRect visibleContentRect(graphicsLayerBoundsInScreenSpace);
2323 rootView->frameView()->clipPaintRect(&visibleContentRect);
2321 2324
2322 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds)); 2325 IntRect enclosingGraphicsLayerBounds(enclosingIntRect(graphicsLayerBounds));
2323 2326
2324 // Map the visible content rect from screen space to local graphics layer sp ace. 2327 // Map the visible content rect from screen space to local graphics layer sp ace.
2325 IntRect localInterestRect; 2328 IntRect localInterestRect;
2326 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map. 2329 // If the visible content rect is empty, then it makes no sense to map it ba ck since there is nothing to map.
2327 if (!visibleContentRect.isEmpty()) { 2330 if (!visibleContentRect.isEmpty()) {
2328 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(FloatRect(vi sibleContentRect), UseTransforms | TraverseDocumentBoundaries).enclosingBounding Box(); 2331 localInterestRect = anchorLayoutObject->absoluteToLocalQuad(visibleConte ntRect, UseTransforms | TraverseDocumentBoundaries).enclosingBoundingBox();
2329 localInterestRect.move(-offsetFromAnchorLayoutObject); 2332 localInterestRect.move(-offsetFromAnchorLayoutObject);
2330 // TODO(chrishtr): the code below is a heuristic, instead we should dete ct and return whether the mapping failed. 2333 // TODO(chrishtr): the code below is a heuristic, instead we should dete ct and return whether the mapping failed.
2331 // In some cases, absoluteToLocalQuad can fail to map back to the local space, due to passing through 2334 // In some cases, absoluteToLocalQuad can fail to map back to the local space, due to passing through
2332 // non-invertible transforms or floating-point accuracy issues. Examples include rotation near 90 degrees 2335 // non-invertible transforms or floating-point accuracy issues. Examples include rotation near 90 degrees
2333 // or perspective. In such cases, fall back to painting the first kPixel DistanceToRecord pixels in each direction. 2336 // or perspective. In such cases, fall back to painting the first kPixel DistanceToRecord pixels in each direction.
2334 localInterestRect.intersect(enclosingGraphicsLayerBounds); 2337 localInterestRect.intersect(enclosingGraphicsLayerBounds);
2335 } 2338 }
2336 // Expand by interest rect padding amount. 2339 // Expand by interest rect padding amount.
2337 localInterestRect.inflate(kPixelDistanceToRecord); 2340 localInterestRect.inflate(kPixelDistanceToRecord);
2338 localInterestRect.intersect(enclosingGraphicsLayerBounds); 2341 localInterestRect.intersect(enclosingGraphicsLayerBounds);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 return false; 2376 return false;
2374 } 2377 }
2375 2378
2376 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, const IntRect& previousInterestRect) const 2379 IntRect CompositedLayerMapping::computeInterestRect(const GraphicsLayer* graphic sLayer, const IntRect& previousInterestRect) const
2377 { 2380 {
2378 // Use the previous interest rect if it covers the whole layer. 2381 // Use the previous interest rect if it covers the whole layer.
2379 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer-> size())); 2382 IntRect wholeLayerRect = IntRect(IntPoint(), expandedIntSize(graphicsLayer-> size()));
2380 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect) 2383 if (!needsRepaint(*graphicsLayer) && previousInterestRect == wholeLayerRect)
2381 return previousInterestRect; 2384 return previousInterestRect;
2382 2385
2383 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W ebPreferences::record_whole_document is true. 2386 // Paint the whole layer if "mainFrameClipsContent" is false, meaning that W ebPreferences::record_whole_document is true.
dgozman 2016/08/22 22:22:06 I'd suggest to unify this setting with clipPaintRe
2384 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin gs()->mainFrameClipsContent(); 2387 bool shouldPaintWholePage = !m_owningLayer.layoutObject()->document().settin gs()->mainFrameClipsContent();
2385 if (shouldPaintWholePage 2388 if (shouldPaintWholePage
2386 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi ngLayer.get() && graphicsLayer != m_scrollingContentsLayer.get())) 2389 || (graphicsLayer != m_graphicsLayer.get() && graphicsLayer != m_squashi ngLayer.get() && graphicsLayer != m_scrollingContentsLayer.get()))
2387 return wholeLayerRect; 2390 return wholeLayerRect;
2388 2391
2389 IntRect newInterestRect = recomputeInterestRect(graphicsLayer); 2392 IntRect newInterestRect = recomputeInterestRect(graphicsLayer);
2390 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect , expandedIntSize(graphicsLayer->size()))) 2393 if (interestRectChangedEnoughToRepaint(previousInterestRect, newInterestRect , expandedIntSize(graphicsLayer->size())))
2391 return newInterestRect; 2394 return newInterestRect;
2392 return previousInterestRect; 2395 return previousInterestRect;
2393 } 2396 }
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 } else if (graphicsLayer == m_scrollingContentsLayer.get()) { 2694 } else if (graphicsLayer == m_scrollingContentsLayer.get()) {
2692 name = "Scrolling Contents Layer"; 2695 name = "Scrolling Contents Layer";
2693 } else { 2696 } else {
2694 ASSERT_NOT_REACHED(); 2697 ASSERT_NOT_REACHED();
2695 } 2698 }
2696 2699
2697 return name; 2700 return name;
2698 } 2701 }
2699 2702
2700 } // namespace blink 2703 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698