1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#include "SkSVGElements.h"
11#include "SkSVGParser.h"
12
13SkSVGBase::~SkSVGBase() {
14}
15
16void SkSVGBase::addAttribute(SkSVGParser& parser, int attrIndex,
17        const char* attrValue, size_t attrLength) {
18    SkString* first = (SkString*) ((char*) this + sizeof(SkSVGElement));
19    first += attrIndex;
20    first->set(attrValue, attrLength);
21}
22
23
24SkSVGElement::SkSVGElement() : fParent(NULL), fIsDef(false), fIsNotDef(true) {
25}
26
27SkSVGElement::~SkSVGElement() {
28}
29
30SkSVGElement* SkSVGElement::getGradient() {
31    return NULL;
32}
33
34bool SkSVGElement::isGroupParent() {
35    SkSVGElement* parent = fParent;
36    while (parent) {
37        if (parent->getType() != SkSVGType_G)
38            return false;
39        parent = parent->fParent;
40    }
41    return true;
42}
43
44bool SkSVGElement::isDef() {
45    return isGroupParent() == false ? fParent->isDef() : fIsDef;
46}
47
48bool SkSVGElement::isFlushable() {
49    return true;
50}
51
52bool SkSVGElement::isGroup() {
53    return false;
54}
55
56bool SkSVGElement::isNotDef() {
57    return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef;
58}
59
60bool SkSVGElement::onEndElement(SkSVGParser& parser) {
61    if (f_id.size() > 0)
62        parser.getIDs().set(f_id.c_str(), f_id.size(), this);
63    return false;
64}
65
66bool SkSVGElement::onStartElement(SkSVGElement* child) {
67    *fChildren.append() = child;
68    return false;
69}
70
71void SkSVGElement::translate(SkSVGParser& parser, bool) {
72    if (f_id.size() > 0)
73        SVG_ADD_ATTRIBUTE(id);
74}
75
76void SkSVGElement::setIsDef() {
77    fIsDef = isDef();
78}
79
80//void SkSVGElement::setIsNotDef() {
81//  fIsNotDef = isNotDef();
82//}
83
84void SkSVGElement::write(SkSVGParser& , SkString& ) {
85    SkASSERT(0);
86}
87