| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 ClipRect clipRect; | 203 ClipRect clipRect; |
| 204 calculateClipRectWithGeometryMapper(context, false, clipRect); | 204 calculateClipRectWithGeometryMapper(context, false, clipRect); |
| 205 applyOverflowClipToBackgroundRectWithGeometryMapper(context, clipRect); | 205 applyOverflowClipToBackgroundRectWithGeometryMapper(context, clipRect); |
| 206 LayoutRect premappedRect = clipRect.rect(); | 206 LayoutRect premappedRect = clipRect.rect(); |
| 207 | 207 |
| 208 // The rect now needs to be transformed to the local space of this | 208 // The rect now needs to be transformed to the local space of this |
| 209 // PaintLayer. | 209 // PaintLayer. |
| 210 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset()); | 210 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset()); |
| 211 | 211 |
| 212 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject() | 212 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject() |
| 213 .paintProperties() | 213 .localBorderBoxProperties() |
| 214 ->localBorderBoxProperties() | |
| 215 ->transform(); | 214 ->transform(); |
| 216 const auto* layerTransform = m_layer.layoutObject() | 215 const auto* layerTransform = |
| 217 .paintProperties() | 216 m_layer.layoutObject().localBorderBoxProperties()->transform(); |
| 218 ->localBorderBoxProperties() | |
| 219 ->transform(); | |
| 220 FloatRect clippedRectInLocalSpace(premappedRect); | 217 FloatRect clippedRectInLocalSpace(premappedRect); |
| 221 m_geometryMapper->sourceToDestinationRect( | 218 m_geometryMapper->sourceToDestinationRect( |
| 222 clipRootLayerTransform, layerTransform, clippedRectInLocalSpace); | 219 clipRootLayerTransform, layerTransform, clippedRectInLocalSpace); |
| 223 clippedRectInLocalSpace.moveBy( | 220 clippedRectInLocalSpace.moveBy( |
| 224 -FloatPoint(m_layer.layoutObject().paintOffset())); | 221 -FloatPoint(m_layer.layoutObject().paintOffset())); |
| 225 | 222 |
| 226 return LayoutRect(clippedRectInLocalSpace); | 223 return LayoutRect(clippedRectInLocalSpace); |
| 227 } | 224 } |
| 228 | 225 |
| 229 LayoutRect layerBounds; | 226 LayoutRect layerBounds; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 255 << " actual=" << actual.toString(); \ | 252 << " actual=" << actual.toString(); \ |
| 256 } \ | 253 } \ |
| 257 } while (false); | 254 } while (false); |
| 258 #endif | 255 #endif |
| 259 | 256 |
| 260 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( | 257 void PaintLayerClipper::mapLocalToRootWithGeometryMapper( |
| 261 const ClipRectsContext& context, | 258 const ClipRectsContext& context, |
| 262 LayoutRect& rectToMap) const { | 259 LayoutRect& rectToMap) const { |
| 263 DCHECK(m_geometryMapper); | 260 DCHECK(m_geometryMapper); |
| 264 | 261 |
| 265 const auto* layerTransform = m_layer.layoutObject() | 262 const auto* layerTransform = |
| 266 .paintProperties() | 263 m_layer.layoutObject().localBorderBoxProperties()->transform(); |
| 267 ->localBorderBoxProperties() | 264 const auto* rootTransform = |
| 268 ->transform(); | 265 context.rootLayer->layoutObject().localBorderBoxProperties()->transform(); |
| 269 const auto* rootTransform = context.rootLayer->layoutObject() | |
| 270 .paintProperties() | |
| 271 ->localBorderBoxProperties() | |
| 272 ->transform(); | |
| 273 | 266 |
| 274 FloatRect floatRect(rectToMap); | 267 FloatRect floatRect(rectToMap); |
| 275 floatRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset())); | 268 floatRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset())); |
| 276 m_geometryMapper->sourceToDestinationRect(layerTransform, rootTransform, | 269 m_geometryMapper->sourceToDestinationRect(layerTransform, rootTransform, |
| 277 floatRect); | 270 floatRect); |
| 278 rectToMap = LayoutRect(floatRect); | 271 rectToMap = LayoutRect(floatRect); |
| 279 rectToMap.moveBy(-context.rootLayer->layoutObject().paintOffset()); | 272 rectToMap.moveBy(-context.rootLayer->layoutObject().paintOffset()); |
| 280 rectToMap.move(context.subPixelAccumulation); | 273 rectToMap.move(context.subPixelAccumulation); |
| 281 } | 274 } |
| 282 | 275 |
| 283 void PaintLayerClipper::calculateRectsWithGeometryMapper( | 276 void PaintLayerClipper::calculateRectsWithGeometryMapper( |
| 284 const ClipRectsContext& context, | 277 const ClipRectsContext& context, |
| 285 const LayoutRect& paintDirtyRect, | 278 const LayoutRect& paintDirtyRect, |
| 286 LayoutRect& layerBounds, | 279 LayoutRect& layerBounds, |
| 287 ClipRect& backgroundRect, | 280 ClipRect& backgroundRect, |
| 288 ClipRect& foregroundRect, | 281 ClipRect& foregroundRect, |
| 289 const LayoutPoint* offsetFromRoot) const { | 282 const LayoutPoint* offsetFromRoot) const { |
| 290 const auto* properties = m_layer.layoutObject().paintProperties(); | 283 calculateClipRectWithGeometryMapper(context, false, backgroundRect); |
| 291 // TODO(chrishtr): fix the underlying bug that causes this situation. | |
| 292 if (!properties) { | |
| 293 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | |
| 294 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect())); | |
| 295 } else { | |
| 296 calculateClipRectWithGeometryMapper(context, false, backgroundRect); | |
| 297 | 284 |
| 298 backgroundRect.move(context.subPixelAccumulation); | 285 backgroundRect.move(context.subPixelAccumulation); |
| 299 backgroundRect.intersect(paintDirtyRect); | 286 backgroundRect.intersect(paintDirtyRect); |
| 300 | 287 |
| 301 applyOverflowClipToBackgroundRectWithGeometryMapper(context, | 288 applyOverflowClipToBackgroundRectWithGeometryMapper(context, backgroundRect); |
| 302 backgroundRect); | |
| 303 | 289 |
| 304 calculateClipRectWithGeometryMapper(context, true, foregroundRect); | 290 calculateClipRectWithGeometryMapper(context, true, foregroundRect); |
| 305 foregroundRect.move(context.subPixelAccumulation); | 291 foregroundRect.move(context.subPixelAccumulation); |
| 306 foregroundRect.intersect(paintDirtyRect); | 292 foregroundRect.intersect(paintDirtyRect); |
| 307 } | 293 |
| 308 LayoutPoint offset; | 294 LayoutPoint offset; |
| 309 if (offsetFromRoot) | 295 if (offsetFromRoot) |
| 310 offset = *offsetFromRoot; | 296 offset = *offsetFromRoot; |
| 311 else | 297 else |
| 312 m_layer.convertToLayerCoords(context.rootLayer, offset); | 298 m_layer.convertToLayerCoords(context.rootLayer, offset); |
| 313 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); | 299 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); |
| 314 | 300 |
| 315 #ifdef CHECK_CLIP_RECTS | 301 #ifdef CHECK_CLIP_RECTS |
| 316 ClipRect testBackgroundRect, testForegroundRect; | 302 ClipRect testBackgroundRect, testForegroundRect; |
| 317 LayoutRect testLayerBounds; | 303 LayoutRect testLayerBounds; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 return parentRects.posClipRect(); | 427 return parentRects.posClipRect(); |
| 442 | 428 |
| 443 return parentRects.overflowClipRect(); | 429 return parentRects.overflowClipRect(); |
| 444 } | 430 } |
| 445 | 431 |
| 446 void PaintLayerClipper::calculateClipRectWithGeometryMapper( | 432 void PaintLayerClipper::calculateClipRectWithGeometryMapper( |
| 447 const ClipRectsContext& context, | 433 const ClipRectsContext& context, |
| 448 bool isForeground, | 434 bool isForeground, |
| 449 ClipRect& output) const { | 435 ClipRect& output) const { |
| 450 DCHECK(m_geometryMapper); | 436 DCHECK(m_geometryMapper); |
| 451 const auto* properties = m_layer.layoutObject().paintProperties(); | 437 const auto* localBorderBox = |
| 452 DCHECK(properties && properties->localBorderBoxProperties()); | 438 m_layer.layoutObject().localBorderBoxProperties(); |
| 439 DCHECK(localBorderBox); |
| 440 PropertyTreeState propertyTreeState = *localBorderBox; |
| 453 | 441 |
| 454 PropertyTreeState propertyTreeState = *properties->localBorderBoxProperties(); | 442 const auto* ancestorLocalBorderBox = |
| 443 context.rootLayer->layoutObject().localBorderBoxProperties(); |
| 444 DCHECK(ancestorLocalBorderBox); |
| 445 PropertyTreeState destinationPropertyTreeState = *ancestorLocalBorderBox; |
| 446 |
| 455 const auto* ancestorProperties = | 447 const auto* ancestorProperties = |
| 456 context.rootLayer->layoutObject().paintProperties(); | 448 context.rootLayer->layoutObject().paintProperties(); |
| 457 DCHECK(ancestorProperties && ancestorProperties->localBorderBoxProperties()); | 449 const auto* ancestorCssClip = |
| 458 PropertyTreeState destinationPropertyTreeState = | 450 ancestorProperties ? ancestorProperties->cssClip() : nullptr; |
| 459 *ancestorProperties->localBorderBoxProperties(); | |
| 460 // CSS clip of the root is always applied. | 451 // CSS clip of the root is always applied. |
| 461 if (ancestorProperties->cssClip()) { | 452 if (ancestorCssClip) { |
| 462 DCHECK(destinationPropertyTreeState.clip() == | 453 DCHECK(destinationPropertyTreeState.clip() == ancestorCssClip); |
| 463 ancestorProperties->cssClip()); | 454 destinationPropertyTreeState.setClip(ancestorCssClip->parent()); |
| 464 destinationPropertyTreeState.setClip( | |
| 465 ancestorProperties->cssClip()->parent()); | |
| 466 } | 455 } |
| 467 | 456 |
| 457 const auto* properties = m_layer.layoutObject().paintProperties(); |
| 458 const auto* overflowClip = properties ? properties->overflowClip() : nullptr; |
| 468 if (&m_layer == context.rootLayer) { | 459 if (&m_layer == context.rootLayer) { |
| 469 // Set the overflow clip for |propertyTreeState| so that it differs from | 460 // Set the overflow clip for |propertyTreeState| so that it differs from |
| 470 // |destinationPropertyTreeState| in its clip. | 461 // |destinationPropertyTreeState| in its clip. |
| 471 if (isForeground && context.respectOverflowClip == RespectOverflowClip && | 462 if (isForeground && context.respectOverflowClip == RespectOverflowClip && |
| 472 properties->overflowClip()) | 463 overflowClip) |
| 473 propertyTreeState.setClip(properties->overflowClip()); | 464 propertyTreeState.setClip(overflowClip); |
| 474 } else { | 465 } else { |
| 466 const auto* ancestorOverflowClip = |
| 467 ancestorProperties ? ancestorProperties->overflowClip() : nullptr; |
| 475 // Set the clip of |destinationPropertyTreeState| to be inside the | 468 // Set the clip of |destinationPropertyTreeState| to be inside the |
| 476 // ancestor's overflow clip, so that that clip is not applied. | 469 // ancestor's overflow clip, so that that clip is not applied. |
| 477 if (context.respectOverflowClip == IgnoreOverflowClip && | 470 if (context.respectOverflowClip == IgnoreOverflowClip && |
| 478 ancestorProperties->overflowClip()) | 471 ancestorOverflowClip) |
| 479 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); | 472 destinationPropertyTreeState.setClip(ancestorOverflowClip); |
| 480 | 473 |
| 481 // Set the overflow clip for |propertyTreeState| so that it differs from | 474 // Set the overflow clip for |propertyTreeState| so that it differs from |
| 482 // destinationPropertyTreeState| in its clip. | 475 // destinationPropertyTreeState| in its clip. |
| 483 if (isForeground && properties->overflowClip()) | 476 if (isForeground && overflowClip) |
| 484 propertyTreeState.setClip(properties->overflowClip()); | 477 propertyTreeState.setClip(overflowClip); |
| 485 } | 478 } |
| 486 | 479 |
| 487 const FloatClipRect& clippedRectInRootLayerSpace = | 480 const FloatClipRect& clippedRectInRootLayerSpace = |
| 488 m_geometryMapper->sourceToDestinationClipRect( | 481 m_geometryMapper->sourceToDestinationClipRect( |
| 489 propertyTreeState, destinationPropertyTreeState); | 482 propertyTreeState, destinationPropertyTreeState); |
| 490 output.setRect(clippedRectInRootLayerSpace); | 483 output.setRect(clippedRectInRootLayerSpace); |
| 491 | 484 |
| 492 output.moveBy(-context.rootLayer->layoutObject().paintOffset()); | 485 output.moveBy(-context.rootLayer->layoutObject().paintOffset()); |
| 493 } | 486 } |
| 494 | 487 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 DCHECK(!m_geometryMapper); | 589 DCHECK(!m_geometryMapper); |
| 597 ClipRectsContext context(rootLayer, PaintingClipRects, | 590 ClipRectsContext context(rootLayer, PaintingClipRects, |
| 598 IgnorePlatformOverlayScrollbarSize, | 591 IgnorePlatformOverlayScrollbarSize, |
| 599 subpixelAccumulation); | 592 subpixelAccumulation); |
| 600 if (respectOverflowClip == IgnoreOverflowClip) | 593 if (respectOverflowClip == IgnoreOverflowClip) |
| 601 context.setIgnoreOverflowClip(); | 594 context.setIgnoreOverflowClip(); |
| 602 return getClipRects(context); | 595 return getClipRects(context); |
| 603 } | 596 } |
| 604 | 597 |
| 605 } // namespace blink | 598 } // namespace blink |
| OLD | NEW |