Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2007 Rob Buis <buis (at) kde.org>
      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 #ifndef SVGViewSpec_h
     21 #define SVGViewSpec_h
     22 
     23 #include "bindings/v8/ScriptWrappable.h"
     24 #include "core/svg/SVGFitToViewBox.h"
     25 #include "core/svg/SVGSVGElement.h"
     26 #include "core/svg/SVGZoomAndPan.h"
     27 #include "platform/heap/Handle.h"
     28 #include "wtf/WeakPtr.h"
     29 
     30 namespace WebCore {
     31 
     32 class SVGViewSpec FINAL : public RefCountedWillBeGarbageCollectedFinalized<SVGViewSpec>, public ScriptWrappable, public SVGZoomAndPan, public SVGFitToViewBox {
     33 public:
     34 #if !ENABLE(OILPAN)
     35     using RefCounted<SVGViewSpec>::ref;
     36     using RefCounted<SVGViewSpec>::deref;
     37 #endif
     38 
     39     static PassRefPtrWillBeRawPtr<SVGViewSpec> create(SVGSVGElement* contextElement)
     40     {
     41         return adoptRefWillBeNoop(new SVGViewSpec(contextElement));
     42     }
     43 
     44     bool parseViewSpec(const String&);
     45     void reset();
     46     void detachContextElement();
     47 
     48     // JS API
     49     SVGTransformList* transform() { return m_transform ? m_transform->baseValue() : 0; }
     50     PassRefPtr<SVGTransformListTearOff> transformFromJavascript() { return m_transform ? m_transform->baseVal() : 0; }
     51     SVGElement* viewTarget() const;
     52     String viewBoxString() const;
     53     String preserveAspectRatioString() const;
     54     String transformString() const;
     55     String viewTargetString() const { return m_viewTargetString; }
     56     // override SVGZoomAndPan.setZoomAndPan so can throw exception on write
     57     void setZoomAndPan(unsigned short value) { } // read only
     58     void setZoomAndPan(unsigned short value, ExceptionState&);
     59 
     60     void trace(Visitor*);
     61 
     62     SVGSVGElement* contextElement() { return m_contextElement.get(); }
     63 
     64 private:
     65     explicit SVGViewSpec(SVGSVGElement*);
     66 
     67     template<typename CharType>
     68     bool parseViewSpecInternal(const CharType* ptr, const CharType* end);
     69 
     70     RawPtrWillBeMember<SVGSVGElement> m_contextElement;
     71     RefPtr<SVGAnimatedTransformList> m_transform;
     72     String m_viewTargetString;
     73 };
     74 
     75 } // namespace WebCore
     76 
     77 #endif
     78