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

Unified Diff: third_party/WebKit/Source/core/paint/BoxClipper.cpp

Issue 1448253002: Clip scrollbars to box bounds when they don't fit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/BoxClipper.cpp
diff --git a/third_party/WebKit/Source/core/paint/BoxClipper.cpp b/third_party/WebKit/Source/core/paint/BoxClipper.cpp
index 6355078338ba7f8605031ba53decf96cabb74ae5..19c86d7ea712dbe9bbe0e6a7330205a0b987f8d0 100644
--- a/third_party/WebKit/Source/core/paint/BoxClipper.cpp
+++ b/third_party/WebKit/Source/core/paint/BoxClipper.cpp
@@ -20,19 +20,34 @@ BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L
, m_paintInfo(paintInfo)
, m_clipType(DisplayItem::UninitializedType)
{
- if (m_paintInfo.phase == PaintPhaseBlockBackground || m_paintInfo.phase == PaintPhaseSelfOutline || m_paintInfo.phase == PaintPhaseMask)
+ if ((m_paintInfo.phase == PaintPhaseBlockBackground && contentsClipBehavior != ClipForScrollbars)
+ || m_paintInfo.phase == PaintPhaseSelfOutline || m_paintInfo.phase == PaintPhaseMask)
return;
- bool isControlClip = m_box.hasControlClip();
- bool isOverflowClip = m_box.hasOverflowClip() && !m_box.layer()->isSelfPaintingLayer();
+ bool hasControlClip = m_box.hasControlClip();
+ bool hasOverflowClip = m_box.hasOverflowClip() && !m_box.layer()->isSelfPaintingLayer();
- if (!isControlClip && !isOverflowClip)
+ if (!hasControlClip && !hasOverflowClip)
return;
- LayoutRect clipRect = isControlClip ? m_box.controlClipRect(accumulatedOffset) : m_box.overflowClipRect(accumulatedOffset);
+ LayoutRect clipRect;
+
+ if (hasControlClip) {
+ clipRect = m_box.controlClipRect(accumulatedOffset);
+ } else {
+ ASSERT(hasOverflowClip);
+ if (contentsClipBehavior == ClipForScrollbars) {
+ clipRect = m_box.borderBoxRect();
+ clipRect.moveBy(accumulatedOffset);
+ } else {
+ clipRect = m_box.overflowClipRect(accumulatedOffset);
+ }
+ }
+
FloatRoundedRect clipRoundedRect(0, 0, 0, 0);
- bool hasBorderRadius = m_box.style()->hasBorderRadius();
- if (hasBorderRadius)
+ // Scrollbars paint on top of a rounded border.
+ bool shouldClipBorderRadius = m_box.style()->hasBorderRadius() && contentsClipBehavior != ClipForScrollbars;
+ if (shouldClipBorderRadius)
clipRoundedRect = m_box.style()->getRoundedInnerBorderFor(LayoutRect(accumulatedOffset, m_box.size()));
if (contentsClipBehavior == SkipContentsClipIfPossible) {
@@ -41,7 +56,7 @@ BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L
return;
LayoutRect conservativeClipRect = clipRect;
- if (hasBorderRadius)
+ if (shouldClipBorderRadius)
conservativeClipRect.intersect(LayoutRect(clipRoundedRect.radiusCenterRect()));
conservativeClipRect.moveBy(-accumulatedOffset);
if (m_box.hasLayer())
@@ -53,7 +68,7 @@ BoxClipper::BoxClipper(const LayoutBox& box, const PaintInfo& paintInfo, const L
if (!m_paintInfo.context->paintController().displayItemConstructionIsDisabled()) {
m_clipType = m_paintInfo.displayItemTypeForClipping();
Vector<FloatRoundedRect> roundedRects;
- if (hasBorderRadius)
+ if (shouldClipBorderRadius)
roundedRects.append(clipRoundedRect);
m_paintInfo.context->paintController().createAndAppend<ClipDisplayItem>(m_box, m_clipType, pixelSnappedIntRect(clipRect), roundedRects);
}

Powered by Google App Engine
This is Rietveld 408576698