| 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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 CHECK((expected.isEmpty() && actual.isEmpty()) || expected == actual) \ | 250 do { \ |
| 251 << "expected=" << expected.toString() << " actual=" << actual.toString() | 251 bool matches = \ |
| 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); |
| 252 #endif | 260 #endif |
| 253 | 261 |
| 254 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( | 262 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( |
| 255 const ClipRectsContext& context, | 263 const ClipRectsContext& context, |
| 256 LayoutRect& rectToMap) const { | 264 LayoutRect& rectToMap) const { |
| 257 DCHECK(m_geometryMapper); | 265 DCHECK(m_geometryMapper); |
| 258 | 266 |
| 259 const auto* layerTransform = m_layer.layoutObject() | 267 const auto* layerTransform = m_layer.layoutObject() |
| 260 ->paintProperties() | 268 ->paintProperties() |
| 261 ->localBorderBoxProperties() | 269 ->localBorderBoxProperties() |
| 262 ->transform(); | 270 ->transform(); |
| 263 const auto* rootTransform = context.rootLayer->layoutObject() | 271 const auto* rootTransform = context.rootLayer->layoutObject() |
| 264 ->paintProperties() | 272 ->paintProperties() |
| 265 ->localBorderBoxProperties() | 273 ->localBorderBoxProperties() |
| 266 ->transform(); | 274 ->transform(); |
| 267 | 275 |
| 268 FloatRect localRect(rectToMap); | 276 FloatRect localRect(rectToMap); |
| 269 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); | 277 localRect.moveBy(FloatPoint(m_layer.layoutObject()->paintOffset())); |
| 270 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect( | 278 rectToMap = LayoutRect(m_geometryMapper->sourceToDestinationRect( |
| 271 localRect, layerTransform, rootTransform)); | 279 localRect, layerTransform, rootTransform)); |
| 272 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); | 280 rectToMap.moveBy(-context.rootLayer->layoutObject()->paintOffset()); |
| 281 rectToMap.move(context.subPixelAccumulation); |
| 273 } | 282 } |
| 274 | 283 |
| 275 void PaintLayerClipper::calculateRectsWithGeometryMapper( | 284 void PaintLayerClipper::calculateRectsWithGeometryMapper( |
| 276 const ClipRectsContext& context, | 285 const ClipRectsContext& context, |
| 277 const LayoutRect& paintDirtyRect, | 286 const LayoutRect& paintDirtyRect, |
| 278 LayoutRect& layerBounds, | 287 LayoutRect& layerBounds, |
| 279 ClipRect& backgroundRect, | 288 ClipRect& backgroundRect, |
| 280 ClipRect& foregroundRect, | 289 ClipRect& foregroundRect, |
| 281 const LayoutPoint* offsetFromRoot) const { | 290 const LayoutPoint* offsetFromRoot) const { |
| 282 const auto* properties = m_layer.layoutObject()->paintProperties(); | 291 const auto* properties = m_layer.layoutObject()->paintProperties(); |
| 283 // TODO(chrishtr): fix the underlying bug that causes this situation. | 292 // TODO(chrishtr): fix the underlying bug that causes this situation. |
| 284 if (!properties) { | 293 if (!properties) { |
| 285 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | 294 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); |
| 286 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | 295 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); |
| 287 } else { | 296 } else { |
| 288 backgroundRect = clipRectWithGeometryMapper(context, false); | 297 backgroundRect = clipRectWithGeometryMapper(context, false); |
| 298 |
| 299 backgroundRect.move(context.subPixelAccumulation); |
| 300 backgroundRect.intersect(paintDirtyRect); |
| 301 |
| 289 applyOverflowClipToBackgroundRectWithGeometryMapper(context, | 302 applyOverflowClipToBackgroundRectWithGeometryMapper(context, |
| 290 backgroundRect); | 303 backgroundRect); |
| 291 | 304 |
| 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? | |
| 298 foregroundRect = clipRectWithGeometryMapper(context, true); | 305 foregroundRect = clipRectWithGeometryMapper(context, true); |
| 306 foregroundRect.move(context.subPixelAccumulation); |
| 299 foregroundRect.intersect(paintDirtyRect); | 307 foregroundRect.intersect(paintDirtyRect); |
| 300 } | 308 } |
| 301 LayoutPoint offset; | 309 LayoutPoint offset; |
| 302 if (offsetFromRoot) | 310 if (offsetFromRoot) |
| 303 offset = *offsetFromRoot; | 311 offset = *offsetFromRoot; |
| 304 else | 312 else |
| 305 m_layer.convertToLayerCoords(context.rootLayer, offset); | 313 m_layer.convertToLayerCoords(context.rootLayer, offset); |
| 306 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); | 314 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); |
| 307 | 315 |
| 308 #ifdef CHECK_CLIP_RECTS | 316 #ifdef CHECK_CLIP_RECTS |
| 309 ClipRect testBackgroundRect, testForegroundRect; | 317 ClipRect testBackgroundRect, testForegroundRect; |
| 310 LayoutRect testLayerBounds; | 318 LayoutRect testLayerBounds; |
| 311 PaintLayerClipper(m_layer, false) | 319 PaintLayerClipper(m_layer, nullptr) |
| 312 .calculateRects(context, paintDirtyRect, testLayerBounds, | 320 .calculateRects(context, paintDirtyRect, testLayerBounds, |
| 313 testBackgroundRect, testForegroundRect); | 321 testBackgroundRect, testForegroundRect, offsetFromRoot); |
| 314 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); | 322 CHECK_RECTS_EQ(testBackgroundRect, backgroundRect); |
| 315 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); | 323 CHECK_RECTS_EQ(testForegroundRect, foregroundRect); |
| 316 CHECK_RECTS_EQ(testLayerBounds, layerBounds); | 324 CHECK_RECTS_EQ(testLayerBounds, layerBounds); |
| 317 #endif | 325 #endif |
| 318 } | 326 } |
| 319 | 327 |
| 320 void PaintLayerClipper::calculateRects( | 328 void PaintLayerClipper::calculateRects( |
| 321 const ClipRectsContext& context, | 329 const ClipRectsContext& context, |
| 322 const LayoutRect& paintDirtyRect, | 330 const LayoutRect& paintDirtyRect, |
| 323 LayoutRect& layerBounds, | 331 LayoutRect& layerBounds, |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); | 506 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); |
| 499 clip.intersect(layerBoundsWithVisualOverflow); | 507 clip.intersect(layerBoundsWithVisualOverflow); |
| 500 } | 508 } |
| 501 | 509 |
| 502 ClipRect PaintLayerClipper::backgroundClipRect( | 510 ClipRect PaintLayerClipper::backgroundClipRect( |
| 503 const ClipRectsContext& context) const { | 511 const ClipRectsContext& context) const { |
| 504 if (m_geometryMapper) { | 512 if (m_geometryMapper) { |
| 505 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); | 513 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); |
| 506 #ifdef CHECK_CLIP_RECTS | 514 #ifdef CHECK_CLIP_RECTS |
| 507 ClipRect testBackgroundClipRect = | 515 ClipRect testBackgroundClipRect = |
| 508 PaintLayerClipper(m_layer, false).backgroundClipRect(context); | 516 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); |
| 509 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); | 517 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); |
| 510 #endif | 518 #endif |
| 511 return backgroundClipRect; | 519 return backgroundClipRect; |
| 512 } | 520 } |
| 513 DCHECK(m_layer.parent()); | 521 DCHECK(m_layer.parent()); |
| 514 LayoutView* layoutView = m_layer.layoutObject()->view(); | 522 LayoutView* layoutView = m_layer.layoutObject()->view(); |
| 515 DCHECK(layoutView); | 523 DCHECK(layoutView); |
| 516 | 524 |
| 517 RefPtr<ClipRects> parentClipRects = ClipRects::create(); | 525 RefPtr<ClipRects> parentClipRects = ClipRects::create(); |
| 518 if (&m_layer == context.rootLayer) { | 526 if (&m_layer == context.rootLayer) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 const LayoutSize& subpixelAccumulation) const { | 586 const LayoutSize& subpixelAccumulation) const { |
| 579 DCHECK(!m_geometryMapper); | 587 DCHECK(!m_geometryMapper); |
| 580 ClipRectsContext context(rootLayer, PaintingClipRects, | 588 ClipRectsContext context(rootLayer, PaintingClipRects, |
| 581 IgnoreOverlayScrollbarSize, subpixelAccumulation); | 589 IgnoreOverlayScrollbarSize, subpixelAccumulation); |
| 582 if (respectOverflowClip == IgnoreOverflowClip) | 590 if (respectOverflowClip == IgnoreOverflowClip) |
| 583 context.setIgnoreOverflowClip(); | 591 context.setIgnoreOverflowClip(); |
| 584 return getClipRects(context); | 592 return getClipRects(context); |
| 585 } | 593 } |
| 586 | 594 |
| 587 } // namespace blink | 595 } // namespace blink |
| OLD | NEW |