2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
23 #include "ShadowData.h"
29 ShadowData::ShadowData(const ShadowData& o)
33 , m_spread(o.m_spread)
36 , m_isWebkitBoxShadow(o.m_isWebkitBoxShadow)
37 , m_next(o.m_next ? adoptPtr(new ShadowData(*o.m_next)) : nullptr)
41 bool ShadowData::operator==(const ShadowData& o) const
43 if ((m_next && !o.m_next) || (!m_next && o.m_next)
44 || (m_next && o.m_next && *m_next != *o.m_next))
50 && m_spread == o.m_spread
51 && m_style == o.m_style
52 && m_color == o.m_color
53 && m_isWebkitBoxShadow == o.m_isWebkitBoxShadow;
56 static inline void calculateShadowExtent(const ShadowData* shadow, int additionalOutlineSize, LayoutUnit& shadowLeft, LayoutUnit& shadowRight, LayoutUnit& shadowTop, LayoutUnit& shadowBottom)
59 int blurAndSpread = shadow->blur() + shadow->spread() + additionalOutlineSize;
60 if (shadow->style() == Normal) {
61 shadowLeft = min(shadow->x() - blurAndSpread, shadowLeft);
62 shadowRight = max(shadow->x() + blurAndSpread, shadowRight);
63 shadowTop = min(shadow->y() - blurAndSpread, shadowTop);
64 shadowBottom = max(shadow->y() + blurAndSpread, shadowBottom);
67 shadow = shadow->next();
71 void ShadowData::adjustRectForShadow(IntRect& rect, int additionalOutlineSize) const
73 LayoutUnit shadowLeft = 0;
74 LayoutUnit shadowRight = 0;
75 LayoutUnit shadowTop = 0;
76 LayoutUnit shadowBottom = 0;
77 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
79 rect.move(shadowLeft, shadowTop);
80 rect.setWidth(rect.width() - shadowLeft + shadowRight);
81 rect.setHeight(rect.height() - shadowTop + shadowBottom);
84 void ShadowData::adjustRectForShadow(FloatRect& rect, int additionalOutlineSize) const
86 LayoutUnit shadowLeft = 0;
87 LayoutUnit shadowRight = 0;
88 LayoutUnit shadowTop = 0;
89 LayoutUnit shadowBottom = 0;
90 calculateShadowExtent(this, additionalOutlineSize, shadowLeft, shadowRight, shadowTop, shadowBottom);
92 rect.move(shadowLeft, shadowTop);
93 rect.setWidth(rect.width() - shadowLeft + shadowRight);
94 rect.setHeight(rect.height() - shadowTop + shadowBottom);
97 } // namespace WebCore