2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
4 * Copyright (C) 2012 Google Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef CSSToStyleMap_h
23 #define CSSToStyleMap_h
25 #include "core/CSSPropertyNames.h"
26 #include "core/animation/Timing.h"
27 #include "core/animation/css/CSSTransitionData.h"
28 #include "core/css/resolver/ElementStyleResources.h"
29 #include "core/rendering/style/RenderStyleConstants.h"
30 #include "platform/animation/TimingFunction.h"
31 #include "wtf/Noncopyable.h"
36 class CSSToLengthConversionData;
40 class StyleResolverState;
42 class BorderImageLengthBox;
44 // CSSToStyleMap is a short-lived helper object which
45 // given the current StyleResolverState can map
46 // CSSValue objects into their RenderStyle equivalents.
50 WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
52 CSSToStyleMap(const StyleResolverState& state, ElementStyleResources& elementStyleResources) : m_state(state), m_elementStyleResources(elementStyleResources) { }
53 void mapFillAttachment(FillLayer*, CSSValue*) const;
54 void mapFillClip(FillLayer*, CSSValue*) const;
55 void mapFillComposite(FillLayer*, CSSValue*) const;
56 void mapFillBlendMode(FillLayer*, CSSValue*) const;
57 void mapFillOrigin(FillLayer*, CSSValue*) const;
58 void mapFillImage(FillLayer*, CSSValue*);
59 void mapFillRepeatX(FillLayer*, CSSValue*) const;
60 void mapFillRepeatY(FillLayer*, CSSValue*) const;
61 void mapFillSize(FillLayer*, CSSValue*) const;
62 void mapFillXPosition(FillLayer*, CSSValue*) const;
63 void mapFillYPosition(FillLayer*, CSSValue*) const;
64 void mapFillMaskSourceType(FillLayer*, CSSValue*) const;
66 static double mapAnimationDelay(CSSValue*);
67 static Timing::PlaybackDirection mapAnimationDirection(CSSValue*);
68 static double mapAnimationDuration(CSSValue*);
69 static Timing::FillMode mapAnimationFillMode(CSSValue*);
70 static double mapAnimationIterationCount(CSSValue*);
71 static AtomicString mapAnimationName(CSSValue*);
72 static EAnimPlayState mapAnimationPlayState(CSSValue*);
73 static CSSTransitionData::TransitionProperty mapAnimationProperty(CSSValue*);
74 static PassRefPtr<TimingFunction> mapAnimationTimingFunction(CSSValue*, bool allowStepMiddle = false);
76 void mapNinePieceImage(RenderStyle* mutableStyle, CSSPropertyID, CSSValue*, NinePieceImage&);
77 void mapNinePieceImageSlice(CSSValue*, NinePieceImage&) const;
78 BorderImageLengthBox mapNinePieceImageQuad(CSSValue*) const;
79 void mapNinePieceImageRepeat(CSSValue*, NinePieceImage&) const;
82 const CSSToLengthConversionData& cssToLengthConversionData() const;
84 PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*);
86 // FIXME: Consider passing a StyleResolverState (or ElementResolveState)
87 // as an argument instead of caching it on this object.
88 const StyleResolverState& m_state;
89 ElementStyleResources& m_elementStyleResources;