add length parameter to addText, to match attr values
BUG=skia:3392 Review URL: https://codereview.chromium.org/896363002
This commit is contained in:
parent
a9d9de45c1
commit
e73da40c35
@ -243,7 +243,7 @@ public:
|
||||
}
|
||||
|
||||
void addText(const SkString& text) {
|
||||
fWriter->addText(text.c_str());
|
||||
fWriter->addText(text.c_str(), text.size());
|
||||
}
|
||||
|
||||
void addRectAttributes(const SkRect&);
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef SkXMLWriter_DEFINED
|
||||
#define SkXMLWriter_DEFINED
|
||||
|
||||
@ -27,7 +25,7 @@ public:
|
||||
void addAttributeLen(const char name[], const char value[], size_t length);
|
||||
void addHexAttribute(const char name[], uint32_t value, int minDigits = 0);
|
||||
void addScalarAttribute(const char name[], SkScalar value);
|
||||
void addText(const char text[]);
|
||||
void addText(const char text[], size_t length);
|
||||
void endElement() { this->onEndElement(); }
|
||||
void startElement(const char elem[]);
|
||||
void startElementLen(const char elem[], size_t length);
|
||||
@ -38,7 +36,7 @@ public:
|
||||
protected:
|
||||
virtual void onStartElementLen(const char elem[], size_t length) = 0;
|
||||
virtual void onAddAttributeLen(const char name[], const char value[], size_t length) = 0;
|
||||
virtual void onAddText(const char text[]) = 0;
|
||||
virtual void onAddText(const char text[], size_t length) = 0;
|
||||
virtual void onEndElement() = 0;
|
||||
|
||||
struct Elem {
|
||||
@ -69,11 +67,12 @@ public:
|
||||
virtual ~SkXMLStreamWriter();
|
||||
virtual void writeHeader();
|
||||
SkDEBUGCODE(static void UnitTest();)
|
||||
|
||||
protected:
|
||||
virtual void onStartElementLen(const char elem[], size_t length);
|
||||
virtual void onEndElement();
|
||||
virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
|
||||
virtual void onAddText(const char text[]) SK_OVERRIDE;
|
||||
void onStartElementLen(const char elem[], size_t length) SK_OVERRIDE;
|
||||
void onEndElement() SK_OVERRIDE;
|
||||
void onAddAttributeLen(const char name[], const char value[], size_t length) SK_OVERRIDE;
|
||||
void onAddText(const char text[], size_t length) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkWStream& fStream;
|
||||
@ -87,7 +86,7 @@ protected:
|
||||
virtual void onStartElementLen(const char elem[], size_t length);
|
||||
virtual void onEndElement();
|
||||
virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
|
||||
virtual void onAddText(const char text[]) SK_OVERRIDE;
|
||||
virtual void onAddText(const char text[], size_t length) SK_OVERRIDE;
|
||||
private:
|
||||
SkXMLParser& fParser;
|
||||
};
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "SkXMLAnimatorWriter.h"
|
||||
#include "SkAnimator.h"
|
||||
#include "SkAnimateMaker.h"
|
||||
@ -26,8 +24,7 @@ void SkXMLAnimatorWriter::onAddAttributeLen(const char name[], const char value[
|
||||
fParser->onAddAttributeLen(name, value, length);
|
||||
}
|
||||
|
||||
void SkXMLAnimatorWriter::onAddText(const char text[])
|
||||
{
|
||||
void SkXMLAnimatorWriter::onAddText(const char text[], size_t length) {
|
||||
SkDebugf("not implemented: SkXMLAnimatorWriter::onAddText()\n");
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,12 @@ public:
|
||||
virtual ~SkXMLAnimatorWriter();
|
||||
virtual void writeHeader();
|
||||
SkDEBUGCODE(static void UnitTest(class SkCanvas* canvas);)
|
||||
|
||||
protected:
|
||||
virtual void onAddAttributeLen(const char name[], const char value[], size_t length);
|
||||
virtual void onEndElement();
|
||||
virtual void onStartElementLen(const char elem[], size_t length);
|
||||
virtual void onAddText(const char text[]) SK_OVERRIDE;
|
||||
void onAddAttributeLen(const char name[], const char value[], size_t length) SK_OVERRIDE;
|
||||
void onEndElement() SK_OVERRIDE;
|
||||
void onStartElementLen(const char elem[], size_t length) SK_OVERRIDE;
|
||||
void onAddText(const char text[], size_t length) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkAnimator* fAnimator;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2006 The Android Open Source Project
|
||||
*
|
||||
@ -6,7 +5,6 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
|
||||
#include "SkXMLWriter.h"
|
||||
#include "SkStream.h"
|
||||
|
||||
@ -51,14 +49,13 @@ void SkXMLWriter::addScalarAttribute(const char name[], SkScalar value)
|
||||
this->addAttribute(name, tmp.c_str());
|
||||
}
|
||||
|
||||
void SkXMLWriter::addText(const char text[])
|
||||
{
|
||||
void SkXMLWriter::addText(const char text[], size_t length) {
|
||||
if (fElems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->onAddText(text);
|
||||
|
||||
|
||||
this->onAddText(text, length);
|
||||
|
||||
fElems.top()->fHasText = true;
|
||||
}
|
||||
|
||||
@ -229,8 +226,7 @@ void SkXMLStreamWriter::onAddAttributeLen(const char name[], const char value[],
|
||||
fStream.writeText("\"");
|
||||
}
|
||||
|
||||
void SkXMLStreamWriter::onAddText(const char text[])
|
||||
{
|
||||
void SkXMLStreamWriter::onAddText(const char text[], size_t length) {
|
||||
Elem* elem = fElems.top();
|
||||
|
||||
if (!elem->fHasChildren && !elem->fHasText) {
|
||||
@ -239,7 +235,7 @@ void SkXMLStreamWriter::onAddText(const char text[])
|
||||
}
|
||||
|
||||
tab(fStream, fElems.count() + 1);
|
||||
fStream.writeText(text);
|
||||
fStream.write(text, length);
|
||||
fStream.newline();
|
||||
}
|
||||
|
||||
@ -302,9 +298,8 @@ void SkXMLParserWriter::onAddAttributeLen(const char name[], const char value[],
|
||||
fParser.addAttribute(name, str.c_str());
|
||||
}
|
||||
|
||||
void SkXMLParserWriter::onAddText(const char text[])
|
||||
{
|
||||
fParser.text(text, SkToInt(strlen(text)));
|
||||
void SkXMLParserWriter::onAddText(const char text[], size_t length) {
|
||||
fParser.text(text, SkToInt(length));
|
||||
}
|
||||
|
||||
void SkXMLParserWriter::onEndElement()
|
||||
|
Loading…
Reference in New Issue
Block a user