diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-06-29 11:18:49 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-29 15:40:59 +0000 |
commit | f1eae2c37cb4bbf7a536cf251706147bbac51880 (patch) | |
tree | 8eead543163dddefc63a518d9d44b5ca1ee49875 /fpdfsdk/pdfwindow/cpwl_caret.cpp | |
parent | a0b48aa8043be95e5c6b602e0e261fb163282536 (diff) | |
download | pdfium-f1eae2c37cb4bbf7a536cf251706147bbac51880.tar.xz |
Converted low-hanging cpwl classes in CFX_ByteTextBuf to ostringstream.
Bug: pdfium:731
Change-Id: I3faf5a4ec4b2af6145348e526f39ccbc2055e62e
Reviewed-on: https://pdfium-review.googlesource.com/7050
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/pdfwindow/cpwl_caret.cpp')
-rw-r--r-- | fpdfsdk/pdfwindow/cpwl_caret.cpp | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/fpdfsdk/pdfwindow/cpwl_caret.cpp b/fpdfsdk/pdfwindow/cpwl_caret.cpp index 3275dd1b33..a6a165f9a0 100644 --- a/fpdfsdk/pdfwindow/cpwl_caret.cpp +++ b/fpdfsdk/pdfwindow/cpwl_caret.cpp @@ -6,6 +6,8 @@ #include "fpdfsdk/pdfwindow/cpwl_caret.h" +#include <sstream> + #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" @@ -24,70 +26,68 @@ CFX_ByteString CPWL_Caret::GetClassName() const { return "CPWL_Caret"; } -void CPWL_Caret::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { - GetCaretApp(sAppStream, CFX_PointF()); +void CPWL_Caret::GetThisAppearanceStream(std::ostringstream* psAppStream) { + GetCaretApp(CFX_PointF(), psAppStream); } void CPWL_Caret::DrawThisAppearance(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device) { - if (IsVisible() && m_bFlash) { - CFX_FloatRect rcRect = GetCaretRect(); - CFX_FloatRect rcClip = GetClipRect(); - CFX_PathData path; - - float fCaretX = rcRect.left + m_fWidth * 0.5f; - float fCaretTop = rcRect.top; - float fCaretBottom = rcRect.bottom; - if (!rcClip.IsEmpty()) { - rcRect.Intersect(rcClip); - if (rcRect.IsEmpty()) - return; - - fCaretTop = rcRect.top; - fCaretBottom = rcRect.bottom; - } + if (!IsVisible() || !m_bFlash) + return; + + CFX_FloatRect rcRect = GetCaretRect(); + CFX_FloatRect rcClip = GetClipRect(); + CFX_PathData path; + + float fCaretX = rcRect.left + m_fWidth * 0.5f; + float fCaretTop = rcRect.top; + float fCaretBottom = rcRect.bottom; + if (!rcClip.IsEmpty()) { + rcRect.Intersect(rcClip); + if (rcRect.IsEmpty()) + return; + + fCaretTop = rcRect.top; + fCaretBottom = rcRect.bottom; + } - path.AppendPoint(CFX_PointF(fCaretX, fCaretBottom), FXPT_TYPE::MoveTo, - false); - path.AppendPoint(CFX_PointF(fCaretX, fCaretTop), FXPT_TYPE::LineTo, false); + path.AppendPoint(CFX_PointF(fCaretX, fCaretBottom), FXPT_TYPE::MoveTo, false); + path.AppendPoint(CFX_PointF(fCaretX, fCaretTop), FXPT_TYPE::LineTo, false); - CFX_GraphStateData gsd; - gsd.m_LineWidth = m_fWidth; - pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0), - FXFILL_ALTERNATE); - } + CFX_GraphStateData gsd; + gsd.m_LineWidth = m_fWidth; + pDevice->DrawPath(&path, pUser2Device, &gsd, 0, ArgbEncode(255, 0, 0, 0), + FXFILL_ALTERNATE); } -void CPWL_Caret::GetCaretApp(CFX_ByteTextBuf& sAppStream, - const CFX_PointF& ptOffset) { - if (IsVisible() && m_bFlash) { - CFX_ByteTextBuf sCaret; - - CFX_FloatRect rcRect = GetCaretRect(); - CFX_FloatRect rcClip = GetClipRect(); +void CPWL_Caret::GetCaretApp(const CFX_PointF& ptOffset, + std::ostringstream* psAppStream) { + if (!IsVisible() || !m_bFlash) + return; - rcRect = CPWL_Utils::OffsetRect(rcRect, ptOffset.x, ptOffset.y); - rcClip = CPWL_Utils::OffsetRect(rcClip, ptOffset.x, ptOffset.y); + CFX_FloatRect rcRect = GetCaretRect(); + CFX_FloatRect rcClip = GetClipRect(); - sCaret << "q\n"; - if (!rcClip.IsEmpty()) { - sCaret << rcClip.left << " " << rcClip.bottom + 2.5f << " " - << rcClip.right - rcClip.left << " " - << rcClip.top - rcClip.bottom - 4.5f << " re W n\n"; - } - sCaret << m_fWidth << " w\n0 G\n"; - sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.bottom << " m\n"; - sCaret << rcRect.left + m_fWidth / 2 << " " << rcRect.top << " l S\nQ\n"; + rcRect = CPWL_Utils::OffsetRect(rcRect, ptOffset.x, ptOffset.y); + rcClip = CPWL_Utils::OffsetRect(rcClip, ptOffset.x, ptOffset.y); - sAppStream << sCaret; + *psAppStream << "q\n"; + if (!rcClip.IsEmpty()) { + *psAppStream << rcClip.left << " " << rcClip.bottom + 2.5f << " " + << rcClip.right - rcClip.left << " " + << rcClip.top - rcClip.bottom - 4.5f << " re W n\n"; } + *psAppStream << m_fWidth << " w\n0 G\n" + << rcRect.left + m_fWidth / 2 << " " << rcRect.bottom << " m\n" + << rcRect.left + m_fWidth / 2 << " " << rcRect.top + << " l S\nQ\n"; } CFX_ByteString CPWL_Caret::GetCaretAppearanceStream( const CFX_PointF& ptOffset) { - CFX_ByteTextBuf sCaret; - GetCaretApp(sCaret, ptOffset); - return sCaret.MakeString(); + std::ostringstream sCaret; + GetCaretApp(ptOffset, &sCaret); + return CFX_ByteString(sCaret); } void CPWL_Caret::TimerProc() { |