gfx/skia/trunk/include/svg/SkSVGParser.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkSVGParser_DEFINED
michael@0 11 #define SkSVGParser_DEFINED
michael@0 12
michael@0 13 #include "SkMatrix.h"
michael@0 14 #include "SkTDict.h"
michael@0 15 #include "SkTDStack.h"
michael@0 16 #include "SkSVGPaintState.h"
michael@0 17 #include "SkSVGTypes.h"
michael@0 18 #include "SkStream.h"
michael@0 19 #include "SkString.h"
michael@0 20 #include "SkXMLParser.h"
michael@0 21 #include "SkXMLWriter.h"
michael@0 22
michael@0 23 class SkSVGBase;
michael@0 24 class SkSVGElement;
michael@0 25
michael@0 26 class SkSVGParser : public SkXMLParser {
michael@0 27 public:
michael@0 28 SkSVGParser(SkXMLParserError* err = NULL);
michael@0 29 virtual ~SkSVGParser();
michael@0 30 void _addAttribute(const char* attrName, const char* attrValue) {
michael@0 31 fXMLWriter.addAttribute(attrName, attrValue); }
michael@0 32 void _addAttribute(const char* attrName, SkString& attrValue) {
michael@0 33 fXMLWriter.addAttribute(attrName, attrValue.c_str()); }
michael@0 34 void _addAttributeLen(const char* attrName, const char* attrValue, size_t len) {
michael@0 35 fXMLWriter.addAttributeLen(attrName, attrValue, len); }
michael@0 36 void _endElement() { fXMLWriter.endElement(); }
michael@0 37 int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPaint);
michael@0 38 // const char* getFinal();
michael@0 39 SkTDict<SkSVGElement*>& getIDs() { return fIDs; }
michael@0 40 SkString& getPaintLast(SkSVGPaint::Field field);
michael@0 41 void _startElement(const char name[]) { fXMLWriter.startElement(name); }
michael@0 42 void translate(SkSVGElement*, bool isDef);
michael@0 43 void translateMatrix(SkString& , SkString* id);
michael@0 44 static void ConvertToArray(SkString& vals);
michael@0 45 protected:
michael@0 46 virtual bool onAddAttribute(const char name[], const char value[]);
michael@0 47 bool onAddAttributeLen(const char name[], const char value[], size_t len);
michael@0 48 virtual bool onEndElement(const char elem[]);
michael@0 49 virtual bool onStartElement(const char elem[]);
michael@0 50 bool onStartElementLen(const char elem[], size_t len);
michael@0 51 virtual bool onText(const char text[], int len);
michael@0 52 private:
michael@0 53 bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill);
michael@0 54 static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent);
michael@0 55 static void Delete(SkTDArray<SkSVGElement*>& fChildren);
michael@0 56 static SkSVGTypes GetType(const char name[], size_t len);
michael@0 57 SkSVGPaint* fHead;
michael@0 58 SkSVGPaint fEmptyPaint;
michael@0 59 SkSVGPaint fLastFlush;
michael@0 60 SkString fLastColor;
michael@0 61 SkMatrix fLastTransform;
michael@0 62 SkTDArray<SkSVGElement*> fChildren;
michael@0 63 SkTDict<SkSVGElement*> fIDs;
michael@0 64 SkTDArray<SkSVGElement*> fParents;
michael@0 65 SkDynamicMemoryWStream fStream;
michael@0 66 SkXMLStreamWriter fXMLWriter;
michael@0 67 SkSVGElement* fCurrElement;
michael@0 68 SkBool8 fInSVG;
michael@0 69 SkBool8 fSuppressPaint;
michael@0 70 friend class SkSVGPaint;
michael@0 71 friend class SkSVGGradient;
michael@0 72 };
michael@0 73
michael@0 74 #endif // SkSVGParser_DEFINED

mercurial