Do not check null return from CFWL_Widget::GetOwnerApp(). Because it can't return null. The underlying member returned by this method is const, and the constructor immediately derefernces it to initialize other members, so in turn it can't be null. It is a good thing, since there are other existing places that omit the check. Remove some no-op casts along the way. Change-Id: I0ecd4bd7ff46d1c074ef90bba0792ee593d74518 Reviewed-on: https://pdfium-review.googlesource.com/c/48313 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fwl/cfwl_timer.cpp b/xfa/fwl/cfwl_timer.cpp index b7c54fd..ae9bcf2 100644 --- a/xfa/fwl/cfwl_timer.cpp +++ b/xfa/fwl/cfwl_timer.cpp
@@ -17,11 +17,7 @@ CFWL_Timer::~CFWL_Timer() {} CFWL_TimerInfo* CFWL_Timer::StartTimer(uint32_t dwElapse, bool bImmediately) { - const CFWL_App* pApp = m_pWidget->GetOwnerApp(); - if (!pApp) - return nullptr; - - CXFA_FFApp* pAdapterNative = pApp->GetAdapterNative(); + CXFA_FFApp* pAdapterNative = m_pWidget->GetOwnerApp()->GetAdapterNative(); if (!pAdapterNative) return nullptr;
diff --git a/xfa/fwl/cfwl_widget.cpp b/xfa/fwl/cfwl_widget.cpp index d1ef66b..4d988bd 100644 --- a/xfa/fwl/cfwl_widget.cpp +++ b/xfa/fwl/cfwl_widget.cpp
@@ -134,8 +134,7 @@ if (IsVisible()) return; - CFWL_NoteDriver* noteDriver = - static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); + CFWL_NoteDriver* noteDriver = GetOwnerApp()->GetNoteDriver(); CFWL_WidgetMgr* widgetMgr = GetOwnerApp()->GetWidgetMgr(); noteDriver->NotifyTargetHide(this); CFWL_Widget* child = widgetMgr->GetFirstChildWidget(this); @@ -292,21 +291,12 @@ } void CFWL_Widget::SetGrab(bool bSet) { - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); + CFWL_NoteDriver* pDriver = GetOwnerApp()->GetNoteDriver(); pDriver->SetGrab(this, bSet); } void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource) { - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); + CFWL_NoteDriver* pNoteDriver = GetOwnerApp()->GetNoteDriver(); if (!pNoteDriver) return; @@ -314,11 +304,7 @@ } void CFWL_Widget::UnregisterEventTarget() { - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); + CFWL_NoteDriver* pNoteDriver = GetOwnerApp()->GetNoteDriver(); if (!pNoteDriver) return; @@ -330,13 +316,10 @@ m_pOuter->GetDelegate()->OnProcessEvent(pEvent); return; } - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); + CFWL_NoteDriver* pNoteDriver = GetOwnerApp()->GetNoteDriver(); if (!pNoteDriver) return; + pNoteDriver->SendEvent(pEvent); } @@ -372,12 +355,7 @@ } void CFWL_Widget::NotifyDriver() { - const CFWL_App* pApp = GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pDriver = - static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); + CFWL_NoteDriver* pDriver = GetOwnerApp()->GetNoteDriver(); if (!pDriver) return;
diff --git a/xfa/fwl/cfwl_widgetmgr.cpp b/xfa/fwl/cfwl_widgetmgr.cpp index 3b0674b..a5f7145 100644 --- a/xfa/fwl/cfwl_widgetmgr.cpp +++ b/xfa/fwl/cfwl_widgetmgr.cpp
@@ -354,12 +354,7 @@ if (!pDstWidget) return; - const CFWL_App* pApp = pDstWidget->GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = - static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); + CFWL_NoteDriver* pNoteDriver = pDstWidget->GetOwnerApp()->GetNoteDriver(); if (!pNoteDriver) return;