| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | |
| 3 2004, 2005, 2010 Rob Buis <buis@kde.org> | |
| 4 Copyright (C) Research In Motion Limited 2010. All rights reserved. | |
| 5 | |
| 6 Based on khtml code by: | |
| 7 Copyright (C) 1999 Antti Koivisto (koivisto@kde.org) | |
| 8 Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org) | |
| 9 Copyright (C) 2002-2003 Dirk Mueller (mueller@kde.org) | |
| 10 Copyright (C) 2002 Apple Computer, Inc. | |
| 11 | |
| 12 This library is free software; you can redistribute it and/or | |
| 13 modify it under the terms of the GNU Library General Public | |
| 14 License as published by the Free Software Foundation; either | |
| 15 version 2 of the License, or (at your option) any later version. | |
| 16 | |
| 17 This library is distributed in the hope that it will be useful, | |
| 18 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 20 Library General Public License for more details. | |
| 21 | |
| 22 You should have received a copy of the GNU Library General Public License | |
| 23 along with this library; see the file COPYING.LIB. If not, write to | |
| 24 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
| 25 Boston, MA 02110-1301, USA. | |
| 26 */ | |
| 27 | |
| 28 #include "config.h" | |
| 29 | |
| 30 #include "core/layout/style/SVGLayoutStyle.h" | |
| 31 | |
| 32 namespace blink { | |
| 33 | |
| 34 SVGLayoutStyle::SVGLayoutStyle() | |
| 35 { | |
| 36 static SVGLayoutStyle* initialStyle = new SVGLayoutStyle(CreateInitial); | |
| 37 | |
| 38 fill = initialStyle->fill; | |
| 39 stroke = initialStyle->stroke; | |
| 40 stops = initialStyle->stops; | |
| 41 misc = initialStyle->misc; | |
| 42 inheritedResources = initialStyle->inheritedResources; | |
| 43 layout = initialStyle->layout; | |
| 44 resources = initialStyle->resources; | |
| 45 | |
| 46 setBitDefaults(); | |
| 47 } | |
| 48 | |
| 49 SVGLayoutStyle::SVGLayoutStyle(CreateInitialType) | |
| 50 { | |
| 51 setBitDefaults(); | |
| 52 | |
| 53 fill.init(); | |
| 54 stroke.init(); | |
| 55 stops.init(); | |
| 56 misc.init(); | |
| 57 inheritedResources.init(); | |
| 58 layout.init(); | |
| 59 resources.init(); | |
| 60 } | |
| 61 | |
| 62 SVGLayoutStyle::SVGLayoutStyle(const SVGLayoutStyle& other) | |
| 63 : RefCounted<SVGLayoutStyle>() | |
| 64 { | |
| 65 fill = other.fill; | |
| 66 stroke = other.stroke; | |
| 67 stops = other.stops; | |
| 68 misc = other.misc; | |
| 69 inheritedResources = other.inheritedResources; | |
| 70 layout = other.layout; | |
| 71 resources = other.resources; | |
| 72 | |
| 73 svg_inherited_flags = other.svg_inherited_flags; | |
| 74 svg_noninherited_flags = other.svg_noninherited_flags; | |
| 75 } | |
| 76 | |
| 77 SVGLayoutStyle::~SVGLayoutStyle() | |
| 78 { | |
| 79 } | |
| 80 | |
| 81 bool SVGLayoutStyle::operator==(const SVGLayoutStyle& other) const | |
| 82 { | |
| 83 return fill == other.fill | |
| 84 && stroke == other.stroke | |
| 85 && stops == other.stops | |
| 86 && misc == other.misc | |
| 87 && inheritedResources == other.inheritedResources | |
| 88 && layout == other.layout | |
| 89 && resources == other.resources | |
| 90 && svg_inherited_flags == other.svg_inherited_flags | |
| 91 && svg_noninherited_flags == other.svg_noninherited_flags; | |
| 92 } | |
| 93 | |
| 94 bool SVGLayoutStyle::inheritedNotEqual(const SVGLayoutStyle* other) const | |
| 95 { | |
| 96 return fill != other->fill | |
| 97 || stroke != other->stroke | |
| 98 || inheritedResources != other->inheritedResources | |
| 99 || svg_inherited_flags != other->svg_inherited_flags; | |
| 100 } | |
| 101 | |
| 102 void SVGLayoutStyle::inheritFrom(const SVGLayoutStyle* svgInheritParent) | |
| 103 { | |
| 104 if (!svgInheritParent) | |
| 105 return; | |
| 106 | |
| 107 fill = svgInheritParent->fill; | |
| 108 stroke = svgInheritParent->stroke; | |
| 109 inheritedResources = svgInheritParent->inheritedResources; | |
| 110 | |
| 111 svg_inherited_flags = svgInheritParent->svg_inherited_flags; | |
| 112 } | |
| 113 | |
| 114 void SVGLayoutStyle::copyNonInheritedFromCached(const SVGLayoutStyle* other) | |
| 115 { | |
| 116 svg_noninherited_flags = other->svg_noninherited_flags; | |
| 117 stops = other->stops; | |
| 118 misc = other->misc; | |
| 119 layout = other->layout; | |
| 120 resources = other->resources; | |
| 121 } | |
| 122 | |
| 123 PassRefPtr<SVGDashArray> SVGLayoutStyle::initialStrokeDashArray() | |
| 124 { | |
| 125 DEFINE_STATIC_REF(SVGDashArray, initialDashArray, SVGDashArray::create()); | |
| 126 return initialDashArray; | |
| 127 } | |
| 128 | |
| 129 StyleDifference SVGLayoutStyle::diff(const SVGLayoutStyle* other) const | |
| 130 { | |
| 131 StyleDifference styleDifference; | |
| 132 | |
| 133 if (diffNeedsLayoutAndPaintInvalidation(other)) { | |
| 134 styleDifference.setNeedsFullLayout(); | |
| 135 styleDifference.setNeedsPaintInvalidationObject(); | |
| 136 } else if (diffNeedsPaintInvalidation(other)) { | |
| 137 styleDifference.setNeedsPaintInvalidationObject(); | |
| 138 } | |
| 139 | |
| 140 return styleDifference; | |
| 141 } | |
| 142 | |
| 143 bool SVGLayoutStyle::diffNeedsLayoutAndPaintInvalidation(const SVGLayoutStyle* o
ther) const | |
| 144 { | |
| 145 // If resources change, we need a relayout, as the presence of resources inf
luences the paint invalidation rect. | |
| 146 if (resources != other->resources) | |
| 147 return true; | |
| 148 | |
| 149 // If markers change, we need a relayout, as marker boundaries are cached in
LayoutSVGPath. | |
| 150 if (inheritedResources != other->inheritedResources) | |
| 151 return true; | |
| 152 | |
| 153 // All text related properties influence layout. | |
| 154 if (svg_inherited_flags._textAnchor != other->svg_inherited_flags._textAncho
r | |
| 155 || svg_inherited_flags._writingMode != other->svg_inherited_flags._writi
ngMode | |
| 156 || svg_inherited_flags._glyphOrientationHorizontal != other->svg_inherit
ed_flags._glyphOrientationHorizontal | |
| 157 || svg_inherited_flags._glyphOrientationVertical != other->svg_inherited
_flags._glyphOrientationVertical | |
| 158 || svg_noninherited_flags.f._alignmentBaseline != other->svg_noninherite
d_flags.f._alignmentBaseline | |
| 159 || svg_noninherited_flags.f._dominantBaseline != other->svg_noninherited
_flags.f._dominantBaseline | |
| 160 || svg_noninherited_flags.f._baselineShift != other->svg_noninherited_fl
ags.f._baselineShift) | |
| 161 return true; | |
| 162 | |
| 163 // Text related properties influence layout. | |
| 164 if (misc->baselineShiftValue != other->misc->baselineShiftValue) | |
| 165 return true; | |
| 166 | |
| 167 // These properties affect the cached stroke bounding box rects. | |
| 168 if (svg_inherited_flags._capStyle != other->svg_inherited_flags._capStyle | |
| 169 || svg_inherited_flags._joinStyle != other->svg_inherited_flags._joinSty
le) | |
| 170 return true; | |
| 171 | |
| 172 // vector-effect changes require a re-layout. | |
| 173 if (svg_noninherited_flags.f._vectorEffect != other->svg_noninherited_flags.
f._vectorEffect) | |
| 174 return true; | |
| 175 | |
| 176 // Some stroke properties, requires relayouts, as the cached stroke boundari
es need to be recalculated. | |
| 177 if (stroke.get() != other->stroke.get()) { | |
| 178 if (stroke->width != other->stroke->width | |
| 179 || stroke->paintType != other->stroke->paintType | |
| 180 || stroke->paintColor != other->stroke->paintColor | |
| 181 || stroke->paintUri != other->stroke->paintUri | |
| 182 || stroke->miterLimit != other->stroke->miterLimit | |
| 183 || *stroke->dashArray != *other->stroke->dashArray | |
| 184 || stroke->dashOffset != other->stroke->dashOffset | |
| 185 || stroke->visitedLinkPaintColor != other->stroke->visitedLinkPaintC
olor | |
| 186 || stroke->visitedLinkPaintUri != other->stroke->visitedLinkPaintUri | |
| 187 || stroke->visitedLinkPaintType != other->stroke->visitedLinkPaintTy
pe) | |
| 188 return true; | |
| 189 } | |
| 190 | |
| 191 // The x, y, rx and ry properties require a re-layout. | |
| 192 if (layout.get() != other->layout.get()) { | |
| 193 if (layout->x != other->layout->x | |
| 194 || layout->y != other->layout->y | |
| 195 || layout->r != other->layout->r | |
| 196 || layout->rx != other->layout->rx | |
| 197 || layout->ry != other->layout->ry | |
| 198 || layout->cx != other->layout->cx | |
| 199 || layout->cy != other->layout->cy) | |
| 200 return true; | |
| 201 } | |
| 202 | |
| 203 return false; | |
| 204 } | |
| 205 | |
| 206 bool SVGLayoutStyle::diffNeedsPaintInvalidation(const SVGLayoutStyle* other) con
st | |
| 207 { | |
| 208 if (stroke->opacity != other->stroke->opacity) | |
| 209 return true; | |
| 210 | |
| 211 // Painting related properties only need paint invalidation. | |
| 212 if (misc.get() != other->misc.get()) { | |
| 213 if (misc->floodColor != other->misc->floodColor | |
| 214 || misc->floodOpacity != other->misc->floodOpacity | |
| 215 || misc->lightingColor != other->misc->lightingColor) | |
| 216 return true; | |
| 217 } | |
| 218 | |
| 219 // If fill changes, we just need to issue paint invalidations. Fill boundari
es are not influenced by this, only by the Path, that LayoutSVGPath contains. | |
| 220 if (fill.get() != other->fill.get()) { | |
| 221 if (fill->paintType != other->fill->paintType | |
| 222 || fill->paintColor != other->fill->paintColor | |
| 223 || fill->paintUri != other->fill->paintUri | |
| 224 || fill->opacity != other->fill->opacity) | |
| 225 return true; | |
| 226 } | |
| 227 | |
| 228 // If gradient stops change, we just need to issue paint invalidations. Styl
e updates are already handled through LayoutSVGGradientSTop. | |
| 229 if (stops != other->stops) | |
| 230 return true; | |
| 231 | |
| 232 // Changes of these flags only cause paint invalidations. | |
| 233 if (svg_inherited_flags._colorRendering != other->svg_inherited_flags._color
Rendering | |
| 234 || svg_inherited_flags._shapeRendering != other->svg_inherited_flags._sh
apeRendering | |
| 235 || svg_inherited_flags._clipRule != other->svg_inherited_flags._clipRule | |
| 236 || svg_inherited_flags._fillRule != other->svg_inherited_flags._fillRule | |
| 237 || svg_inherited_flags._colorInterpolation != other->svg_inherited_flags
._colorInterpolation | |
| 238 || svg_inherited_flags._colorInterpolationFilters != other->svg_inherite
d_flags._colorInterpolationFilters | |
| 239 || svg_inherited_flags._paintOrder != other->svg_inherited_flags._paintO
rder) | |
| 240 return true; | |
| 241 | |
| 242 if (svg_noninherited_flags.f.bufferedRendering != other->svg_noninherited_fl
ags.f.bufferedRendering) | |
| 243 return true; | |
| 244 | |
| 245 if (svg_noninherited_flags.f.maskType != other->svg_noninherited_flags.f.mas
kType) | |
| 246 return true; | |
| 247 | |
| 248 return false; | |
| 249 } | |
| 250 | |
| 251 EPaintOrderType SVGLayoutStyle::paintOrderType(unsigned index) const | |
| 252 { | |
| 253 ASSERT(index < ((1 << kPaintOrderBitwidth)-1)); | |
| 254 unsigned pt = (paintOrder() >> (kPaintOrderBitwidth*index)) & ((1u << kPaint
OrderBitwidth) - 1); | |
| 255 return (EPaintOrderType)pt; | |
| 256 } | |
| 257 | |
| 258 } | |
| OLD | NEW |