Home | History | Annotate | Download | only in svg
      1 /*
      2  * Copyright (C) 2014 Google Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are
      6  * met:
      7  *
      8  *     * Redistributions of source code must retain the above copyright
      9  * notice, this list of conditions and the following disclaimer.
     10  *     * Redistributions in binary form must reproduce the above
     11  * copyright notice, this list of conditions and the following disclaimer
     12  * in the documentation and/or other materials provided with the
     13  * distribution.
     14  *     * Neither the name of Google Inc. nor the names of its
     15  * contributors may be used to endorse or promote products derived from
     16  * this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #include "config.h"
     32 #include "core/svg/SVGTransformTearOff.h"
     33 
     34 #include "bindings/v8/ExceptionState.h"
     35 #include "core/dom/ExceptionCode.h"
     36 
     37 namespace WebCore {
     38 
     39 SVGTransformTearOff::SVGTransformTearOff(PassRefPtr<SVGTransform> target, SVGElement* contextElement, PropertyIsAnimValType propertyIsAnimVal, const QualifiedName& attributeName)
     40     : SVGPropertyTearOff<SVGTransform>(target, contextElement, propertyIsAnimVal, attributeName)
     41 {
     42     ScriptWrappable::init(this);
     43 }
     44 
     45 SVGTransformTearOff::~SVGTransformTearOff()
     46 {
     47 }
     48 
     49 SVGMatrixTearOff* SVGTransformTearOff::matrix()
     50 {
     51     if (!m_matrixTearoff) {
     52         m_matrixTearoff = SVGMatrixTearOff::create(this);
     53     }
     54 
     55     return m_matrixTearoff.get();
     56 }
     57 
     58 void SVGTransformTearOff::setMatrix(PassRefPtr<SVGMatrixTearOff> matrix, ExceptionState& exceptionState)
     59 {
     60     if (isImmutable()) {
     61         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
     62         return;
     63     }
     64 
     65     target()->setMatrix(matrix->value());
     66     commitChange();
     67 }
     68 
     69 void SVGTransformTearOff::setTranslate(float tx, float ty, ExceptionState& exceptionState)
     70 {
     71     if (isImmutable()) {
     72         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
     73         return;
     74     }
     75 
     76     target()->setTranslate(tx, ty);
     77     commitChange();
     78 }
     79 
     80 void SVGTransformTearOff::setScale(float sx, float sy, ExceptionState& exceptionState)
     81 {
     82     if (isImmutable()) {
     83         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
     84         return;
     85     }
     86 
     87     target()->setScale(sx, sy);
     88     commitChange();
     89 }
     90 
     91 void SVGTransformTearOff::setRotate(float angle, float cx, float cy, ExceptionState& exceptionState)
     92 {
     93     if (isImmutable()) {
     94         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
     95         return;
     96     }
     97 
     98     target()->setRotate(angle, cx, cy);
     99     commitChange();
    100 }
    101 
    102 void SVGTransformTearOff::setSkewX(float x, ExceptionState& exceptionState)
    103 {
    104     if (isImmutable()) {
    105         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
    106         return;
    107     }
    108 
    109     target()->setSkewX(x);
    110     commitChange();
    111 }
    112 
    113 void SVGTransformTearOff::setSkewY(float y, ExceptionState& exceptionState)
    114 {
    115     if (isImmutable()) {
    116         exceptionState.throwDOMException(NoModificationAllowedError, "The attribute is read-only.");
    117         return;
    118     }
    119 
    120     target()->setSkewY(y);
    121     commitChange();
    122 }
    123 
    124 }
    125