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

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

Issue 2623213002: Expand PaintLayer clip to account for hidden URL bar with document.rootScroller (Closed)
Patch Set: Rebase Created 3 years, 11 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 ClipRect& backgroundRect, 323 ClipRect& backgroundRect,
324 ClipRect& foregroundRect, 324 ClipRect& foregroundRect,
325 const LayoutPoint* offsetFromRoot) const { 325 const LayoutPoint* offsetFromRoot) const {
326 if (m_geometryMapper) { 326 if (m_geometryMapper) {
327 calculateRectsWithGeometryMapper(context, paintDirtyRect, layerBounds, 327 calculateRectsWithGeometryMapper(context, paintDirtyRect, layerBounds,
328 backgroundRect, foregroundRect, 328 backgroundRect, foregroundRect,
329 offsetFromRoot); 329 offsetFromRoot);
330 return; 330 return;
331 } 331 }
332 332
333 bool isClippingRoot = &m_layer == context.rootLayer;
334 LayoutBoxModelObject& layoutObject = *m_layer.layoutObject(); 333 LayoutBoxModelObject& layoutObject = *m_layer.layoutObject();
335 334
336 if (!isClippingRoot && m_layer.parent()) { 335 if (!isClippingRoot(context) && m_layer.parent()) {
337 backgroundRect = backgroundClipRect(context); 336 backgroundRect = backgroundClipRect(context);
338 backgroundRect.move(context.subPixelAccumulation); 337 backgroundRect.move(context.subPixelAccumulation);
339 backgroundRect.intersect(paintDirtyRect); 338 backgroundRect.intersect(paintDirtyRect);
340 } else { 339 } else {
341 backgroundRect = paintDirtyRect; 340 backgroundRect = paintDirtyRect;
342 } 341 }
343 342
344 foregroundRect = backgroundRect; 343 foregroundRect = backgroundRect;
345 344
346 LayoutPoint offset; 345 LayoutPoint offset;
347 if (offsetFromRoot) 346 if (offsetFromRoot)
348 offset = *offsetFromRoot; 347 offset = *offsetFromRoot;
349 else 348 else
350 m_layer.convertToLayerCoords(context.rootLayer, offset); 349 m_layer.convertToLayerCoords(context.rootLayer, offset);
351 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size())); 350 layerBounds = LayoutRect(offset, LayoutSize(m_layer.size()));
352 351
353 // Update the clip rects that will be passed to child layers. 352 // Update the clip rects that will be passed to child layers.
354 if (shouldClipOverflow(context)) { 353 if (shouldClipOverflow(context)) {
355 foregroundRect.intersect( 354 foregroundRect.intersect(
356 toLayoutBox(layoutObject) 355 toLayoutBox(layoutObject)
357 .overflowClipRect(offset, context.overlayScrollbarClipBehavior)); 356 .overflowClipRect(offset, context.overlayScrollbarClipBehavior));
358 if (layoutObject.styleRef().hasBorderRadius()) 357 if (layoutObject.styleRef().hasBorderRadius())
359 foregroundRect.setHasRadius(true); 358 foregroundRect.setHasRadius(true);
360 359
361 // FIXME: Does not do the right thing with columns yet, since we don't yet 360 // FIXME: Does not do the right thing with columns yet, since we don't yet
362 // factor in the individual column boxes as overflow. 361 // factor in the individual column boxes as overflow.
363 362
364 // The LayoutView is special since its overflow clipping rect may be larger 363 // The RootScroller (typically LayoutView) is special since its overflow
365 // than its box rect (crbug.com/492871). 364 // clipping rect may be larger than its box rect (crbug.com/492871).
365 DCHECK(!m_layer.isRootScrollerLayer() ||
366 layoutObject.document().topDocument().layoutView());
366 LayoutRect layerBoundsWithVisualOverflow = 367 LayoutRect layerBoundsWithVisualOverflow =
367 layoutObject.isLayoutView() 368 m_layer.isRootScrollerLayer()
368 ? toLayoutView(layoutObject).viewRect() 369 ? layoutObject.document().topDocument().layoutView()->viewRect()
369 : toLayoutBox(layoutObject).visualOverflowRect(); 370 : toLayoutBox(layoutObject).visualOverflowRect();
370 // PaintLayer are in physical coordinates, so the overflow has to be 371 // PaintLayer are in physical coordinates, so the overflow has to be
371 // flipped. 372 // flipped.
372 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverflow); 373 toLayoutBox(layoutObject).flipForWritingMode(layerBoundsWithVisualOverflow);
373 layerBoundsWithVisualOverflow.moveBy(offset); 374 layerBoundsWithVisualOverflow.moveBy(offset);
374 backgroundRect.intersect(layerBoundsWithVisualOverflow); 375 backgroundRect.intersect(layerBoundsWithVisualOverflow);
375 } 376 }
376 377
377 // CSS clip (different than clipping due to overflow) can clip to any box, 378 // CSS clip (different than clipping due to overflow) can clip to any box,
378 // even if it falls outside of the border box. 379 // even if it falls outside of the border box.
(...skipping 10 matching lines...) Expand all
389 void PaintLayerClipper::calculateClipRects(const ClipRectsContext& context, 390 void PaintLayerClipper::calculateClipRects(const ClipRectsContext& context,
390 ClipRects& clipRects) const { 391 ClipRects& clipRects) const {
391 const LayoutBoxModelObject& layoutObject = *m_layer.layoutObject(); 392 const LayoutBoxModelObject& layoutObject = *m_layer.layoutObject();
392 if (!m_layer.parent() && 393 if (!m_layer.parent() &&
393 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 394 !RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
394 // The root layer's clip rect is always infinite. 395 // The root layer's clip rect is always infinite.
395 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); 396 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
396 return; 397 return;
397 } 398 }
398 399
399 bool isClippingRoot = &m_layer == context.rootLayer;
400
401 // For transformed layers, the root layer was shifted to be us, so there is no 400 // For transformed layers, the root layer was shifted to be us, so there is no
402 // need to examine the parent. We want to cache clip rects with us as the 401 // need to examine the parent. We want to cache clip rects with us as the
403 // root. 402 // root.
404 PaintLayer* parentLayer = !isClippingRoot ? m_layer.parent() : nullptr; 403 PaintLayer* parentLayer =
404 !isClippingRoot(context) ? m_layer.parent() : nullptr;
405 // Ensure that our parent's clip has been calculated so that we can examine 405 // Ensure that our parent's clip has been calculated so that we can examine
406 // the values. 406 // the values.
407 if (parentLayer) { 407 if (parentLayer) {
408 parentLayer->clipper().getOrCalculateClipRects(context, clipRects); 408 parentLayer->clipper().getOrCalculateClipRects(context, clipRects);
409 } else { 409 } else {
410 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect())); 410 clipRects.reset(LayoutRect(LayoutRect::infiniteIntRect()));
411 } 411 }
412 412
413 adjustClipRectsForChildren(layoutObject, clipRects); 413 adjustClipRectsForChildren(layoutObject, clipRects);
414 414
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // PaintLayer are in physical coordinates, so the overflow has to be 492 // PaintLayer are in physical coordinates, so the overflow has to be
493 // flipped. 493 // flipped.
494 layerBoundsWithVisualOverflow); 494 layerBoundsWithVisualOverflow);
495 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow); 495 mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow);
496 clipRect.intersect(FloatRect(layerBoundsWithVisualOverflow)); 496 clipRect.intersect(FloatRect(layerBoundsWithVisualOverflow));
497 } 497 }
498 498
499 return ClipRect(LayoutRect(clipRect)); 499 return ClipRect(LayoutRect(clipRect));
500 } 500 }
501 501
502 bool PaintLayerClipper::isClippingRoot(const ClipRectsContext& context) const {
503 return &m_layer == context.rootLayer || m_layer.isRootScrollerLayer();
504 }
505
502 ClipRect PaintLayerClipper::backgroundClipRect( 506 ClipRect PaintLayerClipper::backgroundClipRect(
503 const ClipRectsContext& context) const { 507 const ClipRectsContext& context) const {
504 if (m_geometryMapper) { 508 if (m_geometryMapper) {
505 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false); 509 ClipRect backgroundClipRect = clipRectWithGeometryMapper(context, false);
506 #ifdef CHECK_CLIP_RECTS 510 #ifdef CHECK_CLIP_RECTS
507 ClipRect testBackgroundClipRect = 511 ClipRect testBackgroundClipRect =
508 PaintLayerClipper(m_layer, false).backgroundClipRect(context); 512 PaintLayerClipper(m_layer, false).backgroundClipRect(context);
509 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect); 513 CHECK_RECTS_EQ(testBackgroundClipRect, backgroundClipRect);
510 #endif 514 #endif
511 return backgroundClipRect; 515 return backgroundClipRect;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 const LayoutSize& subpixelAccumulation) const { 577 const LayoutSize& subpixelAccumulation) const {
574 DCHECK(!m_geometryMapper); 578 DCHECK(!m_geometryMapper);
575 ClipRectsContext context(rootLayer, PaintingClipRects, 579 ClipRectsContext context(rootLayer, PaintingClipRects,
576 IgnoreOverlayScrollbarSize, subpixelAccumulation); 580 IgnoreOverlayScrollbarSize, subpixelAccumulation);
577 if (respectOverflowClip == IgnoreOverflowClip) 581 if (respectOverflowClip == IgnoreOverflowClip)
578 context.setIgnoreOverflowClip(); 582 context.setIgnoreOverflowClip();
579 return getClipRects(context); 583 return getClipRects(context);
580 } 584 }
581 585
582 } // namespace blink 586 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698