blob: e539064f8ba52b5b45fdf34d90fa7d2e0a78926a [file] [log] [blame]
Torne (Richard Coles)a854de02013-12-18 16:25:25 +00001/*
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.
5 *
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.
10 *
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.
15 *
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.
20 */
21
22#ifndef CSSToStyleMap_h
23#define CSSToStyleMap_h
24
Torne (Richard Coles)5d92fed2014-06-20 14:52:37 +010025#include "core/CSSPropertyNames.h"
Torne (Richard Coles)d6cdb822014-06-03 10:59:05 +010026#include "core/animation/Timing.h"
27#include "core/animation/css/CSSTransitionData.h"
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000028#include "core/css/resolver/ElementStyleResources.h"
Torne (Richard Coles)d6cdb822014-06-03 10:59:05 +010029#include "core/rendering/style/RenderStyleConstants.h"
Torne (Richard Coles)09380292014-02-21 12:17:33 +000030#include "platform/animation/TimingFunction.h"
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000031#include "wtf/Noncopyable.h"
32
33namespace WebCore {
34
35class FillLayer;
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000036class CSSToLengthConversionData;
37class CSSValue;
38class RenderStyle;
39class StyleImage;
40class StyleResolverState;
41class NinePieceImage;
42class BorderImageLengthBox;
43
44// CSSToStyleMap is a short-lived helper object which
45// given the current StyleResolverState can map
46// CSSValue objects into their RenderStyle equivalents.
47
48class CSSToStyleMap {
Ben Murdoch07a852d2014-03-31 11:51:52 +010049 STACK_ALLOCATED();
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000050 WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
51public:
52 CSSToStyleMap(const StyleResolverState& state, ElementStyleResources& elementStyleResources) : m_state(state), m_elementStyleResources(elementStyleResources) { }
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000053 void mapFillAttachment(CSSPropertyID, FillLayer*, CSSValue*) const;
54 void mapFillClip(CSSPropertyID, FillLayer*, CSSValue*) const;
55 void mapFillComposite(CSSPropertyID, FillLayer*, CSSValue*) const;
56 void mapFillBlendMode(CSSPropertyID, FillLayer*, CSSValue*) const;
57 void mapFillOrigin(CSSPropertyID, FillLayer*, CSSValue*) const;
58 void mapFillImage(CSSPropertyID, FillLayer*, CSSValue*);
59 void mapFillRepeatX(CSSPropertyID, FillLayer*, CSSValue*) const;
60 void mapFillRepeatY(CSSPropertyID, FillLayer*, CSSValue*) const;
61 void mapFillSize(CSSPropertyID, FillLayer*, CSSValue*) const;
62 void mapFillXPosition(CSSPropertyID, FillLayer*, CSSValue*) const;
63 void mapFillYPosition(CSSPropertyID, FillLayer*, CSSValue*) const;
64 void mapFillMaskSourceType(CSSPropertyID, FillLayer*, CSSValue*);
65
Torne (Richard Coles)d6cdb822014-06-03 10:59:05 +010066 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);
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000075
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;
80
81private:
82 const CSSToLengthConversionData& cssToLengthConversionData() const;
Torne (Richard Coles)a854de02013-12-18 16:25:25 +000083
84 PassRefPtr<StyleImage> styleImage(CSSPropertyID, CSSValue*);
85
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;
90};
91
92}
93
94#endif