summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-04-29 18:14:37 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-29 18:14:37 -0700
commit8c32dfa88b9deedb5add135301a0f6b1128882ed (patch)
treeea2b004c4286b3b16113189b16a274dafe9c8163
parente801d4e064690fbe1815d25d220cfbca79976a4f (diff)
downloadpdfium-8c32dfa88b9deedb5add135301a0f6b1128882ed.tar.xz
Subtract instead of adding the negation.
Do more cleanup in modified files. Review-Url: https://codereview.chromium.org/1938613003
-rw-r--r--core/fpdfdoc/doc_vt.cpp12
-rw-r--r--core/fxge/ge/fx_ge_text.cpp4
-rw-r--r--fpdfsdk/fxedit/fxet_edit.cpp2
-rw-r--r--xfa/fwl/basewidget/fwl_editimp.cpp127
4 files changed, 72 insertions, 73 deletions
diff --git a/core/fpdfdoc/doc_vt.cpp b/core/fpdfdoc/doc_vt.cpp
index b728c68af6..88a4636bbc 100644
--- a/core/fpdfdoc/doc_vt.cpp
+++ b/core/fpdfdoc/doc_vt.cpp
@@ -372,7 +372,7 @@ CPVT_FloatRect CTypeset::CharArray() {
pLine->m_LineInfo.fLineWidth = x - pLine->m_LineInfo.fLineX;
pLine->m_LineInfo.fLineAscent = fLineAscent;
pLine->m_LineInfo.fLineDescent = fLineDescent;
- y += (-fLineDescent);
+ y -= fLineDescent;
}
return m_rcRet = CPVT_FloatRect(0, 0, x, y);
}
@@ -640,7 +640,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
m_pSection->AddLine(line);
}
fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
- fMaxY += (-fLineDescent);
+ fMaxY -= fLineDescent;
fMaxX = std::max(fLineWidth, fMaxX);
nLineHead = i;
fLineWidth = 0.0f;
@@ -666,7 +666,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
m_pSection->AddLine(line);
}
fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecInfo));
- fMaxY += (-fLineDescent);
+ fMaxY -= fLineDescent;
fMaxX = std::max(fLineWidth, fMaxX);
}
} else {
@@ -688,8 +688,8 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) {
line.fLineDescent = fLineDescent;
m_pSection->AddLine(line);
}
- fMaxY += (m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent +
- (-fLineDescent));
+ fMaxY += m_pVT->GetLineLeading(m_pSection->m_SecInfo) + fLineAscent -
+ fLineDescent;
}
m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY);
}
@@ -761,7 +761,7 @@ void CTypeset::OutputLines() {
fPosX += m_pVT->GetWordWidth(*pWord);
}
}
- fPosY += (-pLine->m_LineInfo.fLineDescent);
+ fPosY -= pLine->m_LineInfo.fLineDescent;
}
}
}
diff --git a/core/fxge/ge/fx_ge_text.cpp b/core/fxge/ge/fx_ge_text.cpp
index f65e34a3e8..9ad93d872a 100644
--- a/core/fxge/ge/fx_ge_text.cpp
+++ b/core/fxge/ge/fx_ge_text.cpp
@@ -1580,7 +1580,7 @@ CFX_GlyphBitmap* CFX_FaceCache::RenderGlyph(CFX_Font* pFont,
if (pFont->IsVertical())
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
- ft_matrix.xy += -ft_matrix.xx * skew / 100;
+ ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
if (pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
pFont->AdjustMMParams(glyph_index, dest_width,
@@ -1850,7 +1850,7 @@ CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, int dest_width) {
if (m_bVertical)
ft_matrix.yx += ft_matrix.yy * skew / 100;
else
- ft_matrix.xy += -ft_matrix.xx * skew / 100;
+ ft_matrix.xy -= ft_matrix.xx * skew / 100;
}
if (m_pSubstFont->m_SubstFlags & FXFONT_SUBST_MM) {
AdjustMMParams(glyph_index, dest_width, m_pSubstFont->m_Weight);
diff --git a/fpdfsdk/fxedit/fxet_edit.cpp b/fpdfsdk/fxedit/fxet_edit.cpp
index 07a9d864d7..bdd2c75325 100644
--- a/fpdfsdk/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/fxedit/fxet_edit.cpp
@@ -219,7 +219,7 @@ void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
rcResult.left = rcResult.right - fWidthDiff;
} else {
rcResult.left = rcResult.right;
- rcResult.right += (-fWidthDiff);
+ rcResult.right -= fWidthDiff;
}
}
m_RefreshRects.Add(rcResult);
diff --git a/xfa/fwl/basewidget/fwl_editimp.cpp b/xfa/fwl/basewidget/fwl_editimp.cpp
index 86c6fe8874..17aef3bb16 100644
--- a/xfa/fwl/basewidget/fwl_editimp.cpp
+++ b/xfa/fwl/basewidget/fwl_editimp.cpp
@@ -29,6 +29,28 @@
#include "xfa/fxfa/include/xfa_ffwidget.h"
#include "xfa/fxgraphics/cfx_path.h"
+namespace {
+
+bool FX_EDIT_ISLATINWORD(FX_WCHAR c) {
+ return c == 0x2D || (c <= 0x005A && c >= 0x0041) ||
+ (c <= 0x007A && c >= 0x0061) || (c <= 0x02AF && c >= 0x00C0) ||
+ c == 0x0027;
+}
+
+void AddSquigglyPath(CFX_Path* pPathData,
+ FX_FLOAT fStartX,
+ FX_FLOAT fEndX,
+ FX_FLOAT fY,
+ FX_FLOAT fStep) {
+ pPathData->MoveTo(fStartX, fY);
+ int i = 1;
+ for (FX_FLOAT fx = fStartX + fStep; fx < fEndX; fx += fStep, ++i) {
+ pPathData->LineTo(fx, fY + (i & 1) * fStep);
+ }
+}
+
+} // namespace
+
// static
IFWL_Edit* IFWL_Edit::Create(const CFWL_WidgetImpProperties& properties,
IFWL_Widget* pOuter) {
@@ -298,44 +320,27 @@ FWL_ERR CFWL_EditImp::Update() {
InitCaret();
return FWL_ERR_Succeeded;
}
+
uint32_t CFWL_EditImp::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) {
if (IsShowScrollBar(TRUE)) {
CFX_RectF rect;
m_pVertScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
+ if (rect.Contains(fx, fy))
return FWL_WGTHITTEST_VScrollBar;
- }
}
if (IsShowScrollBar(FALSE)) {
CFX_RectF rect;
m_pHorzScrollBar->GetWidgetRect(rect);
- if (rect.Contains(fx, fy)) {
+ if (rect.Contains(fx, fy))
return FWL_WGTHITTEST_HScrollBar;
- }
}
}
- if (m_rtClient.Contains(fx, fy)) {
+ if (m_rtClient.Contains(fx, fy))
return FWL_WGTHITTEST_Edit;
- }
return FWL_WGTHITTEST_Unknown;
}
-#define FX_EDIT_ISLATINWORD(u) \
- (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \
- (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0) || \
- u == 0x0027)
-static void AddSquigglyPath(CFX_Path& PathData,
- FX_FLOAT fStartX,
- FX_FLOAT fEndX,
- FX_FLOAT fY,
- FX_FLOAT fStep) {
- PathData.MoveTo(fStartX, fY);
- FX_FLOAT fx;
- int32_t i;
- for (i = 1, fx = fStartX + fStep; fx < fEndX; fx += fStep, i++) {
- PathData.LineTo(fx, fY + (i & 1) * fStep);
- }
-}
+
void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData,
int32_t nStart,
int32_t nCount,
@@ -358,7 +363,7 @@ void CFWL_EditImp::AddSpellCheckObj(CFX_Path& PathData,
fStep = txtEdtParams->fFontSize / 16.0f;
fStartX = rectText.left + fOffSetX;
fEndX = fStartX + rectText.Width();
- AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
+ AddSquigglyPath(&PathData, fStartX, fEndX, fY, fStep);
}
}
int32_t CFWL_EditImp::GetWordAtPoint(CFX_PointF pointf, int32_t& nCount) {
@@ -1215,57 +1220,48 @@ FX_BOOL CFWL_EditImp::UpdateOffset() {
IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
return FALSE;
+
CFX_RectF rtFDE = pPage->GetContentsBox();
rtFDE.Offset(fOffSetX, fOffSetY);
if (rtFDE.right() < rtEidt.right() && m_fScrollOffsetX > 0) {
m_fScrollOffsetX += rtFDE.right() - rtEidt.right();
- if (m_fScrollOffsetX < 0) {
- m_fScrollOffsetX = 0;
- }
+ m_fScrollOffsetX = std::max(m_fScrollOffsetX, 0.0f);
}
if (rtFDE.bottom() < rtEidt.bottom() && m_fScrollOffsetY > 0) {
m_fScrollOffsetY += rtFDE.bottom() - rtEidt.bottom();
- if (m_fScrollOffsetY < 0) {
- m_fScrollOffsetY = 0;
- }
+ m_fScrollOffsetY = std::max(m_fScrollOffsetY, 0.0f);
}
return FALSE;
- } else {
- FX_FLOAT offsetX = 0.0;
- FX_FLOAT offsetY = 0.0;
- if (rtCaret.left < rtEidt.left) {
- offsetX = rtCaret.left - rtEidt.left;
- }
- if (rtCaret.right() > rtEidt.right()) {
- offsetX = rtCaret.right() - rtEidt.right();
- }
- if (rtCaret.top < rtEidt.top) {
- offsetY = rtCaret.top - rtEidt.top;
- }
- if (rtCaret.bottom() > rtEidt.bottom()) {
- offsetY = rtCaret.bottom() - rtEidt.bottom();
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption)) {
- m_fScrollOffsetX += offsetX;
- }
- if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption)) {
- m_fScrollOffsetY += offsetY;
- }
- if (m_fFontSize > m_rtEngine.height) {
- m_fScrollOffsetY = 0;
- }
- return TRUE;
}
+
+ FX_FLOAT offsetX = 0.0;
+ FX_FLOAT offsetY = 0.0;
+ if (rtCaret.left < rtEidt.left)
+ offsetX = rtCaret.left - rtEidt.left;
+ if (rtCaret.right() > rtEidt.right())
+ offsetX = rtCaret.right() - rtEidt.right();
+ if (rtCaret.top < rtEidt.top)
+ offsetY = rtCaret.top - rtEidt.top;
+ if (rtCaret.bottom() > rtEidt.bottom())
+ offsetY = rtCaret.bottom() - rtEidt.bottom();
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_HSelfAdaption))
+ m_fScrollOffsetX += offsetX;
+ if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_VSelfAdaption))
+ m_fScrollOffsetY += offsetY;
+ if (m_fFontSize > m_rtEngine.height)
+ m_fScrollOffsetY = 0;
+ return TRUE;
}
+
FX_BOOL CFWL_EditImp::UpdateOffset(IFWL_ScrollBar* pScrollBar,
FX_FLOAT fPosChanged) {
- if (pScrollBar == m_pHorzScrollBar.get()) {
+ if (pScrollBar == m_pHorzScrollBar.get())
m_fScrollOffsetX += fPosChanged;
- } else {
+ else
m_fScrollOffsetY += fPosChanged;
- }
return TRUE;
}
+
void CFWL_EditImp::UpdateVAlignment() {
IFDE_TxtEdtPage* pPage = m_pEdtEngine->GetPage(0);
if (!pPage)
@@ -1592,10 +1588,12 @@ void CFWL_EditImp::LayoutScrollBar() {
UpdateScroll();
}
}
+
void CFWL_EditImp::DeviceToEngine(CFX_PointF& pt) {
- pt.x += -m_rtEngine.left + m_fScrollOffsetX;
- pt.y += -m_rtEngine.top - m_fVAlignOffset + m_fScrollOffsetY;
+ pt.x += m_fScrollOffsetX - m_rtEngine.left;
+ pt.y += m_fScrollOffsetY - m_rtEngine.top - m_fVAlignOffset;
}
+
void CFWL_EditImp::InitScrollBar(FX_BOOL bVert) {
if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
return;
@@ -1619,14 +1617,15 @@ void CFWL_EditImp::InitEngine() {
FX_BOOL FWL_ShowCaret(IFWL_Widget* pWidget,
FX_BOOL bVisible,
const CFX_RectF* pRtAnchor) {
- CXFA_FFWidget* pXFAWidget = (CXFA_FFWidget*)pWidget->GetPrivateData(pWidget);
- if (!pXFAWidget) {
+ CXFA_FFWidget* pXFAWidget =
+ static_cast<CXFA_FFWidget*>(pWidget->GetPrivateData(pWidget));
+ if (!pXFAWidget)
return FALSE;
- }
+
IXFA_DocProvider* pDocProvider = pXFAWidget->GetDoc()->GetDocProvider();
- if (!pDocProvider) {
+ if (!pDocProvider)
return FALSE;
- }
+
if (bVisible) {
CFX_Matrix mt;
pXFAWidget->GetRotateMatrix(mt);