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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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  */
    10 #ifndef SkSVGParser_DEFINED
    11 #define SkSVGParser_DEFINED
    13 #include "SkMatrix.h"
    14 #include "SkTDict.h"
    15 #include "SkTDStack.h"
    16 #include "SkSVGPaintState.h"
    17 #include "SkSVGTypes.h"
    18 #include "SkStream.h"
    19 #include "SkString.h"
    20 #include "SkXMLParser.h"
    21 #include "SkXMLWriter.h"
    23 class SkSVGBase;
    24 class SkSVGElement;
    26 class SkSVGParser : public SkXMLParser {
    27 public:
    28     SkSVGParser(SkXMLParserError* err = NULL);
    29     virtual ~SkSVGParser();
    30     void _addAttribute(const char* attrName, const char* attrValue) {
    31         fXMLWriter.addAttribute(attrName, attrValue); }
    32     void _addAttribute(const char* attrName, SkString& attrValue) {
    33         fXMLWriter.addAttribute(attrName, attrValue.c_str()); }
    34     void _addAttributeLen(const char* attrName, const char* attrValue, size_t len) {
    35         fXMLWriter.addAttributeLen(attrName, attrValue, len); }
    36     void _endElement() { fXMLWriter.endElement(); }
    37     int findAttribute(SkSVGBase* , const char* attrValue, size_t len, bool isPaint);
    38 //    const char* getFinal();
    39     SkTDict<SkSVGElement*>& getIDs() { return fIDs; }
    40     SkString& getPaintLast(SkSVGPaint::Field field);
    41     void _startElement(const char name[]) { fXMLWriter.startElement(name); }
    42     void translate(SkSVGElement*, bool isDef);
    43     void translateMatrix(SkString& , SkString* id);
    44     static void ConvertToArray(SkString& vals);
    45 protected:
    46     virtual bool onAddAttribute(const char name[], const char value[]);
    47     bool onAddAttributeLen(const char name[], const char value[], size_t len);
    48     virtual bool onEndElement(const char elem[]);
    49     virtual bool onStartElement(const char elem[]);
    50     bool onStartElementLen(const char elem[], size_t len);
    51     virtual bool onText(const char text[], int len);
    52 private:
    53     bool isStrokeAndFill(SkSVGPaint** stroke, SkSVGPaint** fill);
    54     static SkSVGElement* CreateElement(SkSVGTypes type, SkSVGElement* parent);
    55     static void Delete(SkTDArray<SkSVGElement*>& fChildren);
    56     static SkSVGTypes GetType(const char name[], size_t len);
    57     SkSVGPaint* fHead;
    58     SkSVGPaint fEmptyPaint;
    59     SkSVGPaint fLastFlush;
    60     SkString fLastColor;
    61     SkMatrix fLastTransform;
    62     SkTDArray<SkSVGElement*> fChildren;
    63     SkTDict<SkSVGElement*> fIDs;
    64     SkTDArray<SkSVGElement*> fParents;
    65     SkDynamicMemoryWStream fStream;
    66     SkXMLStreamWriter fXMLWriter;
    67     SkSVGElement*   fCurrElement;
    68     SkBool8 fInSVG;
    69     SkBool8 fSuppressPaint;
    70     friend class SkSVGPaint;
    71     friend class SkSVGGradient;
    72 };
    74 #endif // SkSVGParser_DEFINED

mercurial