diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-07-19 12:18:35 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-19 16:33:08 +0000 |
commit | 56a805477a72a540a520b08cedd48f1cf250ae8b (patch) | |
tree | 22a38c493c0863568201cca1768307ce25d6532c | |
parent | 4442d453f570fda76ec4852e2bb03e7ec8bfb825 (diff) | |
download | pdfium-56a805477a72a540a520b08cedd48f1cf250ae8b.tar.xz |
Revert "Converting CFX_ByteTextBuf to ostringstream in SAX."
This reverts commit 7ca47d55c9cbbec7e0a0b0beffffe348ae655086.
Reason for revert: Caused pdfium:821
Original change's description:
> Converting CFX_ByteTextBuf to ostringstream in SAX.
>
> Bug: pdfium:731
> Change-Id: Ic492e8900c4a69082ff9c2384006a4e6bfa3313e
> Reviewed-on: https://pdfium-review.googlesource.com/6592
> Reviewed-by: Lei Zhang <thestig@chromium.org>
> Reviewed-by: dsinclair <dsinclair@chromium.org>
> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
TBR=thestig@chromium.org,dsinclair@chromium.org,hnakashima@chromium.org
Bug: pdfium:731
Change-Id: Ic7390c3f53d67d6eecf7f669e329702daa16f339
Reviewed-on: https://pdfium-review.googlesource.com/8230
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_saxcontext.cpp | 9 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_saxcontext.h | 7 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_saxreaderhandler.cpp | 34 |
4 files changed, 20 insertions, 31 deletions
@@ -887,7 +887,6 @@ static_library("fxcrt") { "core/fxcrt/fx_arabic.h", "core/fxcrt/ifx_chariter.h", "core/fxcrt/ifx_locale.h", - "core/fxcrt/xml/cfx_saxcontext.cpp", "core/fxcrt/xml/cfx_saxcontext.h", "core/fxcrt/xml/cfx_saxreader.cpp", "core/fxcrt/xml/cfx_saxreader.h", diff --git a/core/fxcrt/xml/cfx_saxcontext.cpp b/core/fxcrt/xml/cfx_saxcontext.cpp deleted file mode 100644 index 4e2f0c58c9..0000000000 --- a/core/fxcrt/xml/cfx_saxcontext.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "core/fxcrt/xml/cfx_saxcontext.h" - -CFX_SAXContext::CFX_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {} - -CFX_SAXContext::~CFX_SAXContext() {} diff --git a/core/fxcrt/xml/cfx_saxcontext.h b/core/fxcrt/xml/cfx_saxcontext.h index fcc889f7a3..7afebed98d 100644 --- a/core/fxcrt/xml/cfx_saxcontext.h +++ b/core/fxcrt/xml/cfx_saxcontext.h @@ -7,18 +7,15 @@ #ifndef CORE_FXCRT_XML_CFX_SAXCONTEXT_H_ #define CORE_FXCRT_XML_CFX_SAXCONTEXT_H_ -#include <sstream> - #include "core/fxcrt/fx_basic.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/xml/cfx_saxreader.h" class CFX_SAXContext { public: - CFX_SAXContext(); - ~CFX_SAXContext(); + CFX_SAXContext() : m_eNode(CFX_SAXItem::Type::Unknown) {} - std::ostringstream m_TextBuf; + CFX_ByteTextBuf m_TextBuf; CFX_ByteString m_bsTagName; CFX_SAXItem::Type m_eNode; }; diff --git a/core/fxcrt/xml/cfx_saxreaderhandler.cpp b/core/fxcrt/xml/cfx_saxreaderhandler.cpp index f1e0c7ad94..e7b6cd186c 100644 --- a/core/fxcrt/xml/cfx_saxreaderhandler.cpp +++ b/core/fxcrt/xml/cfx_saxreaderhandler.cpp @@ -26,11 +26,12 @@ CFX_SAXContext* CFX_SAXReaderHandler::OnTagEnter( } m_SAXContext.m_eNode = eType; - m_SAXContext.m_TextBuf << "<"; + CFX_ByteTextBuf& textBuf = m_SAXContext.m_TextBuf; + textBuf << "<"; if (eType == CFX_SAXItem::Type::Instruction) - m_SAXContext.m_TextBuf << "?"; + textBuf << "?"; - m_SAXContext.m_TextBuf << bsTagName; + textBuf << bsTagName; m_SAXContext.m_bsTagName = bsTagName; return &m_SAXContext; } @@ -40,7 +41,7 @@ void CFX_SAXReaderHandler::OnTagAttribute(CFX_SAXContext* pTag, const CFX_ByteStringC& bsValue) { if (!pTag) return; - pTag->m_TextBuf << " " << bsAttri.c_str() << "=\"" << bsValue.c_str() << "\""; + pTag->m_TextBuf << " " << bsAttri << "=\"" << bsValue << "\""; } void CFX_SAXReaderHandler::OnTagBreak(CFX_SAXContext* pTag) { @@ -58,22 +59,24 @@ void CFX_SAXReaderHandler::OnTagData(CFX_SAXContext* pTag, if (!pTag) return; + CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; if (eType == CFX_SAXItem::Type::CharData) - pTag->m_TextBuf << "<![CDATA["; + textBuf << "<![CDATA["; - pTag->m_TextBuf << bsData.c_str(); + textBuf << bsData; if (eType == CFX_SAXItem::Type::CharData) - pTag->m_TextBuf << "]]>"; + textBuf << "]]>"; } void CFX_SAXReaderHandler::OnTagClose(CFX_SAXContext* pTag, uint32_t dwEndPos) { if (!pTag) return; + CFX_ByteTextBuf& textBuf = pTag->m_TextBuf; if (pTag->m_eNode == CFX_SAXItem::Type::Instruction) - pTag->m_TextBuf << "?>"; + textBuf << "?>"; else if (pTag->m_eNode == CFX_SAXItem::Type::Tag) - pTag->m_TextBuf << "></" << pTag->m_bsTagName.AsStringC().c_str() << ">"; + textBuf << "></" << pTag->m_bsTagName.AsStringC() << ">"; UpdateChecksum(false); } @@ -84,7 +87,7 @@ void CFX_SAXReaderHandler::OnTagEnd(CFX_SAXContext* pTag, if (!pTag) return; - pTag->m_TextBuf << "</" << bsTagName.c_str() << ">"; + pTag->m_TextBuf << "</" << bsTagName << ">"; UpdateChecksum(false); } @@ -96,20 +99,19 @@ void CFX_SAXReaderHandler::OnTargetData(CFX_SAXContext* pTag, return; if (eType == CFX_SAXItem::Type::Comment) { - m_SAXContext.m_TextBuf << "<!--" << bsData.c_str() << "-->"; + m_SAXContext.m_TextBuf << "<!--" << bsData << "-->"; UpdateChecksum(false); } else { - pTag->m_TextBuf << " " << bsData.c_str(); + pTag->m_TextBuf << " " << bsData; } } void CFX_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { - int32_t iLength = m_SAXContext.m_TextBuf.tellp(); + int32_t iLength = m_SAXContext.m_TextBuf.GetLength(); if (iLength < 1) return; - const uint8_t* pBuffer = - reinterpret_cast<const uint8_t*>(m_SAXContext.m_TextBuf.str().c_str()); + uint8_t* pBuffer = m_SAXContext.m_TextBuf.GetBuffer(); bool bUpdata = true; if (bCheckSpace) { bUpdata = false; @@ -122,5 +124,5 @@ void CFX_SAXReaderHandler::UpdateChecksum(bool bCheckSpace) { if (bUpdata) m_pContext->Update(CFX_ByteStringC(pBuffer, iLength)); - m_SAXContext.m_TextBuf.str(""); + m_SAXContext.m_TextBuf.Clear(); } |