1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2016 Google Inc.
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef SkSVGSVG_DEFINED
9cb93a386Sopenharmony_ci#define SkSVGSVG_DEFINED
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGContainer.h"
12cb93a386Sopenharmony_ci#include "modules/svg/include/SkSVGTypes.h"
13cb93a386Sopenharmony_ci#include "src/core/SkTLazy.h"
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_ciclass SkSVGLengthContext;
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_ciclass SkSVGSVG : public SkSVGContainer {
18cb93a386Sopenharmony_cipublic:
19cb93a386Sopenharmony_ci    enum class Type {
20cb93a386Sopenharmony_ci        kRoot,
21cb93a386Sopenharmony_ci        kInner,
22cb93a386Sopenharmony_ci    };
23cb93a386Sopenharmony_ci    static sk_sp<SkSVGSVG> Make(Type t = Type::kInner) { return sk_sp<SkSVGSVG>(new SkSVGSVG(t)); }
24cb93a386Sopenharmony_ci
25cb93a386Sopenharmony_ci    SVG_ATTR(X                  , SkSVGLength, SkSVGLength(0))
26cb93a386Sopenharmony_ci    SVG_ATTR(Y                  , SkSVGLength, SkSVGLength(0))
27cb93a386Sopenharmony_ci    SVG_ATTR(Width              , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage))
28cb93a386Sopenharmony_ci    SVG_ATTR(Height             , SkSVGLength, SkSVGLength(100, SkSVGLength::Unit::kPercentage))
29cb93a386Sopenharmony_ci    SVG_ATTR(PreserveAspectRatio, SkSVGPreserveAspectRatio, SkSVGPreserveAspectRatio())
30cb93a386Sopenharmony_ci
31cb93a386Sopenharmony_ci    SVG_OPTIONAL_ATTR(ViewBox, SkSVGViewBoxType)
32cb93a386Sopenharmony_ci
33cb93a386Sopenharmony_ci    SkSize intrinsicSize(const SkSVGLengthContext&) const;
34cb93a386Sopenharmony_ci
35cb93a386Sopenharmony_ciprotected:
36cb93a386Sopenharmony_ci    bool onPrepareToRender(SkSVGRenderContext*) const override;
37cb93a386Sopenharmony_ci
38cb93a386Sopenharmony_ci    void onSetAttribute(SkSVGAttribute, const SkSVGValue&) override;
39cb93a386Sopenharmony_ci
40cb93a386Sopenharmony_ciprivate:
41cb93a386Sopenharmony_ci    explicit SkSVGSVG(Type t)
42cb93a386Sopenharmony_ci        : INHERITED(SkSVGTag::kSvg)
43cb93a386Sopenharmony_ci        , fType(t)
44cb93a386Sopenharmony_ci    {}
45cb93a386Sopenharmony_ci
46cb93a386Sopenharmony_ci    // Some attributes behave differently for the outermost svg element.
47cb93a386Sopenharmony_ci    const Type fType;
48cb93a386Sopenharmony_ci
49cb93a386Sopenharmony_ci    using INHERITED = SkSVGContainer;
50cb93a386Sopenharmony_ci};
51cb93a386Sopenharmony_ci
52cb93a386Sopenharmony_ci#endif // SkSVGSVG_DEFINED
53