diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-02-07 16:36:39 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-08 01:36:02 +0000 |
commit | bba2a7cf30da9e84bcc14ef32dbb0bb944229219 (patch) | |
tree | 94a74de8d07b3e395bf6e08a62811a3a0d652d19 | |
parent | 55e026b7b6eec17b012c819c4a7d39e63094b5c4 (diff) | |
download | pdfium-bba2a7cf30da9e84bcc14ef32dbb0bb944229219.tar.xz |
Update to use CFX_Rect{F} and CFX_Matrix constructors.
This Cl updates the code to use the constructors instead of creating an
empty object and calling Set(). It also removes the various memsets of
the CFX_Rect{F} classes.
Change-Id: I6e20cec00866a38372858dcba5a30d31103172e4
Reviewed-on: https://pdfium-review.googlesource.com/2550
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
62 files changed, 507 insertions, 647 deletions
diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp index f9c02837a7..7714369df8 100644 --- a/core/fpdfapi/page/cpdf_page.cpp +++ b/core/fpdfapi/page/cpdf_page.cpp @@ -66,16 +66,17 @@ CPDF_Page::CPDF_Page(CPDF_Document* pDocument, switch (rotate) { case 0: - m_PageMatrix.Set(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom); + m_PageMatrix = CFX_Matrix(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom); break; case 1: - m_PageMatrix.Set(0, -1.0f, 1.0f, 0, -m_BBox.bottom, m_BBox.right); + m_PageMatrix = + CFX_Matrix(0, -1.0f, 1.0f, 0, -m_BBox.bottom, m_BBox.right); break; case 2: - m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top); + m_PageMatrix = CFX_Matrix(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top); break; case 3: - m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left); + m_PageMatrix = CFX_Matrix(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left); break; } @@ -128,7 +129,6 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, if (m_PageWidth == 0 || m_PageHeight == 0) { return; } - CFX_Matrix display_matrix; float x0 = 0; float y0 = 0; float x1 = 0; @@ -170,9 +170,8 @@ void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix, y2 = yPos; break; } - display_matrix.Set((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth, - (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight, x0, - y0); matrix = m_PageMatrix; - matrix.Concat(display_matrix); + matrix.Concat(CFX_Matrix((x2 - x0) / m_PageWidth, (y2 - y0) / m_PageWidth, + (x1 - x0) / m_PageHeight, (y1 - y0) / m_PageHeight, + x0, y0)); } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index 3dec01a52e..28f3594f47 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -673,7 +673,7 @@ void CPDF_StreamContentParser::Handle_BeginMarkedContent() { } void CPDF_StreamContentParser::Handle_BeginText() { - m_pCurStates->m_TextMatrix.Set(1.0f, 0, 0, 1.0f, 0, 0); + m_pCurStates->m_TextMatrix = CFX_Matrix(); OnChangeTextMatrix(); m_pCurStates->m_TextX = 0; m_pCurStates->m_TextY = 0; @@ -1365,8 +1365,9 @@ void CPDF_StreamContentParser::Handle_SetTextLeading() { } void CPDF_StreamContentParser::Handle_SetTextMatrix() { - m_pCurStates->m_TextMatrix.Set(GetNumber(5), GetNumber(4), GetNumber(3), - GetNumber(2), GetNumber(1), GetNumber(0)); + m_pCurStates->m_TextMatrix = + CFX_Matrix(GetNumber(5), GetNumber(4), GetNumber(3), GetNumber(2), + GetNumber(1), GetNumber(0)); OnChangeTextMatrix(); m_pCurStates->m_TextX = 0; m_pCurStates->m_TextY = 0; diff --git a/core/fpdfapi/page/cpdf_textobject.cpp b/core/fpdfapi/page/cpdf_textobject.cpp index 0979fcfb33..fb81a40d0c 100644 --- a/core/fpdfapi/page/cpdf_textobject.cpp +++ b/core/fpdfapi/page/cpdf_textobject.cpp @@ -162,8 +162,12 @@ const CPDF_TextObject* CPDF_TextObject::AsText() const { void CPDF_TextObject::GetTextMatrix(CFX_Matrix* pMatrix) const { const FX_FLOAT* pTextMatrix = m_TextState.GetMatrix(); - pMatrix->Set(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3], - m_PosX, m_PosY); + pMatrix->a = pTextMatrix[0]; + pMatrix->b = pTextMatrix[2]; + pMatrix->c = pTextMatrix[1]; + pMatrix->d = pTextMatrix[3]; + pMatrix->e = m_PosX; + pMatrix->f = m_PosY; } void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs, diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp index 64010e19e8..05a93702f1 100644 --- a/core/fpdfapi/parser/cpdf_array.cpp +++ b/core/fpdfapi/parser/cpdf_array.cpp @@ -78,11 +78,10 @@ CFX_FloatRect CPDF_Array::GetRect() { CFX_Matrix CPDF_Array::GetMatrix() { CFX_Matrix matrix; if (!IsArray() || m_Objects.size() != 6) - return matrix; + return CFX_Matrix(); - matrix.Set(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), GetNumberAt(3), - GetNumberAt(4), GetNumberAt(5)); - return matrix; + return CFX_Matrix(GetNumberAt(0), GetNumberAt(1), GetNumberAt(2), + GetNumberAt(3), GetNumberAt(4), GetNumberAt(5)); } CPDF_Object* CPDF_Array::GetObjectAt(size_t i) const { diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index 8fe7a31ce4..861aec4eea 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -327,8 +327,10 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap, ymax = pDomain->GetNumberAt(3); } CFX_Matrix mtDomain2Target = pDict->GetMatrixFor("Matrix"); - CFX_Matrix matrix, reverse_matrix; + CFX_Matrix matrix; matrix.SetReverse(*pObject2Bitmap); + + CFX_Matrix reverse_matrix; reverse_matrix.SetReverse(mtDomain2Target); matrix.Concat(reverse_matrix); int width = pBitmap->GetWidth(); @@ -891,6 +893,7 @@ std::unique_ptr<CFX_DIBitmap> DrawPatternBitmap( CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height); CFX_Matrix mtAdjust; mtAdjust.MatchRect(bitmap_rect, cell_bbox); + CFX_Matrix mtPattern2Bitmap = *pObject2Device; mtPattern2Bitmap.Concat(mtAdjust); CPDF_RenderOptions options; @@ -1987,16 +1990,19 @@ void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj, : pFont->m_FontFallbacks[charpos.m_FallbackFontPosition].get(); const CFX_PathData* pPath = font->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth); - if (!pPath) { + if (!pPath) continue; - } + CPDF_PathObject path; path.m_GraphState = textobj->m_GraphState; path.m_ColorState = textobj->m_ColorState; + CFX_Matrix matrix; - if (charpos.m_bGlyphAdjust) - matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], - charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + if (charpos.m_bGlyphAdjust) { + matrix = CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], + charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], + 0, 0); + } matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, charpos.m_OriginY); path.m_Path.Append(pPath, &matrix); diff --git a/core/fpdfapi/render/cpdf_type3cache.cpp b/core/fpdfapi/render/cpdf_type3cache.cpp index b27fdf507e..63cc780d1d 100644 --- a/core/fpdfapi/render/cpdf_type3cache.cpp +++ b/core/fpdfapi/render/cpdf_type3cache.cpp @@ -122,10 +122,10 @@ CFX_GlyphBitmap* CPDF_Type3Cache::RenderGlyph(CPDF_Type3Glyphs* pSize, return nullptr; CFX_DIBitmap* pBitmap = pChar->m_pBitmap.get(); - CFX_Matrix image_matrix, text_matrix; - image_matrix = pChar->m_ImageMatrix; - text_matrix.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0); + CFX_Matrix image_matrix = pChar->m_ImageMatrix; + CFX_Matrix text_matrix(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d, 0, 0); image_matrix.Concat(text_matrix); + std::unique_ptr<CFX_DIBitmap> pResBitmap; int left = 0; int top = 0; diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp index daf93414bf..19767650f3 100644 --- a/core/fpdfdoc/cpdf_defaultappearance.cpp +++ b/core/fpdfdoc/cpdf_defaultappearance.cpp @@ -209,16 +209,15 @@ CFX_ByteString CPDF_DefaultAppearance::GetTextMatrixString() { } CFX_Matrix CPDF_DefaultAppearance::GetTextMatrix() { - CFX_Matrix tm; if (m_csDA.IsEmpty()) - return tm; + return CFX_Matrix(); CPDF_SimpleParser syntax(m_csDA.AsStringC()); - if (syntax.FindTagParamFromStart("Tm", 6)) { - FX_FLOAT f[6]; - for (int i = 0; i < 6; i++) - f[i] = FX_atof(syntax.GetWord()); - tm.Set(f[0], f[1], f[2], f[3], f[4], f[5]); - } - return tm; + if (!syntax.FindTagParamFromStart("Tm", 6)) + return CFX_Matrix(); + + FX_FLOAT f[6]; + for (int i = 0; i < 6; i++) + f[i] = FX_atof(syntax.GetWord()); + return CFX_Matrix(f); } diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 9cde4f5026..a919aa51ec 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -239,9 +239,11 @@ std::vector<CFX_FloatRect> CPDF_TextPage::GetRectArray(int start, } if (bFlagNewRect) { FX_FLOAT orgX = info_curchar.m_OriginX, orgY = info_curchar.m_OriginY; - CFX_Matrix matrix, matrix_reverse; + CFX_Matrix matrix; info_curchar.m_pTextObj->GetTextMatrix(&matrix); matrix.Concat(info_curchar.m_Matrix); + + CFX_Matrix matrix_reverse; matrix_reverse.SetReverse(matrix); matrix_reverse.Transform(orgX, orgY); rect.left = info_curchar.m_CharBox.left; @@ -766,6 +768,7 @@ void CPDF_TextPage::ProcessTextObject( FX_FLOAT this_width = GetCharWidth(item.m_CharCode, pTextObj->GetFont()) * pTextObj->GetFontSize() / 1000; this_width = FXSYS_fabs(this_width); + CFX_Matrix this_matrix; pTextObj->GetTextMatrix(&this_matrix); this_width = FXSYS_fabs(this_width); @@ -1218,6 +1221,7 @@ CPDF_TextPage::TextOrientation CPDF_TextPage::GetTextObjectWritingMode( CPDF_TextObjectItem first, last; pTextObj->GetCharInfo(0, &first); pTextObj->GetCharInfo(nChars - 1, &last); + CFX_Matrix textMatrix; pTextObj->GetTextMatrix(&textMatrix); textMatrix.TransformPoint(first.m_OriginX, first.m_OriginY); @@ -1327,9 +1331,12 @@ CPDF_TextPage::GenerateCharacter CPDF_TextPage::ProcessInsertObject( this_width = FXSYS_fabs(this_width); FX_FLOAT threshold = last_width > this_width ? last_width / 4 : this_width / 4; - CFX_Matrix prev_matrix, prev_reverse; + + CFX_Matrix prev_matrix; m_pPreTextObj->GetTextMatrix(&prev_matrix); prev_matrix.Concat(m_perMatrix); + + CFX_Matrix prev_reverse; prev_reverse.SetReverse(prev_matrix); FX_FLOAT x = pObj->GetPosX(); FX_FLOAT y = pObj->GetPosY(); diff --git a/core/fxcrt/fx_basic_coords.cpp b/core/fxcrt/fx_basic_coords.cpp index d2bcc2b3ed..62cc4f5890 100644 --- a/core/fxcrt/fx_basic_coords.cpp +++ b/core/fxcrt/fx_basic_coords.cpp @@ -239,27 +239,7 @@ CFX_FloatRect CFX_FloatRect::GetBBox(const CFX_PointF* pPoints, int nPoints) { } return CFX_FloatRect(min_x, min_y, max_x, max_y); } -void CFX_Matrix::Set(FX_FLOAT other_a, - FX_FLOAT other_b, - FX_FLOAT other_c, - FX_FLOAT other_d, - FX_FLOAT other_e, - FX_FLOAT other_f) { - a = other_a; - b = other_b; - c = other_c; - d = other_d; - e = other_e; - f = other_f; -} -void CFX_Matrix::Set(const FX_FLOAT n[6]) { - a = n[0]; - b = n[1]; - c = n[2]; - d = n[3]; - e = n[4]; - f = n[5]; -} + void CFX_Matrix::SetReverse(const CFX_Matrix& m) { FX_FLOAT i = m.a * m.d - m.b * m.c; if (FXSYS_fabs(i) == 0) { @@ -284,6 +264,7 @@ static void FXCRT_Matrix_Concat(CFX_Matrix& m, FX_FLOAT ff = m1.e * m2.b + m1.f * m2.d + m2.f; m.a = aa, m.b = bb, m.c = cc, m.d = dd, m.e = ee, m.f = ff; } + void CFX_Matrix::Concat(FX_FLOAT a_in, FX_FLOAT b_in, FX_FLOAT c_in, @@ -291,10 +272,9 @@ void CFX_Matrix::Concat(FX_FLOAT a_in, FX_FLOAT e_in, FX_FLOAT f_in, bool bPrepended) { - CFX_Matrix m; - m.Set(a_in, b_in, c_in, d_in, e_in, f_in); - Concat(m, bPrepended); + Concat(CFX_Matrix(a_in, b_in, c_in, d_in, e_in, f_in), bPrepended); } + void CFX_Matrix::Concat(const CFX_Matrix& m, bool bPrepended) { if (bPrepended) { FXCRT_Matrix_Concat(*this, m, *this); @@ -338,17 +318,17 @@ void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) { f *= sy; } } + void CFX_Matrix::Rotate(FX_FLOAT fRadian, bool bPrepended) { FX_FLOAT cosValue = FXSYS_cos(fRadian); FX_FLOAT sinValue = FXSYS_sin(fRadian); - CFX_Matrix m; - m.Set(cosValue, sinValue, -sinValue, cosValue, 0, 0); - if (bPrepended) { + CFX_Matrix m(cosValue, sinValue, -sinValue, cosValue, 0, 0); + if (bPrepended) FXCRT_Matrix_Concat(*this, m, *this); - } else { + else FXCRT_Matrix_Concat(*this, *this, m); - } } + void CFX_Matrix::RotateAt(FX_FLOAT fRadian, FX_FLOAT dx, FX_FLOAT dy, @@ -357,17 +337,17 @@ void CFX_Matrix::RotateAt(FX_FLOAT fRadian, Rotate(fRadian, bPrepended); Translate(-dx, -dy, bPrepended); } + void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, bool bPrepended) { - CFX_Matrix m; - m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0); - if (bPrepended) { + CFX_Matrix m(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0); + if (bPrepended) FXCRT_Matrix_Concat(*this, m, *this); - } else { + else FXCRT_Matrix_Concat(*this, *this, m); - } } + void CFX_Matrix::MatchRect(const CFX_FloatRect& dest, const CFX_FloatRect& src) { FX_FLOAT fDiff = src.left - src.right; diff --git a/core/fxcrt/fx_coordinates.h b/core/fxcrt/fx_coordinates.h index f00675842d..359bf46884 100644 --- a/core/fxcrt/fx_coordinates.h +++ b/core/fxcrt/fx_coordinates.h @@ -270,48 +270,22 @@ class CFX_RTemplate { : left(p.x), top(p.y), width(dst_width), height(dst_height) {} CFX_RTemplate(const PointType& p1, const SizeType& s2) : left(p1.x), top(p1.y), width(s2.x), height(s2.y) {} - - void Set(BaseType dst_left, - BaseType dst_top, - BaseType dst_width, - BaseType dst_height) { - left = dst_left; - top = dst_top; - width = dst_width; - height = dst_height; - } - void Set(BaseType dst_left, BaseType dst_top, const SizeType& dst_size) { - left = dst_left; - top = dst_top; - width = dst_size.x; - height = dst_size.y; - } - void Set(const PointType& p, BaseType dst_width, BaseType dst_height) { - left = p.x; - top = p.y; - width = dst_width; - height = dst_height; - } - void Set(const PointType& p, const SizeType& s) { - left = p.x; - top = p.y; - width = s.x; - height = s.y; - } - void Set(const PointType& p1, const PointType& p2) { - left = p1.x; - top = p1.y; - width = p2.x - p1.x; - height = p2.y - p1.y; + CFX_RTemplate(const PointType& p1, const PointType& p2) + : left(p1.x), top(p1.y), width(p2.x - p1.x), height(p2.y - p1.y) { Normalize(); } - void Set(const PointType& p, const VectorType& v) { - left = p.x; - top = p.y; - width = v.x; - height = v.y; + CFX_RTemplate(const PointType& p, const VectorType& v) + : left(p.x), top(p.y), width(v.x), height(v.y) { Normalize(); } + + // NOLINTNEXTLINE(runtime/explicit) + CFX_RTemplate(const RectType& other) + : left(other.left), + top(other.top), + width(other.width), + height(other.height) {} + void Reset() { left = 0; top = 0; @@ -595,31 +569,40 @@ class CFX_Matrix { public: CFX_Matrix() { SetIdentity(); } + explicit CFX_Matrix(const FX_FLOAT n[6]) + : a(n[0]), b(n[1]), c(n[2]), d(n[3]), e(n[4]), f(n[5]) {} + + CFX_Matrix(const CFX_Matrix& other) + : a(other.a), + b(other.b), + c(other.c), + d(other.d), + e(other.e), + f(other.f) {} CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, - FX_FLOAT f1) { - a = a1; - b = b1; - c = c1; - d = d1; - e = e1; - f = f1; - } - - void Set(FX_FLOAT a, - FX_FLOAT b, - FX_FLOAT c, - FX_FLOAT d, - FX_FLOAT e, - FX_FLOAT f); - void Set(const FX_FLOAT n[6]); + FX_FLOAT f1) + : a(a1), b(b1), c(c1), d(d1), e(e1), f(f1) {} + + void operator=(const CFX_Matrix& other) { + a = other.a; + b = other.b; + c = other.c; + d = other.d; + e = other.e; + f = other.f; + } void SetIdentity() { - a = d = 1; - b = c = e = f = 0; + a = 1; + b = 0; + c = 0; + d = 1; + e = 0; + f = 0; } void SetReverse(const CFX_Matrix& m); diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp index fa361547a9..71d6dbaf86 100644 --- a/core/fxge/agg/fx_agg_driver.cpp +++ b/core/fxge/agg/fx_agg_driver.cpp @@ -1501,14 +1501,16 @@ bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, matrix1.a = std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b)); matrix1.d = matrix1.a; - matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, - pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, - 0); + matrix2 = CFX_Matrix( + pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, + pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, 0); + CFX_Matrix mtRervese; mtRervese.SetReverse(matrix2); matrix1 = *pObject2Device; matrix1.Concat(mtRervese); } + CAgg_PathData path_data; path_data.BuildPath(pPathData, &matrix1); agg::rasterizer_scanline_aa rasterizer; diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 7fc12fd362..6d7fb2e06a 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -35,12 +35,12 @@ bool CGDrawGlyphRun(CGContextRef pContext, if (nChars == 0) return true; - CFX_Matrix new_matrix; bool bNegSize = font_size < 0; if (bNegSize) font_size = -font_size; FX_FLOAT ori_x = pCharPos[0].m_OriginX, ori_y = pCharPos[0].m_OriginY; + CFX_Matrix new_matrix; new_matrix.Transform(ori_x, ori_y); if (pObject2Device) new_matrix.Concat(*pObject2Device); diff --git a/core/fxge/ge/cfx_renderdevice.cpp b/core/fxge/ge/cfx_renderdevice.cpp index 4353e0a414..2f3d1bb60e 100644 --- a/core/fxge/ge/cfx_renderdevice.cpp +++ b/core/fxge/ge/cfx_renderdevice.cpp @@ -1060,8 +1060,9 @@ bool CFX_RenderDevice::DrawTextPath(int nChars, const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; CFX_Matrix matrix; if (charpos.m_bGlyphAdjust) { - matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], - charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + matrix = CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], + charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], + 0, 0); } matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, charpos.m_OriginY); diff --git a/core/fxge/skia/fx_skia_device_unittest.cpp b/core/fxge/skia/fx_skia_device_unittest.cpp index c77c8f88e6..693cf1b616 100644 --- a/core/fxge/skia/fx_skia_device_unittest.cpp +++ b/core/fxge/skia/fx_skia_device_unittest.cpp @@ -46,7 +46,9 @@ void CommonTest(CFX_SkiaDeviceDriver* driver, const State& state) { driver->SaveState(); CFX_PathData path1; path1.AppendRect(0, 0, 1, 2); - CFX_Matrix matrix, matrix2; + + CFX_Matrix matrix; + CFX_Matrix matrix2; matrix2.Translate(1, 0); CFX_GraphStateData graphState; if (state.m_save == State::Save::kYes) diff --git a/core/fxge/win32/cfx_psrenderer.cpp b/core/fxge/win32/cfx_psrenderer.cpp index c01c4c0060..9970e21254 100644 --- a/core/fxge/win32/cfx_psrenderer.cpp +++ b/core/fxge/win32/cfx_psrenderer.cpp @@ -581,10 +581,13 @@ void CFX_PSRenderer::FindPSFontGlyph(CFX_FaceCache* pFaceCache, pPSFont->m_Glyphs[glyphindex].m_AdjustMatrix[3] = charpos.m_AdjustMatrix[3]; } pPSFont->m_nGlyphs++; + CFX_Matrix matrix; - if (charpos.m_bGlyphAdjust) - matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], - charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + if (charpos.m_bGlyphAdjust) { + matrix = + CFX_Matrix(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], + charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); + } matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0); const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); diff --git a/fpdfsdk/cpdfsdk_pageview.cpp b/fpdfsdk/cpdfsdk_pageview.cpp index 416adffbe6..aae903eeb1 100644 --- a/fpdfsdk/cpdfsdk_pageview.cpp +++ b/fpdfsdk/cpdfsdk_pageview.cpp @@ -97,11 +97,10 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, if (pPage->GetContext()->GetDocType() == DOCTYPE_DYNAMIC_XFA) { CFX_Graphics gs; gs.Create(pDevice); - CFX_RectF rectClip; - rectClip.Set(static_cast<FX_FLOAT>(pClip.left), - static_cast<FX_FLOAT>(pClip.top), - static_cast<FX_FLOAT>(pClip.Width()), - static_cast<FX_FLOAT>(pClip.Height())); + CFX_RectF rectClip(static_cast<FX_FLOAT>(pClip.left), + static_cast<FX_FLOAT>(pClip.top), + static_cast<FX_FLOAT>(pClip.Width()), + static_cast<FX_FLOAT>(pClip.Height())); gs.SetClipRect(rectClip); std::unique_ptr<CXFA_RenderContext> pRenderContext(new CXFA_RenderContext); CXFA_RenderOptions renderOptions; diff --git a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp index eff351b55d..8d511fcc96 100644 --- a/fpdfsdk/cpdfsdk_xfawidgethandler.cpp +++ b/fpdfsdk/cpdfsdk_xfawidgethandler.cpp @@ -56,9 +56,7 @@ void CPDFSDK_XFAWidgetHandler::OnDraw(CPDFSDK_PageView* pPageView, CFX_Graphics gs; gs.Create(pDevice); - CFX_Matrix mt; - mt = *pUser2Device; - + CFX_Matrix mt = *pUser2Device; bool bIsHighlight = false; if (pPageView->GetFormFillEnv()->GetFocusAnnot() != pAnnot) bIsHighlight = true; diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp index 281057a6ac..71feb54bef 100644 --- a/fpdfsdk/formfiller/cffl_formfiller.cpp +++ b/fpdfsdk/formfiller/cffl_formfiller.cpp @@ -395,6 +395,7 @@ CFX_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) { if (pPrivateData->pPageView) { CFX_Matrix mtPageView; pPrivateData->pPageView->GetCurrentMatrix(mtPageView); + CFX_Matrix mt = GetCurMatrix(); mt.Concat(mtPageView); diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp index c1dc0df73e..8aa6ec0fb9 100644 --- a/fpdfsdk/fpdfview.cpp +++ b/fpdfsdk/fpdfview.cpp @@ -756,14 +756,8 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmapWithMatrix(FPDF_BITMAP bitmap, CFX_Matrix transform_matrix = pPage->GetPageMatrix(); if (matrix) { - CFX_Matrix cmatrix; - cmatrix.a = matrix->a; - cmatrix.b = matrix->b; - cmatrix.c = matrix->c; - cmatrix.d = matrix->d; - cmatrix.e = matrix->e; - cmatrix.f = matrix->f; - transform_matrix.Concat(cmatrix); + transform_matrix.Concat(CFX_Matrix(matrix->a, matrix->b, matrix->c, + matrix->d, matrix->e, matrix->f)); } CFX_FloatRect clipping_rect; diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 8cc325009b..8011295f96 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -156,12 +156,12 @@ void CPDFXFA_Page::DeviceToPage(int start_x, if (!m_pPDFPage && !m_pXFAPageView) return; - CFX_Matrix page2device; - CFX_Matrix device2page; FX_FLOAT page_x_f, page_y_f; + CFX_Matrix page2device; GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate); + CFX_Matrix device2page; device2page.SetReverse(page2device); device2page.Transform((FX_FLOAT)(device_x), (FX_FLOAT)(device_y), page_x_f, page_y_f); @@ -182,9 +182,9 @@ void CPDFXFA_Page::PageToDevice(int start_x, if (!m_pPDFPage && !m_pXFAPageView) return; - CFX_Matrix page2device; FX_FLOAT device_x_f, device_y_f; + CFX_Matrix page2device; GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y, rotate); page2device.Transform(((FX_FLOAT)page_x), ((FX_FLOAT)page_y), device_x_f, @@ -207,8 +207,7 @@ void CPDFXFA_Page::GetDisplayMatrix(CFX_Matrix& matrix, switch (nDocType) { case DOCTYPE_DYNAMIC_XFA: { if (m_pXFAPageView) { - CFX_Rect rect; - rect.Set(xPos, yPos, xSize, ySize); + CFX_Rect rect(xPos, yPos, xSize, ySize); m_pXFAPageView->GetDisplayMatrix(matrix, rect, iRotate); } } break; diff --git a/xfa/fde/cfde_path.cpp b/xfa/fde/cfde_path.cpp index cd65d9ee09..15d33339bf 100644 --- a/xfa/fde/cfde_path.cpp +++ b/xfa/fde/cfde_path.cpp @@ -255,7 +255,7 @@ void CFDE_Path::AddRectangle(const CFX_RectF& rect) { void CFDE_Path::GetBBox(CFX_RectF& bbox) const { CFX_FloatRect rect = m_Path.GetBoundingBox(); - bbox.Set(rect.left, rect.top, rect.Width(), rect.Height()); + bbox = CFX_RectF(rect.left, rect.top, rect.Width(), rect.Height()); bbox.Normalize(); } @@ -263,6 +263,6 @@ void CFDE_Path::GetBBox(CFX_RectF& bbox, FX_FLOAT fLineWidth, FX_FLOAT fMiterLimit) const { CFX_FloatRect rect = m_Path.GetBoundingBox(fLineWidth, fMiterLimit); - bbox.Set(rect.left, rect.top, rect.Width(), rect.Height()); + bbox = CFX_RectF(rect.left, rect.top, rect.Width(), rect.Height()); bbox.Normalize(); } diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp index 7ef6b3ff06..a61f6ab4d9 100644 --- a/xfa/fde/cfde_txtedtengine.cpp +++ b/xfa/fde/cfde_txtedtengine.cpp @@ -69,7 +69,6 @@ CFDE_TxtEdtEngine::CFDE_TxtEdtEngine() m_nFirstLineEnd(FDE_TXTEDIT_LINEEND_Auto), m_bAutoLineEnd(true), m_wLineEnd(kUnicodeParagraphSeparator) { - FXSYS_memset(&m_rtCaret, 0, sizeof(CFX_RectF)); m_bAutoLineEnd = (m_Param.nLineEnd == FDE_TXTEDIT_LINEEND_Auto); } @@ -663,14 +662,14 @@ int32_t CFDE_TxtEdtEngine::DoLayout(IFX_Pause* pPause) { void CFDE_TxtEdtEngine::EndLayout() { UpdatePages(); int32_t nLength = GetTextLength(); - if (m_nCaret > nLength) { + if (m_nCaret > nLength) m_nCaret = nLength; - } + int32_t nIndex = m_nCaret; - if (!m_bBefore) { + if (!m_bBefore) nIndex--; - } - m_rtCaret.Set(0, 0, 1, m_Param.fFontSize); + + m_rtCaret = CFX_RectF(0, 0, 1, m_Param.fFontSize); Unlock(); } @@ -1381,12 +1380,11 @@ bool CFDE_TxtEdtEngine::IsFitArea(CFX_WideString& wsText) { pTextOut->SetLineSpace(m_Param.fLineSpace); pTextOut->SetFont(m_Param.pFont); pTextOut->SetFontSize(m_Param.fFontSize); - CFX_RectF rcText; - FXSYS_memset(&rcText, 0, sizeof(rcText)); uint32_t dwStyle = 0; if (!(m_Param.dwMode & FDE_TEXTEDITMODE_MultiLines)) dwStyle |= FDE_TTOSTYLE_SingleLine; + CFX_RectF rcText; if (m_Param.dwMode & FDE_TEXTEDITMODE_AutoLineWrap) { dwStyle |= FDE_TTOSTYLE_LineWrap; rcText.width = m_Param.fPlateWidth; diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp index a049548269..cfb7f83b2c 100644 --- a/xfa/fde/cfde_txtedtpage.cpp +++ b/xfa/fde/cfde_txtedtpage.cpp @@ -39,10 +39,6 @@ CFDE_TxtEdtPage::CFDE_TxtEdtPage(CFDE_TxtEdtEngine* pEngine, int32_t nPageIndex) m_nCharCount(0), m_nPageIndex(nPageIndex), m_bLoaded(false) { - FXSYS_memset(&m_rtPage, 0, sizeof(CFX_RectF)); - FXSYS_memset(&m_rtPageMargin, 0, sizeof(CFX_RectF)); - FXSYS_memset(&m_rtPageContents, 0, sizeof(CFX_RectF)); - FXSYS_memset(&m_rtPageCanvas, 0, sizeof(CFX_RectF)); } CFDE_TxtEdtPage::~CFDE_TxtEdtPage() { diff --git a/xfa/fde/fde_gedevice.cpp b/xfa/fde/fde_gedevice.cpp index b5220cdf13..8b5ef1c40e 100644 --- a/xfa/fde/fde_gedevice.cpp +++ b/xfa/fde/fde_gedevice.cpp @@ -24,29 +24,36 @@ CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, ASSERT(pDevice); FX_RECT rt = m_pDevice->GetClipBox(); - m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), - (FX_FLOAT)rt.Height()); + m_rtClip = CFX_RectF( + static_cast<FX_FLOAT>(rt.left), static_cast<FX_FLOAT>(rt.top), + static_cast<FX_FLOAT>(rt.Width()), static_cast<FX_FLOAT>(rt.Height())); } CFDE_RenderDevice::~CFDE_RenderDevice() { if (m_bOwnerDevice) delete m_pDevice; } + int32_t CFDE_RenderDevice::GetWidth() const { return m_pDevice->GetWidth(); } + int32_t CFDE_RenderDevice::GetHeight() const { return m_pDevice->GetHeight(); } + void CFDE_RenderDevice::SaveState() { m_pDevice->SaveState(); } + void CFDE_RenderDevice::RestoreState() { m_pDevice->RestoreState(false); const FX_RECT& rt = m_pDevice->GetClipBox(); - m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), - (FX_FLOAT)rt.Height()); + m_rtClip = CFX_RectF( + static_cast<FX_FLOAT>(rt.left), static_cast<FX_FLOAT>(rt.top), + static_cast<FX_FLOAT>(rt.Width()), static_cast<FX_FLOAT>(rt.Height())); } + bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { m_rtClip = rtClip; return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left), @@ -54,21 +61,27 @@ bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { (int32_t)FXSYS_ceil(rtClip.right()), (int32_t)FXSYS_ceil(rtClip.bottom()))); } + const CFX_RectF& CFDE_RenderDevice::GetClipRect() { return m_rtClip; } + bool CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) { return false; } + CFDE_Path* CFDE_RenderDevice::GetClipPath() const { return nullptr; } + FX_FLOAT CFDE_RenderDevice::GetDpiX() const { return 96; } + FX_FLOAT CFDE_RenderDevice::GetDpiY() const { return 96; } + bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, const CFX_RectF* pSrcRect, const CFX_RectF& dstRect, @@ -78,11 +91,13 @@ bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, if (pSrcRect) { srcRect = *pSrcRect; } else { - srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); + srcRect = CFX_RectF(0, 0, static_cast<FX_FLOAT>(pDib->GetWidth()), + static_cast<FX_FLOAT>(pDib->GetHeight())); } - if (srcRect.IsEmpty()) { + + if (srcRect.IsEmpty()) return false; - } + CFX_Matrix dib2fxdev; if (pImgMatrix) { dib2fxdev = *pImgMatrix; @@ -104,6 +119,7 @@ bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, m_pDevice->CancelDIBits(handle); return !!handle; } + bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, const CFX_RetainPtr<CFGAS_GEFont>& pFont, const FXTEXT_CHARPOS* pCharPos, @@ -207,6 +223,7 @@ bool CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, path.AddBezier(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const std::vector<CFX_PointF>& points, @@ -217,6 +234,7 @@ bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, path.AddCurve(points, bClosed, fTension); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, @@ -225,6 +243,7 @@ bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, path.AddEllipse(rect); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const std::vector<CFX_PointF>& points, @@ -233,6 +252,7 @@ bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, path.AddLines(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_PointF& pt1, @@ -242,6 +262,7 @@ bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, path.AddLine(pt1, pt2); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFDE_Path* pPath, @@ -257,6 +278,7 @@ bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, &graphState, 0, pPen->GetColor(), 0); } + bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const std::vector<CFX_PointF>& points, @@ -265,6 +287,7 @@ bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, path.AddPolygon(points); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, FX_FLOAT fPenWidth, const CFX_RectF& rect, @@ -273,6 +296,7 @@ bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, path.AddRectangle(rect); return DrawPath(pPen, fPenWidth, &path, pMatrix); } + bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, const std::vector<CFX_PointF>& points, FX_FLOAT fTension, @@ -281,6 +305,7 @@ bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, path.AddCurve(points, true, fTension); return FillPath(pBrush, &path, pMatrix); } + bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { @@ -288,6 +313,7 @@ bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, path.AddEllipse(rect); return FillPath(pBrush, &path, pMatrix); } + bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, const std::vector<CFX_PointF>& points, const CFX_Matrix* pMatrix) { @@ -295,6 +321,7 @@ bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, path.AddPolygon(points); return FillPath(pBrush, &path, pMatrix); } + bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, const CFX_RectF& rect, const CFX_Matrix* pMatrix) { @@ -302,6 +329,7 @@ bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, path.AddRectangle(rect); return FillPath(pBrush, &path, pMatrix); } + bool CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen, FX_FLOAT fPenWidth, CFX_GraphStateData& graphState) { diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index ca5aa566e1..b126d4e583 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -138,8 +138,10 @@ void CFDE_TextOut::SetRenderDevice(CFX_RenderDevice* pDevice) { } void CFDE_TextOut::SetClipRect(const CFX_Rect& rtClip) { - m_rtClip.Set((FX_FLOAT)rtClip.left, (FX_FLOAT)rtClip.top, - (FX_FLOAT)rtClip.Width(), (FX_FLOAT)rtClip.Height()); + m_rtClip = CFX_RectF(static_cast<FX_FLOAT>(rtClip.left), + static_cast<FX_FLOAT>(rtClip.top), + static_cast<FX_FLOAT>(rtClip.Width()), + static_cast<FX_FLOAT>(rtClip.Height())); } void CFDE_TextOut::SetClipRect(const CFX_RectF& rtClip) { @@ -166,8 +168,8 @@ int32_t CFDE_TextOut::GetTotalLines() { void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, (FX_FLOAT)size.x, (FX_FLOAT)size.y); + CFX_RectF rtText(0.0f, 0.0f, static_cast<FX_FLOAT>(size.x), + static_cast<FX_FLOAT>(size.y)); CalcSize(pwsStr, iLength, rtText); size.x = (int32_t)rtText.Width(); size.y = (int32_t)rtText.Height(); @@ -176,8 +178,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); + CFX_RectF rtText(0.0f, 0.0f, size.x, size.y); CalcSize(pwsStr, iLength, rtText); size.x = rtText.Width(); size.y = rtText.Height(); @@ -186,12 +187,15 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.Width(), - (FX_FLOAT)rect.Height()); + CFX_RectF rtText(static_cast<FX_FLOAT>(rect.left), + static_cast<FX_FLOAT>(rect.top), + static_cast<FX_FLOAT>(rect.Width()), + static_cast<FX_FLOAT>(rect.Height())); CalcSize(pwsStr, iLength, rtText); - rect.Set((int32_t)rtText.left, (int32_t)rtText.top, (int32_t)rtText.Width(), - (int32_t)rtText.Height()); + rect = CFX_Rect(static_cast<int32_t>(rtText.left), + static_cast<int32_t>(rtText.top), + static_cast<int32_t>(rtText.Width()), + static_cast<int32_t>(rtText.Height())); } void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, @@ -212,8 +216,7 @@ void CFDE_TextOut::CalcSize(const FX_WCHAR* pwsStr, void CFDE_TextOut::CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size) { - CFX_RectF rtText; - rtText.Set(0.0f, 0.0f, size.x, size.y); + CFX_RectF rtText(0.0f, 0.0f, size.x, size.y); CalcLogicSize(pwsStr, iLength, rtText); size.x = rtText.Width(); size.y = rtText.Height(); @@ -346,9 +349,8 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)x, (FX_FLOAT)y, m_fFontSize * 1000.0f, - m_fFontSize * 1000.0f); + CFX_RectF rtText(static_cast<FX_FLOAT>(x), static_cast<FX_FLOAT>(y), + m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawText(pwsStr, iLength, rtText); } @@ -356,25 +358,23 @@ void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, FX_FLOAT x, FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect) { - CFX_RectF rtText; - rtText.Set((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, (FX_FLOAT)rect.width, - (FX_FLOAT)rect.height); + CFX_RectF rtText( + static_cast<FX_FLOAT>(rect.left), static_cast<FX_FLOAT>(rect.top), + static_cast<FX_FLOAT>(rect.width), static_cast<FX_FLOAT>(rect.height)); DrawText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { - CFX_RectF rtText; - rtText.Set(rect.left, rect.top, rect.width, rect.height); + CFX_RectF rtText(rect.left, rect.top, rect.width, rect.height); CFX_Matrix rm; rm.SetReverse(m_Matrix); rm.TransformRect(rtText); @@ -385,17 +385,15 @@ void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, int32_t iLength, FX_FLOAT x, FX_FLOAT y) { - CFX_RectF rtText; - rtText.Set(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); + CFX_RectF rtText(x, y, m_fFontSize * 1000.0f, m_fFontSize * 1000.0f); DrawLogicText(pwsStr, iLength, rtText); } void CFDE_TextOut::DrawLogicText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect) { - CFX_RectF rtClip; - rtClip.Set(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, - m_rtLogicClip.height); + CFX_RectF rtClip(m_rtLogicClip.left, m_rtLogicClip.top, m_rtLogicClip.width, + m_rtLogicClip.height); m_Matrix.TransformRect(rtClip); DrawText(pwsStr, iLength, rect, rtClip); } diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp index d0e7f13c3a..a175202e7d 100644 --- a/xfa/fgas/font/cfgas_gefont.cpp +++ b/xfa/fgas/font/cfgas_gefont.cpp @@ -325,8 +325,7 @@ bool CFGAS_GEFont::GetCharBBoxInternal(FX_WCHAR wUnicode, if (pFont.Get() == this) { FX_RECT rtBBox; if (m_pFont->GetGlyphBBox(iGlyph, rtBBox)) { - CFX_Rect rt; - rt.Set(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); + CFX_Rect rt(rtBBox.left, rtBBox.top, rtBBox.Width(), rtBBox.Height()); int32_t index = m_pRectArray->Add(rt); pRect = m_pRectArray->GetPtrAt(index); m_BBoxMap[wUnicode] = pRect; diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 7463eaa6c1..62e33fe9c2 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -1302,7 +1302,6 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, } if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) { CFX_Rect rtBBox; - rtBBox.Reset(); if (pFont->GetCharBBox(wForm, &rtBBox, bMBCSCode)) { ptOffset.x = fFontSize * (850 - rtBBox.right()) / 1000.0f; ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; @@ -1418,7 +1417,6 @@ int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, bCharBBox = false; CFX_Rect bbox; - bbox.Set(0, 0, 0, 0); if (bCharBBox) bCharBBox = pFont->GetBBox(&bbox); diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 74f8cb4756..69773f8eb0 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -1461,7 +1461,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } if (chartype == FX_CHARTYPE_Combination) { CFX_Rect rtBBox; - rtBBox.Reset(); if (pFont->GetCharBBox(wForm, &rtBBox, false)) { pCharPos->m_OriginY = fYBase + fFontSize - @@ -1472,7 +1471,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, if ((dwLastProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination) { CFX_Rect rtBox; - rtBox.Reset(); if (pFont->GetCharBBox(wLast, &rtBox, false)) { pCharPos->m_OriginY -= fFontSize * rtBox.height / iMaxHeight; } @@ -1487,7 +1485,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, } if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) { CFX_Rect rtBBox; - rtBBox.Reset(); if (pFont->GetCharBBox(wForm, &rtBBox, false)) { ptOffset.x = fFontSize * (850 - rtBBox.right()) / iMaxHeight; ptOffset.y = fFontSize * (iAscent - rtBBox.top - 150) / iMaxHeight; @@ -1602,7 +1599,6 @@ int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, bCharBBox = false; CFX_Rect bbox; - bbox.Set(0, 0, 0, 0); if (bCharBBox) bCharBBox = pFont->GetBBox(&bbox); diff --git a/xfa/fwl/cfwl_caret.cpp b/xfa/fwl/cfwl_caret.cpp index 4a95b0924b..da57cb408c 100644 --- a/xfa/fwl/cfwl_caret.cpp +++ b/xfa/fwl/cfwl_caret.cpp @@ -76,13 +76,10 @@ void CFWL_Caret::DrawCaretBK(CFX_Graphics* pGraphics, if (!(m_pProperties->m_dwStates & FWL_STATE_CAT_HightLight)) return; - CFX_RectF rect = GetWidgetRect(); - rect.Set(0, 0, rect.width, rect.height); - CFWL_ThemeBackground param; param.m_pWidget = this; param.m_pGraphics = pGraphics; - param.m_rtPart = rect; + param.m_rtPart = CFX_RectF(0, 0, GetWidgetRect().Size()); param.m_iPart = CFWL_Part::Background; param.m_dwStates = CFWL_PartState_HightLight; if (pMatrix) @@ -107,6 +104,5 @@ void CFWL_Caret::Timer::Run(CFWL_TimerInfo* pTimerInfo) { pCaret->RemoveStates(FWL_STATE_CAT_HightLight); CFX_RectF rt = pCaret->GetWidgetRect(); - rt.Set(0, 0, rt.width + 1, rt.height); - pCaret->RepaintRect(rt); + pCaret->RepaintRect(CFX_RectF(0, 0, rt.width + 1, rt.height)); } diff --git a/xfa/fwl/cfwl_checkbox.cpp b/xfa/fwl/cfwl_checkbox.cpp index 4a2d2dbaee..2dc0808831 100644 --- a/xfa/fwl/cfwl_checkbox.cpp +++ b/xfa/fwl/cfwl_checkbox.cpp @@ -129,27 +129,21 @@ void CFWL_CheckBox::Layout() { FXSYS_round(m_pProperties->m_rtWidget.height); m_rtClient = GetClientRect(); - FX_FLOAT fBoxTop = m_rtClient.top; - FX_FLOAT fBoxLeft = m_rtClient.left; - FX_FLOAT fTextLeft = fBoxLeft + m_fBoxHeight; - FX_FLOAT fTextRight = m_rtClient.right(); - m_rtBox.Set(fBoxLeft, fBoxTop, m_fBoxHeight, m_fBoxHeight); - m_rtCaption.Set(fTextLeft, m_rtClient.top, fTextRight - fTextLeft, - m_rtClient.height); + FX_FLOAT fTextLeft = m_rtClient.left + m_fBoxHeight; + m_rtBox = CFX_RectF(m_rtClient.TopLeft(), m_fBoxHeight, m_fBoxHeight); + m_rtCaption = CFX_RectF(fTextLeft, m_rtClient.top, + m_rtClient.right() - fTextLeft, m_rtClient.height); m_rtCaption.Inflate(-kCaptionMargin, -kCaptionMargin); - CFX_RectF rtFocus; - rtFocus.Set(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, - m_rtCaption.height); + CFX_RectF rtFocus(m_rtCaption.left, m_rtCaption.top, m_rtCaption.width, + m_rtCaption.height); CalcTextRect(L"Check box", m_pProperties->m_pThemeProvider, m_dwTTOStyles, m_iTTOAlign, rtFocus); - FX_FLOAT fWidth = std::max(m_rtCaption.width, rtFocus.width); - FX_FLOAT fHeight = std::min(m_rtCaption.height, rtFocus.height); - FX_FLOAT fLeft = m_rtCaption.left; - FX_FLOAT fTop = m_rtCaption.top; - m_rtFocus.Set(fLeft, fTop, fWidth, fHeight); + m_rtFocus = CFX_RectF(m_rtCaption.TopLeft(), + std::max(m_rtCaption.width, rtFocus.width), + std::min(m_rtCaption.height, rtFocus.height)); m_rtFocus.Inflate(1, 1); } @@ -195,9 +189,8 @@ void CFWL_CheckBox::NextStates() { if (pCheckBox != this && pCheckBox->GetStates() & FWL_STATE_CKB_Checked) { pCheckBox->SetCheckState(0); - CFX_RectF rt = pCheckBox->GetWidgetRect(); - rt.left = rt.top = 0; - m_pWidgetMgr->RepaintWidget(pCheckBox, rt); + m_pWidgetMgr->RepaintWidget( + pCheckBox, CFX_RectF(0, 0, pCheckBox->GetWidgetRect().Size())); break; } } diff --git a/xfa/fwl/cfwl_combobox.cpp b/xfa/fwl/cfwl_combobox.cpp index 03d2921e65..a0a4cc0a79 100644 --- a/xfa/fwl/cfwl_combobox.cpp +++ b/xfa/fwl/cfwl_combobox.cpp @@ -326,9 +326,8 @@ void CFWL_ComboBox::ShowDropList(bool bActivate) { m_pListBox->ModifyStylesEx(dwStyleAdd, 0); m_rtList = m_pListBox->GetAutosizedWidgetRect(); - CFX_RectF rtAnchor; - rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rtAnchor(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); m_rtList.width = std::max(m_rtList.width, m_rtClient.width); m_rtProxy = m_rtList; @@ -378,14 +377,13 @@ void CFWL_ComboBox::Layout() { return; FX_FLOAT fBtn = theme->GetScrollBarWidth(); - m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, - m_rtClient.height); + m_rtBtn = CFX_RectF(m_rtClient.right() - fBtn, m_rtClient.top, fBtn, + m_rtClient.height); if (!IsDropDownStyle() || !m_pEdit) return; - CFX_RectF rtEdit; - rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, - m_rtClient.height); + CFX_RectF rtEdit(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, + m_rtClient.height); m_pEdit->SetWidgetRect(rtEdit); if (m_iCurSel >= 0) { @@ -552,11 +550,7 @@ void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { fPopupMin = fItemHeight * 3 + fBorder * 2; FX_FLOAT fPopupMax = fItemHeight * iItems + fBorder * 2; - CFX_RectF rtList; - rtList.left = m_rtClient.left; - rtList.width = m_pProperties->m_rtWidget.width; - rtList.top = 0; - rtList.height = 0; + CFX_RectF rtList(m_rtClient.left, 0, m_pProperties->m_rtWidget.width, 0); GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); m_pListBox->SetWidgetRect(rtList); @@ -606,9 +600,8 @@ void CFWL_ComboBox::DisForm_Update() { } FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { - CFX_RectF rect; - rect.Set(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width - m_rtBtn.width, + m_pProperties->m_rtWidget.height); if (rect.Contains(fx, fy)) return FWL_WidgetHit::Edit; if (m_rtBtn.Contains(fx, fy)) @@ -624,8 +617,7 @@ FWL_WidgetHit CFWL_ComboBox::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) { void CFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; - CFX_Matrix mtOrg; - mtOrg.Set(1, 0, 0, 1, 0, 0); + CFX_Matrix mtOrg(1, 0, 0, 1, 0, 0); if (pMatrix) mtOrg = *pMatrix; @@ -644,15 +636,13 @@ void CFWL_ComboBox::DisForm_DrawWidget(CFX_Graphics* pGraphics, if (m_pEdit) { CFX_RectF rtEdit = m_pEdit->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); + CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top); mt.Concat(mtOrg); m_pEdit->DrawWidget(pGraphics, &mt); } if (m_pListBox && DisForm_IsDropListVisible()) { CFX_RectF rtList = m_pListBox->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtList.left, rtList.top); + CFX_Matrix mt(1, 0, 0, 1, rtList.left, rtList.top); mt.Concat(mtOrg); m_pListBox->DrawWidget(pGraphics, &mt); } @@ -679,8 +669,9 @@ void CFWL_ComboBox::DisForm_Layout() { FX_FLOAT borderWidth = 1; FX_FLOAT fBtn = theme->GetScrollBarWidth(); if (!(GetStylesEx() & FWL_STYLEEXT_CMB_ReadOnly)) { - m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth, - fBtn - borderWidth, m_rtClient.height - 2 * borderWidth); + m_rtBtn = + CFX_RectF(m_rtClient.right() - fBtn, m_rtClient.top + borderWidth, + fBtn - borderWidth, m_rtClient.height - 2 * borderWidth); } CFWL_ThemePart part; @@ -692,9 +683,8 @@ void CFWL_ComboBox::DisForm_Layout() { if (!IsDropDownStyle() || !m_pEdit) return; - CFX_RectF rtEdit; - rtEdit.Set(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, - m_rtContent.height); + CFX_RectF rtEdit(m_rtContent.left, m_rtContent.top, m_rtContent.width - fBtn, + m_rtContent.height); m_pEdit->SetWidgetRect(rtEdit); if (m_iCurSel >= 0) { diff --git a/xfa/fwl/cfwl_comboboxproxy.cpp b/xfa/fwl/cfwl_comboboxproxy.cpp index 7bf311d198..35ff3ef6e0 100644 --- a/xfa/fwl/cfwl_comboboxproxy.cpp +++ b/xfa/fwl/cfwl_comboboxproxy.cpp @@ -70,11 +70,9 @@ void CFWL_ComboBoxProxy::OnLButtonDown(CFWL_Message* pMessage) { CFWL_NoteDriver* pDriver = static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); - CFX_RectF rtWidget = GetWidgetRect(); - rtWidget.left = rtWidget.top = 0; - CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - if (rtWidget.Contains(pMsg->m_fx, pMsg->m_fy)) { + if (CFX_RectF(0, 0, GetWidgetRect().Size()) + .Contains(pMsg->m_fx, pMsg->m_fy)) { m_bLButtonDown = true; pDriver->SetGrab(this, true); } else { @@ -99,9 +97,8 @@ void CFWL_ComboBoxProxy::OnLButtonUp(CFWL_Message* pMessage) { } CFWL_MessageMouse* pMsg = static_cast<CFWL_MessageMouse*>(pMessage); - CFX_RectF rect = GetWidgetRect(); - rect.left = rect.top = 0; - if (!rect.Contains(pMsg->m_fx, pMsg->m_fy) && + if (!CFX_RectF(0, 0, GetWidgetRect().Size()) + .Contains(pMsg->m_fx, pMsg->m_fy) && m_pComboBox->IsDropListVisible()) { m_pComboBox->ShowDropList(false); } diff --git a/xfa/fwl/cfwl_combolist.cpp b/xfa/fwl/cfwl_combolist.cpp index e78372cb26..d411f03ca3 100644 --- a/xfa/fwl/cfwl_combolist.cpp +++ b/xfa/fwl/cfwl_combolist.cpp @@ -231,9 +231,8 @@ void CFWL_ComboList::OnDropListKeyDown(CFWL_MessageKey* pKey) { SetSelection(hItem, hItem, true); ScrollToVisible(hItem); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rtInvalidate(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); RepaintRect(rtInvalidate); break; } diff --git a/xfa/fwl/cfwl_datetimepicker.cpp b/xfa/fwl/cfwl_datetimepicker.cpp index 861692f8e2..1a76727dac 100644 --- a/xfa/fwl/cfwl_datetimepicker.cpp +++ b/xfa/fwl/cfwl_datetimepicker.cpp @@ -33,8 +33,6 @@ CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app) m_iMonth(-1), m_iDay(-1), m_bLBtnDown(false) { - m_rtBtn.Set(0, 0, 0, 0); - m_pProperties->m_dwStyleExes = FWL_STYLEEXT_DTP_ShortDateFormat; auto monthProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); @@ -45,9 +43,8 @@ CFWL_DateTimePicker::CFWL_DateTimePicker(const CFWL_App* app) m_pMonthCal.reset( new CFWL_MonthCalendar(m_pOwnerApp, std::move(monthProp), this)); - CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); - rtMonthCal.Set(0, 0, rtMonthCal.width, rtMonthCal.height); - m_pMonthCal->SetWidgetRect(rtMonthCal); + m_pMonthCal->SetWidgetRect( + CFX_RectF(0, 0, m_pMonthCal->GetAutosizedWidgetRect().Size())); auto editProp = pdfium::MakeUnique<CFWL_WidgetProperties>(); editProp->m_pParent = this; @@ -85,12 +82,11 @@ void CFWL_DateTimePicker::Update() { return; FX_FLOAT fBtn = theme->GetScrollBarWidth(); - m_rtBtn.Set(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, - m_rtClient.height - 1); + m_rtBtn = CFX_RectF(m_rtClient.right() - fBtn, m_rtClient.top, fBtn - 1, + m_rtClient.height - 1); - CFX_RectF rtEdit; - rtEdit.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, - m_rtClient.height); + CFX_RectF rtEdit(m_rtClient.left, m_rtClient.top, m_rtClient.width - fBtn, + m_rtClient.height); m_pEdit->SetWidgetRect(rtEdit); ResetEditAlignment(); m_pEdit->Update(); @@ -98,9 +94,8 @@ void CFWL_DateTimePicker::Update() { m_pMonthCal->SetThemeProvider(m_pProperties->m_pThemeProvider); CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); - CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, - rtMonthCal.width, rtMonthCal.height); + CFX_RectF rtPopUp(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, + rtMonthCal.width, rtMonthCal.height); m_pMonthCal->SetWidgetRect(rtPopUp); m_pMonthCal->Update(); return; @@ -242,9 +237,8 @@ void CFWL_DateTimePicker::ShowMonthCalendar(bool bActivate) { CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); - CFX_RectF rtAnchor; - rtAnchor.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rtAnchor(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); GetPopupPos(0, rtMonth.height, rtAnchor, rtMonth); m_pForm->SetWidgetRect(rtMonth); @@ -377,9 +371,8 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { m_pEdit->GetDelegate()->OnProcessMessage(&msg); } - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rtInvalidate(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); CFX_RectF rtCal = m_pMonthCal->GetWidgetRect(); rtInvalidate.Union(rtCal); @@ -389,9 +382,8 @@ void CFWL_DateTimePicker::DisForm_ShowMonthCalendar(bool bActivate) { FWL_WidgetHit CFWL_DateTimePicker::DisForm_HitTest(FX_FLOAT fx, FX_FLOAT fy) const { - CFX_RectF rect; - rect.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rect(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); if (rect.Contains(fx, fy)) return FWL_WidgetHit::Edit; if (DisForm_IsNeedShowButton()) @@ -432,9 +424,8 @@ void CFWL_DateTimePicker::DisForm_Update() { m_fBtn = theme->GetScrollBarWidth(); CFX_RectF rtMonthCal = m_pMonthCal->GetAutosizedWidgetRect(); - CFX_RectF rtPopUp; - rtPopUp.Set(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, - rtMonthCal.width, rtMonthCal.height); + CFX_RectF rtPopUp(rtMonthCal.left, rtMonthCal.top + kDateTimePickerHeight, + rtMonthCal.width, rtMonthCal.height); m_pMonthCal->SetWidgetRect(rtPopUp); m_pMonthCal->Update(); } @@ -459,8 +450,7 @@ void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, if (m_pEdit) { CFX_RectF rtEdit = m_pEdit->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtEdit.left, rtEdit.top); + CFX_Matrix mt(1, 0, 0, 1, rtEdit.left, rtEdit.top); if (pMatrix) mt.Concat(*pMatrix); m_pEdit->DrawWidget(pGraphics, &mt); @@ -469,8 +459,7 @@ void CFWL_DateTimePicker::DisForm_DrawWidget(CFX_Graphics* pGraphics, return; CFX_RectF rtMonth = m_pMonthCal->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtMonth.left, rtMonth.top); + CFX_Matrix mt(1, 0, 0, 1, rtMonth.left, rtMonth.top); if (pMatrix) mt.Concat(*pMatrix); m_pMonthCal->DrawWidget(pGraphics, &mt); @@ -594,15 +583,16 @@ void CFWL_DateTimePicker::DisForm_OnFocusChanged(CFWL_Message* pMsg, if (bSet) { m_pProperties->m_dwStates |= FWL_WGTSTATE_Focused; if (m_pEdit && !(m_pEdit->GetStylesEx() & FWL_STYLEEXT_EDT_ReadOnly)) { - m_rtBtn.Set(m_pProperties->m_rtWidget.width, 0, m_fBtn, - m_pProperties->m_rtWidget.height - 1); + m_rtBtn = CFX_RectF(m_pProperties->m_rtWidget.width, 0, m_fBtn, + m_pProperties->m_rtWidget.height - 1); } rtInvalidate = m_rtBtn; pMsg->m_pDstTarget = m_pEdit.get(); m_pEdit->GetDelegate()->OnProcessMessage(pMsg); } else { m_pProperties->m_dwStates &= ~FWL_WGTSTATE_Focused; - m_rtBtn.Set(0, 0, 0, 0); + m_rtBtn.Reset(); + if (DisForm_IsMonthCalendarVisible()) ShowMonthCalendar(false); if (m_pEdit->GetStates() & FWL_WGTSTATE_Focused) { diff --git a/xfa/fwl/cfwl_edit.cpp b/xfa/fwl/cfwl_edit.cpp index 87a49e0f45..5c024785f0 100644 --- a/xfa/fwl/cfwl_edit.cpp +++ b/xfa/fwl/cfwl_edit.cpp @@ -112,7 +112,7 @@ CFX_RectF CFWL_Edit::GetAutosizedWidgetRect() { CFX_SizeF sz = CalcTextSize( m_EdtEngine.GetText(0, -1), m_pProperties->m_pThemeProvider, !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine)); - rect.Set(0, 0, sz.x, sz.y); + rect = CFX_RectF(0, 0, sz); } InflateWidgetRect(rect); return rect; @@ -231,8 +231,7 @@ void CFWL_Edit::DrawSpellCheck(CFX_Graphics* pGraphics, } if (!pathSpell.IsEmpty()) { CFX_RectF rtClip = m_rtEngine; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); + CFX_Matrix mt(1, 0, 0, 1, fOffSetX, fOffSetY); if (pMatrix) { pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); @@ -408,7 +407,6 @@ void CFWL_Edit::OnCaretChanged() { bool bRepaintContent = UpdateOffset(); UpdateCaret(); CFX_RectF rtInvalid; - rtInvalid.Set(0, 0, 0, 0); bool bRepaintScroll = false; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_MultiLine) { CFWL_ScrollBar* pScroll = UpdateScroll(); @@ -501,10 +499,9 @@ void CFWL_Edit::DrawTextBk(CFX_Graphics* pGraphics, CFX_RectF rtScroll = m_pHorzScrollBar->GetWidgetRect(); - CFX_RectF rtStatic; - rtStatic.Set(m_rtClient.right() - rtScroll.height, - m_rtClient.bottom() - rtScroll.height, rtScroll.height, - rtScroll.height); + CFX_RectF rtStatic(m_rtClient.right() - rtScroll.height, + m_rtClient.bottom() - rtScroll.height, rtScroll.height, + rtScroll.height); param.m_bStaticBackground = true; param.m_bMaximize = true; param.m_rtPart = rtStatic; @@ -525,8 +522,7 @@ void CFWL_Edit::DrawContent(CFX_Graphics* pGraphics, CFX_RectF rtClip = m_rtEngine; FX_FLOAT fOffSetX = m_rtEngine.left - m_fScrollOffsetX; FX_FLOAT fOffSetY = m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, fOffSetX, fOffSetY); + CFX_Matrix mt(1, 0, 0, 1, fOffSetX, fOffSetY); if (pMatrix) { pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); @@ -812,8 +808,7 @@ void CFWL_Edit::UpdateCaret() { rtFDE.Offset(m_rtEngine.left - m_fScrollOffsetX, m_rtEngine.top - m_fScrollOffsetY + m_fVAlignOffset); - CFX_RectF rtCaret; - rtCaret.Set(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); + CFX_RectF rtCaret(rtFDE.left, rtFDE.top, rtFDE.width, rtFDE.height); CFX_RectF rtClient = GetClientRect(); rtCaret.Intersect(rtClient); @@ -966,11 +961,11 @@ void CFWL_Edit::Layout() { CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, - m_rtClient.height); + rtVertScr = CFX_RectF(m_rtClient.right() + kEditMargin, m_rtClient.top, + fWidth, m_rtClient.height); } else { - rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, - m_rtClient.height); + rtVertScr = CFX_RectF(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, + m_rtClient.height); if (bShowHorzScrollbar) rtVertScr.height -= fWidth; m_rtEngine.width -= fWidth; @@ -988,11 +983,11 @@ void CFWL_Edit::Layout() { CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, - m_rtClient.width, fWidth); + rtHoriScr = CFX_RectF(m_rtClient.left, m_rtClient.bottom() + kEditMargin, + m_rtClient.width, fWidth); } else { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, - m_rtClient.width, fWidth); + rtHoriScr = CFX_RectF(m_rtClient.left, m_rtClient.bottom() - fWidth, + m_rtClient.width, fWidth); if (bShowVertScrollbar) rtHoriScr.width -= fWidth; m_rtEngine.height -= fWidth; @@ -1021,11 +1016,11 @@ void CFWL_Edit::LayoutScrollBar() { InitVerticalScrollBar(); CFX_RectF rtVertScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtVertScr.Set(m_rtClient.right() + kEditMargin, m_rtClient.top, fWidth, - m_rtClient.height); + rtVertScr = CFX_RectF(m_rtClient.right() + kEditMargin, m_rtClient.top, + fWidth, m_rtClient.height); } else { - rtVertScr.Set(m_rtClient.right() - fWidth, m_rtClient.top, fWidth, - m_rtClient.height); + rtVertScr = CFX_RectF(m_rtClient.right() - fWidth, m_rtClient.top, + fWidth, m_rtClient.height); if (bShowHorzScrollbar) rtVertScr.height -= fWidth; } @@ -1042,11 +1037,12 @@ void CFWL_Edit::LayoutScrollBar() { InitHorizontalScrollBar(); CFX_RectF rtHoriScr; if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_EDT_OuterScrollbar) { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() + kEditMargin, + rtHoriScr = + CFX_RectF(m_rtClient.left, m_rtClient.bottom() + kEditMargin, m_rtClient.width, fWidth); } else { - rtHoriScr.Set(m_rtClient.left, m_rtClient.bottom() - fWidth, - m_rtClient.width, fWidth); + rtHoriScr = CFX_RectF(m_rtClient.left, m_rtClient.bottom() - fWidth, + m_rtClient.width, fWidth); if (bShowVertScrollbar) rtHoriScr.width -= (fWidth); } @@ -1312,9 +1308,8 @@ void CFWL_Edit::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { if (!bRepaint) return; - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); + CFX_RectF rtInvalidate(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); RepaintRect(rtInvalidate); } @@ -1561,8 +1556,6 @@ bool CFWL_Edit::OnScroll(CFWL_ScrollBar* pScrollBar, UpdateCaret(); CFX_RectF rect = GetWidgetRect(); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, rect.width + 2, rect.height + 2); - RepaintRect(rtInvalidate); + RepaintRect(CFX_RectF(0, 0, rect.width + 2, rect.height + 2)); return true; } diff --git a/xfa/fwl/cfwl_form.cpp b/xfa/fwl/cfwl_form.cpp index d0d6ef211c..54a77dc65f 100644 --- a/xfa/fwl/cfwl_form.cpp +++ b/xfa/fwl/cfwl_form.cpp @@ -70,8 +70,7 @@ void CFWL_Form::Update() { FWL_WidgetHit CFWL_Form::HitTest(FX_FLOAT fx, FX_FLOAT fy) { GetAvailableTheme(); - CFX_RectF rtCap; - rtCap.Set(m_fCYBorder, m_fCXBorder, -2 * m_fCYBorder, 0 - m_fCXBorder); + CFX_RectF rtCap(m_fCYBorder, m_fCXBorder, -2 * m_fCYBorder, 0 - m_fCXBorder); return rtCap.Contains(fx, fy) ? FWL_WidgetHit::Titlebar : FWL_WidgetHit::Client; } diff --git a/xfa/fwl/cfwl_listbox.cpp b/xfa/fwl/cfwl_listbox.cpp index a7a568cd14..14d9886480 100644 --- a/xfa/fwl/cfwl_listbox.cpp +++ b/xfa/fwl/cfwl_listbox.cpp @@ -475,7 +475,6 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { m_rtClient = GetClientRect(); m_rtConent = m_rtClient; CFX_RectF rtUIMargin; - rtUIMargin.Set(0, 0, 0, 0); if (!m_pOuter) { CFWL_ThemePart part; part.m_pWidget = this; @@ -514,9 +513,9 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { if (!m_pVertScrollBar) InitVerticalScrollBar(); - CFX_RectF rtScrollBar; - rtScrollBar.Set(m_rtClient.right() - m_fScorllBarWidth, m_rtClient.top, - m_fScorllBarWidth, m_rtClient.height - 1); + CFX_RectF rtScrollBar(m_rtClient.right() - m_fScorllBarWidth, + m_rtClient.top, m_fScorllBarWidth, + m_rtClient.height - 1); if (bShowHorzScr) rtScrollBar.height -= m_fScorllBarWidth; @@ -547,9 +546,9 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { if (!m_pHorzScrollBar) InitHorizontalScrollBar(); - CFX_RectF rtScrollBar; - rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, - m_rtClient.width, m_fScorllBarWidth); + CFX_RectF rtScrollBar(m_rtClient.left, + m_rtClient.bottom() - m_fScorllBarWidth, + m_rtClient.width, m_fScorllBarWidth); if (bShowVertScr) rtScrollBar.width -= m_fScorllBarWidth; @@ -575,9 +574,9 @@ CFX_SizeF CFWL_ListBox::CalcSize(bool bAutoSize) { m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); } if (bShowVertScr && bShowHorzScr) { - m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, - m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, - m_fScorllBarWidth); + m_rtStatic = CFX_RectF(m_rtClient.right() - m_fScorllBarWidth, + m_rtClient.bottom() - m_fScorllBarWidth, + m_fScorllBarWidth, m_fScorllBarWidth); } return fs; } @@ -588,8 +587,7 @@ void CFWL_ListBox::UpdateItemSize(CFWL_ListItem* pItem, FX_FLOAT fItemHeight, bool bAutoSize) const { if (!bAutoSize && pItem) { - CFX_RectF rtItem; - rtItem.Set(0, size.y, fWidth, fItemHeight); + CFX_RectF rtItem(0, size.y, fWidth, fItemHeight); pItem->SetRect(rtItem); } size.x = fWidth; @@ -833,10 +831,8 @@ void CFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { SetFocusItem(pItem); ScrollToVisible(pItem); - CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, - m_pProperties->m_rtWidget.height); - RepaintRect(rtInvalidate); + RepaintRect(CFX_RectF(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height)); } bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, diff --git a/xfa/fwl/cfwl_monthcalendar.cpp b/xfa/fwl/cfwl_monthcalendar.cpp index d72e4a0d9a..2158da2064 100644 --- a/xfa/fwl/cfwl_monthcalendar.cpp +++ b/xfa/fwl/cfwl_monthcalendar.cpp @@ -125,8 +125,7 @@ FWL_Type CFWL_MonthCalendar::GetClassID() const { CFX_RectF CFWL_MonthCalendar::GetAutosizedWidgetRect() { CFX_SizeF fs = CalcSize(); - CFX_RectF rect; - rect.Set(0, 0, fs.x, fs.y); + CFX_RectF rect(0, 0, fs.x, fs.y); InflateWidgetRect(rect); return rect; } @@ -314,8 +313,9 @@ void CFWL_MonthCalendar::DrawWeek(CFX_Graphics* pGraphics, params.m_matrix.Concat(*pMatrix); for (int32_t i = 0; i < 7; i++) { - rtDayOfWeek.Set(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2), - m_rtWeek.top, m_szCell.x, m_szCell.y); + rtDayOfWeek = + CFX_RectF(m_rtWeek.left + i * (m_szCell.x + MONTHCAL_HMARGIN * 2), + m_rtWeek.top, m_szCell.x, m_szCell.y); params.m_rtPart = rtDayOfWeek; params.m_wsText = GetCapacityForDay(pTheme, params, i); params.m_dwTTOStyles = FDE_TTOSTYLE_SingleLine; @@ -469,18 +469,18 @@ CFX_SizeF CFWL_MonthCalendar::CalcSize() { void CFWL_MonthCalendar::CalcHeadSize() { FX_FLOAT fHeadHMargin = (m_rtClient.width - m_szHead.x) / 2; FX_FLOAT fHeadVMargin = (m_szCell.x - m_szHead.y) / 2; - m_rtHeadText.Set(m_rtClient.left + fHeadHMargin, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + - MONTHCAL_VMARGIN + fHeadVMargin, - m_szHead.x, m_szHead.y); + m_rtHeadText = CFX_RectF(m_rtClient.left + fHeadHMargin, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN + + MONTHCAL_VMARGIN + fHeadVMargin, + m_szHead.x, m_szHead.y); } void CFWL_MonthCalendar::CalcTodaySize() { - m_rtTodayFlag.Set( + m_rtTodayFlag = CFX_RectF( m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, m_szCell.x, m_szToday.y); - m_rtToday.Set( + m_rtToday = CFX_RectF( m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + m_szCell.x + MONTHCAL_HMARGIN * 2, m_rtDates.bottom() + MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN, @@ -490,30 +490,31 @@ void CFWL_MonthCalendar::CalcTodaySize() { void CFWL_MonthCalendar::Layout() { m_rtClient = GetClientRect(); - m_rtHead.Set( + m_rtHead = CFX_RectF( m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtClient.top, m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, m_szCell.x + (MONTHCAL_HEADER_BTN_VMARGIN + MONTHCAL_VMARGIN) * 2); - m_rtWeek.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, m_rtHead.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y + MONTHCAL_VMARGIN * 2); - m_rtLBtn.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtRBtn.Set(m_rtClient.left + m_rtClient.width - - MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, - m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, - m_szCell.x); - m_rtHSep.Set( + m_rtWeek = CFX_RectF(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtHead.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y + MONTHCAL_VMARGIN * 2); + m_rtLBtn = CFX_RectF(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtRBtn = CFX_RectF(m_rtClient.left + m_rtClient.width - + MONTHCAL_HEADER_BTN_HMARGIN - m_szCell.x, + m_rtClient.top + MONTHCAL_HEADER_BTN_VMARGIN, m_szCell.x, + m_szCell.x); + m_rtHSep = CFX_RectF( m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN, m_rtWeek.bottom() - MONTHCAL_VMARGIN, m_rtClient.width - (MONTHCAL_HEADER_BTN_HMARGIN + MONTHCAL_HMARGIN) * 2, MONTHCAL_HSEP_HEIGHT); - m_rtDates.Set(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, - m_rtWeek.bottom(), - m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, - m_szCell.y * (MONTHCAL_ROWS - 3) + - MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); + m_rtDates = CFX_RectF(m_rtClient.left + MONTHCAL_HEADER_BTN_HMARGIN, + m_rtWeek.bottom(), + m_rtClient.width - MONTHCAL_HEADER_BTN_HMARGIN * 2, + m_szCell.y * (MONTHCAL_ROWS - 3) + + MONTHCAL_VMARGIN * (MONTHCAL_ROWS - 3) * 2); CalDateItem(); } @@ -528,7 +529,7 @@ void CFWL_MonthCalendar::CalDateItem() { iWeekOfMonth++; bNewWeek = false; } - pDateInfo->rect.Set( + pDateInfo->rect = CFX_RectF( fLeft + pDateInfo->iDayOfWeek * (m_szCell.x + (MONTHCAL_HMARGIN * 2)), fTop + iWeekOfMonth * (m_szCell.y + (MONTHCAL_VMARGIN * 2)), m_szCell.x + (MONTHCAL_HMARGIN * 2), @@ -579,7 +580,6 @@ void CFWL_MonthCalendar::ResetDateItem() { dwStates |= FWL_ITEMSTATE_MCD_Selected; CFX_RectF rtDate; - rtDate.Set(0, 0, 0, 0); m_arrDates.push_back(pdfium::MakeUnique<DATEINFO>(i + 1, iDayOfWeek, dwStates, rtDate, wsDay)); iDayOfWeek++; @@ -787,8 +787,6 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { int32_t iCurSel = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); CFWL_DateTimePicker* pIPicker = static_cast<CFWL_DateTimePicker*>(m_pOuter); - CFX_RectF rt = pIPicker->GetFormProxy()->GetWidgetRect(); - rt.Set(0, 0, rt.width, rt.height); if (iCurSel > 0) { DATEINFO* lpDatesInfo = m_arrDates[iCurSel - 1].get(); CFX_RectF rtInvalidate(lpDatesInfo->rect); @@ -802,7 +800,9 @@ void CFWL_MonthCalendar::OnLButtonUp(CFWL_MessageMouse* pMsg) { pIPicker->ProcessSelChanged(m_iCurYear, m_iCurMonth, iCurSel); pIPicker->ShowMonthCalendar(false); - } else if (m_bFlag && (!rt.Contains(pMsg->m_fx, pMsg->m_fy))) { + } else if (m_bFlag && + (!CFX_RectF(0, 0, pIPicker->GetFormProxy()->GetWidgetRect().Size()) + .Contains(pMsg->m_fx, pMsg->m_fy))) { pIPicker->ShowMonthCalendar(false); } m_bFlag = false; @@ -845,7 +845,6 @@ void CFWL_MonthCalendar::DisForm_OnLButtonUp(CFWL_MessageMouse* pMsg) { void CFWL_MonthCalendar::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; CFX_RectF rtInvalidate; - rtInvalidate.Set(0, 0, 0, 0); if (m_rtDates.Contains(pMsg->m_fx, pMsg->m_fy)) { int32_t iHover = GetDayAtPoint(pMsg->m_fx, pMsg->m_fy); bRepaint = m_iHovered != iHover; diff --git a/xfa/fwl/cfwl_pushbutton.cpp b/xfa/fwl/cfwl_pushbutton.cpp index 3f0be45d10..d36d1d8ca7 100644 --- a/xfa/fwl/cfwl_pushbutton.cpp +++ b/xfa/fwl/cfwl_pushbutton.cpp @@ -24,10 +24,7 @@ CFWL_PushButton::CFWL_PushButton(const CFWL_App* app) : CFWL_Widget(app, pdfium::MakeUnique<CFWL_WidgetProperties>(), nullptr), m_bBtnDown(false), m_dwTTOStyles(FDE_TTOSTYLE_SingleLine), - m_iTTOAlign(FDE_TTOALIGNMENT_Center) { - m_rtClient.Set(0, 0, 0, 0); - m_rtCaption.Set(0, 0, 0, 0); -} + m_iTTOAlign(FDE_TTOALIGNMENT_Center) {} CFWL_PushButton::~CFWL_PushButton() {} diff --git a/xfa/fwl/cfwl_scrollbar.cpp b/xfa/fwl/cfwl_scrollbar.cpp index d4dd8885e3..b928d4c5b3 100644 --- a/xfa/fwl/cfwl_scrollbar.cpp +++ b/xfa/fwl/cfwl_scrollbar.cpp @@ -176,30 +176,22 @@ void CFWL_ScrollBar::CalcButtonLen() { } CFX_RectF CFWL_ScrollBar::CalcMinButtonRect() { - CFX_RectF rect; if (IsVertical()) - rect.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width, m_fButtonLen); - else - rect.Set(m_rtClient.left, m_rtClient.top, m_fButtonLen, m_rtClient.height); - return rect; + return CFX_RectF(m_rtClient.TopLeft(), m_rtClient.width, m_fButtonLen); + return CFX_RectF(m_rtClient.TopLeft(), m_fButtonLen, m_rtClient.height); } CFX_RectF CFWL_ScrollBar::CalcMaxButtonRect() { - CFX_RectF rect; if (IsVertical()) { - rect.Set(m_rtClient.left, m_rtClient.bottom() - m_fButtonLen, - m_rtClient.width, m_fButtonLen); - } else { - rect.Set(m_rtClient.right() - m_fButtonLen, m_rtClient.top, m_fButtonLen, - m_rtClient.height); + return CFX_RectF(m_rtClient.left, m_rtClient.bottom() - m_fButtonLen, + m_rtClient.width, m_fButtonLen); } - return rect; + return CFX_RectF(m_rtClient.right() - m_fButtonLen, m_rtClient.top, + m_fButtonLen, m_rtClient.height); } CFX_RectF CFWL_ScrollBar::CalcThumbButtonRect(const CFX_RectF& rtThumb) { CFX_RectF rect; - rect.Reset(); - if (!IsEnabled()) return rect; @@ -211,11 +203,11 @@ CFX_RectF CFWL_ScrollBar::CalcThumbButtonRect(const CFX_RectF& rtThumb) { FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; if (fRange < 0) { - if (IsVertical()) - rect.Set(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, 0); - else - rect.Set(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height); - return rect; + if (IsVertical()) { + return CFX_RectF(m_rtClient.left, m_rtMaxBtn.bottom(), m_rtClient.width, + 0); + } + return CFX_RectF(m_rtMaxBtn.right(), m_rtClient.top, 0, m_rtClient.height); } CFX_RectF rtClient = m_rtClient; @@ -251,8 +243,6 @@ CFX_RectF CFWL_ScrollBar::CalcThumbButtonRect(const CFX_RectF& rtThumb) { CFX_RectF CFWL_ScrollBar::CalcMinTrackRect(const CFX_RectF& rtMinRect) { CFX_RectF rect; - rect.Reset(); - if (m_bMinSize) { rect.left = rtMinRect.left; rect.top = rtMinRect.top; @@ -272,20 +262,18 @@ CFX_RectF CFWL_ScrollBar::CalcMinTrackRect(const CFX_RectF& rtMinRect) { } CFX_RectF CFWL_ScrollBar::CalcMaxTrackRect(const CFX_RectF& rtMaxRect) { - CFX_RectF rect; - if (m_bMinSize) { - rect.Set(rtMaxRect.left, rtMaxRect.top, 0, 0); - return rect; - } + if (m_bMinSize) + return CFX_RectF(rtMaxRect.TopLeft(), 0, 0); if (IsVertical()) { FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; - rect.Set(m_rtClient.left, iy, m_rtClient.width, m_rtClient.bottom() - iy); - } else { - FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; - rect.Set(ix, m_rtClient.top, m_rtClient.height - ix, m_rtClient.height); + return CFX_RectF(m_rtClient.left, iy, m_rtClient.width, + m_rtClient.bottom() - iy); } - return rect; + + FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; + return CFX_RectF(ix, m_rtClient.top, m_rtClient.height - ix, + m_rtClient.height); } FX_FLOAT CFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { diff --git a/xfa/fwl/cfwl_spinbutton.cpp b/xfa/fwl/cfwl_spinbutton.cpp index 3748d36a30..140cdd50be 100644 --- a/xfa/fwl/cfwl_spinbutton.cpp +++ b/xfa/fwl/cfwl_spinbutton.cpp @@ -52,15 +52,17 @@ void CFWL_SpinButton::Update() { m_rtClient = GetClientRect(); if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { - m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, - m_rtClient.height / 2); - m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, - m_rtClient.width, m_rtClient.height / 2); + m_rtUpButton = CFX_RectF(m_rtClient.top, m_rtClient.left, m_rtClient.width, + m_rtClient.height / 2); + m_rtDnButton = + CFX_RectF(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, + m_rtClient.width, m_rtClient.height / 2); } else { - m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, - m_rtClient.height); - m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, - m_rtClient.width / 2, m_rtClient.height); + m_rtUpButton = CFX_RectF(m_rtClient.TopLeft(), m_rtClient.width / 2, + m_rtClient.height); + m_rtDnButton = + CFX_RectF(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, + m_rtClient.width / 2, m_rtClient.height); } } @@ -253,7 +255,6 @@ void CFWL_SpinButton::OnMouseMove(CFWL_MessageMouse* pMsg) { bool bRepaint = false; CFX_RectF rtInvlidate; - rtInvlidate.Reset(); if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { if (IsUpButtonEnabled()) { if (m_dwUpState == CFWL_PartState_Hovered) { diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index e7085ba405..72af87fc86 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp @@ -281,8 +281,8 @@ bool CFWL_Widget::IsChild() const { } CFX_RectF CFWL_Widget::GetEdgeRect() { - CFX_RectF rtEdge = m_pProperties->m_rtWidget; - rtEdge.left = rtEdge.top = 0; + CFX_RectF rtEdge(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); if (HasBorder()) { FX_FLOAT fCX = GetBorderSize(true); FX_FLOAT fCY = GetBorderSize(false); @@ -299,10 +299,8 @@ FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) { } CFX_RectF CFWL_Widget::GetRelativeRect() { - CFX_RectF rect = m_pProperties->m_rtWidget; - rect.left = 0; - rect.top = 0; - return rect; + return CFX_RectF(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height); } IFWL_ThemeProvider* CFWL_Widget::GetAvailableTheme() { @@ -345,10 +343,9 @@ CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, calPart.m_dwTTOStyles = bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - CFX_RectF rect; FX_FLOAT fWidth = bMultiLine ? FWL_WGT_CalcMultiLineDefWidth : FWL_WGT_CalcWidth; - rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); + CFX_RectF rect(0, 0, fWidth, FWL_WGT_CalcHeight); pTheme->CalcTextRect(&calPart, rect); return CFX_SizeF(rect.width, rect.height); } @@ -430,21 +427,21 @@ bool CFWL_Widget::GetPopupPosMenu(FX_FLOAT fMinHeight, FX_FLOAT fRight = rtAnchor.right() + rtPopup.width; TransformTo(nullptr, fx, fy); if (fRight + fx > 0.0f || bLeft) { - rtPopup.Set(rtAnchor.left - rtPopup.width, rtAnchor.top, rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.left - rtPopup.width, rtAnchor.top, + rtPopup.width, rtPopup.height); } else { - rtPopup.Set(rtAnchor.right(), rtAnchor.top, rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.right(), rtAnchor.top, rtPopup.width, + rtPopup.height); } } else { FX_FLOAT fBottom = rtAnchor.bottom() + rtPopup.height; TransformTo(nullptr, fx, fy); if (fBottom + fy > 0.0f) { - rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height, + rtPopup.width, rtPopup.height); } else { - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, + rtPopup.height); } } rtPopup.Offset(fx, fy); @@ -467,10 +464,12 @@ bool CFWL_Widget::GetPopupPosComboBox(FX_FLOAT fMinHeight, FX_FLOAT fWidth = std::max(rtAnchor.width, rtPopup.width); FX_FLOAT fBottom = rtAnchor.bottom() + fPopHeight; TransformTo(nullptr, fx, fy); - if (fBottom + fy > 0.0f) - rtPopup.Set(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); - else - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); + if (fBottom + fy > 0.0f) { + rtPopup = + CFX_RectF(rtAnchor.left, rtAnchor.top - fPopHeight, fWidth, fPopHeight); + } else { + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), fWidth, fPopHeight); + } rtPopup.Offset(fx, fy); return true; @@ -485,11 +484,11 @@ bool CFWL_Widget::GetPopupPosGeneral(FX_FLOAT fMinHeight, TransformTo(nullptr, fx, fy); if (rtAnchor.bottom() + fy > 0.0f) { - rtPopup.Set(rtAnchor.left, rtAnchor.top - rtPopup.height, rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.top - rtPopup.height, + rtPopup.width, rtPopup.height); } else { - rtPopup.Set(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, - rtPopup.height); + rtPopup = CFX_RectF(rtAnchor.left, rtAnchor.bottom(), rtPopup.width, + rtPopup.height); } rtPopup.Offset(fx, fy); return true; @@ -535,11 +534,8 @@ void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { } void CFWL_Widget::Repaint() { - CFX_RectF rect; - rect = m_pProperties->m_rtWidget; - rect.left = 0; - rect.top = 0; - RepaintRect(rect); + RepaintRect(CFX_RectF(0, 0, m_pProperties->m_rtWidget.width, + m_pProperties->m_rtWidget.height)); } void CFWL_Widget::RepaintRect(const CFX_RectF& pRect) { diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index cd9c3e609d..6e537a4ad9 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp @@ -267,9 +267,10 @@ CFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(CFWL_Widget* parent, if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { x1 = x; y1 = y; - CFX_Matrix matrixOnParent; CFX_Matrix m; m.SetIdentity(); + + CFX_Matrix matrixOnParent; m.SetReverse(matrixOnParent); m.TransformPoint(x1, y1); CFX_RectF bounds = child->GetWidgetRect(); @@ -428,9 +429,7 @@ void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget, if (!pWidget || !pGraphics) return; - CFX_RectF clipCopy = pWidget->GetWidgetRect(); - clipCopy.left = clipCopy.top = 0; - + CFX_RectF clipCopy(0, 0, pWidget->GetWidgetRect().Size()); CFX_RectF clipBounds; #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ @@ -444,7 +443,7 @@ void CFWL_WidgetMgr::OnDrawWidget(CFWL_Widget* pWidget, pGraphics->GetClipRect(clipBounds); clipCopy = clipBounds; } else { - clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); + clipBounds = CFX_RectF(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. pWidget->GetDelegate()->OnDrawWidget(pGraphics, pMatrix); } @@ -518,8 +517,7 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, return true; } - CFX_RectF rtWidget = pWidget->GetWidgetRect(); - rtWidget.left = rtWidget.top = 0; + CFX_RectF rtWidget(0, 0, pWidget->GetWidgetRect().Size()); pMatrix->TransformRect(rtWidget); if (!rtWidget.IntersectWith(rtDirty)) return false; @@ -530,7 +528,6 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, return true; CFX_RectF rtChilds; - rtChilds.Empty(); bool bChildIntersectWithDirty = false; bool bOrginPtIntersectWidthChild = false; bool bOrginPtIntersectWidthDirty = @@ -555,9 +552,8 @@ bool CFWL_WidgetMgr::IsNeedRepaint(CFWL_Widget* pWidget, rtWidget.height + rtWidget.top; do { CFX_RectF rect = pChild->GetWidgetRect(); - CFX_RectF r = rect; - r.left += rtWidget.left; - r.top += rtWidget.top; + CFX_RectF r(rect.left + rtWidget.left, rect.top + rtWidget.top, rect.width, + rect.height); if (r.IsEmpty()) continue; if (r.Contains(rtDirty)) diff --git a/xfa/fwl/cfwl_widgetproperties.cpp b/xfa/fwl/cfwl_widgetproperties.cpp index 1b41105ef3..fee957aecf 100644 --- a/xfa/fwl/cfwl_widgetproperties.cpp +++ b/xfa/fwl/cfwl_widgetproperties.cpp @@ -12,8 +12,6 @@ CFWL_WidgetProperties::CFWL_WidgetProperties() m_dwStates(0), m_pThemeProvider(nullptr), m_pParent(nullptr), - m_pOwner(nullptr) { - m_rtWidget.Set(0, 0, 0, 0); -} + m_pOwner(nullptr) {} CFWL_WidgetProperties::~CFWL_WidgetProperties() {} diff --git a/xfa/fwl/theme/cfwl_checkboxtp.cpp b/xfa/fwl/theme/cfwl_checkboxtp.cpp index 0bc75ec66b..052b9c1638 100644 --- a/xfa/fwl/theme/cfwl_checkboxtp.cpp +++ b/xfa/fwl/theme/cfwl_checkboxtp.cpp @@ -275,8 +275,7 @@ void CFWL_CheckBoxTP::InitCheckPath(FX_FLOAT fCheckLen) { pt1.x + px2 * FX_BEZIER, pt1.y + py2 * FX_BEZIER, pt1.x, pt1.y); FX_FLOAT fScale = fCheckLen / kSignPath; - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, 0, 0); + CFX_Matrix mt(1, 0, 0, 1, 0, 0); mt.Scale(fScale, fScale); CFX_PathData* pData = m_pCheckPath->GetPathData(); pData->Transform(&mt); diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index d98cf24f85..476135fa44 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -132,8 +132,7 @@ void CFWL_MonthCalendarTP::DrawLButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtLBtn; - rtLBtn = pParams->m_rtPart; + CFX_RectF rtLBtn = pParams->m_rtPart; path.AddRectangle(rtLBtn.left, rtLBtn.top, rtLBtn.width, rtLBtn.height); pParams->m_pGraphics->SaveGraphState(); CFX_Color clrLBtnEdge(ArgbEncode(0xff, 205, 219, 243)); @@ -164,8 +163,7 @@ void CFWL_MonthCalendarTP::DrawRButton(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtRBtn; - rtRBtn = pParams->m_rtPart; + CFX_RectF rtRBtn = pParams->m_rtPart; path.AddRectangle(rtRBtn.left, rtRBtn.top, rtRBtn.width, rtRBtn.height); pParams->m_pGraphics->SaveGraphState(); CFX_Color clrRBtnEdge(ArgbEncode(0xff, 205, 219, 243)); @@ -196,8 +194,7 @@ void CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtHSep; - rtHSep = pParams->m_rtPart; + CFX_RectF rtHSep = pParams->m_rtPart; path.MoveTo(rtHSep.left, rtHSep.top + rtHSep.height / 2); path.LineTo(rtHSep.right(), rtHSep.top + rtHSep.height / 2); pParams->m_pGraphics->SaveGraphState(); @@ -211,8 +208,7 @@ void CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtWeekSep; - rtWeekSep = pParams->m_rtPart; + CFX_RectF rtWeekSep = pParams->m_rtPart; path.MoveTo(rtWeekSep.left, rtWeekSep.top); path.LineTo(rtWeekSep.left, rtWeekSep.bottom()); pParams->m_pGraphics->SaveGraphState(); @@ -228,8 +224,7 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, if (pParams->m_dwStates & CFWL_PartState_Selected) { CFX_Path path; path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; + CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); CFX_Color clrSelDayBK(m_pThemeData->clrDatesSelectedBK); @@ -238,8 +233,7 @@ void CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, } else if (pParams->m_dwStates & CFWL_PartState_Hovered) { CFX_Path path; path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; + CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); CFX_Color clrSelDayBK(m_pThemeData->clrDatesHoverBK); @@ -253,8 +247,7 @@ void CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtSelDay; - rtSelDay = pParams->m_rtPart; + CFX_RectF rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); pParams->m_pGraphics->SaveGraphState(); @@ -268,8 +261,7 @@ void CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_RectF rtTodayCircle; - rtTodayCircle = pParams->m_rtPart; + CFX_RectF rtTodayCircle = pParams->m_rtPart; path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, rtTodayCircle.height); pParams->m_pGraphics->SaveGraphState(); diff --git a/xfa/fxfa/app/xfa_ffbarcode.cpp b/xfa/fxfa/app/xfa_ffbarcode.cpp index e42bf919c7..78452d5dd3 100644 --- a/xfa/fxfa/app/xfa_ffbarcode.cpp +++ b/xfa/fxfa/app/xfa_ffbarcode.cpp @@ -157,8 +157,8 @@ void CXFA_FFBarcode::RenderWidget(CFX_Graphics* pGS, DrawBorder(pGS, borderUI, m_rtUI, &mtRotate); RenderCaption(pGS, &mtRotate); CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); m_pNormalWidget->DrawWidget(pGS, &mt); } diff --git a/xfa/fxfa/app/xfa_ffcheckbutton.cpp b/xfa/fxfa/app/xfa_ffcheckbutton.cpp index 3de3672a63..c8ede3761a 100644 --- a/xfa/fxfa/app/xfa_ffcheckbutton.cpp +++ b/xfa/fxfa/app/xfa_ffcheckbutton.cpp @@ -19,9 +19,7 @@ #include "xfa/fxfa/xfa_ffwidget.h" CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) { - m_rtCheckBox.Set(0, 0, 0, 0); -} + : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} CXFA_FFCheckButton::~CXFA_FFCheckButton() {} @@ -99,8 +97,7 @@ bool CXFA_FFCheckButton::PerformLayout() { FX_FLOAT fCapReserve = 0; CXFA_Caption caption = m_pDataAcc->GetCaption(); if (caption && caption.GetPresence()) { - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); + m_rtCaption = rtWidget; iCapPlacement = caption.GetPlacementType(); fCapReserve = caption.GetReserve(); if (fCapReserve <= 0) { @@ -232,8 +229,7 @@ void CXFA_FFCheckButton::RenderWidget(CFX_Graphics* pGS, RenderCaption(pGS, &mtRotate); DrawHighlight(pGS, &mtRotate, dwStatus, m_pDataAcc->GetCheckButtonShape() == XFA_ATTRIBUTEENUM_Round); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); + CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); mt.Concat(mtRotate); GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget, pGS, &mt); } diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 847ae07d87..87441814e5 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -551,10 +551,7 @@ void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, m_mapPageInvalidate[pPageView]->Union(rtInvalidate); return; } - CFX_RectF* pRect = new CFX_RectF; - pRect->Set(rtInvalidate.left, rtInvalidate.top, rtInvalidate.width, - rtInvalidate.height); - m_mapPageInvalidate[pPageView].reset(pRect); + m_mapPageInvalidate[pPageView] = pdfium::MakeUnique<CFX_RectF>(rtInvalidate); } void CXFA_FFDocView::RunInvalidate() { diff --git a/xfa/fxfa/app/xfa_ffexclgroup.cpp b/xfa/fxfa/app/xfa_ffexclgroup.cpp index 6b47cfb8eb..938cdbcb23 100644 --- a/xfa/fxfa/app/xfa_ffexclgroup.cpp +++ b/xfa/fxfa/app/xfa_ffexclgroup.cpp @@ -19,13 +19,13 @@ CXFA_FFExclGroup::~CXFA_FFExclGroup() {} void CXFA_FFExclGroup::RenderWidget(CFX_Graphics* pGS, CFX_Matrix* pMatrix, uint32_t dwStatus) { - if (!IsMatchVisibleStatus(dwStatus)) { + if (!IsMatchVisibleStatus(dwStatus)) return; - } + CFX_Matrix mtRotate; GetRotateMatrix(mtRotate); - if (pMatrix) { + if (pMatrix) mtRotate.Concat(*pMatrix); - } + CXFA_FFWidget::RenderWidget(pGS, &mtRotate, dwStatus); } diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index c053a8c6ca..0f9bb65b6f 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -26,10 +26,7 @@ #include "xfa/fxgraphics/cfx_path.h" CXFA_FFField::CXFA_FFField(CXFA_WidgetAcc* pDataAcc) - : CXFA_FFWidget(pDataAcc), m_pNormalWidget(nullptr) { - m_rtUI.Set(0, 0, 0, 0); - m_rtCaption.Set(0, 0, 0, 0); -} + : CXFA_FFWidget(pDataAcc), m_pNormalWidget(nullptr) {} CXFA_FFField::~CXFA_FFField() { CXFA_FFField::UnloadWidget(); @@ -72,8 +69,7 @@ void CXFA_FFField::RenderWidget(CFX_Graphics* pGS, DrawHighlight(pGS, &mtRotate, dwStatus, false); CFX_RectF rtWidget = m_pNormalWidget->GetWidgetRect(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget, pGS, &mt); } @@ -186,15 +182,14 @@ void CXFA_FFField::CapPlacement() { if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { - m_rtCaption.Set(0, 0, 0, 0); + m_rtCaption.Reset(); } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { - m_rtCaption.Set(0, 0, 0, 0); + m_rtCaption.Reset(); } else { fCapReserve = caption.GetReserve(); CXFA_LayoutItem* pItem = this; if (!pItem->GetPrev() && !pItem->GetNext()) { - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, - rtWidget.height); + m_rtCaption = rtWidget; } else { pItem = pItem->GetFirst(); m_rtCaption = pItem->GetRect(false); @@ -617,8 +612,7 @@ void CXFA_FFField::RenderCaption(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { CFX_RectF rtClip = m_rtCaption; rtClip.Intersect(rtWidget); CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); if (pMatrix) { pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index 3dfa237c0f..da31cbf3b3 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -33,8 +33,7 @@ void GetPageMatrix(CFX_Matrix& pageMatrix, ASSERT(iRotate >= 0 && iRotate <= 3); bool bFlipX = (dwCoordinatesType & 0x01) != 0; bool bFlipY = (dwCoordinatesType & 0x02) != 0; - CFX_Matrix m; - m.Set((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0); + CFX_Matrix m((bFlipX ? -1.0f : 1.0f), 0, 0, (bFlipY ? -1.0f : 1.0f), 0, 0); if (iRotate == 0 || iRotate == 2) { m.a *= (FX_FLOAT)devicePageRect.width / docPageRect.width; m.d *= (FX_FLOAT)devicePageRect.height / docPageRect.height; @@ -126,16 +125,14 @@ CXFA_FFDocView* CXFA_FFPageView::GetDocView() const { } void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) const { - rtPage.Set(0, 0, GetPageSize()); + rtPage = CFX_RectF(0, 0, GetPageSize()); } void CXFA_FFPageView::GetDisplayMatrix(CFX_Matrix& mt, const CFX_Rect& rtDisp, int32_t iRotate) const { CFX_SizeF sz = GetPageSize(); - CFX_RectF fdePage; - fdePage.Set(0, 0, sz.x, sz.y); - GetPageMatrix(mt, fdePage, rtDisp, iRotate, 0); + GetPageMatrix(mt, CFX_RectF(0, 0, sz.x, sz.y), rtDisp, iRotate, 0); } IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( @@ -370,8 +367,10 @@ static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, const void* phWidget2) { CXFA_FFWidget* pWidget1 = (*(CXFA_TabParam**)phWidget1)->m_pWidget; CXFA_FFWidget* pWidget2 = (*(CXFA_TabParam**)phWidget2)->m_pWidget; - CFX_RectF rt1, rt2; + CFX_RectF rt1; pWidget1->GetWidgetRect(rt1); + + CFX_RectF rt2; pWidget2->GetWidgetRect(rt2); FX_FLOAT x1 = rt1.left, y1 = rt1.top, x2 = rt2.left, y2 = rt2.top; if (y1 < y2 || (y1 - y2 < XFA_FLOAT_PERCISION && x1 < x2)) { diff --git a/xfa/fxfa/app/xfa_ffpushbutton.cpp b/xfa/fxfa/app/xfa_ffpushbutton.cpp index 92e5b70d4e..fcb7d32761 100644 --- a/xfa/fxfa/app/xfa_ffpushbutton.cpp +++ b/xfa/fxfa/app/xfa_ffpushbutton.cpp @@ -45,8 +45,8 @@ void CXFA_FFPushButton::RenderWidget(CFX_Graphics* pGS, RenderHighlightCaption(pGS, &mtRotate); CFX_RectF rtWidget; GetRectWithoutRotate(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtWidget.left, rtWidget.top); + + CFX_Matrix mt(1, 0, 0, 1, rtWidget.left, rtWidget.top); mt.Concat(mtRotate); GetApp()->GetWidgetMgrDelegate()->OnDrawWidget(m_pNormalWidget, pGS, &mt); } @@ -102,20 +102,21 @@ bool CXFA_FFPushButton::PerformLayout() { CXFA_FFWidget::PerformLayout(); CFX_RectF rtWidget; GetRectWithoutRotate(rtWidget); + m_rtUI = rtWidget; - if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) { + if (CXFA_Margin mgWidget = m_pDataAcc->GetMargin()) XFA_RectWidthoutMargin(rtWidget, mgWidget); - } + CXFA_Caption caption = m_pDataAcc->GetCaption(); - m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height); - if (CXFA_Margin mgCap = caption.GetMargin()) { + m_rtCaption = rtWidget; + if (CXFA_Margin mgCap = caption.GetMargin()) XFA_RectWidthoutMargin(m_rtCaption, mgCap); - } + LayoutHighlightCaption(); SetFWLRect(); - if (m_pNormalWidget) { + if (m_pNormalWidget) m_pNormalWidget->Update(); - } + return true; } FX_FLOAT CXFA_FFPushButton::GetLineWidth() { @@ -176,8 +177,7 @@ void CXFA_FFPushButton::RenderHighlightCaption(CFX_Graphics* pGS, GetRectWithoutRotate(rtWidget); CFX_RectF rtClip = m_rtCaption; rtClip.Intersect(rtWidget); - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); + CFX_Matrix mt(1, 0, 0, 1, m_rtCaption.left, m_rtCaption.top); if (pMatrix) { pMatrix->TransformRect(rtClip); mt.Concat(*pMatrix); @@ -215,8 +215,7 @@ void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { - CFX_RectF rtFill = m_pNormalWidget->GetWidgetRect(); - rtFill.left = rtFill.top = 0; + CFX_RectF rtFill(0, 0, m_pNormalWidget->GetWidgetRect().Size()); FX_FLOAT fLineWith = GetLineWidth(); rtFill.Deflate(fLineWith, fLineWith); CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index b87645d8a7..9176276d85 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -57,8 +57,8 @@ void CXFA_FFText::RenderWidget(CFX_Graphics* pGS, rtText.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); } } - CFX_Matrix mt; - mt.Set(1, 0, 0, 1, rtText.left, rtText.top); + + CFX_Matrix mt(1, 0, 0, 1, rtText.left, rtText.top); CFX_RectF rtClip = rtText; mtRotate.TransformRect(rtClip); mt.Concat(mtRotate); diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 95cfe2e59f..d34cecc44c 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -35,9 +35,7 @@ CXFA_FFWidget::CXFA_FFWidget(CXFA_WidgetAcc* pDataAcc) : CXFA_ContentLayoutItem(pDataAcc->GetNode()), m_pPageView(nullptr), - m_pDataAcc(pDataAcc) { - m_rtWidget.Set(0, 0, 0, 0); -} + m_pDataAcc(pDataAcc) {} CXFA_FFWidget::~CXFA_FFWidget() {} @@ -380,7 +378,7 @@ static void XFA_GetMatrix(CFX_Matrix& m, } } void CXFA_FFWidget::GetRotateMatrix(CFX_Matrix& mt) { - mt.Set(1, 0, 0, 1, 0, 0); + mt = CFX_Matrix(); int32_t iRotate = m_pDataAcc->GetRotate(); if (!iRotate) { return; @@ -831,18 +829,15 @@ void XFA_DrawImage(CFX_Graphics* pGS, int32_t iImageYDpi, int32_t iHorzAlign, int32_t iVertAlign) { - if (rtImage.IsEmpty()) { + if (rtImage.IsEmpty()) return; - } - if (!pDIBitmap || !pDIBitmap->GetBuffer()) { + if (!pDIBitmap || !pDIBitmap->GetBuffer()) return; - } - FX_FLOAT fWidth = - XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - FX_FLOAT fHeight = - XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); - CFX_RectF rtFit; - rtFit.Set(rtImage.left, rtImage.top, fWidth, fHeight); + + CFX_RectF rtFit( + rtImage.TopLeft(), + XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetWidth(), (FX_FLOAT)iImageXDpi), + XFA_UnitPx2Pt((FX_FLOAT)pDIBitmap->GetHeight(), (FX_FLOAT)iImageYDpi)); switch (iAspect) { case XFA_ATTRIBUTEENUM_Fit: { FX_FLOAT f1 = rtImage.height / rtFit.height; @@ -1348,10 +1343,9 @@ static void XFA_BOX_GetPath(CXFA_Box box, if (bInverted) { sy *= -1; } - CFX_RectF rtRadius; - rtRadius.Set(cp1.x + offsetX * 2, cp1.y + offsetY * 2, - fRadius1 * 2 * vx - offsetX * 2, - fRadius1 * 2 * vy - offsetY * 2); + CFX_RectF rtRadius(cp1.x + offsetX * 2, cp1.y + offsetY * 2, + fRadius1 * 2 * vx - offsetX * 2, + fRadius1 * 2 * vy - offsetY * 2); rtRadius.Normalize(); if (bInverted) { rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); @@ -1501,8 +1495,7 @@ static void XFA_BOX_GetFillPath(CXFA_Box box, if (bInverted) { sy *= -1; } - CFX_RectF rtRadius; - rtRadius.Set(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); + CFX_RectF rtRadius(cp1.x, cp1.y, fRadius1 * 2 * vx, fRadius1 * 2 * vy); rtRadius.Normalize(); if (bInverted) { rtRadius.Offset(-fRadius1 * vx, -fRadius1 * vy); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 97adff30ac..704aec634d 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -927,16 +927,15 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { } size.clear(); if (CFX_DIBitmap* pBitmap = GetImageImage()) { - CFX_RectF rtImage, rtFit; - rtImage.Set(0, 0, 0, 0); - rtFit.Set(0, 0, 0, 0); int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; GetImageDpi(iImageXDpi, iImageYDpi); - rtImage.width = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - rtImage.height = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); + CFX_RectF rtImage( + 0, 0, + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi), + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi)); + + CFX_RectF rtFit; if (GetWidth(rtFit.width)) { GetWidthWithoutMargin(rtFit.width); } else { @@ -958,16 +957,15 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { } size.clear(); if (CFX_DIBitmap* pBitmap = GetImageEditImage()) { - CFX_RectF rtImage, rtFit; - rtImage.Set(0, 0, 0, 0); - rtFit.Set(0, 0, 0, 0); int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; GetImageEditDpi(iImageXDpi, iImageYDpi); - rtImage.width = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi); - rtImage.height = - XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi); + CFX_RectF rtImage( + 0, 0, + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetWidth(), (FX_FLOAT)iImageXDpi), + XFA_UnitPx2Pt((FX_FLOAT)pBitmap->GetHeight(), (FX_FLOAT)iImageYDpi)); + + CFX_RectF rtFit; if (GetWidth(rtFit.width)) { GetWidthWithoutMargin(rtFit.width); } else { diff --git a/xfa/fxfa/app/xfa_fwltheme.cpp b/xfa/fxfa/app/xfa_fwltheme.cpp index 1de302e995..3398c8a25c 100644 --- a/xfa/fxfa/app/xfa_fwltheme.cpp +++ b/xfa/fxfa/app/xfa_fwltheme.cpp @@ -149,8 +149,6 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { CFX_RectF CXFA_FWLTheme::GetUIMargin(CFWL_ThemePart* pThemePart) const { CFX_RectF rect; - rect.Reset(); - CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget); if (!pWidget) return rect; diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index 75e7e7d84e..f103b23520 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -36,7 +36,7 @@ int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, pGS->GetClipRect(rtPage); CFX_Matrix mtRes; mtRes.SetReverse(matrix); - m_rtClipRect.Set(rtPage.left, rtPage.top, rtPage.width, rtPage.height); + m_rtClipRect = rtPage; mtRes.TransformRect(m_rtClipRect); m_dwStatus = m_options.m_bHighlight ? XFA_WidgetStatus_Highlight : 0; uint32_t dwFilterType = XFA_WidgetStatus_Visible | diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp index 7a373e1e9a..476d6118ac 100644 --- a/xfa/fxfa/parser/cxfa_layoutitem.cpp +++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp @@ -67,11 +67,8 @@ CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const { auto pThis = static_cast<const CXFA_ContentLayoutItem*>(this); CFX_PointF sPos = pThis->m_sPos; CFX_SizeF sSize = pThis->m_sSize; - if (bRelative) { - CFX_RectF rtLayout; - rtLayout.Set(sPos.x, sPos.y, sSize.x, sSize.y); - return rtLayout; - } + if (bRelative) + return CFX_RectF(sPos, sSize); for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem; pLayoutItem = pLayoutItem->m_pParent) { @@ -99,10 +96,7 @@ CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const { if (pLayoutItem->m_pFormNode->GetElementType() == XFA_Element::PageArea) break; } - - CFX_RectF rtLayout; - rtLayout.Set(sPos.x, sPos.y, sSize.x, sSize.y); - return rtLayout; + return CFX_RectF(sPos, sSize); } CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() { diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 6dc3fa6561..d3533c277a 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -407,19 +407,17 @@ CXFA_Border CXFA_WidgetData::GetUIBorder() { } CFX_RectF CXFA_WidgetData::GetUIMargin() { - CFX_RectF rtUIMargin; - rtUIMargin.Reset(); - CXFA_Node* pUIChild = GetUIChild(); CXFA_Margin mgUI = CXFA_Margin( pUIChild ? pUIChild->GetProperty(0, XFA_Element::Margin, false) : nullptr); + if (!mgUI) - return rtUIMargin; + return CFX_RectF(); CXFA_Border border = GetUIBorder(); if (border && border.GetPresence() != XFA_ATTRIBUTEENUM_Visible) - return rtUIMargin; + return CFX_RectF(); FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; bool bLeft = mgUI.GetLeftInset(fLeftInset); @@ -443,8 +441,7 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() { fLeftInset = GetEdgeThickness(strokes, bVisible, 3); } } - rtUIMargin.Set(fLeftInset, fTopInset, fRightInset, fBottomInset); - return rtUIMargin; + return CFX_RectF(fLeftInset, fTopInset, fRightInset, fBottomInset); } int32_t CXFA_WidgetData::GetButtonHighlight() { diff --git a/xfa/fxgraphics/cfx_graphics.cpp b/xfa/fxgraphics/cfx_graphics.cpp index 120634ca51..7ad1aa45e5 100644 --- a/xfa/fxgraphics/cfx_graphics.cpp +++ b/xfa/fxgraphics/cfx_graphics.cpp @@ -969,9 +969,8 @@ FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix) { if (!graphics || !graphics->m_renderDevice) return FWL_Error::ParameterInvalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m.Concat(*matrix); } @@ -992,9 +991,8 @@ FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics, const CFX_Matrix* matrix) { if (!graphics || !graphics->m_renderDevice) return FWL_Error::ParameterInvalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m.Concat(*matrix); } @@ -1030,8 +1028,7 @@ FWL_Error CFX_Graphics::InverseRect(const CFX_RectF& rect) { return FWL_Error::PropertyInvalid; CFX_RectF temp(rect); m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); + CFX_RectF r(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); r.Intersect(temp); if (r.IsEmpty()) { return FWL_Error::ParameterInvalid; @@ -1060,8 +1057,7 @@ FWL_Error CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, return FWL_Error::PropertyInvalid; CFX_RectF temp(rect); m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); + CFX_RectF r(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); r.Intersect(temp); if (r.IsEmpty()) { return FWL_Error::ParameterInvalid; @@ -1096,8 +1092,7 @@ FWL_Error CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, return FWL_Error::PropertyInvalid; CFX_RectF temp(rect); m_info.CTM.TransformRect(temp); - CFX_RectF r; - r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); + CFX_RectF r(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); r.Intersect(temp); if (r.IsEmpty()) { return FWL_Error::ParameterInvalid; @@ -1158,9 +1153,8 @@ FWL_Error CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, CFX_Matrix* matrix) { if (!m_info.strokeColor) return FWL_Error::PropertyInvalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m.Concat(*matrix); } @@ -1187,9 +1181,8 @@ FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, CFX_Matrix* matrix) { if (!m_info.fillColor) return FWL_Error::PropertyInvalid; - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m.Concat(*matrix); } @@ -1214,15 +1207,13 @@ FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, const CFX_PointF& point, CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m1.Concat(*matrix); } - CFX_Matrix m2; - m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), - point.x, point.y); + CFX_Matrix m2((FX_FLOAT)source->GetWidth(), 0.0, 0.0, + (FX_FLOAT)source->GetHeight(), point.x, point.y); m2.Concat(m1); int32_t left, top; std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); @@ -1246,18 +1237,18 @@ FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, FWL_Error CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, const CFX_RectF& rect, CFX_Matrix* matrix) { - CFX_Matrix m1; - m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m1(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); if (matrix) { m1.Concat(*matrix); } std::unique_ptr<CFX_DIBitmap> bmp1 = source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()); - CFX_Matrix m2; - m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); + CFX_Matrix m2(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); m2.Concat(m1); - int32_t left, top; + + int32_t left; + int32_t top; std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->FlipImage(false, true); std::unique_ptr<CFX_DIBitmap> bmp3 = bmp2->TransformTo(&m2, left, top); CFX_RectF r; @@ -1278,12 +1269,10 @@ FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, int32_t length = text.GetLength(); uint32_t* charCodes = FX_Alloc(uint32_t, length); FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); - CFX_RectF rect; - rect.Set(point.x, point.y, 0, 0); + CFX_RectF rect(point.x, point.y, 0, 0); CalcTextInfo(text, charCodes, charPos, rect); - CFX_Matrix m; - m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, - m_info.CTM.f); + CFX_Matrix m(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, + m_info.CTM.e, m_info.CTM.f); m.Translate(0, m_info.fontSize * m_info.fontHScale); if (matrix) { m.Concat(*matrix); @@ -1477,11 +1466,11 @@ FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, if (matrix->IsIdentity()) { m_renderDevice->SetDIBits(source, 0, 0); } else { - CFX_Matrix m; - m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, - 0); + CFX_Matrix m((FX_FLOAT)source->GetWidth(), 0, 0, + (FX_FLOAT)source->GetHeight(), 0, 0); m.Concat(*matrix); - int32_t left, top; + int32_t left; + int32_t top; std::unique_ptr<CFX_DIBitmap> bmp1 = source->FlipImage(false, true); std::unique_ptr<CFX_DIBitmap> bmp2 = bmp1->TransformTo(&m, left, top); m_renderDevice->SetDIBits(bmp2.get(), left, top); diff --git a/xfa/fxgraphics/cfx_pattern.cpp b/xfa/fxgraphics/cfx_pattern.cpp index f70a78d566..8293ba1748 100644 --- a/xfa/fxgraphics/cfx_pattern.cpp +++ b/xfa/fxgraphics/cfx_pattern.cpp @@ -14,13 +14,10 @@ CFX_Pattern::CFX_Pattern(FX_HatchStyle hatchStyle, ASSERT(m_hatchStyle >= FX_HATCHSTYLE_Horizontal && m_hatchStyle <= FX_HATCHSTYLE_SolidDiamond); - if (matrix) { - // TODO(dsinclair): Add a Set(const CFX_Matrix&) method. pdfium:436 - m_matrix.Set(matrix->a, matrix->b, matrix->c, matrix->d, matrix->e, - matrix->f); - } else { + if (matrix) + m_matrix = *matrix; + else m_matrix.SetIdentity(); - } } CFX_Pattern::~CFX_Pattern() {} |