Home | History | Annotate | Download | only in resolver
      1 /*
      2  * Copyright (C) 1999 Lars Knoll (knoll (at) 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 
     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"
     32 
     33 namespace blink {
     34 
     35 class FillLayer;
     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 {
     49     STACK_ALLOCATED();
     50     WTF_MAKE_NONCOPYABLE(CSSToStyleMap);
     51 public:
     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;
     65 
     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);
     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;
     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
     95