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