OLD | NEW |
---|---|
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 | 242 |
243 LayoutPoint clippingRootOffset; | 243 LayoutPoint clippingRootOffset; |
244 m_layer.convertToLayerCoords(&clippingRootLayer, clippingRootOffset); | 244 m_layer.convertToLayerCoords(&clippingRootLayer, clippingRootOffset); |
245 clipRect.moveBy(-clippingRootOffset); | 245 clipRect.moveBy(-clippingRootOffset); |
246 | 246 |
247 return clipRect; | 247 return clipRect; |
248 } | 248 } |
249 | 249 |
250 #ifdef CHECK_CLIP_RECTS | 250 #ifdef CHECK_CLIP_RECTS |
251 #define CHECK_RECTS_EQ(expected, actual) \ | 251 #define CHECK_RECTS_EQ(expected, actual) \ |
252 CHECK((expected.isEmpty() && actual.isEmpty()) || expected == actual) \ | 252 do { \ |
chrishtr
2017/02/16 21:44:28
I adjusted this to not assert, in order to get bet
| |
253 << "expected=" << expected.toString() << " actual=" << actual.toString() | 253 bool matches = \ |
254 (expected.isEmpty() && actual.isEmpty()) || expected == actual; \ | |
255 if (!matches) { \ | |
256 LOG(ERROR) << "Rects don't match for m_layer=" \ | |
257 << m_layer.layoutObject()->debugName() \ | |
258 << " expected=" << expected.toString() \ | |
259 << " actual=" << actual.toString(); \ | |
260 } \ | |
261 } while (false); | |
254 #endif | 262 #endif |
255 | 263 |
256 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( | 264 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( |
257 const ClipRectsContext& context, | 265 const ClipRectsContext& context, |
258 LayoutRect& rectToMap) const { | 266 LayoutRect& rectToMap) const { |
259 DCHECK(m_geometryMapper); | 267 DCHECK(m_geometryMapper); |
260 | 268 |
261 const auto* layerTransform = m_layer.layoutObject() | 269 const auto* layerTransform = m_layer.layoutObject() |
262 ->paintProperties() | 270 ->paintProperties() |
263 ->localBorderBoxProperties() | 271 ->localBorderBoxProperties() |
264 ->transform(); | 272 ->transform(); |
265 const auto* rootTransform = context.rootLayer->layoutObject() | 273 const auto* rootTransform = context.rootLayer->layoutObject() |
266 ->paintProperties() | 274 ->paintProperties() |
267 ->localBorderBoxProperties() | 275 ->localBorderBoxProperties() |
268 ->transform(); | 276 ->transform(); |
269 | 277 |
270 FloatRect localRect(rectToMap); | 278 FloatRect localRect(rectToMap); |
271 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); | 279 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); |
272 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect( | 280 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect( |
273 localRect, layerTransform, rootTransform)); | 281 localRect, layerTransform, rootTransform)); |
274 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); | 282 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); |
283 rectToMap.move(context.subPixelAccumulation); | |
chrishtr
2017/02/16 21:44:28
This is exercised by the layout test
fast/sub-pixe
| |
275 } | 284 } |
276 | 285 |
277 void PaintLayerClipper::calculateRectsWithGeometryMapper( | 286 void PaintLayerClipper::calculateRectsWithGeometryMapper( |
278 const ClipRectsContext& context, | 287 const ClipRectsContext& context, |
279 const LayoutRect& paintDirtyRect, | 288 const LayoutRect& paintDirtyRect, |
280 LayoutRect& layerBounds, | 289 LayoutRect& layerBounds, |
281 ClipRect& backgroundRect, | 290 ClipRect& backgroundRect, |
282 ClipRect& foregroundRect, | 291 ClipRect& foregroundRect, |
283 const LayoutPoint* offsetFromRoot) const { | 292 const LayoutPoint* offsetFromRoot) const { |
284 const auto* properties = m_layer.layoutObject()->paintProperties(); | 293 const auto* properties = m_layer.layoutObject()->paintProperties(); |
285 // TODO(chrishtr): fix the underlying bug that causes this situation. | 294 // TODO(chrishtr): fix the underlying bug that causes this situation. |
286 if (!properties) { | 295 if (!properties) { |
287 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | 296 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); |
288 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | 297 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); |
289 } else { | 298 } else { |
290 backgroundRect = clipRectWithGeometryMapper(context, false); | 299 backgroundRect = clipRectWithGeometryMapper(context, false); |
300 | |
301 backgroundRect.move(context.subPixelAccumulation); | |
302 backgroundRect.intersect(paintDirtyRect); | |
303 | |
291 applyOverflowClipToBackgroundRectWithGeometryMapper(context, | 304 applyOverflowClipToBackgroundRectWithGeometryMapper(context, |
292 backgroundRect); | 305 backgroundRect); |
293 | 306 |
294 backgroundRect.move( | |
295 context.subPixelAccumulation); // TODO(chrishtr): is this needed? | |
chrishtr
2017/02/16 21:44:28
Confirmed that it is needed.
| |
296 backgroundRect.intersect(paintDirtyRect); | |
297 | |
298 foregroundRect.move( | |
299 context.subPixelAccumulation); // TODO(chrishtr): is this needed? | |
300 foregroundRect = clipRectWithGeometryMapper(context, true); | 307 foregroundRect = clipRectWithGeometryMapper(context, true); |
308 foregroundRect.move(context.subPixelAccumulation); | |
chrishtr
2017/02/16 21:44:28
I moved this above new line 309 for consistency wi
| |
301 foregroundRect.intersect(paintDirtyRect); | 309 foregroundRect.intersect(paintDirtyRect); |
302 } | 310 } |
303 LayoutPoint offset; | 311 LayoutPoint offset; |
304 if (offsetFromRoot) | 312 if (offsetFromRoot) |
305 offset = *offsetFromRoot; | 313 offset = *offsetFromRoot; |
306 else | 314 else |
307 m_layer.convertToLayerCoords(context.rootLayer, offset); | 315 m_layer.convertToLayerCoords(context.rootLayer, offset); |
308 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); | 316 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); |
309 | 317 |
310 #ifdef CHECK_CLIP_RECTS | 318 #ifdef CHECK_CLIP_RECTS |
311 ClipRect testBackgroundRect, testForegroundRect; | 319 ClipRect testBackgroundRect, testForegroundRect; |
312 LayoutRect testLayerBounds; | 320 LayoutRect testLayerBounds; |
313 PaintLayerClipper(m_layer, false) | 321 PaintLayerClipper(m_layer, nullptr) |
314 .calculateRects(context, paintDirtyRect, testLayerBounds, | 322 .calculateRects(context, paintDirtyRect, testLayerBounds, |
315 testBackgroundRect, testForegroundRect); | 323 testBackgroundRect, testForegroundRect, offsetFromRoot); |
316 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); | 324 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); |
317 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); | 325 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); |
318 CHECK_RECTS_EQ(testLayerBounds, layerBounds); | 326 CHECK_RECTS_EQ(testLayerBounds, layerBounds); |
319 #endif | 327 #endif |
320 } | 328 } |
321 | 329 |
322 void PaintLayerClipper::calculateRects( | 330 void PaintLayerClipper::calculateRects( |
323 const ClipRectsContext& context, | 331 const ClipRectsContext& context, |
324 const LayoutRect& paintDirtyRect, | 332 const LayoutRect& paintDirtyRect, |
325 LayoutRect& layerBounds, | 333 LayoutRect& layerBounds, |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); | 511 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); |
504 clip.intersect(layerBoundsWithVisualOverflow); | 512 clip.intersect(layerBoundsWithVisualOverflow); |
505 } | 513 } |
506 | 514 |
507 ClipRect PaintLayerClipper::backgroundClipRect( | 515 ClipRect PaintLayerClipper::backgroundClipRect( |
508 const ClipRectsContext& context) const { | 516 const ClipRectsContext& context) const { |
509 if (m_geometryMapper) { | 517 if (m_geometryMapper) { |
510 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); | 518 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); |
511 #ifdef CHECK_CLIP_RECTS | 519 #ifdef CHECK_CLIP_RECTS |
512 ClipRect testBackgroundClipRect = | 520 ClipRect testBackgroundClipRect = |
513 PaintLayerClipper(m_layer, false).backgroundClipRect(context); | 521 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); |
514 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); | 522 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); |
515 #endif | 523 #endif |
516 return backgroundClipRect; | 524 return backgroundClipRect; |
517 } | 525 } |
518 DCHECK(m_layer.parent()); | 526 DCHECK(m_layer.parent()); |
519 LayoutView* layoutView = m_layer.layoutObject()->view(); | 527 LayoutView* layoutView = m_layer.layoutObject()->view(); |
520 DCHECK(layoutView); | 528 DCHECK(layoutView); |
521 | 529 |
522 RefPtr<ClipRects> parentClipRects = ClipRects::create(); | 530 RefPtr<ClipRects> parentClipRects = ClipRects::create(); |
523 if (&m_layer == context.rootLayer) { | 531 if (&m_layer == context.rootLayer) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
583 const LayoutSize& subpixelAccumulation) const { | 591 const LayoutSize& subpixelAccumulation) const { |
584 DCHECK(!m_geometryMapper); | 592 DCHECK(!m_geometryMapper); |
585 ClipRectsContext context(rootLayer, PaintingClipRects, | 593 ClipRectsContext context(rootLayer, PaintingClipRects, |
586 IgnoreOverlayScrollbarSize, subpixelAccumulation); | 594 IgnoreOverlayScrollbarSize, subpixelAccumulation); |
587 if (respectOverflowClip == IgnoreOverflowClip) | 595 if (respectOverflowClip == IgnoreOverflowClip) |
588 context.setIgnoreOverflowClip(); | 596 context.setIgnoreOverflowClip(); |
589 return getClipRects(context); | 597 return getClipRects(context); |
590 } | 598 } |
591 | 599 |
592 } // namespace blink | 600 } // namespace blink |
OLD | NEW |