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