180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkDisplayXMLParser_DEFINED
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkDisplayXMLParser_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkIntArray.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTDict.h"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDisplayType.h"
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkXMLParser.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAnimateMaker;
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDisplayable;
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDisplayXMLParserError : public SkXMLParserError {
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum ErrorCode {
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kApplyScopesItself = kUnknownError + 1,
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDisplayTreeTooDeep,
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kElementMissingParent,
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kElementTypeNotAllowedInParent,
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorAddingDataToPost,
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorAddingToMatrix,
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorAddingToPaint,
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorAddingToPath,
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorInAttributeValue,
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kErrorInScript,
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kExpectedMovie,
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFieldNotInTarget,
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientOffsetsDontMatchColors,
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientOffsetsMustBeNoMoreThanOne,
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientOffsetsMustEndWithOne,
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientOffsetsMustIncrease,
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientOffsetsMustStartWithZero,
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGradientPointsLengthMustBeFour,
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kInInclude,
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kInMovie,
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kIncludeNameUnknownOrMissing,
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kIndexOutOfRange,
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMovieNameUnknownOrMissing,
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNoParentAvailable,
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kParentElementCantContain,
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSaveLayerNeedsBounds,
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kTargetIDNotFound,
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnexpectedType
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~SkDisplayXMLParserError();
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void getErrorString(SkString* str) const;
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setCode(ErrorCode code) { INHERITED::setCode((INHERITED::ErrorCode) code); }
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setInnerError(SkAnimateMaker* maker, const SkString& str);
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkXMLParserError INHERITED;
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkDisplayXMLParser;
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDisplayXMLParser : public SkXMLParser {
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayXMLParser(SkAnimateMaker& maker);
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~SkDisplayXMLParser();
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprotected:
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool onAddAttribute(const char name[], const char value[]);
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool onAddAttributeLen(const char name[], const char value[], size_t len);
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool onEndElement(const char elem[]);
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool onStartElement(const char elem[]);
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool onStartElementLen(const char elem[], size_t len);
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct Parent {
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkDisplayable* fDisplayable;
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkDisplayTypes fType;
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTDArray<Parent> fParents;
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayXMLParser& operator= (const SkDisplayXMLParser& );
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayXMLParserError* getError() { return (SkDisplayXMLParserError*) fError; }
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkMemberInfo* searchContainer(const SkMemberInfo* ,
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        int infoCount);
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAnimateMaker& fMaker;
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkBool fInInclude;
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkBool fInSkia;
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // local state between onStartElement and onAddAttribute
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayable*  fCurrDisplayable;
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDisplayTypes  fCurrType;
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkXMLAnimatorWriter;
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef SkXMLParser INHERITED;
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif // SkDisplayXMLParser_DEFINED
92