summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-08-01 16:30:14 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-01 16:30:14 +0000
commit56094c50c0da84258e6d4348a860e588114e590d (patch)
treee1463000cabfa194a621857284acddda0b01a8e3 /xfa
parent3a40bed9d6e573f2c280bf7581249cb2d9163771 (diff)
downloadpdfium-56094c50c0da84258e6d4348a860e588114e590d.tar.xz
Rename PageSetContainerLayoutItem to TraverseStrategy_PageSet.chromium/3509
Provides consistency with the naming of other traverse strategies. Fix dubious casting inside the strategy. Change-Id: Ic96b1922ae1dc601a37c8c3b3dd0f118ab6b2eea Reviewed-on: https://pdfium-review.googlesource.com/39210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index 411ad24e45..d1106ffae6 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -34,41 +34,48 @@
namespace {
-class PageSetContainerLayoutItem {
+class TraverseStrategy_PageSet {
public:
static CXFA_ContainerLayoutItem* GetFirstChild(
CXFA_ContainerLayoutItem* pLayoutItem) {
if (pLayoutItem->GetFormNode()->GetElementType() != XFA_Element::PageSet)
return nullptr;
- CXFA_ContainerLayoutItem* pChildItem =
- static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild);
- while (pChildItem && pChildItem->GetFormNode()->GetElementType() !=
- XFA_Element::PageSet) {
- pChildItem =
- static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling);
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pFirstChild; pChildItem;
+ pChildItem = pChildItem->m_pNextSibling) {
+ CXFA_ContainerLayoutItem* pContainer =
+ pChildItem->AsContainerLayoutItem();
+ if (pContainer &&
+ pContainer->GetFormNode()->GetElementType() == XFA_Element::PageSet) {
+ return pContainer;
+ }
}
- return pChildItem;
+ return nullptr;
}
static CXFA_ContainerLayoutItem* GetNextSibling(
CXFA_ContainerLayoutItem* pLayoutItem) {
- CXFA_ContainerLayoutItem* pChildItem =
- static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling);
- while (pChildItem && pChildItem->GetFormNode()->GetElementType() !=
- XFA_Element::PageSet) {
- pChildItem =
- static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling);
+ for (CXFA_LayoutItem* pChildItem = pLayoutItem->m_pNextSibling; pChildItem;
+ pChildItem = pChildItem->m_pNextSibling) {
+ CXFA_ContainerLayoutItem* pContainer =
+ pChildItem->AsContainerLayoutItem();
+ if (pContainer &&
+ pContainer->GetFormNode()->GetElementType() == XFA_Element::PageSet) {
+ return pContainer;
+ }
}
- return pChildItem;
+ return nullptr;
}
static CXFA_ContainerLayoutItem* GetParent(
CXFA_ContainerLayoutItem* pLayoutItem) {
- return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent);
+ return ToContainerLayoutItem(pLayoutItem->m_pParent);
}
};
+using PageSetIterator = CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem,
+ TraverseStrategy_PageSet>;
+
uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) {
uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable;
WideString wsRelevant =
@@ -613,9 +620,7 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
for (; pRootPageSetLayoutItem;
pRootPageSetLayoutItem = static_cast<CXFA_ContainerLayoutItem*>(
pRootPageSetLayoutItem->m_pNextSibling)) {
- CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem,
- PageSetContainerLayoutItem>
- sIterator(pRootPageSetLayoutItem);
+ PageSetIterator sIterator(pRootPageSetLayoutItem);
for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent();
pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) {
XFA_AttributeEnum ePageRelation =