Commit 021cace4 authored by leviw@chromium.org's avatar leviw@chromium.org
Browse files

Convert ShadowData and DropShadowFilterOperation to use IntPoint

https://bugs.webkit.org/show_bug.cgi?id=84098

Reviewed by Eric Seidel.

Shadows do not flow with the page, so sub-pixel layout doesn't actually offer any benefit that
couldn't have been attained before that conversion. With that in mind, this patch reverts
drop shadow offsets to integers, but also cleans up the code by switching the x/y location pair
to be an IntPoint.

No new tests. No change in behavior.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::valueForFilter):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
* css/SVGCSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applySVGProperty):
* page/animation/AnimationBase.cpp:
(WebCore::blendFunc):
(WebCore::shadowForBlending):
* platform/animation/AnimationUtilities.h:
(WebCore::blend): New blend function that operates on IntPoints.
(WebCore):
* platform/chromium/support/WebFilterOperations.cpp:
(WebKit::WebDropShadowFilterOperation):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::DropShadowFilterOperation::blend):
* platform/graphics/filters/FilterOperation.h:
(WebCore::DropShadowFilterOperation::clone):
(WebCore::DropShadowFilterOperation::x):
(WebCore::DropShadowFilterOperation::y):
(WebCore::DropShadowFilterOperation::location): Preserved the comment about lengths.
(WebCore::DropShadowFilterOperation::operator==):
(WebCore::DropShadowFilterOperation::DropShadowFilterOperation):
(DropShadowFilterOperation):
* rendering/RenderBoxModelObject.cpp:
(WebCore::areaCastingShadowInHole): Reverted to integers since this operates on the IntRect from
a RoundedRect.
(WebCore::RenderBoxModelObject::paintBoxShadow): Reduced the complexity and unnecessary conversion
between LayoutUnits and integers by using all integers after we calculate the pixel-snapped
RoundedRect that we use for painting.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getShadowExtent):
(WebCore::RenderStyle::getShadowHorizontalExtent):
(WebCore::RenderStyle::getShadowVerticalExtent):
* rendering/style/ShadowData.cpp:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::operator==):
(WebCore::calculateShadowExtent):
(WebCore::ShadowData::adjustRectForShadow):
* rendering/style/ShadowData.h:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::x):
(WebCore::ShadowData::y):
(WebCore::ShadowData::location):
(ShadowData):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 405e386d
2012-04-18 Levi Weintraub <leviw@chromium.org>
Convert ShadowData and DropShadowFilterOperation to use IntPoint
https://bugs.webkit.org/show_bug.cgi?id=84098
Reviewed by Eric Seidel.
Shadows do not flow with the page, so sub-pixel layout doesn't actually offer any benefit that
couldn't have been attained before that conversion. With that in mind, this patch reverts
drop shadow offsets to integers, but also cleans up the code by switching the x/y location pair
to be an IntPoint.
No new tests. No change in behavior.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::valueForFilter):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::collectMatchingRulesForList):
* css/SVGCSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applySVGProperty):
* page/animation/AnimationBase.cpp:
(WebCore::blendFunc):
(WebCore::shadowForBlending):
* platform/animation/AnimationUtilities.h:
(WebCore::blend): New blend function that operates on IntPoints.
(WebCore):
* platform/chromium/support/WebFilterOperations.cpp:
(WebKit::WebDropShadowFilterOperation):
* platform/graphics/filters/FilterOperation.cpp:
(WebCore::DropShadowFilterOperation::blend):
* platform/graphics/filters/FilterOperation.h:
(WebCore::DropShadowFilterOperation::clone):
(WebCore::DropShadowFilterOperation::x):
(WebCore::DropShadowFilterOperation::y):
(WebCore::DropShadowFilterOperation::location): Preserved the comment about lengths.
(WebCore::DropShadowFilterOperation::operator==):
(WebCore::DropShadowFilterOperation::DropShadowFilterOperation):
(DropShadowFilterOperation):
* rendering/RenderBoxModelObject.cpp:
(WebCore::areaCastingShadowInHole): Reverted to integers since this operates on the IntRect from
a RoundedRect.
(WebCore::RenderBoxModelObject::paintBoxShadow): Reduced the complexity and unnecessary conversion
between LayoutUnits and integers by using all integers after we calculate the pixel-snapped
RoundedRect that we use for painting.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::getShadowExtent):
(WebCore::RenderStyle::getShadowHorizontalExtent):
(WebCore::RenderStyle::getShadowVerticalExtent):
* rendering/style/ShadowData.cpp:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::operator==):
(WebCore::calculateShadowExtent):
(WebCore::ShadowData::adjustRectForShadow):
* rendering/style/ShadowData.h:
(WebCore::ShadowData::ShadowData):
(WebCore::ShadowData::x):
(WebCore::ShadowData::y):
(WebCore::ShadowData::location):
(ShadowData):
2012-04-17 Kentaro Hara <haraken@chromium.org>
 
[V8] Add an optional Isolate argument to wrap()
......@@ -825,7 +825,7 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForFilter(RenderStyle* st
DropShadowFilterOperation* dropShadowOperation = static_cast<DropShadowFilterOperation*>(filterOperation);
filterValue = WebKitCSSFilterValue::create(WebKitCSSFilterValue::DropShadowFilterOperation);
// We want our computed style to look like that of a text shadow (has neither spread nor inset style).
ShadowData shadowData = ShadowData(dropShadowOperation->x(), dropShadowOperation->y(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
ShadowData shadowData = ShadowData(dropShadowOperation->location(), dropShadowOperation->stdDeviation(), 0, Normal, false, dropShadowOperation->color());
filterValue->append(valueForShadow(&shadowData, CSSPropertyTextShadow, style));
break;
}
......
......@@ -3450,7 +3450,7 @@ void CSSStyleSelector::applyProperty(CSSPropertyID id, CSSValue *value)
else if (m_style)
color = m_style->color();
OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(x, y, blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));
OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(IntPoint(x, y), blur, spread, shadowStyle, id == CSSPropertyWebkitBoxShadow, color.isValid() ? color : Color::transparent));
if (id == CSSPropertyTextShadow)
m_style->setTextShadow(shadowData.release(), i.index()); // add to the list if this is not the first entry
else
......@@ -5714,14 +5714,14 @@ bool CSSStyleSelector::createFilterOperations(CSSValue* inValue, RenderStyle* st
continue;
ShadowValue* item = static_cast<ShadowValue*>(cssValue);
int x = item->x->computeLength<int>(style, rootStyle, zoomFactor);
int y = item->y->computeLength<int>(style, rootStyle, zoomFactor);
IntPoint location(item->x->computeLength<int>(style, rootStyle, zoomFactor),
item->y->computeLength<int>(style, rootStyle, zoomFactor));
int blur = item->blur ? item->blur->computeLength<int>(style, rootStyle, zoomFactor) : 0;
Color color;
if (item->color)
color = colorFromPrimitiveValue(item->color.get());
operations.operations().append(DropShadowFilterOperation::create(x, y, blur, color.isValid() ? color : Color::transparent, operationType));
operations.operations().append(DropShadowFilterOperation::create(location, blur, color.isValid() ? color : Color::transparent, operationType));
break;
}
case WebKitCSSFilterValue::UnknownFilterOperation:
......
......@@ -571,8 +571,8 @@ void CSSStyleSelector::applySVGProperty(CSSPropertyID id, CSSValue* value)
if (!firstValue->isShadowValue())
return;
ShadowValue* item = static_cast<ShadowValue*>(firstValue);
int x = item->x->computeLength<int>(style(), m_rootElementStyle);
int y = item->y->computeLength<int>(style(), m_rootElementStyle);
IntPoint location(item->x->computeLength<int>(style(), m_rootElementStyle),
item->y->computeLength<int>(style(), m_rootElementStyle));
int blur = item->blur ? item->blur->computeLength<int>(style(), m_rootElementStyle) : 0;
Color color;
if (item->color)
......@@ -582,7 +582,7 @@ void CSSStyleSelector::applySVGProperty(CSSPropertyID id, CSSValue* value)
ASSERT(!item->spread);
ASSERT(!item->style);
OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(x, y, blur, 0, Normal, false, color.isValid() ? color : Color::transparent));
OwnPtr<ShadowData> shadowData = adoptPtr(new ShadowData(location, blur, 0, Normal, false, color.isValid() ? color : Color::transparent));
svgstyle->setShadow(shadowData.release());
return;
}
......
......@@ -135,8 +135,7 @@ static inline PassOwnPtr<ShadowData> blendFunc(const AnimationBase* anim, const
if (from->style() != to->style())
return adoptPtr(new ShadowData(*to));
return adoptPtr(new ShadowData(blend(from->x(), to->x(), progress),
blend(from->y(), to->y(), progress),
return adoptPtr(new ShadowData(blend(from->location(), to->location(), progress),
blend(from->blur(), to->blur(), progress),
blend(from->spread(), to->spread(), progress),
blendFunc(anim, from->style(), to->style(), progress),
......@@ -494,11 +493,11 @@ static inline size_t shadowListLength(const ShadowData* shadow)
static inline const ShadowData* shadowForBlending(const ShadowData* srcShadow, const ShadowData* otherShadow)
{
DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (0, 0, 0, 0, Normal, false, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (0, 0, 0, 0, Inset, false, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultShadowData, (IntPoint(), 0, 0, Normal, false, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultInsetShadowData, (IntPoint(), 0, 0, Inset, false, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultWebKitBoxShadowData, (0, 0, 0, 0, Normal, true, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultInsetWebKitBoxShadowData, (0, 0, 0, 0, Inset, true, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultWebKitBoxShadowData, (IntPoint(), 0, 0, Normal, true, Color::transparent));
DEFINE_STATIC_LOCAL(ShadowData, defaultInsetWebKitBoxShadowData, (IntPoint(), 0, 0, Inset, true, Color::transparent));
if (srcShadow)
return srcShadow;
......
......@@ -27,6 +27,7 @@
#define AnimationUtilities_h
#include "FractionalLayoutUnit.h"
#include "IntPoint.h"
#include <wtf/MathExtras.h>
namespace WebCore {
......@@ -56,6 +57,12 @@ inline FractionalLayoutUnit blend(FractionalLayoutUnit from, FractionalLayoutUni
return from + (to - from) * progress;
}
inline IntPoint blend(const IntPoint& from, const IntPoint& to, double progress)
{
return IntPoint(blend(from.x(), to.x(), progress),
blend(from.y(), to.y(), progress));
}
} // namespace WebCore
#endif // AnimationUtilities_h
......@@ -50,7 +50,7 @@ PassRefPtr<WebCore::FilterOperation> WebBlurFilterOperation::toFilterOperation()
PassRefPtr<WebCore::FilterOperation> WebDropShadowFilterOperation::toFilterOperation() const
{
return DropShadowFilterOperation::create(x, y, stdDeviation, color, FilterOperation::DROP_SHADOW);
return DropShadowFilterOperation::create(IntPoint(x, y), stdDeviation, color, FilterOperation::DROP_SHADOW);
}
} // namespace WebKit
......@@ -133,21 +133,18 @@ PassRefPtr<FilterOperation> DropShadowFilterOperation::blend(const FilterOperati
if (blendToPassthrough)
return DropShadowFilterOperation::create(
WebCore::blend(m_x, 0, progress),
WebCore::blend(m_y, 0, progress),
WebCore::blend(m_location, IntPoint(), progress),
WebCore::blend(m_stdDeviation, 0, progress),
WebCore::blend(m_color, Color(Color::transparent), progress),
m_type);
const DropShadowFilterOperation* fromOp = static_cast<const DropShadowFilterOperation*>(from);
int fromX = fromOp ? fromOp->x() : 0;
int fromY = fromOp ? fromOp->y() : 0;
IntPoint fromLocation = fromOp ? fromOp->location() : IntPoint();
int fromStdDeviation = fromOp ? fromOp->stdDeviation() : 0;
Color fromColor = fromOp ? fromOp->color() : Color(Color::transparent);
return DropShadowFilterOperation::create(
WebCore::blend(fromX, m_x, progress),
WebCore::blend(fromY, m_y, progress),
WebCore::blend(fromLocation, m_location, progress),
WebCore::blend(fromStdDeviation, m_stdDeviation, progress),
WebCore::blend(fromColor, m_color, progress), m_type);
}
......
......@@ -338,18 +338,19 @@ private:
class DropShadowFilterOperation : public FilterOperation {
public:
static PassRefPtr<DropShadowFilterOperation> create(int x, int y, int stdDeviation, Color color, OperationType type)
static PassRefPtr<DropShadowFilterOperation> create(const IntPoint& location, int stdDeviation, Color color, OperationType type)
{
return adoptRef(new DropShadowFilterOperation(x, y, stdDeviation, color, type));
return adoptRef(new DropShadowFilterOperation(location, stdDeviation, color, type));
}
virtual PassRefPtr<FilterOperation> clone() const
{
return adoptRef(new DropShadowFilterOperation(m_x, m_y, m_stdDeviation, m_color, m_type));
return adoptRef(new DropShadowFilterOperation(m_location, m_stdDeviation, m_color, m_type));
}
int x() const { return m_x; }
int y() const { return m_y; }
int x() const { return m_location.x(); }
int y() const { return m_location.y(); }
IntPoint location() const { return m_location; }
int stdDeviation() const { return m_stdDeviation; }
Color color() const { return m_color; }
......@@ -365,20 +366,18 @@ private:
if (!isSameType(o))
return false;
const DropShadowFilterOperation* other = static_cast<const DropShadowFilterOperation*>(&o);
return m_x == other->m_x && m_y == other->m_y && m_stdDeviation == other->m_stdDeviation && m_color == other->m_color;
return m_location == other->m_location && m_stdDeviation == other->m_stdDeviation && m_color == other->m_color;
}
DropShadowFilterOperation(int x, int y, int stdDeviation, Color color, OperationType type)
DropShadowFilterOperation(const IntPoint& location, int stdDeviation, Color color, OperationType type)
: FilterOperation(type)
, m_x(x)
, m_y(y)
, m_location(location)
, m_stdDeviation(stdDeviation)
, m_color(color)
{
}
int m_x; // FIXME: x and y should be Lengths?
int m_y;
IntPoint m_location; // FIXME: should location be in Lengths?
int m_stdDeviation;
Color m_color;
};
......
......@@ -2814,16 +2814,16 @@ bool RenderBoxModelObject::boxShadowShouldBeAppliedToBackground(BackgroundBleedA
return true;
}
static inline LayoutRect areaCastingShadowInHole(const LayoutRect& holeRect, int shadowBlur, int shadowSpread, const LayoutSize& shadowOffset)
static inline IntRect areaCastingShadowInHole(const IntRect& holeRect, int shadowBlur, int shadowSpread, const IntSize& shadowOffset)
{
LayoutRect bounds(holeRect);
IntRect bounds(holeRect);
bounds.inflate(shadowBlur);
if (shadowSpread < 0)
bounds.inflate(-shadowSpread);
LayoutRect offsetBounds = bounds;
IntRect offsetBounds = bounds;
offsetBounds.move(-shadowOffset);
return unionRect(bounds, offsetBounds);
}
......@@ -2846,9 +2846,9 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
if (shadow->style() != shadowStyle)
continue;
LayoutSize shadowOffset(shadow->x(), shadow->y());
LayoutUnit shadowBlur = shadow->blur();
LayoutUnit shadowSpread = shadow->spread();
IntSize shadowOffset(shadow->x(), shadow->y());
int shadowBlur = shadow->blur();
int shadowSpread = shadow->spread();
if (shadowOffset.isZero() && !shadowBlur && !shadowSpread)
continue;
......@@ -2861,7 +2861,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
if (fillRect.isEmpty())
continue;
LayoutRect shadowRect(border.rect());
IntRect shadowRect(border.rect());
shadowRect.inflate(shadowBlur + shadowSpread);
shadowRect.move(shadowOffset);
......@@ -2870,7 +2870,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
// Move the fill just outside the clip, adding 1 pixel separation so that the fill does not
// bleed in (due to antialiasing) if the context is transformed.
LayoutSize extraOffset(paintRect.width() + max<LayoutUnit>(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
IntSize extraOffset(paintRect.pixelSnappedWidth() + max(0, shadowOffset.width()) + shadowBlur + 2 * shadowSpread + 1, 0);
shadowOffset -= extraOffset;
fillRect.move(extraOffset);
......@@ -2901,7 +2901,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
context->fillRoundedRect(fillRect, Color::black, s->colorSpace());
}
} else {
LayoutRect rectToClipOut = border.rect();
IntRect rectToClipOut = border.rect();
// If the box is opaque, it is unnecessary to clip it out. However, doing so saves time
// when painting the shadow. On the other hand, it introduces subpixel gaps along the
......@@ -2916,12 +2916,12 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
}
if (!rectToClipOut.isEmpty())
context->clipOut(pixelSnappedIntRect(rectToClipOut));
context->clipOut(rectToClipOut);
context->fillRect(fillRect.rect(), Color::black, s->colorSpace());
}
} else {
// Inset shadow.
LayoutRect holeRect(border.rect());
IntRect holeRect(border.rect());
holeRect.inflate(-shadowSpread);
if (holeRect.isEmpty()) {
......@@ -2934,11 +2934,11 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
if (!includeLogicalLeftEdge) {
if (isHorizontal) {
holeRect.move(-max<LayoutUnit>(shadowOffset.width(), 0) - shadowBlur, 0);
holeRect.setWidth(holeRect.width() + max<LayoutUnit>(shadowOffset.width(), 0) + shadowBlur);
holeRect.move(-max(shadowOffset.width(), 0) - shadowBlur, 0);
holeRect.setWidth(holeRect.width() + max(shadowOffset.width(), 0) + shadowBlur);
} else {
holeRect.move(0, -max<LayoutUnit>(shadowOffset.height(), 0) - shadowBlur);
holeRect.setHeight(holeRect.height() + max<LayoutUnit>(shadowOffset.height(), 0) + shadowBlur);
holeRect.move(0, -max(shadowOffset.height(), 0) - shadowBlur);
holeRect.setHeight(holeRect.height() + max(shadowOffset.height(), 0) + shadowBlur);
}
}
if (!includeLogicalRightEdge) {
......@@ -2950,8 +2950,8 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
Color fillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), 255);
LayoutRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset);
RoundedRect roundedHole(pixelSnappedIntRect(holeRect), border.radii());
IntRect outerRect = areaCastingShadowInHole(border.rect(), shadowBlur, shadowSpread, shadowOffset);
RoundedRect roundedHole(holeRect, border.radii());
GraphicsContextStateSaver stateSaver(*context);
if (hasBorderRadius) {
......@@ -2962,7 +2962,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
} else
context->clip(border.rect());
LayoutSize extraOffset(2 * paintRect.width() + max<LayoutUnit>(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
IntSize extraOffset(2 * paintRect.pixelSnappedWidth() + max(0, shadowOffset.width()) + shadowBlur - 2 * shadowSpread + 1, 0);
context->translate(extraOffset.width(), extraOffset.height());
shadowOffset -= extraOffset;
......@@ -2971,7 +2971,7 @@ void RenderBoxModelObject::paintBoxShadow(const PaintInfo& info, const LayoutRec
else
context->setShadow(shadowOffset, shadowBlur, shadowColor, s->colorSpace());
context->fillRectWithRoundedHole(pixelSnappedIntRect(outerRect), roundedHole, fillColor, s->colorSpace());
context->fillRectWithRoundedHole(outerRect, roundedHole, fillColor, s->colorSpace());
}
}
}
......
......@@ -1169,10 +1169,10 @@ void RenderStyle::getShadowExtent(const ShadowData* shadow, LayoutUnit &top, Lay
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
top = min(top, shadow->y() - blurAndSpread);
right = max(right, shadow->x() + blurAndSpread);
bottom = max(bottom, shadow->y() + blurAndSpread);
left = min(left, shadow->x() - blurAndSpread);
top = min<LayoutUnit>(top, shadow->y() - blurAndSpread);
right = max<LayoutUnit>(right, shadow->x() + blurAndSpread);
bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread);
left = min<LayoutUnit>(left, shadow->x() - blurAndSpread);
}
}
......@@ -1186,8 +1186,8 @@ void RenderStyle::getShadowHorizontalExtent(const ShadowData* shadow, LayoutUnit
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
left = min(left, shadow->x() - blurAndSpread);
right = max(right, shadow->x() + blurAndSpread);
left = min<LayoutUnit>(left, shadow->x() - blurAndSpread);
right = max<LayoutUnit>(right, shadow->x() + blurAndSpread);
}
}
......@@ -1201,8 +1201,8 @@ void RenderStyle::getShadowVerticalExtent(const ShadowData* shadow, LayoutUnit &
continue;
int blurAndSpread = shadow->blur() + shadow->spread();
top = min(top, shadow->y() - blurAndSpread);
bottom = max(bottom, shadow->y() + blurAndSpread);
top = min<LayoutUnit>(top, shadow->y() - blurAndSpread);
bottom = max<LayoutUnit>(bottom, shadow->y() + blurAndSpread);
}
}
......
......@@ -27,8 +27,7 @@ using namespace std;
namespace WebCore {
ShadowData::ShadowData(const ShadowData& o)
: m_x(o.m_x)
, m_y(o.m_y)
: m_location(o.m_location)
, m_blur(o.m_blur)
, m_spread(o.m_spread)
, m_color(o.m_color)
......@@ -44,8 +43,7 @@ bool ShadowData::operator==(const ShadowData& o) const
|| (m_next && o.m_next && *m_next != *o.m_next))
return false;
return m_x == o.m_x
&& m_y == o.m_y
return m_location == o.m_location
&& m_blur == o.m_blur
&& m_spread == o.m_spread
&& m_style == o.m_style
......@@ -53,7 +51,7 @@ bool ShadowData::operator==(const ShadowData& o) const
&& m_isWebkitBoxShadow == o.m_isWebkitBoxShadow;
}
static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, LayoutUnit& shadowLeft, LayoutUnit& shadowRight, LayoutUnit& shadowTop, LayoutUnit& shadowBottom)
static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, int& shadowLeft, int& shadowRight, int& shadowTop, int& shadowBottom)
{
do {
int blurAndSpread = shadow->blur() + shadow->spread() + additionalOutlineSize;
......@@ -70,10 +68,10 @@ static inline void calculateShadowExtent(const ShadowData* shadow, int additiona
void ShadowData::adjustRectForShadow(LayoutRect& rect, int additionalOutlineSize) const
{
LayoutUnit shadowLeft = 0;
LayoutUnit shadowRight = 0;
LayoutUnit shadowTop = 0;
LayoutUnit shadowBottom = 0;
int shadowLeft = 0;
int shadowRight = 0;
int shadowTop = 0;
int shadowBottom = 0;
calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
rect.move(shadowLeft, shadowTop);
......@@ -83,10 +81,10 @@ void ShadowData::adjustRectForShadow(LayoutRect& rect, int additionalOutlineSize
void ShadowData::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const
{
LayoutUnit shadowLeft = 0;
LayoutUnit shadowRight = 0;
LayoutUnit shadowTop = 0;
LayoutUnit shadowBottom = 0;
int shadowLeft = 0;
int shadowRight = 0;
int shadowTop = 0;
int shadowBottom = 0;
calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
rect.move(shadowLeft, shadowTop);
......
......@@ -40,18 +40,15 @@ class ShadowData {
WTF_MAKE_FAST_ALLOCATED;
public:
ShadowData()
: m_x(0)
, m_y(0)
, m_blur(0)
: m_blur(0)
, m_spread(0)
, m_style(Normal)
, m_isWebkitBoxShadow(false)
{
}
ShadowData(LayoutUnit x, LayoutUnit y, int blur, int spread, ShadowStyle style, bool isWebkitBoxShadow, const Color& color)
: m_x(x)
, m_y(y)
ShadowData(const IntPoint& location, int blur, int spread, ShadowStyle style, bool isWebkitBoxShadow, const Color& color)
: m_location(location)
, m_blur(blur)
, m_spread(spread)
, m_color(color)
......@@ -68,8 +65,9 @@ public:
return !(*this == o);
}
LayoutUnit x() const { return m_x; }
LayoutUnit y() const { return m_y; }
int x() const { return m_location.x(); }
int y() const { return m_location.y(); }
IntPoint location() const { return m_location; }
int blur() const { return m_blur; }
int spread() const { return m_spread; }
ShadowStyle style() const { return m_style; }
......@@ -83,8 +81,7 @@ public:
void adjustRectForShadow(FloatRect&, int additionalOutlineSize = 0) const;
private:
LayoutUnit m_x;
LayoutUnit m_y;
IntPoint m_location;
int m_blur;
int m_spread;
Color m_color;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment