From 9b99ebf5159d98cc83fb2e8ebac6750e158841d6 Mon Sep 17 00:00:00 2001 From: weili Date: Mon, 22 Aug 2016 13:37:04 -0700 Subject: Make CFX_Color constructor explicit Change the places which require implicit construction, and make the construction from ARGB_Color explicit. Review-Url: https://codereview.chromium.org/2263923003 --- xfa/fwl/theme/cfwl_carettp.cpp | 9 ++++++--- xfa/fwl/theme/cfwl_comboboxtp.cpp | 9 +++++---- xfa/fwl/theme/cfwl_monthcalendartp.cpp | 16 ++++++++-------- xfa/fwl/theme/cfwl_widgettp.cpp | 2 +- xfa/fxfa/app/xfa_ffwidget.cpp | 2 +- xfa/fxgraphics/cfx_color.h | 8 +++----- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/xfa/fwl/theme/cfwl_carettp.cpp b/xfa/fwl/theme/cfwl_carettp.cpp index eb73231317..b517172fff 100644 --- a/xfa/fwl/theme/cfwl_carettp.cpp +++ b/xfa/fwl/theme/cfwl_carettp.cpp @@ -44,10 +44,13 @@ void CFWL_CaretTP::DrawCaretBK(CFX_Graphics* pGraphics, CFX_Matrix* pMatrix) { CFX_Path path; path.Create(); - CFX_Color crFilltemp; - crFill ? crFilltemp = *crFill : crFilltemp = ArgbEncode(255, 0, 0, 0); CFX_RectF rect = *pRect; path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - pGraphics->SetFillColor(&crFilltemp); + if (crFill) { + pGraphics->SetFillColor(crFill); + } else { + CFX_Color crFilltemp(ArgbEncode(255, 0, 0, 0)); + pGraphics->SetFillColor(&crFilltemp); + } pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } diff --git a/xfa/fwl/theme/cfwl_comboboxtp.cpp b/xfa/fwl/theme/cfwl_comboboxtp.cpp index 92f2296105..9fdb776820 100644 --- a/xfa/fwl/theme/cfwl_comboboxtp.cpp +++ b/xfa/fwl/theme/cfwl_comboboxtp.cpp @@ -47,18 +47,19 @@ FX_BOOL CFWL_ComboBoxTP::DrawBackground(CFWL_ThemeBackground* pParams) { path.Create(); CFX_RectF& rect = pParams->m_rtPart; path.AddRectangle(rect.left, rect.top, rect.width, rect.height); - CFX_Color cr; + FX_ARGB argb_color; switch (pParams->m_dwStates) { case CFWL_PartState_Selected: - cr = FWLTHEME_COLOR_BKSelected; + argb_color = FWLTHEME_COLOR_BKSelected; break; case CFWL_PartState_Disabled: - cr = FWLTHEME_COLOR_EDGERB1; + argb_color = FWLTHEME_COLOR_EDGERB1; break; default: - cr = 0xFFFFFFFF; + argb_color = 0xFFFFFFFF; } pParams->m_pGraphics->SaveGraphState(); + CFX_Color cr(argb_color); pParams->m_pGraphics->SetFillColor(&cr); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, &pParams->m_matrix); pParams->m_pGraphics->RestoreGraphState(); diff --git a/xfa/fwl/theme/cfwl_monthcalendartp.cpp b/xfa/fwl/theme/cfwl_monthcalendartp.cpp index 7faa8e1533..eee199ee6d 100644 --- a/xfa/fwl/theme/cfwl_monthcalendartp.cpp +++ b/xfa/fwl/theme/cfwl_monthcalendartp.cpp @@ -461,6 +461,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawHSeperator(CFWL_ThemeBackground* pParams, pParams->m_pGraphics->RestoreGraphState(); return TRUE; } + FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; @@ -476,6 +477,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawWeekNumSep(CFWL_ThemeBackground* pParams, pParams->m_pGraphics->RestoreGraphState(); return TRUE; } + FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { pParams->m_pGraphics->SaveGraphState(); @@ -486,8 +488,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesSelectedBK; + CFX_Color clrSelDayBK(m_pThemeData->clrDatesSelectedBK); pParams->m_pGraphics->SetFillColor(&clrSelDayBK); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } else if (pParams->m_dwStates & CFWL_PartState_Hovered) { @@ -497,14 +498,14 @@ FX_BOOL CFWL_MonthCalendarTP::DrawDatesInBK(CFWL_ThemeBackground* pParams, rtSelDay = pParams->m_rtPart; path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesHoverBK; + CFX_Color clrSelDayBK(m_pThemeData->clrDatesHoverBK); pParams->m_pGraphics->SetFillColor(&clrSelDayBK); pParams->m_pGraphics->FillPath(&path, FXFILL_WINDING, pMatrix); } pParams->m_pGraphics->RestoreGraphState(); return FALSE; } + FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; @@ -514,13 +515,13 @@ FX_BOOL CFWL_MonthCalendarTP::DrawDatesInCircle(CFWL_ThemeBackground* pParams, path.AddRectangle(rtSelDay.left, rtSelDay.top, rtSelDay.width, rtSelDay.height); pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrSelDayBK; - clrSelDayBK = m_pThemeData->clrDatesCircle; + CFX_Color clrSelDayBK(m_pThemeData->clrDatesCircle); pParams->m_pGraphics->SetStrokeColor(&clrSelDayBK); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); return TRUE; } + FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, CFX_Matrix* pMatrix) { CFX_Path path; @@ -530,8 +531,7 @@ FX_BOOL CFWL_MonthCalendarTP::DrawTodayCircle(CFWL_ThemeBackground* pParams, path.AddRectangle(rtTodayCircle.left, rtTodayCircle.top, rtTodayCircle.width, rtTodayCircle.height); pParams->m_pGraphics->SaveGraphState(); - CFX_Color clrTodayCircle; - clrTodayCircle = m_pThemeData->clrDatesCircle; + CFX_Color clrTodayCircle(m_pThemeData->clrDatesCircle); pParams->m_pGraphics->SetStrokeColor(&clrTodayCircle); pParams->m_pGraphics->StrokePath(&path, pMatrix); pParams->m_pGraphics->RestoreGraphState(); diff --git a/xfa/fwl/theme/cfwl_widgettp.cpp b/xfa/fwl/theme/cfwl_widgettp.cpp index b5658cf7b2..a1b458cb41 100644 --- a/xfa/fwl/theme/cfwl_widgettp.cpp +++ b/xfa/fwl/theme/cfwl_widgettp.cpp @@ -274,7 +274,7 @@ void CFWL_WidgetTP::DrawEdge(CFX_Graphics* pGraphics, pRect->height - 1); pGraphics->StrokePath(&path, pMatrix); path.Clear(); - crStroke = ArgbEncode(255, 255, 255, 255); + crStroke.Set(ArgbEncode(255, 255, 255, 255)); pGraphics->SetStrokeColor(&crStroke); path.AddRectangle(pRect->left + 1, pRect->top + 1, pRect->width - 3, pRect->height - 3); diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 446fcd6303..d5ffdee55e 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -1590,7 +1590,7 @@ static void XFA_BOX_Fill_Pattern(CXFA_Box box, } CFX_Pattern pattern(iHatch, crEnd, crStart); - CFX_Color cr(&pattern); + CFX_Color cr(&pattern, 0x0); pGS->SetFillColor(&cr); pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); } diff --git a/xfa/fxgraphics/cfx_color.h b/xfa/fxgraphics/cfx_color.h index bf61c6859a..0f321764f9 100644 --- a/xfa/fxgraphics/cfx_color.h +++ b/xfa/fxgraphics/cfx_color.h @@ -18,15 +18,13 @@ enum { FX_COLOR_None = 0, FX_COLOR_Solid, FX_COLOR_Pattern, FX_COLOR_Shading }; class CFX_Color { public: CFX_Color(); - // TODO(weili): Remove implicit conversions. Make this explicit. - CFX_Color(const FX_ARGB argb); - - explicit CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); + explicit CFX_Color(const FX_ARGB argb); explicit CFX_Color(CFX_Shading* shading); + CFX_Color(CFX_Pattern* pattern, const FX_ARGB argb); virtual ~CFX_Color(); FWL_Error Set(const FX_ARGB argb); - FWL_Error Set(CFX_Pattern* pattern, const FX_ARGB argb = 0x0); + FWL_Error Set(CFX_Pattern* pattern, const FX_ARGB argb); FWL_Error Set(CFX_Shading* shading); private: -- cgit v1.2.3