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

Unified Diff: Source/core/rendering/RenderBoxModelObject.cpp

Issue 23241010: Support subpixel values for text-shadow and box-shadow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: all working! Created 7 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: Source/core/rendering/RenderBoxModelObject.cpp
diff --git a/Source/core/rendering/RenderBoxModelObject.cpp b/Source/core/rendering/RenderBoxModelObject.cpp
index d8f3ee81977f8fffa40309594d1719aabfa14186..aacee56026715b5fb1d85eed465c14374c59066b 100644
--- a/Source/core/rendering/RenderBoxModelObject.cpp
+++ b/Source/core/rendering/RenderBoxModelObject.cpp
@@ -2482,9 +2482,9 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
if (shadow.style() != shadowStyle)
continue;
- IntSize shadowOffset(shadow.x(), shadow.y());
- int shadowBlur = shadow.blur();
- int shadowSpread = shadow.spread();
+ LayoutSize shadowOffset(shadow.x(), shadow.y());
+ LayoutUnit shadowBlur = shadow.blur();
+ LayoutUnit shadowSpread = shadow.spread();
if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
continue;
@@ -2492,12 +2492,12 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
const Color& shadowColor = resolveColor(shadow.color());
if (shadow.style() == Normal) {
- RoundedRect fillRect = border;
+ FloatRect fillRect = border.rect();
fillRect.inflate(shadowSpread);
if (fillRect.isEmpty())
continue;
- IntRect shadowRect(border.rect());
+ LayoutRect shadowRect(border.rect());
shadowRect.inflate(shadowBlur + shadowSpread);
shadowRect.move(shadowOffset);
@@ -2518,6 +2518,8 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
context->clipOutRoundedRect(rectToClipOut);
}
} else {
+ // This IntRect is correct even with fractional shadows, because it is used for the rectangle
+ // of the box itself, which is always pixel-aligned.
IntRect rectToClipOut = border.rect();
// If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
@@ -2545,20 +2547,25 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
context->setDrawLooper(drawLooper);
if (hasBorderRadius) {
- RoundedRect influenceRect(shadowRect, border.radii());
+ // XXX is this IntRect conversion correct?
eae 2013/11/27 23:45:27 Why not use pixelSnappedIntRect instead?
cbiesinger 2013/12/18 02:09:12 Good idea, thanks.
+ RoundedRect influenceRect(IntRect(shadowRect.pixelSnappedLocation(), shadowRect.pixelSnappedSize()), border.radii());
influenceRect.expandRadii(2 * shadowBlur + shadowSpread);
if (allCornersClippedOut(influenceRect, info.rect))
- context->fillRect(fillRect.rect(), Color::black);
+ context->fillRect(fillRect, Color::black);
else {
- fillRect.expandRadii(shadowSpread);
- if (!fillRect.isRenderable())
- fillRect.adjustRadii();
- context->fillRoundedRect(fillRect, Color::black);
+ RoundedRect roundedFillRect = border;
+ roundedFillRect.inflate(shadowSpread);
+
+ roundedFillRect.expandRadii(shadowSpread);
+ if (!roundedFillRect.isRenderable())
+ roundedFillRect.adjustRadii();
+ context->fillRoundedRect(roundedFillRect, Color::black);
}
} else {
- context->fillRect(fillRect.rect(), Color::black);
+ context->fillRect(fillRect, Color::black);
}
} else {
+ // inset shadow
eae 2013/11/27 23:45:27 Update comment to be more descriptive or remove it
cbiesinger 2013/12/18 02:09:12 Done.
GraphicsContext::Edges clippedEdges = GraphicsContext::NoEdge;
if (!includeLogicalLeftEdge) {
if (isHorizontal)
@@ -2572,7 +2579,8 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
else
clippedEdges |= GraphicsContext::BottomEdge;
}
- context->drawInnerShadow(border, shadowColor, shadowOffset, shadowBlur, shadowSpread, clippedEdges);
+ // TODO: support non-integer shadows
+ context->drawInnerShadow(border, shadowColor, IntSize(shadowOffset.width(), shadowOffset.height()), shadowBlur, shadowSpread, clippedEdges);
eae 2013/11/27 23:45:27 do you want to floor or round the offset here? Use
cbiesinger 2013/12/18 02:09:12 Ah, thanks - done. Switched to floored because tha
}
}
}

Powered by Google App Engine
This is Rietveld 408576698