summaryrefslogtreecommitdiff
path: root/fpdfsdk/pwl
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-26 19:06:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-26 19:06:06 +0000
commit4ef943b992782d930a7550b98e3d0389886a0ba3 (patch)
treebc063c260a73bc83fbbb77b9bce59d8d97f28965 /fpdfsdk/pwl
parent2daa06ab9596a42c967497c2bae16ddd902dcaf0 (diff)
downloadpdfium-4ef943b992782d930a7550b98e3d0389886a0ba3.tar.xz
Be more careful casting to widget subclasses.
Part of the effort to reduce unchecked static casts. Change-Id: I1bff1c53aa7c5804660de4b65cf01523d70fcbb7 Reviewed-on: https://pdfium-review.googlesource.com/38896 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/pwl')
-rw-r--r--fpdfsdk/pwl/cpwl_wnd.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/fpdfsdk/pwl/cpwl_wnd.cpp b/fpdfsdk/pwl/cpwl_wnd.cpp
index 8782e85a14..a561b2de60 100644
--- a/fpdfsdk/pwl/cpwl_wnd.cpp
+++ b/fpdfsdk/pwl/cpwl_wnd.cpp
@@ -277,33 +277,32 @@ void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
}
bool CPWL_Wnd::InvalidateRect(CFX_FloatRect* pRect) {
- ObservedPtr thisObserved(this);
- if (!IsValid())
+ if (!IsValid())
return true;
+ ObservedPtr thisObserved(this);
CFX_FloatRect rcRefresh = pRect ? *pRect : GetWindowRect();
-
if (!HasFlag(PWS_NOREFRESHCLIP)) {
CFX_FloatRect rcClip = GetClipRect();
- if (!rcClip.IsEmpty()) {
+ if (!rcClip.IsEmpty())
rcRefresh.Intersect(rcClip);
- }
}
CFX_FloatRect rcWin = PWLtoWnd(rcRefresh);
rcWin.Inflate(1, 1);
rcWin.Normalize();
- if (CFX_SystemHandler* pSH = GetSystemHandler()) {
- if (CPDFSDK_Widget* widget = static_cast<CPDFSDK_Widget*>(
- m_CreationParams.pAttachedWidget.Get())) {
- pSH->InvalidateRect(widget, rcWin);
- if (!thisObserved)
- return false;
- }
- }
+ CFX_SystemHandler* pSH = GetSystemHandler();
+ if (!pSH)
+ return true;
- return true;
+ CPDFSDK_Widget* widget =
+ ToCPDFSDKWidget(m_CreationParams.pAttachedWidget.Get());
+ if (!widget)
+ return true;
+
+ pSH->InvalidateRect(widget, rcWin);
+ return !!thisObserved;
}
#define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \