| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 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 | 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, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | |
| 20 #ifndef SVGViewSpec_h | 19 #ifndef SVGViewSpec_h |
| 21 #define SVGViewSpec_h | 20 #define SVGViewSpec_h |
| 22 | 21 |
| 23 #include "bindings/core/v8/ScriptWrappable.h" | |
| 24 #include "core/svg/SVGFitToViewBox.h" | 22 #include "core/svg/SVGFitToViewBox.h" |
| 25 #include "core/svg/SVGSVGElement.h" | 23 #include "core/svg/SVGSVGElement.h" |
| 26 #include "core/svg/SVGZoomAndPan.h" | 24 #include "core/svg/SVGZoomAndPan.h" |
| 27 #include "platform/heap/Handle.h" | |
| 28 | 25 |
| 29 namespace blink { | 26 namespace blink { |
| 30 | 27 |
| 31 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, public
ScriptWrappable, public SVGZoomAndPan, public SVGFitToViewBox { | 28 class SVGViewSpec final : public GarbageCollectedFinalized<SVGViewSpec>, public
SVGZoomAndPan, public SVGFitToViewBox { |
| 32 DEFINE_WRAPPERTYPEINFO(); | |
| 33 USING_GARBAGE_COLLECTED_MIXIN(SVGViewSpec); | 29 USING_GARBAGE_COLLECTED_MIXIN(SVGViewSpec); |
| 34 public: | 30 public: |
| 35 static SVGViewSpec* create(SVGSVGElement* contextElement) | 31 static SVGViewSpec* create(SVGSVGElement* contextElement) |
| 36 { | 32 { |
| 37 return new SVGViewSpec(contextElement); | 33 return new SVGViewSpec(contextElement); |
| 38 } | 34 } |
| 39 | 35 |
| 40 bool parseViewSpec(const String&); | |
| 41 void reset(); | 36 void reset(); |
| 42 void detachContextElement(); | |
| 43 template<typename T> void inheritViewAttributesFromElement(T*); | 37 template<typename T> void inheritViewAttributesFromElement(T*); |
| 44 | |
| 45 // JS API | |
| 46 SVGTransformList* transform() { return m_transform ? m_transform->baseValue(
) : 0; } | |
| 47 SVGTransformListTearOff* transformFromJavascript() { return m_transform ? m_
transform->baseVal() : 0; } | |
| 48 SVGElement* viewTarget() const; | |
| 49 String viewBoxString() const; | |
| 50 String preserveAspectRatioString() const; | |
| 51 String transformString() const; | |
| 52 String viewTargetString() const { return m_viewTargetString; } | |
| 53 // override SVGZoomAndPan.setZoomAndPan so can throw exception on write | |
| 54 void setZoomAndPan(unsigned short value) { } // read only | 38 void setZoomAndPan(unsigned short value) { } // read only |
| 55 void setZoomAndPan(unsigned short value, ExceptionState&); | 39 void setZoomAndPan(unsigned short value, ExceptionState&); |
| 56 | 40 |
| 57 DECLARE_VIRTUAL_TRACE(); | 41 DECLARE_VIRTUAL_TRACE(); |
| 58 | 42 |
| 59 DECLARE_VIRTUAL_TRACE_WRAPPERS(); | 43 DECLARE_VIRTUAL_TRACE_WRAPPERS(); |
| 60 | 44 |
| 61 SVGSVGElement* contextElement() { return m_contextElement.get(); } | |
| 62 | |
| 63 private: | 45 private: |
| 64 explicit SVGViewSpec(SVGSVGElement*); | 46 explicit SVGViewSpec(SVGSVGElement*); |
| 65 | |
| 66 template<typename CharType> | |
| 67 bool parseViewSpecInternal(const CharType* ptr, const CharType* end); | |
| 68 | |
| 69 Member<SVGSVGElement> m_contextElement; | 47 Member<SVGSVGElement> m_contextElement; |
| 70 Member<SVGAnimatedTransformList> m_transform; | |
| 71 String m_viewTargetString; | |
| 72 }; | 48 }; |
| 73 | 49 |
| 74 template <typename T> | 50 template <typename T> |
| 75 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement) | 51 void SVGViewSpec::inheritViewAttributesFromElement(T* inheritFromElement) |
| 76 { | 52 { |
| 77 if (!inheritFromElement->hasEmptyViewBox()) | 53 if (!inheritFromElement->hasEmptyViewBox()) |
| 78 viewBox()->baseValue()->setValue(inheritFromElement->viewBox()->currentV
alue()->value()); | 54 viewBox()->baseValue()->setValue(inheritFromElement->viewBox()->currentV
alue()->value()); |
| 79 | 55 |
| 80 if (inheritFromElement->preserveAspectRatio()->isSpecified()) { | 56 if (inheritFromElement->preserveAspectRatio()->isSpecified()) { |
| 81 preserveAspectRatio()->baseValue()->setAlign(inheritFromElement->preserv
eAspectRatio()->currentValue()->align()); | 57 preserveAspectRatio()->baseValue()->setAlign(inheritFromElement->preserv
eAspectRatio()->currentValue()->align()); |
| 82 preserveAspectRatio()->baseValue()->setMeetOrSlice(inheritFromElement->p
reserveAspectRatio()->currentValue()->meetOrSlice()); | 58 preserveAspectRatio()->baseValue()->setMeetOrSlice(inheritFromElement->p
reserveAspectRatio()->currentValue()->meetOrSlice()); |
| 83 } | 59 } |
| 84 | 60 |
| 85 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr)) | 61 if (inheritFromElement->hasAttribute(SVGNames::zoomAndPanAttr)) |
| 86 setZoomAndPan(inheritFromElement->zoomAndPan()); | 62 setZoomAndPan(inheritFromElement->zoomAndPan()); |
| 87 } | 63 } |
| 88 | 64 |
| 89 } // namespace blink | 65 } // namespace blink |
| 90 | 66 |
| 91 #endif // SVGViewSpec_h | 67 #endif // SVGViewSpec_h |
| OLD | NEW |