Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 1 | /* |
| 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) | 5d92fed | 2014-06-20 14:52:37 +0100 | [diff] [blame] | 25 | #include "core/CSSPropertyNames.h" |
Torne (Richard Coles) | d6cdb82 | 2014-06-03 10:59:05 +0100 | [diff] [blame] | 26 | #include "core/animation/Timing.h" |
| 27 | #include "core/animation/css/CSSTransitionData.h" |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 28 | #include "core/css/resolver/ElementStyleResources.h" |
Torne (Richard Coles) | d6cdb82 | 2014-06-03 10:59:05 +0100 | [diff] [blame] | 29 | #include "core/rendering/style/RenderStyleConstants.h" |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 30 | #include "platform/animation/TimingFunction.h" |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 31 | #include "wtf/Noncopyable.h" |
| 32 | |
| 33 | namespace WebCore { |
| 34 | |
| 35 | class FillLayer; |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 36 | class CSSToLengthConversionData; |
| 37 | class CSSValue; |
| 38 | class RenderStyle; |
| 39 | class StyleImage; |
| 40 | class StyleResolverState; |
| 41 | class NinePieceImage; |
| 42 | class 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 | |
| 48 | class CSSToStyleMap { |
Ben Murdoch | 07a852d | 2014-03-31 11:51:52 +0100 | [diff] [blame] | 49 | STACK_ALLOCATED(); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 50 | WTF_MAKE_NONCOPYABLE(CSSToStyleMap); |
| 51 | public: |
| 52 | CSSToStyleMap(const StyleResolverState& state, ElementStyleResources& elementStyleResources) : m_state(state), m_elementStyleResources(elementStyleResources) { } |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 53 | 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) | d6cdb82 | 2014-06-03 10:59:05 +0100 | [diff] [blame] | 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); |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 75 | |
| 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 | |
| 81 | private: |
| 82 | const CSSToLengthConversionData& cssToLengthConversionData() const; |
Torne (Richard Coles) | a854de0 | 2013-12-18 16:25:25 +0000 | [diff] [blame] | 83 | |
| 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 |