Home | History | Annotate | Download | only in svg
      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 
     13 SkSVGBase::~SkSVGBase() {
     14 }
     15 
     16 void 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 
     24 SkSVGElement::SkSVGElement() : fParent(NULL), fIsDef(false), fIsNotDef(true) {
     25 }
     26 
     27 SkSVGElement::~SkSVGElement() {
     28 }
     29 
     30 SkSVGElement* SkSVGElement::getGradient() {
     31     return NULL;
     32 }
     33 
     34 bool 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 
     44 bool SkSVGElement::isDef() {
     45     return isGroupParent() == false ? fParent->isDef() : fIsDef;
     46 }
     47 
     48 bool SkSVGElement::isFlushable() {
     49     return true;
     50 }
     51 
     52 bool SkSVGElement::isGroup() {
     53     return false;
     54 }
     55 
     56 bool SkSVGElement::isNotDef() {
     57     return isGroupParent() == false ? fParent->isNotDef() : fIsNotDef;
     58 }
     59 
     60 bool 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 
     66 bool SkSVGElement::onStartElement(SkSVGElement* child) {
     67     *fChildren.append() = child;
     68     return false;
     69 }
     70 
     71 void SkSVGElement::translate(SkSVGParser& parser, bool) {
     72     if (f_id.size() > 0)
     73         SVG_ADD_ATTRIBUTE(id);
     74 }
     75 
     76 void SkSVGElement::setIsDef() {
     77     fIsDef = isDef();
     78 }
     79 
     80 //void SkSVGElement::setIsNotDef() {
     81 //  fIsNotDef = isNotDef();
     82 //}
     83 
     84 void SkSVGElement::write(SkSVGParser& , SkString& ) {
     85     SkASSERT(0);
     86 }
     87 
     88 
     89