summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-07-30 21:50:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-30 21:50:07 +0000
commit87c1fdcc9a5669e29c4440e2b220587de7134e7a (patch)
treecf890e10d6233205505a0d89eae13b3bd0deba14 /xfa/fxfa/parser
parent649e059f5fe93c0de53aaa48a74068703df46301 (diff)
downloadpdfium-87c1fdcc9a5669e29c4440e2b220587de7134e7a.tar.xz
Don't static_cast<>(this) to subclass in CXFA_LayoutItem methods.chromium/3508
Instead, move the methods to the subclass where they belong. Fix IWYU in CJX_Object.h to fix compilation. Change-Id: I4c71f28235b9cf5000e9ddaf33d6602baf22205f Reviewed-on: https://pdfium-review.googlesource.com/39170 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_contentlayoutitem.cpp79
-rw-r--r--xfa/fxfa/parser/cxfa_contentlayoutitem.h9
-rw-r--r--xfa/fxfa/parser/cxfa_layoutitem.cpp99
-rw-r--r--xfa/fxfa/parser/cxfa_layoutitem.h11
4 files changed, 89 insertions, 109 deletions
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
index 1ee364b9b7..e763e2d5da 100644
--- a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
#include "fxjs/xfa/cjx_object.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
@@ -19,3 +20,81 @@ CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
if (m_pFormNode->JSObject()->GetLayoutItem() == this)
m_pFormNode->JSObject()->SetLayoutItem(nullptr);
}
+
+CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::GetFirst() {
+ CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pPrev)
+ pCurNode = pCurNode->m_pPrev;
+
+ return pCurNode;
+}
+
+CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::GetLast() {
+ CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pNext)
+ pCurNode = pCurNode->m_pNext;
+
+ return pCurNode;
+}
+
+CFX_RectF CXFA_ContentLayoutItem::GetRect(bool bRelative) const {
+ CFX_PointF sPos = m_sPos;
+ CFX_SizeF sSize = m_sSize;
+ if (bRelative)
+ return CFX_RectF(sPos, sSize);
+
+ for (CXFA_LayoutItem* pLayoutItem = m_pParent; pLayoutItem;
+ pLayoutItem = pLayoutItem->m_pParent) {
+ if (CXFA_ContentLayoutItem* pContent = pLayoutItem->AsContentLayoutItem()) {
+ sPos += pContent->m_sPos;
+ CXFA_Margin* pMarginNode =
+ pContent->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
+ if (pMarginNode) {
+ sPos += CFX_PointF(pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::LeftInset)
+ .ToUnit(XFA_Unit::Pt),
+ pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::TopInset)
+ .ToUnit(XFA_Unit::Pt));
+ }
+ continue;
+ }
+
+ if (pLayoutItem->GetFormNode()->GetElementType() ==
+ XFA_Element::ContentArea) {
+ sPos += CFX_PointF(pLayoutItem->GetFormNode()
+ ->JSObject()
+ ->GetMeasure(XFA_Attribute::X)
+ .ToUnit(XFA_Unit::Pt),
+ pLayoutItem->GetFormNode()
+ ->JSObject()
+ ->GetMeasure(XFA_Attribute::Y)
+ .ToUnit(XFA_Unit::Pt));
+ break;
+ }
+ if (pLayoutItem->GetFormNode()->GetElementType() == XFA_Element::PageArea)
+ break;
+ }
+ return CFX_RectF(sPos, sSize);
+}
+
+int32_t CXFA_ContentLayoutItem::GetIndex() const {
+ int32_t iIndex = 0;
+ const CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pPrev) {
+ pCurNode = pCurNode->m_pPrev;
+ ++iIndex;
+ }
+ return iIndex;
+}
+
+int32_t CXFA_ContentLayoutItem::GetCount() const {
+ int32_t iCount = GetIndex() + 1;
+ const CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pNext) {
+ pCurNode = pCurNode->m_pNext;
+ iCount++;
+ }
+ return iCount;
+}
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.h b/xfa/fxfa/parser/cxfa_contentlayoutitem.h
index 500d3e4959..c7c440f9c2 100644
--- a/xfa/fxfa/parser/cxfa_contentlayoutitem.h
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.h
@@ -14,6 +14,15 @@ class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
explicit CXFA_ContentLayoutItem(CXFA_Node* pNode);
~CXFA_ContentLayoutItem() override;
+ CXFA_ContentLayoutItem* GetFirst();
+ CXFA_ContentLayoutItem* GetLast();
+ CXFA_ContentLayoutItem* GetPrev() const { return m_pPrev; }
+ CXFA_ContentLayoutItem* GetNext() const { return m_pNext; }
+
+ CFX_RectF GetRect(bool bRelative) const;
+ int32_t GetIndex() const;
+ int32_t GetCount() const;
+
CXFA_ContentLayoutItem* m_pPrev;
CXFA_ContentLayoutItem* m_pNext;
CFX_PointF m_sPos;
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.cpp b/xfa/fxfa/parser/cxfa_layoutitem.cpp
index 42294a508b..8b1c30e8cf 100644
--- a/xfa/fxfa/parser/cxfa_layoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutitem.cpp
@@ -57,105 +57,6 @@ CXFA_ContainerLayoutItem* CXFA_LayoutItem::GetPage() const {
}
return nullptr;
}
-
-CFX_RectF CXFA_LayoutItem::GetRect(bool bRelative) const {
- ASSERT(m_bIsContentLayoutItem);
-
- auto* pThis = static_cast<const CXFA_ContentLayoutItem*>(this);
- CFX_PointF sPos = pThis->m_sPos;
- CFX_SizeF sSize = pThis->m_sSize;
- if (bRelative)
- return CFX_RectF(sPos, sSize);
-
- for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem;
- pLayoutItem = pLayoutItem->m_pParent) {
- if (CXFA_ContentLayoutItem* pContent = pLayoutItem->AsContentLayoutItem()) {
- sPos += pContent->m_sPos;
- CXFA_Margin* pMarginNode =
- pLayoutItem->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
- XFA_Element::Margin);
- if (pMarginNode) {
- sPos += CFX_PointF(pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::LeftInset)
- .ToUnit(XFA_Unit::Pt),
- pMarginNode->JSObject()
- ->GetMeasure(XFA_Attribute::TopInset)
- .ToUnit(XFA_Unit::Pt));
- }
- continue;
- }
-
- if (pLayoutItem->m_pFormNode->GetElementType() ==
- XFA_Element::ContentArea) {
- sPos += CFX_PointF(pLayoutItem->m_pFormNode->JSObject()
- ->GetMeasure(XFA_Attribute::X)
- .ToUnit(XFA_Unit::Pt),
- pLayoutItem->m_pFormNode->JSObject()
- ->GetMeasure(XFA_Attribute::Y)
- .ToUnit(XFA_Unit::Pt));
- break;
- }
- if (pLayoutItem->m_pFormNode->GetElementType() == XFA_Element::PageArea)
- break;
- }
- return CFX_RectF(sPos, sSize);
-}
-
-CXFA_LayoutItem* CXFA_LayoutItem::GetFirst() {
- ASSERT(m_bIsContentLayoutItem);
- CXFA_ContentLayoutItem* pCurNode = static_cast<CXFA_ContentLayoutItem*>(this);
- while (pCurNode->m_pPrev)
- pCurNode = pCurNode->m_pPrev;
-
- return pCurNode;
-}
-
-const CXFA_LayoutItem* CXFA_LayoutItem::GetLast() const {
- ASSERT(m_bIsContentLayoutItem);
- const CXFA_ContentLayoutItem* pCurNode =
- static_cast<const CXFA_ContentLayoutItem*>(this);
- while (pCurNode->m_pNext)
- pCurNode = pCurNode->m_pNext;
-
- return pCurNode;
-}
-
-CXFA_LayoutItem* CXFA_LayoutItem::GetPrev() const {
- ASSERT(m_bIsContentLayoutItem);
-
- return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pPrev;
-}
-
-CXFA_LayoutItem* CXFA_LayoutItem::GetNext() const {
- ASSERT(m_bIsContentLayoutItem);
- return static_cast<const CXFA_ContentLayoutItem*>(this)->m_pNext;
-}
-
-int32_t CXFA_LayoutItem::GetIndex() const {
- ASSERT(m_bIsContentLayoutItem);
- int32_t iIndex = 0;
- const CXFA_ContentLayoutItem* pCurNode =
- static_cast<const CXFA_ContentLayoutItem*>(this);
- while (pCurNode->m_pPrev) {
- pCurNode = pCurNode->m_pPrev;
- ++iIndex;
- }
- return iIndex;
-}
-
-int32_t CXFA_LayoutItem::GetCount() const {
- ASSERT(m_bIsContentLayoutItem);
-
- int32_t iCount = GetIndex() + 1;
- const CXFA_ContentLayoutItem* pCurNode =
- static_cast<const CXFA_ContentLayoutItem*>(this);
- while (pCurNode->m_pNext) {
- pCurNode = pCurNode->m_pNext;
- iCount++;
- }
- return iCount;
-}
-
void CXFA_LayoutItem::AddChild(CXFA_LayoutItem* pChildItem) {
if (pChildItem->m_pParent)
pChildItem->m_pParent->RemoveChild(pChildItem);
diff --git a/xfa/fxfa/parser/cxfa_layoutitem.h b/xfa/fxfa/parser/cxfa_layoutitem.h
index 6e51a05e69..f5568df575 100644
--- a/xfa/fxfa/parser/cxfa_layoutitem.h
+++ b/xfa/fxfa/parser/cxfa_layoutitem.h
@@ -24,19 +24,10 @@ class CXFA_LayoutItem {
CXFA_ContentLayoutItem* AsContentLayoutItem();
CXFA_ContainerLayoutItem* GetPage() const;
- CFX_RectF GetRect(bool bRelative) const;
-
+ CXFA_LayoutItem* GetParent() const { return m_pParent; }
CXFA_Node* GetFormNode() const { return m_pFormNode.Get(); }
void SetFormNode(CXFA_Node* pNode) { m_pFormNode = pNode; }
- int32_t GetIndex() const;
- int32_t GetCount() const;
-
- CXFA_LayoutItem* GetParent() const { return m_pParent; }
- CXFA_LayoutItem* GetFirst();
- const CXFA_LayoutItem* GetLast() const;
- CXFA_LayoutItem* GetPrev() const;
- CXFA_LayoutItem* GetNext() const;
void AddChild(CXFA_LayoutItem* pChildItem);
void AddHeadChild(CXFA_LayoutItem* pChildItem);