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

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

Issue 2782343002: Store local border box property cache outside ObjectPaintProperties (Closed)
Patch Set: Rebase Created 3 years, 8 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (m_geometryMapper) { 202 if (m_geometryMapper) {
203 ClipRect clipRect; 203 ClipRect clipRect;
204 calculateBackgroundClipRectWithGeometryMapper(context, clipRect); 204 calculateBackgroundClipRectWithGeometryMapper(context, clipRect);
205 LayoutRect premappedRect = clipRect.rect(); 205 LayoutRect premappedRect = clipRect.rect();
206 206
207 // The rect now needs to be transformed to the local space of this 207 // The rect now needs to be transformed to the local space of this
208 // PaintLayer. 208 // PaintLayer.
209 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset()); 209 premappedRect.moveBy(context.rootLayer->layoutObject().paintOffset());
210 210
211 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject() 211 const auto* clipRootLayerTransform = clippingRootLayer.layoutObject()
212 .paintProperties() 212 .localBorderBoxProperties()
213 ->localBorderBoxProperties()
214 ->transform(); 213 ->transform();
215 const auto* layerTransform = m_layer.layoutObject() 214 const auto* layerTransform =
216 .paintProperties() 215 m_layer.layoutObject().localBorderBoxProperties()->transform();
217 ->localBorderBoxProperties()
218 ->transform();
219 FloatRect clippedRectInLocalSpace(premappedRect); 216 FloatRect clippedRectInLocalSpace(premappedRect);
220 m_geometryMapper->sourceToDestinationRect( 217 m_geometryMapper->sourceToDestinationRect(
221 clipRootLayerTransform, layerTransform, clippedRectInLocalSpace); 218 clipRootLayerTransform, layerTransform, clippedRectInLocalSpace);
222 clippedRectInLocalSpace.moveBy( 219 clippedRectInLocalSpace.moveBy(
223 -FloatPoint(m_layer.layoutObject().paintOffset())); 220 -FloatPoint(m_layer.layoutObject().paintOffset()));
224 221
225 return LayoutRect(clippedRectInLocalSpace); 222 return LayoutRect(clippedRectInLocalSpace);
226 } 223 }
227 224
228 LayoutRect layerBounds; 225 LayoutRect layerBounds;
(...skipping 27 matching lines...) Expand all
256 } while (false); 253 } while (false);
257 #endif 254 #endif
258 255
259 void PaintLayerClipper::calculateRectsWithGeometryMapper( 256 void PaintLayerClipper::calculateRectsWithGeometryMapper(
260 const ClipRectsContext& context, 257 const ClipRectsContext& context,
261 const LayoutRect& paintDirtyRect, 258 const LayoutRect& paintDirtyRect,
262 LayoutRect& layerBounds, 259 LayoutRect& layerBounds,
263 ClipRect& backgroundRect, 260 ClipRect& backgroundRect,
264 ClipRect& foregroundRect, 261 ClipRect& foregroundRect,
265 const LayoutPoint* offsetFromRoot) const { 262 const LayoutPoint* offsetFromRoot) const {
266 const auto* properties = m_layer.layoutObject().paintProperties(); 263 calculateBackgroundClipRectWithGeometryMapper(context, backgroundRect);
267 // TODO(chrishtr): fix the underlying bug that causes this situation. 264 backgroundRect.move(context.subPixelAccumulation);
268 if (!properties) { 265 backgroundRect.intersect(paintDirtyRect);
269 backgroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
270 foregroundRect = ClipRect(LayoutRect(LayoutRect::infiniteIntRect()));
271 } else {
272 calculateBackgroundClipRectWithGeometryMapper(context, backgroundRect);
273 backgroundRect.move(context.subPixelAccumulation);
274 backgroundRect.intersect(paintDirtyRect);
275 266
276 calculateForegroundClipRectWithGeometryMapper(context, foregroundRect); 267 calculateForegroundClipRectWithGeometryMapper(context, foregroundRect);
277 foregroundRect.move(context.subPixelAccumulation); 268 foregroundRect.move(context.subPixelAccumulation);
278 foregroundRect.intersect(paintDirtyRect); 269 foregroundRect.intersect(paintDirtyRect);
279 } 270
280 LayoutPoint offset; 271 LayoutPoint offset;
281 if (offsetFromRoot) 272 if (offsetFromRoot)
282 offset = *offsetFromRoot; 273 offset = *offsetFromRoot;
283 else 274 else
284 m_layer.convertToLayerCoords(context.rootLayer, offset); 275 m_layer.convertToLayerCoords(context.rootLayer, offset);
285 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 276 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
286 277
287 #ifdef CHECK_CLIP_RECTS 278 #ifdef CHECK_CLIP_RECTS
288 ClipRect testBackgroundRect, testForegroundRect; 279 ClipRect testBackgroundRect, testForegroundRect;
289 LayoutRect testLayerBounds; 280 LayoutRect testLayerBounds;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 } 399 }
409 400
410 void PaintLayerClipper::calculateBackgroundClipRectWithGeometryMapper( 401 void PaintLayerClipper::calculateBackgroundClipRectWithGeometryMapper(
411 const ClipRectsContext& context, 402 const ClipRectsContext& context,
412 ClipRect& output) const { 403 ClipRect& output) const {
413 DCHECK(m_geometryMapper); 404 DCHECK(m_geometryMapper);
414 PropertyTreeState sourcePropertyTreeState(nullptr, nullptr, nullptr); 405 PropertyTreeState sourcePropertyTreeState(nullptr, nullptr, nullptr);
415 PropertyTreeState destinationPropertyTreeState(nullptr, nullptr, nullptr); 406 PropertyTreeState destinationPropertyTreeState(nullptr, nullptr, nullptr);
416 initializeCommonClipRectState(context, sourcePropertyTreeState, 407 initializeCommonClipRectState(context, sourcePropertyTreeState,
417 destinationPropertyTreeState); 408 destinationPropertyTreeState);
418 const auto* ancestorProperties =
419 context.rootLayer->layoutObject().paintProperties();
420 409
421 if (&m_layer != context.rootLayer) { 410 if (&m_layer != context.rootLayer) {
411 auto* ancestorProperties =
412 context.rootLayer->layoutObject().paintProperties();
413 const auto* ancestorOverflowClip =
414 ancestorProperties ? ancestorProperties->overflowClip() : nullptr;
422 // Set the clip of |destinationPropertyTreeState| to be inside the 415 // Set the clip of |destinationPropertyTreeState| to be inside the
423 // ancestor's overflow clip, so that that clip is not applied. 416 // ancestor's overflow clip, so that that clip is not applied.
424 if (context.respectOverflowClip == IgnoreOverflowClip && 417 if (context.respectOverflowClip == IgnoreOverflowClip &&
425 ancestorProperties->overflowClip()) 418 ancestorOverflowClip)
426 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); 419 destinationPropertyTreeState.setClip(ancestorOverflowClip);
427 } 420 }
428 421
429 // The background rect applies all clips *above* m_layer, but not the overflow 422 // The background rect applies all clips *above* m_layer, but not the overflow
430 // clip of m_layer. It also applies a clip to the total painting bounds 423 // clip of m_layer. It also applies a clip to the total painting bounds
431 // of m_layer, because nothing in m_layer or its children within the clip can 424 // of m_layer, because nothing in m_layer or its children within the clip can
432 // paint outside of those bounds. 425 // paint outside of those bounds.
433 // The total painting bounds includes any visual overflow (such as shadow) and 426 // The total painting bounds includes any visual overflow (such as shadow) and
434 // filter bounds. 427 // filter bounds.
435 if (shouldClipOverflow(context)) { 428 if (shouldClipOverflow(context)) {
436 FloatRect clipRect(localVisualRect()); 429 FloatRect clipRect(localVisualRect());
437 clipRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset())); 430 clipRect.moveBy(FloatPoint(m_layer.layoutObject().paintOffset()));
438 m_geometryMapper->sourceToDestinationVisualRect( 431 m_geometryMapper->sourceToDestinationVisualRect(
439 sourcePropertyTreeState, destinationPropertyTreeState, clipRect); 432 sourcePropertyTreeState, destinationPropertyTreeState, clipRect);
440 output.setRect(FloatClipRect(clipRect)); 433 output.setRect(FloatClipRect(clipRect));
441 } else { 434 } else {
442 const FloatClipRect& clippedRectInRootLayerSpace = 435 const FloatClipRect& clippedRectInRootLayerSpace =
443 m_geometryMapper->sourceToDestinationClipRect( 436 m_geometryMapper->sourceToDestinationClipRect(
444 sourcePropertyTreeState, destinationPropertyTreeState); 437 sourcePropertyTreeState, destinationPropertyTreeState);
445 output.setRect(clippedRectInRootLayerSpace); 438 output.setRect(clippedRectInRootLayerSpace);
446 } 439 }
447 440
448 output.moveBy(-context.rootLayer->layoutObject().paintOffset()); 441 output.moveBy(-context.rootLayer->layoutObject().paintOffset());
449 } 442 }
450 443
451 void PaintLayerClipper::initializeCommonClipRectState( 444 void PaintLayerClipper::initializeCommonClipRectState(
452 const ClipRectsContext& context, 445 const ClipRectsContext& context,
453 PropertyTreeState& sourcePropertyTreeState, 446 PropertyTreeState& sourcePropertyTreeState,
454 PropertyTreeState& destinationPropertyTreeState) const { 447 PropertyTreeState& destinationPropertyTreeState) const {
455 DCHECK(m_geometryMapper); 448 DCHECK(m_geometryMapper);
456 const auto* properties = m_layer.layoutObject().paintProperties(); 449 DCHECK(m_layer.layoutObject().localBorderBoxProperties());
457 DCHECK(properties && properties->localBorderBoxProperties());
458 450
459 sourcePropertyTreeState = *properties->localBorderBoxProperties(); 451 sourcePropertyTreeState = *m_layer.layoutObject().localBorderBoxProperties();
460 const auto* ancestorProperties = 452 DCHECK(context.rootLayer->layoutObject().localBorderBoxProperties());
453 destinationPropertyTreeState =
454 *context.rootLayer->layoutObject().localBorderBoxProperties();
455
456 auto* ancestorProperties =
461 context.rootLayer->layoutObject().paintProperties(); 457 context.rootLayer->layoutObject().paintProperties();
462 DCHECK(ancestorProperties && ancestorProperties->localBorderBoxProperties()); 458 const auto* ancestorCssClip =
463 destinationPropertyTreeState = 459 ancestorProperties ? ancestorProperties->cssClip() : nullptr;
464 *ancestorProperties->localBorderBoxProperties();
465 // CSS clip of the root is always applied. 460 // CSS clip of the root is always applied.
466 if (ancestorProperties->cssClip()) { 461 if (ancestorCssClip) {
467 DCHECK(destinationPropertyTreeState.clip() == 462 DCHECK(destinationPropertyTreeState.clip() ==
468 ancestorProperties->cssClip()); 463 ancestorProperties->cssClip());
469 destinationPropertyTreeState.setClip( 464 destinationPropertyTreeState.setClip(ancestorCssClip->parent());
470 ancestorProperties->cssClip()->parent());
471 } 465 }
472 } 466 }
473 467
474 void PaintLayerClipper::calculateForegroundClipRectWithGeometryMapper( 468 void PaintLayerClipper::calculateForegroundClipRectWithGeometryMapper(
475 const ClipRectsContext& context, 469 const ClipRectsContext& context,
476 ClipRect& output) const { 470 ClipRect& output) const {
477 DCHECK(m_geometryMapper); 471 DCHECK(m_geometryMapper);
478 PropertyTreeState sourcePropertyTreeState(nullptr, nullptr, nullptr); 472 PropertyTreeState sourcePropertyTreeState(nullptr, nullptr, nullptr);
479 PropertyTreeState destinationPropertyTreeState(nullptr, nullptr, nullptr); 473 PropertyTreeState destinationPropertyTreeState(nullptr, nullptr, nullptr);
480 initializeCommonClipRectState(context, sourcePropertyTreeState, 474 initializeCommonClipRectState(context, sourcePropertyTreeState,
481 destinationPropertyTreeState); 475 destinationPropertyTreeState);
482 const auto* properties = m_layer.layoutObject().paintProperties(); 476 const auto* properties = m_layer.layoutObject().paintProperties();
483 const auto* ancestorProperties =
484 context.rootLayer->layoutObject().paintProperties();
485 477
486 if (&m_layer == context.rootLayer) { 478 if (&m_layer == context.rootLayer) {
487 // Set the overflow clip for |sourcePropertyTreeState| so that it differs 479 // Set the overflow clip for |sourcePropertyTreeState| so that it differs
488 // from |destinationPropertyTreeState| in its clip. 480 // from |destinationPropertyTreeState| in its clip.
489 if (context.respectOverflowClip == RespectOverflowClip && 481 if (context.respectOverflowClip == RespectOverflowClip && properties &&
490 properties->overflowClip()) 482 properties->overflowClip())
491 sourcePropertyTreeState.setClip(properties->overflowClip()); 483 sourcePropertyTreeState.setClip(properties->overflowClip());
492 } else { 484 } else {
485 const auto* ancestorProperties =
486 context.rootLayer->layoutObject().paintProperties();
487
493 // Set the clip of |destinationPropertyTreeState| to be inside the 488 // Set the clip of |destinationPropertyTreeState| to be inside the
494 // ancestor's overflow clip, so that that clip is not applied. 489 // ancestor's overflow clip, so that that clip is not applied.
495 if (context.respectOverflowClip == IgnoreOverflowClip && 490 if (context.respectOverflowClip == IgnoreOverflowClip &&
496 ancestorProperties->overflowClip()) 491 ancestorProperties && ancestorProperties->overflowClip())
497 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip()); 492 destinationPropertyTreeState.setClip(ancestorProperties->overflowClip());
498 493
499 // Set the overflow clip for |sourcePropertyTreeState| so that it differs 494 // Set the overflow clip for |sourcePropertyTreeState| so that it differs
500 // from destinationPropertyTreeState| in its clip. 495 // from destinationPropertyTreeState| in its clip.
501 if (properties->overflowClip()) 496 if (properties && properties->overflowClip())
502 sourcePropertyTreeState.setClip(properties->overflowClip()); 497 sourcePropertyTreeState.setClip(properties->overflowClip());
503 } 498 }
504 499
505 const FloatClipRect& clippedRectInRootLayerSpace = 500 const FloatClipRect& clippedRectInRootLayerSpace =
506 m_geometryMapper->sourceToDestinationClipRect( 501 m_geometryMapper->sourceToDestinationClipRect(
507 sourcePropertyTreeState, destinationPropertyTreeState); 502 sourcePropertyTreeState, destinationPropertyTreeState);
508 output.setRect(clippedRectInRootLayerSpace); 503 output.setRect(clippedRectInRootLayerSpace);
509 504
510 output.moveBy(-context.rootLayer->layoutObject().paintOffset()); 505 output.moveBy(-context.rootLayer->layoutObject().paintOffset());
511 } 506 }
(...skipping 16 matching lines...) Expand all
528 m_layer.mapLayoutRectForFilter(layerBoundsWithVisualOverflow); 523 m_layer.mapLayoutRectForFilter(layerBoundsWithVisualOverflow);
529 } 524 }
530 return layerBoundsWithVisualOverflow; 525 return layerBoundsWithVisualOverflow;
531 } 526 }
532 527
533 void PaintLayerClipper::calculateBackgroundClipRect( 528 void PaintLayerClipper::calculateBackgroundClipRect(
534 const ClipRectsContext& context, 529 const ClipRectsContext& context,
535 ClipRect& output) const { 530 ClipRect& output) const {
536 if (m_geometryMapper) { 531 if (m_geometryMapper) {
537 // TODO(chrishtr): fix the underlying bug that causes this situation. 532 // TODO(chrishtr): fix the underlying bug that causes this situation.
538 if (!m_layer.layoutObject().paintProperties()) { 533 if (!m_layer.layoutObject().paintProperties() &&
534 !m_layer.layoutObject().localBorderBoxProperties()) {
539 output.setRect(FloatClipRect()); 535 output.setRect(FloatClipRect());
540 return; 536 return;
541 } 537 }
542 538
543 calculateBackgroundClipRectWithGeometryMapper(context, output); 539 calculateBackgroundClipRectWithGeometryMapper(context, output);
544 #ifdef CHECK_CLIP_RECTS 540 #ifdef CHECK_CLIP_RECTS
545 ClipRect testBackgroundClipRect = 541 ClipRect testBackgroundClipRect =
546 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context); 542 PaintLayerClipper(m_layer, nullptr).backgroundClipRect(context);
547 CHECK_RECTS_EQ(testBackgroundClipRect, output); 543 CHECK_RECTS_EQ(testBackgroundClipRect, output);
548 #endif 544 #endif
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 DCHECK(!m_geometryMapper); 611 DCHECK(!m_geometryMapper);
616 ClipRectsContext context(rootLayer, PaintingClipRects, 612 ClipRectsContext context(rootLayer, PaintingClipRects,
617 IgnorePlatformOverlayScrollbarSize, 613 IgnorePlatformOverlayScrollbarSize,
618 subpixelAccumulation); 614 subpixelAccumulation);
619 if (respectOverflowClip == IgnoreOverflowClip) 615 if (respectOverflowClip == IgnoreOverflowClip)
620 context.setIgnoreOverflowClip(); 616 context.setIgnoreOverflowClip();
621 return getClipRects(context); 617 return getClipRects(context);
622 } 618 }
623 619
624 } // namespace blink 620 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698