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 "StyleRareNonInheritedData.h" 24 25 #include "CSSStyleSelector.h" 26 #include "ContentData.h" 27 #include "RenderCounter.h" 28 #include "RenderStyle.h" 29 #include "ShadowData.h" 30 #include "StyleImage.h" 31 32 namespace WebCore { 33 34 StyleRareNonInheritedData::StyleRareNonInheritedData() 35 : lineClamp(RenderStyle::initialLineClamp()) 36 , opacity(RenderStyle::initialOpacity()) 37 , m_content(0) 38 , m_counterDirectives(0) 39 , userDrag(RenderStyle::initialUserDrag()) 40 , textOverflow(RenderStyle::initialTextOverflow()) 41 , marginBeforeCollapse(MCOLLAPSE) 42 , marginAfterCollapse(MCOLLAPSE) 43 , matchNearestMailBlockquoteColor(RenderStyle::initialMatchNearestMailBlockquoteColor()) 44 , m_appearance(RenderStyle::initialAppearance()) 45 , m_borderFit(RenderStyle::initialBorderFit()) 46 , m_textCombine(RenderStyle::initialTextCombine()) 47 , m_counterIncrement(0) 48 , m_counterReset(0) 49 #if USE(ACCELERATED_COMPOSITING) 50 , m_runningAcceleratedAnimation(false) 51 #endif 52 , m_boxShadow(0) 53 , m_animations(0) 54 , m_transitions(0) 55 , m_mask(FillLayer(MaskFillLayer)) 56 , m_transformStyle3D(RenderStyle::initialTransformStyle3D()) 57 , m_backfaceVisibility(RenderStyle::initialBackfaceVisibility()) 58 , m_perspective(RenderStyle::initialPerspective()) 59 , m_perspectiveOriginX(RenderStyle::initialPerspectiveOriginX()) 60 , m_perspectiveOriginY(RenderStyle::initialPerspectiveOriginY()) 61 , m_pageSize() 62 , m_pageSizeType(PAGE_SIZE_AUTO) 63 { 64 } 65 66 StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonInheritedData& o) 67 : RefCounted<StyleRareNonInheritedData>() 68 , lineClamp(o.lineClamp) 69 , opacity(o.opacity) 70 , flexibleBox(o.flexibleBox) 71 , marquee(o.marquee) 72 , m_multiCol(o.m_multiCol) 73 , m_transform(o.m_transform) 74 , m_content(0) 75 , m_counterDirectives(0) 76 , userDrag(o.userDrag) 77 , textOverflow(o.textOverflow) 78 , marginBeforeCollapse(o.marginBeforeCollapse) 79 , marginAfterCollapse(o.marginAfterCollapse) 80 , matchNearestMailBlockquoteColor(o.matchNearestMailBlockquoteColor) 81 , m_appearance(o.m_appearance) 82 , m_borderFit(o.m_borderFit) 83 , m_textCombine(o.m_textCombine) 84 , m_counterIncrement(o.m_counterIncrement) 85 , m_counterReset(o.m_counterReset) 86 #if USE(ACCELERATED_COMPOSITING) 87 , m_runningAcceleratedAnimation(o.m_runningAcceleratedAnimation) 88 #endif 89 , m_boxShadow(o.m_boxShadow ? new ShadowData(*o.m_boxShadow) : 0) 90 , m_boxReflect(o.m_boxReflect) 91 , m_animations(o.m_animations ? new AnimationList(*o.m_animations) : 0) 92 , m_transitions(o.m_transitions ? new AnimationList(*o.m_transitions) : 0) 93 , m_mask(o.m_mask) 94 , m_maskBoxImage(o.m_maskBoxImage) 95 , m_transformStyle3D(o.m_transformStyle3D) 96 , m_backfaceVisibility(o.m_backfaceVisibility) 97 , m_perspective(o.m_perspective) 98 , m_perspectiveOriginX(o.m_perspectiveOriginX) 99 , m_perspectiveOriginY(o.m_perspectiveOriginY) 100 , m_pageSize(o.m_pageSize) 101 , m_pageSizeType(o.m_pageSizeType) 102 { 103 } 104 105 StyleRareNonInheritedData::~StyleRareNonInheritedData() 106 { 107 } 108 109 bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) const 110 { 111 return lineClamp == o.lineClamp 112 #if ENABLE(DASHBOARD_SUPPORT) 113 && m_dashboardRegions == o.m_dashboardRegions 114 #endif 115 && opacity == o.opacity 116 && flexibleBox == o.flexibleBox 117 && marquee == o.marquee 118 && m_multiCol == o.m_multiCol 119 && m_transform == o.m_transform 120 && contentDataEquivalent(o) 121 && m_counterDirectives == o.m_counterDirectives 122 && userDrag == o.userDrag 123 && textOverflow == o.textOverflow 124 && marginBeforeCollapse == o.marginBeforeCollapse 125 && marginAfterCollapse == o.marginAfterCollapse 126 && matchNearestMailBlockquoteColor == o.matchNearestMailBlockquoteColor 127 && m_appearance == o.m_appearance 128 && m_borderFit == o.m_borderFit 129 && m_textCombine == o.m_textCombine 130 && m_counterIncrement == o.m_counterIncrement 131 && m_counterReset == o.m_counterReset 132 #if USE(ACCELERATED_COMPOSITING) 133 && !m_runningAcceleratedAnimation && !o.m_runningAcceleratedAnimation 134 #endif 135 && shadowDataEquivalent(o) 136 && reflectionDataEquivalent(o) 137 && animationDataEquivalent(o) 138 && transitionDataEquivalent(o) 139 && m_mask == o.m_mask 140 && m_maskBoxImage == o.m_maskBoxImage 141 && (m_transformStyle3D == o.m_transformStyle3D) 142 && (m_backfaceVisibility == o.m_backfaceVisibility) 143 && (m_perspective == o.m_perspective) 144 && (m_perspectiveOriginX == o.m_perspectiveOriginX) 145 && (m_perspectiveOriginY == o.m_perspectiveOriginY) 146 && (m_pageSize == o.m_pageSize) 147 && (m_pageSizeType == o.m_pageSizeType) 148 ; 149 } 150 151 bool StyleRareNonInheritedData::contentDataEquivalent(const StyleRareNonInheritedData& o) const 152 { 153 ContentData* c1 = m_content.get(); 154 ContentData* c2 = o.m_content.get(); 155 156 while (c1 && c2) { 157 if (!c1->dataEquivalent(*c2)) 158 return false; 159 c1 = c1->next(); 160 c2 = c2->next(); 161 } 162 163 return !c1 && !c2; 164 } 165 166 bool StyleRareNonInheritedData::shadowDataEquivalent(const StyleRareNonInheritedData& o) const 167 { 168 if ((!m_boxShadow && o.m_boxShadow) || (m_boxShadow && !o.m_boxShadow)) 169 return false; 170 if (m_boxShadow && o.m_boxShadow && (*m_boxShadow != *o.m_boxShadow)) 171 return false; 172 return true; 173 } 174 175 bool StyleRareNonInheritedData::reflectionDataEquivalent(const StyleRareNonInheritedData& o) const 176 { 177 if (m_boxReflect != o.m_boxReflect) { 178 if (!m_boxReflect || !o.m_boxReflect) 179 return false; 180 return *m_boxReflect == *o.m_boxReflect; 181 } 182 return true; 183 184 } 185 186 bool StyleRareNonInheritedData::animationDataEquivalent(const StyleRareNonInheritedData& o) const 187 { 188 if ((!m_animations && o.m_animations) || (m_animations && !o.m_animations)) 189 return false; 190 if (m_animations && o.m_animations && (*m_animations != *o.m_animations)) 191 return false; 192 return true; 193 } 194 195 bool StyleRareNonInheritedData::transitionDataEquivalent(const StyleRareNonInheritedData& o) const 196 { 197 if ((!m_transitions && o.m_transitions) || (m_transitions && !o.m_transitions)) 198 return false; 199 if (m_transitions && o.m_transitions && (*m_transitions != *o.m_transitions)) 200 return false; 201 return true; 202 } 203 204 } // namespace WebCore 205