diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-12-04 10:05:37 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-12-04 10:05:37 -0800 |
commit | b54ced58fa30b3e85b2a955d25c974532131ed55 (patch) | |
tree | fca1768d56ab8e608834aaf08a89d7ae602a388c /xfa/src | |
parent | efa402a8016b6a1dbb02c1d5892db675e7d6f350 (diff) | |
download | pdfium-b54ced58fa30b3e85b2a955d25c974532131ed55.tar.xz |
Fix dubious casting in fwl_widgetimp.cpp.
Remove dead code along the way.
BUG=pdfium:300
R=jun_fang@foxitsoftware.com, thestig@chromium.org
Review URL: https://codereview.chromium.org/1490093006 .
Diffstat (limited to 'xfa/src')
-rw-r--r-- | xfa/src/fwl/src/core/fwl_widgetimp.cpp | 54 | ||||
-rw-r--r-- | xfa/src/fwl/src/core/include/fwl_widgetimp.h | 2 |
2 files changed, 4 insertions, 52 deletions
diff --git a/xfa/src/fwl/src/core/fwl_widgetimp.cpp b/xfa/src/fwl/src/core/fwl_widgetimp.cpp index 6d37e73689..1e52e04281 100644 --- a/xfa/src/fwl/src/core/fwl_widgetimp.cpp +++ b/xfa/src/fwl/src/core/fwl_widgetimp.cpp @@ -649,58 +649,12 @@ IFWL_ThemeProvider* CFWL_WidgetImp::GetAvailableTheme() { }
CFWL_WidgetImp* CFWL_WidgetImp::GetRootOuter() {
IFWL_Widget* pRet = m_pOuter;
- IFWL_Widget* pOuter = pRet;
- while (pOuter) {
+ if (!pRet)
+ return nullptr;
+ while (IFWL_Widget* pOuter = pRet->GetOuter()) {
pRet = pOuter;
- pOuter = pOuter->GetOuter();
}
- return (CFWL_WidgetImp*)pRet;
-}
-CFWL_WidgetImp* CFWL_WidgetImp::GetSameAncestor(CFWL_WidgetImp* pWidget) {
- CFX_PtrArray arr1, arr2;
- CFWL_WidgetImp* pAncestor = pWidget;
- FWL_WGTRELATION relation;
- do {
- arr1.Add(pAncestor);
- relation =
- pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(
- pAncestor->m_pInterface, relation)) != NULL);
- pAncestor = this;
- do {
- arr2.Add(pAncestor);
- relation =
- pAncestor->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- } while ((pAncestor = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget(
- pAncestor->m_pInterface, relation)) != NULL);
- for (int32_t i = 0; i < arr1.GetSize(); i++) {
- void* pVoid = arr1[i];
- if (arr2.Find(pVoid) < 0) {
- continue;
- } else {
- return (CFWL_WidgetImp*)pVoid;
- }
- }
- return NULL;
-}
-CFX_SizeF CFWL_WidgetImp::GetOffsetFromAncestor(CFWL_WidgetImp* pAncestor) {
- CFX_SizeF szRet;
- szRet.Set(0, 0);
- if (pAncestor == this) {
- return szRet;
- }
- CFWL_WidgetImp* pWidget = this;
- do {
- CFX_RectF rect;
- pWidget->GetWidgetRect(rect);
- szRet.x += rect.left;
- szRet.y += rect.top;
- FWL_WGTRELATION relation =
- pWidget->IsPopup() ? FWL_WGTRELATION_Owner : FWL_WGTRELATION_Parent;
- pWidget = (CFWL_WidgetImp*)m_pWidgetMgr->GetWidget((IFWL_Widget*)pWidget,
- relation);
- } while (pWidget && pWidget != pAncestor);
- return szRet;
+ return static_cast<CFWL_WidgetImp*>(pRet->GetImpl());
}
FX_BOOL CFWL_WidgetImp::TransformToOuter(FX_FLOAT& fx, FX_FLOAT& fy) {
if (!m_pOuter)
diff --git a/xfa/src/fwl/src/core/include/fwl_widgetimp.h b/xfa/src/fwl/src/core/include/fwl_widgetimp.h index efc7883eca..5a8b79f0f9 100644 --- a/xfa/src/fwl/src/core/include/fwl_widgetimp.h +++ b/xfa/src/fwl/src/core/include/fwl_widgetimp.h @@ -89,8 +89,6 @@ class CFWL_WidgetImp : public CFWL_TargetImp { void* GetThemeCapacity(FX_DWORD dwCapacity);
IFWL_ThemeProvider* GetAvailableTheme();
CFWL_WidgetImp* GetRootOuter();
- CFWL_WidgetImp* GetSameAncestor(CFWL_WidgetImp* pWidget);
- CFX_SizeF GetOffsetFromAncestor(CFWL_WidgetImp* pAncestor);
FX_BOOL TransformToOuter(FX_FLOAT& fx, FX_FLOAT& fy);
FX_BOOL TransformFromOuter(FX_FLOAT& fx, FX_FLOAT& fy);
CFX_SizeF CalcTextSize(const CFX_WideString& wsText,
|