WebCore/rendering/RenderSVGResource.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
       
     3  *
       
     4  * This library is free software; you can redistribute it and/or
       
     5  * modify it under the terms of the GNU Library General Public
       
     6  * License as published by the Free Software Foundation; either
       
     7  * version 2 of the License, or (at your option) any later version.
       
     8  *
       
     9  * This library is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12  * Library General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU Library General Public License
       
    15  * along with this library; see the file COPYING.LIB.  If not, write to
       
    16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    17  * Boston, MA 02110-1301, USA.
       
    18  *
       
    19  */
       
    20 
       
    21 #ifndef RenderSVGResource_h
       
    22 #define RenderSVGResource_h
       
    23 
       
    24 #if ENABLE(SVG)
       
    25 #include "SVGDocumentExtensions.h"
       
    26 
       
    27 namespace WebCore {
       
    28 
       
    29 enum RenderSVGResourceType {
       
    30     MaskerResourceType,
       
    31     MarkerResourceType,
       
    32     PatternResourceType,
       
    33     LinearGradientResourceType,
       
    34     RadialGradientResourceType,
       
    35     SolidColorResourceType,
       
    36     FilterResourceType,
       
    37     ClipperResourceType
       
    38 };
       
    39 
       
    40 enum RenderSVGResourceMode {
       
    41     ApplyToDefaultMode = 1 << 0, // used for all resources except gradient/pattern
       
    42     ApplyToFillMode    = 1 << 1,
       
    43     ApplyToStrokeMode  = 1 << 2,
       
    44     ApplyToTextMode    = 1 << 3 // used in combination with ApplyTo{Fill|Stroke}Mode
       
    45 };
       
    46 
       
    47 class Color;
       
    48 class FloatRect;
       
    49 class GraphicsContext;
       
    50 class RenderObject;
       
    51 class RenderStyle;
       
    52 class RenderSVGResourceSolidColor;
       
    53 
       
    54 class RenderSVGResource {
       
    55 public:
       
    56     RenderSVGResource() { }
       
    57     virtual ~RenderSVGResource() { }
       
    58 
       
    59     virtual void invalidateClients() = 0;
       
    60     virtual void invalidateClient(RenderObject*) = 0;
       
    61 
       
    62     virtual bool applyResource(RenderObject*, RenderStyle*, GraphicsContext*&, unsigned short resourceMode) = 0;
       
    63     virtual void postApplyResource(RenderObject*, GraphicsContext*&, unsigned short) { }
       
    64     virtual FloatRect resourceBoundingBox(RenderObject*) = 0;
       
    65 
       
    66     virtual RenderSVGResourceType resourceType() const = 0;
       
    67 
       
    68     template<class Renderer>
       
    69     Renderer* cast()
       
    70     {
       
    71         if (Renderer::s_resourceType == resourceType())
       
    72             return static_cast<Renderer*>(this);
       
    73 
       
    74         return 0;
       
    75     }
       
    76 
       
    77     // Helper utilities used in the render tree to access resources used for painting shapes/text (gradients & patterns only)
       
    78     static RenderSVGResource* fillPaintingResource(const RenderObject*, const RenderStyle*);
       
    79     static RenderSVGResource* strokePaintingResource(const RenderObject*, const RenderStyle*);
       
    80     static RenderSVGResourceSolidColor* sharedSolidPaintingResource();
       
    81 
       
    82     static void invalidateAllResourcesOfRenderer(RenderObject*);
       
    83     static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool needsLayout = true);
       
    84 
       
    85 private:
       
    86     static void adjustColorForPseudoRules(const RenderStyle*, bool useFillPaint, Color&);
       
    87     
       
    88 protected:
       
    89     void markForLayoutAndResourceInvalidation(RenderObject*, bool needsBoundariesUpdate = true);
       
    90 };
       
    91 
       
    92 }
       
    93 
       
    94 #endif
       
    95 #endif