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

Side by Side Diff: third_party/WebKit/Source/core/paint/PaintLayerClipper.cpp

Issue 2705493003: Revert of Don't pixel-snap overflow clips in clip paint property nodes. (Closed)
Patch Set: Created 3 years, 10 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) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 LayoutPoint clippingRootOffset; 241 LayoutPoint clippingRootOffset;
242 m_layer.convertToLayerCoords(&clippingRootLayer, clippingRootOffset); 242 m_layer.convertToLayerCoords(&clippingRootLayer, clippingRootOffset);
243 clipRect.moveBy(-clippingRootOffset); 243 clipRect.moveBy(-clippingRootOffset);
244 244
245 return clipRect; 245 return clipRect;
246 } 246 }
247 247
248 #ifdef CHECK_CLIP_RECTS 248 #ifdef CHECK_CLIP_RECTS
249 #define CHECK_RECTS_EQ(expected, actual) \ 249 #define CHECK_RECTS_EQ(expected, actual) \
250 do { \ 250 CHECK((expected.isEmpty() && actual.isEmpty()) || expected == actual) \
251 bool matches = \ 251 << "expected=" << expected.toString() << " actual=" << actual.toString()
252 (expected.isEmpty() && actual.isEmpty()) || expected == actual; \
253 if (!matches) { \
254 LOG(ERROR) << "Rects don't match for m_layer=" \
255 << m_layer.layoutObject()->debugName() \
256 << " expected=" << expected.toString() \
257 << " actual=" << actual.toString(); \
258 } \
259 } while (false);
260 #endif 252 #endif
261 253
262 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( 254 void PaintLayerClipper::mapLocalToRootWithGeometryMapper(
263 const ClipRectsContext& context, 255 const ClipRectsContext& context,
264 LayoutRect& rectToMap) const { 256 LayoutRect& rectToMap) const {
265 DCHECK(m_geometryMapper); 257 DCHECK(m_geometryMapper);
266 258
267 const auto* layerTransform = m_layer.layoutObject() 259 const auto* layerTransform = m_layer.layoutObject()
268 ->paintProperties() 260 ->paintProperties()
269 ->localBorderBoxProperties() 261 ->localBorderBoxProperties()
270 ->transform(); 262 ->transform();
271 const auto* rootTransform = context.rootLayer->layoutObject() 263 const auto* rootTransform = context.rootLayer->layoutObject()
272 ->paintProperties() 264 ->paintProperties()
273 ->localBorderBoxProperties() 265 ->localBorderBoxProperties()
274 ->transform(); 266 ->transform();
275 267
276 FloatRect localRect(rectToMap); 268 FloatRect localRect(rectToMap);
277 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); 269 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset()));
278 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect( 270 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect(
279 localRect, layerTransform, rootTransform)); 271 localRect, layerTransform, rootTransform));
280 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); 272 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset());
281 rectToMap.move(context.subPixelAccumulation);
282 } 273 }
283 274
284 void PaintLayerClipper::calculateRectsWithGeometryMapper( 275 void PaintLayerClipper::calculateRectsWithGeometryMapper(
285 const ClipRectsContext& context, 276 const ClipRectsContext& context,
286 const LayoutRect& paintDirtyRect, 277 const LayoutRect& paintDirtyRect,
287 LayoutRect& layerBounds, 278 LayoutRect& layerBounds,
288 ClipRect& backgroundRect, 279 ClipRect& backgroundRect,
289 ClipRect& foregroundRect, 280 ClipRect& foregroundRect,
290 const LayoutPoint* offsetFromRoot) const { 281 const LayoutPoint* offsetFromRoot) const {
291 const auto* properties = m_layer.layoutObject()->paintProperties(); 282 const auto* properties = m_layer.layoutObject()->paintProperties();
292 // TODO(chrishtr): fix the underlying bug that causes this situation. 283 // TODO(chrishtr): fix the underlying bug that causes this situation.
293 if (!properties) { 284 if (!properties) {
294 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); 285 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
295 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); 286 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
296 } else { 287 } else {
297 backgroundRect = clipRectWithGeometryMapper(context, false); 288 backgroundRect = clipRectWithGeometryMapper(context, false);
298
299 backgroundRect.move(context.subPixelAccumulation);
300 backgroundRect.intersect(paintDirtyRect);
301
302 applyOverflowClipToBackgroundRectWithGeometryMapper(context, 289 applyOverflowClipToBackgroundRectWithGeometryMapper(context,
303 backgroundRect); 290 backgroundRect);
304 291
292 backgroundRect.move(
293 context.subPixelAccumulation); // TODO(chrishtr): is this needed?
294 backgroundRect.intersect(paintDirtyRect);
295
296 foregroundRect.move(
297 context.subPixelAccumulation); // TODO(chrishtr): is this needed?
305 foregroundRect = clipRectWithGeometryMapper(context, true); 298 foregroundRect = clipRectWithGeometryMapper(context, true);
306 foregroundRect.move(context.subPixelAccumulation);
307 foregroundRect.intersect(paintDirtyRect); 299 foregroundRect.intersect(paintDirtyRect);
308 } 300 }
309 LayoutPoint offset; 301 LayoutPoint offset;
310 if (offsetFromRoot) 302 if (offsetFromRoot)
311 offset = *offsetFromRoot; 303 offset = *offsetFromRoot;
312 else 304 else
313 m_layer.convertToLayerCoords(context.rootLayer, offset); 305 m_layer.convertToLayerCoords(context.rootLayer, offset);
314 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 306 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
315 307
316 #ifdef CHECK_CLIP_RECTS 308 #ifdef CHECK_CLIP_RECTS
317 ClipRect testBackgroundRect, testForegroundRect; 309 ClipRect testBackgroundRect, testForegroundRect;
318 LayoutRect testLayerBounds; 310 LayoutRect testLayerBounds;
319 PaintLayerClipper(m_layer, nullptr) 311 PaintLayerClipper(m_layer, false)
320 .calculateRects(context, paintDirtyRect, testLayerBounds, 312 .calculateRects(context, paintDirtyRect, testLayerBounds,
321 testBackgroundRect, testForegroundRect, offsetFromRoot); 313 testBackgroundRect, testForegroundRect);
322 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); 314 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect);
323 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); 315 CHECK_RECTS_EQ(testForegroundRect, foregroundRect);
324 CHECK_RECTS_EQ(testLayerBounds, layerBounds); 316 CHECK_RECTS_EQ(testLayerBounds, layerBounds);
325 #endif 317 #endif
326 } 318 }
327 319
328 void PaintLayerClipper::calculateRects( 320 void PaintLayerClipper::calculateRects(
329 const ClipRectsContext& context, 321 const ClipRectsContext& context,
330 const LayoutRect& paintDirtyRect, 322 const LayoutRect& paintDirtyRect,
331 LayoutRect& layerBounds, 323 LayoutRect& layerBounds,
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); 498 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow);
507 clip.intersect(layerBoundsWithVisualOverflow); 499 clip.intersect(layerBoundsWithVisualOverflow);
508 } 500 }
509 501
510 ClipRect PaintLayerClipper::backgroundClipRect( 502 ClipRect PaintLayerClipper::backgroundClipRect(
511 const ClipRectsContext& context) const { 503 const ClipRectsContext& context) const {
512 if (m_geometryMapper) { 504 if (m_geometryMapper) {
513 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); 505 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false);
514 #ifdef CHECK_CLIP_RECTS 506 #ifdef CHECK_CLIP_RECTS
515 ClipRect testBackgroundClipRect = 507 ClipRect testBackgroundClipRect =
516 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); 508 PaintLayerClipper(m_layer, false).backgroundClipRect(context);
517 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); 509 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect);
518 #endif 510 #endif
519 return backgroundClipRect; 511 return backgroundClipRect;
520 } 512 }
521 DCHECK(m_layer.parent()); 513 DCHECK(m_layer.parent());
522 LayoutView* layoutView = m_layer.layoutObject()->view(); 514 LayoutView* layoutView = m_layer.layoutObject()->view();
523 DCHECK(layoutView); 515 DCHECK(layoutView);
524 516
525 RefPtr<ClipRects> parentClipRects = ClipRects::create(); 517 RefPtr<ClipRects> parentClipRects = ClipRects::create();
526 if (&m_layer == context.rootLayer) { 518 if (&m_layer == context.rootLayer) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 const LayoutSize& subpixelAccumulation) const { 578 const LayoutSize& subpixelAccumulation) const {
587 DCHECK(!m_geometryMapper); 579 DCHECK(!m_geometryMapper);
588 ClipRectsContext context(rootLayer, PaintingClipRects, 580 ClipRectsContext context(rootLayer, PaintingClipRects,
589 IgnoreOverlayScrollbarSize, subpixelAccumulation); 581 IgnoreOverlayScrollbarSize, subpixelAccumulation);
590 if (respectOverflowClip == IgnoreOverflowClip) 582 if (respectOverflowClip == IgnoreOverflowClip)
591 context.setIgnoreOverflowClip(); 583 context.setIgnoreOverflowClip();
592 return getClipRects(context); 584 return getClipRects(context);
593 } 585 }
594 586
595 } // namespace blink 587 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/TestExpectations ('k') | third_party/WebKit/Source/core/paint/PaintLayerClipperTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698