michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkSVGElements.h" michael@0: #include "SkSVGParser.h" michael@0: michael@0: SkSVGBase::~SkSVGBase() { michael@0: } michael@0: michael@0: void SkSVGBase::addAttribute(SkSVGParser& parser, int attrIndex, michael@0: const char* attrValue, size_t attrLength) { michael@0: SkString* first = (SkString*) ((char*) this + sizeof(SkSVGElement)); michael@0: first += attrIndex; michael@0: first->set(attrValue, attrLength); michael@0: } michael@0: michael@0: michael@0: SkSVGElement::SkSVGElement() : fParent(NULL), fIsDef(false), fIsNotDef(true) { michael@0: } michael@0: michael@0: SkSVGElement::~SkSVGElement() { michael@0: } michael@0: michael@0: SkSVGElement* SkSVGElement::getGradient() { michael@0: return NULL; michael@0: } michael@0: michael@0: bool SkSVGElement::isGroupParent() { michael@0: SkSVGElement* parent = fParent; michael@0: while (parent) { michael@0: if (parent->getType() != SkSVGType_G) michael@0: return false; michael@0: parent = parent->fParent; michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: bool SkSVGElement::isDef() { michael@0: return isGroupParent() == false ? fParent->isDef() : fIsDef; michael@0: } michael@0: michael@0: bool SkSVGElement::isFlushable() { michael@0: return true; michael@0: } michael@0: michael@0: bool SkSVGElement::isGroup() { michael@0: return false; michael@0: } michael@0: michael@0: bool SkSVGElement::isNotDef() { michael@0: return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef; michael@0: } michael@0: michael@0: bool SkSVGElement::onEndElement(SkSVGParser& parser) { michael@0: if (f_id.size() > 0) michael@0: parser.getIDs().set(f_id.c_str(), f_id.size(), this); michael@0: return false; michael@0: } michael@0: michael@0: bool SkSVGElement::onStartElement(SkSVGElement* child) { michael@0: *fChildren.append() = child; michael@0: return false; michael@0: } michael@0: michael@0: void SkSVGElement::translate(SkSVGParser& parser, bool) { michael@0: if (f_id.size() > 0) michael@0: SVG_ADD_ATTRIBUTE(id); michael@0: } michael@0: michael@0: void SkSVGElement::setIsDef() { michael@0: fIsDef = isDef(); michael@0: } michael@0: michael@0: //void SkSVGElement::setIsNotDef() { michael@0: // fIsNotDef = isNotDef(); michael@0: //} michael@0: michael@0: void SkSVGElement::write(SkSVGParser& , SkString& ) { michael@0: SkASSERT(0); michael@0: }