gfx/skia/trunk/src/ports/SkXMLParser_tinyxml.cpp

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 #include "SkXMLParser.h"
    11 #include "SkStream.h"
    12 #include "SkTemplates.h"
    13 #include "tinyxml.h"
    15 static void walk_elem(SkXMLParser* parser, const TiXmlElement* elem)
    16 {
    17     //printf("walk_elem(%s) ", elem->Value());
    19     parser->startElement(elem->Value());
    21     const TiXmlAttribute* attr = elem->FirstAttribute();
    22     while (attr)
    23     {
    24         //printf("walk_elem_attr(%s=\"%s\") ", attr->Name(), attr->Value());
    26         parser->addAttribute(attr->Name(), attr->Value());
    27         attr = attr->Next();
    28     }
    29     //printf("\n");
    31     const TiXmlNode* node = elem->FirstChild();
    32     while (node)
    33     {
    34         if (node->ToElement())
    35             walk_elem(parser, node->ToElement());
    36         else if (node->ToText())
    37             parser->text(node->Value(), strlen(node->Value()));
    38         node = node->NextSibling();
    39     }
    41     parser->endElement(elem->Value());
    42 }
    44 static bool load_buf(SkXMLParser* parser, const char buf[])
    45 {
    46     TiXmlDocument                   doc;
    48     (void)doc.Parse(buf);
    49     if (doc.Error())
    50     {
    51         printf("tinyxml error: <%s> row[%d] col[%d]\n", doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol());
    52         return false;
    53     }
    55     walk_elem(parser, doc.RootElement());
    56     return true;
    57 }
    59 bool SkXMLParser::parse(SkStream& stream)
    60 {
    61     size_t size = stream.getLength();
    63     SkAutoMalloc    buffer(size + 1);
    64     char*           buf = (char*)buffer.get();
    66     stream.read(buf, size);
    67     buf[size] = 0;
    69     return load_buf(this, buf);
    70 }
    72 bool SkXMLParser::parse(const char doc[], size_t len)
    73 {
    74     SkAutoMalloc    buffer(len + 1);
    75     char*           buf = (char*)buffer.get();
    77     memcpy(buf, doc, len);
    78     buf[len] = 0;
    80     return load_buf(this, buf);
    81 }
    83 void SkXMLParser::GetNativeErrorString(int error, SkString* str)
    84 {
    85     if (str)
    86         str->set("GetNativeErrorString not implemented for TinyXml");
    87 }

mercurial