1 /* 2 * Copyright (C) 1999 Antti Koivisto (koivisto (at) kde.org) 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 4 * 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. 9 * 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. 14 * 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. 19 * 20 */ 21 22 #include "config.h" 23 #include "core/rendering/style/StyleRareNonInheritedData.h" 24 25 #include "core/rendering/style/ContentData.h" 26 #include "core/rendering/style/RenderStyle.h" 27 #include "core/rendering/style/ShadowData.h" 28 #include "core/rendering/style/StyleFilterData.h" 29 #include "core/rendering/style/StyleTransformData.h" 30 31 namespace WebCore { 32 33 StyleRareNonInheritedData::StyleRareNonInheritedData() 34 : opacity(RenderStyle::initialOpacity()) 35 , m_aspectRatioDenominator(RenderStyle::initialAspectRatioDenominator()) 36 , m_aspectRatioNumerator(RenderStyle::initialAspectRatioNumerator()) 37 , m_perspective(RenderStyle::initialPerspective()) 38 , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX()) 39 , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY()) 40 , lineClamp(RenderStyle::initialLineClamp()) 41 , m_draggableRegionMode(DraggableRegionNone) 42 , m_mask(FillLayer(MaskFillLayer)) 43 , m_pageSize() 44 , m_shapeInside(RenderStyle::initialShapeInside()) 45 , m_shapeOutside(RenderStyle::initialShapeOutside()) 46 , m_shapeMargin(RenderStyle::initialShapeMargin()) 47 , m_shapePadding(RenderStyle::initialShapePadding()) 48 , m_clipPath(RenderStyle::initialClipPath()) 49 , m_visitedLinkBackgroundColor(RenderStyle::initialBackgroundColor()) 50 , m_order(RenderStyle::initialOrder()) 51 , m_flowThread(RenderStyle::initialFlowThread()) 52 , m_regionThread(RenderStyle::initialRegionThread()) 53 , m_regionFragment(RenderStyle::initialRegionFragment()) 54 , m_regionBreakAfter(RenderStyle::initialPageBreak()) 55 , m_regionBreakBefore(RenderStyle::initialPageBreak()) 56 , m_regionBreakInside(RenderStyle::initialPageBreak()) 57 , m_pageSizeType(PAGE_SIZE_AUTO) 58 , m_transformStyle3D(RenderStyle::initialTransformStyle3D()) 59 , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility()) 60 , m_alignContent(RenderStyle::initialAlignContent()) 61 , m_alignItems(RenderStyle::initialAlignItems()) 62 , m_alignSelf(RenderStyle::initialAlignSelf()) 63 , m_justifyContent(RenderStyle::initialJustifyContent()) 64 , userDrag(RenderStyle::initialUserDrag()) 65 , textOverflow(RenderStyle::initialTextOverflow()) 66 , marginBeforeCollapse(MCOLLAPSE) 67 , marginAfterCollapse(MCOLLAPSE) 68 , m_appearance(RenderStyle::initialAppearance()) 69 , m_borderFit(RenderStyle::initialBorderFit()) 70 , m_textCombine(RenderStyle::initialTextCombine()) 71 , m_textDecorationStyle(RenderStyle::initialTextDecorationStyle()) 72 , m_wrapFlow(RenderStyle::initialWrapFlow()) 73 , m_wrapThrough(RenderStyle::initialWrapThrough()) 74 , m_runningAcceleratedAnimation(false) 75 , m_hasAspectRatio(false) 76 , m_effectiveBlendMode(RenderStyle::initialBlendMode()) 77 , m_touchAction(RenderStyle::initialTouchAction()) 78 { 79 m_maskBoxImage.setMaskDefaults(); 80 } 81 82 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o) 83 : RefCounted<StyleRareNonInheritedData>() 84 , opacity(o.opacity) 85 , m_aspectRatioDenominator(o.m_aspectRatioDenominator) 86 , m_aspectRatioNumerator(o.m_aspectRatioNumerator) 87 , m_perspective(o.m_perspective) 88 , m_perspectiveOriginX(o.m_perspectiveOriginX) 89 , m_perspectiveOriginY(o.m_perspectiveOriginY) 90 , lineClamp(o.lineClamp) 91 , m_draggableRegionMode(o.m_draggableRegionMode) 92 , m_deprecatedFlexibleBox(o.m_deprecatedFlexibleBox) 93 , m_flexibleBox(o.m_flexibleBox) 94 , m_marquee(o.m_marquee) 95 , m_multiCol(o.m_multiCol) 96 , m_transform(o.m_transform) 97 , m_filter(o.m_filter) 98 , m_grid(o.m_grid) 99 , m_gridItem(o.m_gridItem) 100 , m_content(o.m_content ? o.m_content->clone() : nullptr) 101 , m_counterDirectives(o.m_counterDirectives ? clone(*o.m_counterDirectives) : nullptr) 102 , m_boxShadow(cloneShadow(o.m_boxShadow)) 103 , m_boxReflect(o.m_boxReflect) 104 , m_animations(o.m_animations ? adoptPtr(new CSSAnimationDataList(*o.m_animations)) : nullptr) 105 , m_transitions(o.m_transitions ? adoptPtr(new CSSAnimationDataList(*o.m_transitions)) : nullptr) 106 , m_mask(o.m_mask) 107 , m_maskBoxImage(o.m_maskBoxImage) 108 , m_pageSize(o.m_pageSize) 109 , m_shapeInside(o.m_shapeInside) 110 , m_shapeOutside(o.m_shapeOutside) 111 , m_shapeMargin(o.m_shapeMargin) 112 , m_shapePadding(o.m_shapePadding) 113 , m_clipPath(o.m_clipPath) 114 , m_textDecorationColor(o.m_textDecorationColor) 115 , m_visitedLinkTextDecorationColor(o.m_visitedLinkTextDecorationColor) 116 , m_visitedLinkBackgroundColor(o.m_visitedLinkBackgroundColor) 117 , m_visitedLinkOutlineColor(o.m_visitedLinkOutlineColor) 118 , m_visitedLinkBorderLeftColor(o.m_visitedLinkBorderLeftColor) 119 , m_visitedLinkBorderRightColor(o.m_visitedLinkBorderRightColor) 120 , m_visitedLinkBorderTopColor(o.m_visitedLinkBorderTopColor) 121 , m_visitedLinkBorderBottomColor(o.m_visitedLinkBorderBottomColor) 122 , m_order(o.m_order) 123 , m_flowThread(o.m_flowThread) 124 , m_regionThread(o.m_regionThread) 125 , m_regionFragment(o.m_regionFragment) 126 , m_regionBreakAfter(o.m_regionBreakAfter) 127 , m_regionBreakBefore(o.m_regionBreakBefore) 128 , m_regionBreakInside(o.m_regionBreakInside) 129 , m_pageSizeType(o.m_pageSizeType) 130 , m_transformStyle3D(o.m_transformStyle3D) 131 , m_backfaceVisibility(o.m_backfaceVisibility) 132 , m_alignContent(o.m_alignContent) 133 , m_alignItems(o.m_alignItems) 134 , m_alignSelf(o.m_alignSelf) 135 , m_justifyContent(o.m_justifyContent) 136 , userDrag(o.userDrag) 137 , textOverflow(o.textOverflow) 138 , marginBeforeCollapse(o.marginBeforeCollapse) 139 , marginAfterCollapse(o.marginAfterCollapse) 140 , m_appearance(o.m_appearance) 141 , m_borderFit(o.m_borderFit) 142 , m_textCombine(o.m_textCombine) 143 , m_textDecorationStyle(o.m_textDecorationStyle) 144 , m_wrapFlow(o.m_wrapFlow) 145 , m_wrapThrough(o.m_wrapThrough) 146 , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation) 147 , m_hasAspectRatio(o.m_hasAspectRatio) 148 , m_effectiveBlendMode(o.m_effectiveBlendMode) 149 , m_touchAction(o.m_touchAction) 150 { 151 } 152 153 StyleRareNonInheritedData::~StyleRareNonInheritedData() 154 { 155 } 156 157 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const 158 { 159 return opacity == o.opacity 160 && m_aspectRatioDenominator == o.m_aspectRatioDenominator 161 && m_aspectRatioNumerator == o.m_aspectRatioNumerator 162 && m_perspective == o.m_perspective 163 && m_perspectiveOriginX == o.m_perspectiveOriginX 164 && m_perspectiveOriginY == o.m_perspectiveOriginY 165 && lineClamp == o.lineClamp 166 && m_draggableRegionMode == o.m_draggableRegionMode 167 && m_deprecatedFlexibleBox == o.m_deprecatedFlexibleBox 168 && m_flexibleBox == o.m_flexibleBox 169 && m_marquee == o.m_marquee 170 && m_multiCol == o.m_multiCol 171 && m_transform == o.m_transform 172 && m_filter == o.m_filter 173 && m_grid == o.m_grid 174 && m_gridItem == o.m_gridItem 175 && contentDataEquivalent(o) 176 && counterDataEquivalent(o) 177 && shadowDataEquivalent(o) 178 && reflectionDataEquivalent(o) 179 && animationDataEquivalent(o) 180 && transitionDataEquivalent(o) 181 && m_mask == o.m_mask 182 && m_maskBoxImage == o.m_maskBoxImage 183 && m_pageSize == o.m_pageSize 184 && m_shapeInside == o.m_shapeInside 185 && m_shapeOutside == o.m_shapeOutside 186 && m_shapeMargin == o.m_shapeMargin 187 && m_shapePadding == o.m_shapePadding 188 && m_clipPath == o.m_clipPath 189 && m_textDecorationColor == o.m_textDecorationColor 190 && m_visitedLinkTextDecorationColor == o.m_visitedLinkTextDecorationColor 191 && m_visitedLinkBackgroundColor == o.m_visitedLinkBackgroundColor 192 && m_visitedLinkOutlineColor == o.m_visitedLinkOutlineColor 193 && m_visitedLinkBorderLeftColor == o.m_visitedLinkBorderLeftColor 194 && m_visitedLinkBorderRightColor == o.m_visitedLinkBorderRightColor 195 && m_visitedLinkBorderTopColor == o.m_visitedLinkBorderTopColor 196 && m_visitedLinkBorderBottomColor == o.m_visitedLinkBorderBottomColor 197 && m_order == o.m_order 198 && m_flowThread == o.m_flowThread 199 && m_regionThread == o.m_regionThread 200 && m_regionFragment == o.m_regionFragment 201 && m_regionBreakAfter == o.m_regionBreakAfter 202 && m_regionBreakBefore == o.m_regionBreakBefore 203 && m_regionBreakInside == o.m_regionBreakInside 204 && m_pageSizeType == o.m_pageSizeType 205 && m_transformStyle3D == o.m_transformStyle3D 206 && m_backfaceVisibility == o.m_backfaceVisibility 207 && m_alignContent == o.m_alignContent 208 && m_alignItems == o.m_alignItems 209 && m_alignSelf == o.m_alignSelf 210 && m_justifyContent == o.m_justifyContent 211 && userDrag == o.userDrag 212 && textOverflow == o.textOverflow 213 && marginBeforeCollapse == o.marginBeforeCollapse 214 && marginAfterCollapse == o.marginAfterCollapse 215 && m_appearance == o.m_appearance 216 && m_borderFit == o.m_borderFit 217 && m_textCombine == o.m_textCombine 218 && m_textDecorationStyle == o.m_textDecorationStyle 219 && m_wrapFlow == o.m_wrapFlow 220 && m_wrapThrough == o.m_wrapThrough 221 && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation 222 && m_effectiveBlendMode == o.m_effectiveBlendMode 223 && m_hasAspectRatio == o.m_hasAspectRatio 224 && m_touchAction == o.m_touchAction; 225 } 226 227 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const 228 { 229 ContentData* a = m_content.get(); 230 ContentData* b = o.m_content.get(); 231 232 while (a && b && *a == *b) { 233 a = a->next(); 234 b = b->next(); 235 } 236 237 return !a && !b; 238 } 239 240 bool StyleRareNonInheritedData::counterDataEquivalent(const StyleRareNonInheritedData& o) const 241 { 242 if (m_counterDirectives.get() == o.m_counterDirectives.get()) 243 return true; 244 245 if (m_counterDirectives && o.m_counterDirectives && *m_counterDirectives == *o.m_counterDirectives) 246 return true; 247 248 return false; 249 } 250 251 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const 252 { 253 if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow)) 254 return false; 255 if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow)) 256 return false; 257 return true; 258 } 259 260 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const 261 { 262 if (m_boxReflect != o.m_boxReflect) { 263 if (!m_boxReflect || !o.m_boxReflect) 264 return false; 265 return *m_boxReflect == *o.m_boxReflect; 266 } 267 return true; 268 } 269 270 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const 271 { 272 if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations)) 273 return false; 274 if (m_animations && o.m_animations && (*m_animations != *o.m_animations)) 275 return false; 276 return true; 277 } 278 279 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const 280 { 281 if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions)) 282 return false; 283 if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions)) 284 return false; 285 return true; 286 } 287 288 } // namespace WebCore 289