예제 #1
0
SVGPreserveAspectRatio* SVGSVGElement::currentPreserveAspectRatio() const {
  if (m_viewSpec)
    return m_viewSpec->preserveAspectRatio();

  if (!viewBox()->currentValue()->isValid() && shouldSynthesizeViewBox()) {
    // If no viewBox is specified and we're embedded through SVGImage, then
    // synthesize a pAR with the value 'none'.
    SVGPreserveAspectRatio* synthesizedPAR = SVGPreserveAspectRatio::create();
    synthesizedPAR->setAlign(
        SVGPreserveAspectRatio::kSvgPreserveaspectratioNone);
    return synthesizedPAR;
  }
  return preserveAspectRatio()->currentValue();
}
static void alignAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
{
    SVGPropertyTearOff<SVGPreserveAspectRatio>* wrapper = V8SVGPreserveAspectRatio::toNative(info.Holder());
    if (wrapper->isReadOnly()) {
        setDOMException(NO_MODIFICATION_ALLOWED_ERR, info.GetIsolate());
        return;
    }
    SVGPreserveAspectRatio& impInstance = wrapper->propertyReference();
    SVGPreserveAspectRatio* imp = &impInstance;
    int v = toUInt32(value);
    ExceptionCode ec = 0;
    imp->setAlign(v, ec);
    if (UNLIKELY(ec))
        setDOMException(ec, info.GetIsolate());
    if (!ec)
        wrapper->commitChange();
    return;
}