diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-11-13 14:46:52 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-11-13 14:46:52 -0800 |
commit | ec441e67745054ece5e3d736b60fffa2f7f8d20c (patch) | |
tree | e929662ade5a8a64a10671b07646e8346193e98b /xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp | |
parent | b08ae8e24e68adbd876a8a2b7dcbfa6bc7a42074 (diff) | |
download | pdfium-ec441e67745054ece5e3d736b60fffa2f7f8d20c.tar.xz |
Add AsLayoutItem()/ToLayoutItem() functions.
Also protect the LayoutItem constructor, as !m_bIsContent
implies the object can be cast to the container class, so
ensure we don't make any of parent class.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1441243005 .
Diffstat (limited to 'xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp')
-rw-r--r-- | xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp index 4cb1192d20..263d36dbc7 100644 --- a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp +++ b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp @@ -385,8 +385,9 @@ void CXFA_LayoutItem::GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative) const { if (!bRelative) {
for (CXFA_LayoutItem* pLayoutItem = pThis->m_pParent; pLayoutItem;
pLayoutItem = pLayoutItem->m_pParent) {
- if (pLayoutItem->IsContentLayoutItem()) {
- sPos += static_cast<CXFA_ContentLayoutItem*>(pLayoutItem)->m_sPos;
+ if (CXFA_ContentLayoutItem* pContent =
+ pLayoutItem->AsContentLayoutItem()) {
+ sPos += pContent->m_sPos;
if (CXFA_Node* pMarginNode =
pLayoutItem->m_pFormNode->GetFirstChildByClass(
XFA_ELEMENT_Margin)) {
@@ -556,7 +557,7 @@ CXFA_ContentLayoutItem* CXFA_ItemLayoutProcessor::ExtractLayoutItem() { }
#ifdef _XFA_LAYOUTITEM_ProcessCACHE_
if (m_nCurChildNodeStage == XFA_ItemLayoutProcessorStages_Done &&
- m_pOldLayoutItem && m_pOldLayoutItem->IsContentLayoutItem()) {
+ ToContentLayoutItem(m_pOldLayoutItem)) {
if (m_pOldLayoutItem->m_pPrev) {
m_pOldLayoutItem->m_pPrev->m_pNext = NULL;
}
|