diff options
author | dsinclair <dsinclair@chromium.org> | 2016-10-20 07:19:43 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-20 07:19:43 -0700 |
commit | 73895de7dea3737d1a25801001b8efe186c6f5a3 (patch) | |
tree | 8754626255699818c34d336fccc75926a5958345 /xfa/fwl/lightwidget | |
parent | 2a38a02b0492de0576c2e5b5e7d550f969367f9d (diff) | |
download | pdfium-73895de7dea3737d1a25801001b8efe186c6f5a3.tar.xz |
Cleanup unused methods and return values in FWL code.
This CL does an initial pass to remove unused methods and return values
in the FWL code base.
Review-Url: https://chromiumcodereview.appspot.com/2435603003
Diffstat (limited to 'xfa/fwl/lightwidget')
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_widget.cpp | 237 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_widget.h | 44 |
2 files changed, 32 insertions, 249 deletions
diff --git a/xfa/fwl/lightwidget/cfwl_widget.cpp b/xfa/fwl/lightwidget/cfwl_widget.cpp index fe2b35c46b..c77bfc215c 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.cpp +++ b/xfa/fwl/lightwidget/cfwl_widget.cpp @@ -18,30 +18,24 @@ #define FWL_WGT_CalcWidth 2048 #define FWL_WGT_CalcMultiLineDefWidth 120.0f -IFWL_Widget* CFWL_Widget::GetWidget() { - return m_pIface.get(); -} - -const IFWL_Widget* CFWL_Widget::GetWidget() const { - return m_pIface.get(); +CFWL_Widget::CFWL_Widget() + : m_pDelegate(nullptr), + m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), + m_pProperties(new CFWL_WidgetProperties) { + ASSERT(m_pWidgetMgr); } -FWL_Error CFWL_Widget::GetClassName(CFX_WideString& wsClass) const { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->GetClassName(wsClass); +CFWL_Widget::~CFWL_Widget() { + if (m_pIface) + m_pIface->Finalize(); } -FWL_Type CFWL_Widget::GetClassID() const { - if (!m_pIface) - return FWL_Type::Unknown; - return m_pIface->GetClassID(); +IFWL_Widget* CFWL_Widget::GetWidget() { + return m_pIface.get(); } -FX_BOOL CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { - if (!m_pIface) - return FALSE; - return m_pIface->IsInstance(wsClass); +const IFWL_Widget* CFWL_Widget::GetWidget() const { + return m_pIface.get(); } FWL_Error CFWL_Widget::Initialize(const CFWL_WidgetProperties* pProperties) { @@ -75,39 +69,6 @@ FWL_Error CFWL_Widget::GetClientRect(CFX_RectF& rect) { return m_pIface->GetClientRect(rect); } -CFWL_Widget* CFWL_Widget::GetParent() { - if (!m_pIface) - return nullptr; - - IFWL_Widget* parent = m_pIface->GetParent(); - if (!parent) - return nullptr; - - return static_cast<CFWL_Widget*>(parent->GetAssociateWidget()); -} - -FWL_Error CFWL_Widget::SetParent(CFWL_Widget* pParent) { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->SetParent(pParent ? pParent->GetWidget() : nullptr); -} - -CFWL_Widget* CFWL_Widget::GetOwner() { - return nullptr; -} - -FWL_Error CFWL_Widget::SetOwner(CFWL_Widget* pOwner) { - if (!m_pIface) - return FWL_Error::Indefinite; - return FWL_Error::Succeeded; -} - -uint32_t CFWL_Widget::GetStyles() { - if (!m_pIface) - return 0; - return m_pIface->GetStyles(); -} - FWL_Error CFWL_Widget::ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved) { if (!m_pIface) @@ -135,31 +96,27 @@ void CFWL_Widget::SetStates(uint32_t dwStates, FX_BOOL bSet) { m_pIface->SetStates(dwStates, bSet); } -void* CFWL_Widget::GetLayoutItem() const { - return m_pIface ? m_pIface->GetLayoutItem() : nullptr; -} - void CFWL_Widget::SetLayoutItem(void* pItem) { if (m_pIface) m_pIface->SetLayoutItem(pItem); } -FWL_Error CFWL_Widget::Update() { +void CFWL_Widget::Update() { if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->Update(); + return; + m_pIface->Update(); } -FWL_Error CFWL_Widget::LockUpdate() { +void CFWL_Widget::LockUpdate() { if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->LockUpdate(); + return; + m_pIface->LockUpdate(); } -FWL_Error CFWL_Widget::UnlockUpdate() { +void CFWL_Widget::UnlockUpdate() { if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->UnlockUpdate(); + return; + m_pIface->UnlockUpdate(); } FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { @@ -168,33 +125,6 @@ FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { return m_pIface->HitTest(fx, fy); } -FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget, - FX_FLOAT& fx, - FX_FLOAT& fy) { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, fx, - fy); -} - -FWL_Error CFWL_Widget::TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt) { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->TransformTo(pWidget ? pWidget->GetWidget() : nullptr, rt); -} - -FWL_Error CFWL_Widget::GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal) { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->GetMatrix(matrix, bGlobal); -} - -FWL_Error CFWL_Widget::SetMatrix(const CFX_Matrix& matrix) { - if (!m_pIface) - return FWL_Error::Indefinite; - return m_pIface->SetMatrix(matrix); -} - FWL_Error CFWL_Widget::DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (!m_pIface) @@ -209,128 +139,3 @@ IFWL_WidgetDelegate* CFWL_Widget::SetDelegate(IFWL_WidgetDelegate* pDelegate) { m_pDelegate = m_pIface->SetDelegate(pDelegate); return m_pDelegate; } - -CFWL_Widget::CFWL_Widget() - : m_pDelegate(nullptr), - m_pWidgetMgr(CFWL_WidgetMgr::GetInstance()), - m_pProperties(new CFWL_WidgetProperties) { - ASSERT(m_pWidgetMgr); -} - -CFWL_Widget::~CFWL_Widget() { - if (m_pIface) - m_pIface->Finalize(); -} - -FWL_Error CFWL_Widget::Repaint(const CFX_RectF* pRect) { - if (!m_pIface) - return FWL_Error::Indefinite; - - CFX_RectF rect; - if (pRect) { - rect = *pRect; - } else { - m_pIface->GetWidgetRect(rect); - rect.left = rect.top = 0; - } - return m_pWidgetMgr->RepaintWidget(m_pIface.get(), &rect); -} - -FWL_Error CFWL_Widget::SetFocus(FX_BOOL bFocus) { - if (!m_pIface) - return FWL_Error::Indefinite; - - IFWL_App* pApp = m_pIface->GetOwnerApp(); - if (!pApp) - return FWL_Error::Indefinite; - - CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); - if (!pDriver) - return FWL_Error::Indefinite; - - if (bFocus) { - pDriver->SetFocus(m_pIface.get()); - } else { - if (pDriver->GetFocus() == m_pIface.get()) { - pDriver->SetFocus(nullptr); - } - } - return FWL_Error::Succeeded; -} - -FWL_Error CFWL_Widget::SetGrab(FX_BOOL bSet) { - if (!m_pIface) - return FWL_Error::Indefinite; - - IFWL_App* pApp = m_pIface->GetOwnerApp(); - if (!pApp) - return FWL_Error::Indefinite; - - CFWL_NoteDriver* pDriver = pApp->GetNoteDriver(); - if (!pDriver) - return FWL_Error::Indefinite; - - pDriver->SetGrab(m_pIface.get(), bSet); - return FWL_Error::Succeeded; -} - -void CFWL_Widget::RegisterEventTarget(CFWL_Widget* pEventSource, - uint32_t dwFilter) { - if (!m_pIface) - return; - - IFWL_App* pApp = m_pIface->GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); - if (!pNoteDriver) - return; - - IFWL_Widget* pEventSourceImp = - !pEventSource ? nullptr : pEventSource->GetWidget(); - pNoteDriver->RegisterEventTarget(GetWidget(), pEventSourceImp, dwFilter); -} - -void CFWL_Widget::DispatchEvent(CFWL_Event* pEvent) { - if (!m_pIface) - return; - if (m_pIface->GetOuter()) - return; - - IFWL_App* pApp = m_pIface->GetOwnerApp(); - if (!pApp) - return; - - CFWL_NoteDriver* pNoteDriver = pApp->GetNoteDriver(); - if (!pNoteDriver) - return; - - pNoteDriver->SendEvent(pEvent); -} - -CFX_SizeF CFWL_Widget::CalcTextSize(const CFX_WideString& wsText, - FX_BOOL bMultiLine, - int32_t iLineWidth) { - if (!m_pIface) - return CFX_SizeF(); - - IFWL_ThemeProvider* pTheme = m_pIface->GetThemeProvider(); - if (!pTheme) - return CFX_SizeF(); - - CFWL_ThemeText calPart; - calPart.m_pWidget = m_pIface.get(); - calPart.m_wsText = wsText; - calPart.m_dwTTOStyles = - bMultiLine ? FDE_TTOSTYLE_LineWrap : FDE_TTOSTYLE_SingleLine; - calPart.m_iTTOAlign = FDE_TTOALIGNMENT_TopLeft; - CFX_RectF rect; - FX_FLOAT fWidth = bMultiLine - ? (iLineWidth > 0 ? (FX_FLOAT)iLineWidth - : FWL_WGT_CalcMultiLineDefWidth) - : FWL_WGT_CalcWidth; - rect.Set(0, 0, fWidth, FWL_WGT_CalcHeight); - pTheme->CalcTextRect(&calPart, rect); - return CFX_SizeF(rect.width, rect.height); -} diff --git a/xfa/fwl/lightwidget/cfwl_widget.h b/xfa/fwl/lightwidget/cfwl_widget.h index c230ce200c..16b1141aae 100644 --- a/xfa/fwl/lightwidget/cfwl_widget.h +++ b/xfa/fwl/lightwidget/cfwl_widget.h @@ -21,59 +21,37 @@ class CFWL_WidgetMgr; class CFWL_Widget { public: + CFWL_Widget(); virtual ~CFWL_Widget(); virtual IFWL_Widget* GetWidget(); virtual const IFWL_Widget* GetWidget() const; - FWL_Error GetClassName(CFX_WideString& wsClass) const; - FWL_Type GetClassID() const; - virtual FX_BOOL IsInstance(const CFX_WideStringC& wsClass) const; - FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE); - FWL_Error GetGlobalRect(CFX_RectF& rect); FWL_Error SetWidgetRect(const CFX_RectF& rect); + FWL_Error GetGlobalRect(CFX_RectF& rect); FWL_Error GetClientRect(CFX_RectF& rtClient); - CFWL_Widget* GetParent(); - FWL_Error SetParent(CFWL_Widget* pParent); - CFWL_Widget* GetOwner(); - FWL_Error SetOwner(CFWL_Widget* pOwner); - uint32_t GetStyles(); + FWL_Error ModifyStyles(uint32_t dwStylesAdded, uint32_t dwStylesRemoved); uint32_t GetStylesEx(); FWL_Error ModifyStylesEx(uint32_t dwStylesExAdded, uint32_t dwStylesExRemoved); + uint32_t GetStates(); void SetStates(uint32_t dwStates, FX_BOOL bSet = TRUE); - void* GetLayoutItem() const; + void SetLayoutItem(void* pItem); - FWL_Error SetPrivateData(void* module_id, - void* pData, - PD_CALLBACK_FREEDATA callback); - void* GetPrivateData(void* module_id); - FWL_Error Update(); - FWL_Error LockUpdate(); - FWL_Error UnlockUpdate(); + void Update(); + void LockUpdate(); + void UnlockUpdate(); + FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy); - FWL_Error TransformTo(CFWL_Widget* pWidget, FX_FLOAT& fx, FX_FLOAT& fy); - FWL_Error TransformTo(CFWL_Widget* pWidget, CFX_RectF& rt); - FWL_Error GetMatrix(CFX_Matrix& matrix, FX_BOOL bGlobal = FALSE); - FWL_Error SetMatrix(const CFX_Matrix& matrix); + FWL_Error DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix = nullptr); - IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); - FWL_Error Repaint(const CFX_RectF* pRect = nullptr); - FWL_Error SetFocus(FX_BOOL bFocus); - FWL_Error SetGrab(FX_BOOL bSet); - CFWL_Widget(); - void RegisterEventTarget(CFWL_Widget* pEventSource = nullptr, - uint32_t dwFilter = FWL_EVENT_ALL_MASK); - void DispatchEvent(CFWL_Event* pEvent); - CFX_SizeF CalcTextSize(const CFX_WideString& wsText, - FX_BOOL bMultiLine = FALSE, - int32_t iLineWidth = -1); + IFWL_WidgetDelegate* SetDelegate(IFWL_WidgetDelegate* pDelegate); protected: FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = nullptr); |