1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/svg/SkSVGElements.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#include "SkSVGElements.h" 1.14 +#include "SkSVGParser.h" 1.15 + 1.16 +SkSVGBase::~SkSVGBase() { 1.17 +} 1.18 + 1.19 +void SkSVGBase::addAttribute(SkSVGParser& parser, int attrIndex, 1.20 + const char* attrValue, size_t attrLength) { 1.21 + SkString* first = (SkString*) ((char*) this + sizeof(SkSVGElement)); 1.22 + first += attrIndex; 1.23 + first->set(attrValue, attrLength); 1.24 +} 1.25 + 1.26 + 1.27 +SkSVGElement::SkSVGElement() : fParent(NULL), fIsDef(false), fIsNotDef(true) { 1.28 +} 1.29 + 1.30 +SkSVGElement::~SkSVGElement() { 1.31 +} 1.32 + 1.33 +SkSVGElement* SkSVGElement::getGradient() { 1.34 + return NULL; 1.35 +} 1.36 + 1.37 +bool SkSVGElement::isGroupParent() { 1.38 + SkSVGElement* parent = fParent; 1.39 + while (parent) { 1.40 + if (parent->getType() != SkSVGType_G) 1.41 + return false; 1.42 + parent = parent->fParent; 1.43 + } 1.44 + return true; 1.45 +} 1.46 + 1.47 +bool SkSVGElement::isDef() { 1.48 + return isGroupParent() == false ? fParent->isDef() : fIsDef; 1.49 +} 1.50 + 1.51 +bool SkSVGElement::isFlushable() { 1.52 + return true; 1.53 +} 1.54 + 1.55 +bool SkSVGElement::isGroup() { 1.56 + return false; 1.57 +} 1.58 + 1.59 +bool SkSVGElement::isNotDef() { 1.60 + return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef; 1.61 +} 1.62 + 1.63 +bool SkSVGElement::onEndElement(SkSVGParser& parser) { 1.64 + if (f_id.size() > 0) 1.65 + parser.getIDs().set(f_id.c_str(), f_id.size(), this); 1.66 + return false; 1.67 +} 1.68 + 1.69 +bool SkSVGElement::onStartElement(SkSVGElement* child) { 1.70 + *fChildren.append() = child; 1.71 + return false; 1.72 +} 1.73 + 1.74 +void SkSVGElement::translate(SkSVGParser& parser, bool) { 1.75 + if (f_id.size() > 0) 1.76 + SVG_ADD_ATTRIBUTE(id); 1.77 +} 1.78 + 1.79 +void SkSVGElement::setIsDef() { 1.80 + fIsDef = isDef(); 1.81 +} 1.82 + 1.83 +//void SkSVGElement::setIsNotDef() { 1.84 +// fIsNotDef = isNotDef(); 1.85 +//} 1.86 + 1.87 +void SkSVGElement::write(SkSVGParser& , SkString& ) { 1.88 + SkASSERT(0); 1.89 +}