Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: xfa/fxfa/app/xfa_ffpageview.cpp

Issue 1986503002: XFA_WIDGETSTATUS, LAYOUTSTATUS and WIDGETFILTER cleanup. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_fftextedit.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/include/xfa_ffpageview.h" 7 #include "xfa/fxfa/include/xfa_ffpageview.h"
8 8
9 #include "xfa/fde/fde_render.h" 9 #include "xfa/fde/fde_render.h"
10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" 10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 : (FX_FLOAT)devicePageRect.left; 62 : (FX_FLOAT)devicePageRect.left;
63 m.f = bFlipX ? (FX_FLOAT)devicePageRect.top 63 m.f = bFlipX ? (FX_FLOAT)devicePageRect.top
64 : (FX_FLOAT)devicePageRect.bottom(); 64 : (FX_FLOAT)devicePageRect.bottom();
65 break; 65 break;
66 default: 66 default:
67 break; 67 break;
68 } 68 }
69 pageMatrix = m; 69 pageMatrix = m;
70 } 70 }
71 71
72 bool PageWidgetFilter(CXFA_FFWidget* pWidget,
73 uint32_t dwFilter,
74 FX_BOOL bTraversal,
75 FX_BOOL bIgnorerelevant) {
76 CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
77
78 if (!!(dwFilter & XFA_WidgetStatus_Focused) &&
79 pWidgetAcc->GetClassID() != XFA_ELEMENT_Field) {
80 return false;
81 }
82
83 uint32_t dwStatus = pWidget->GetStatus();
84 if (bTraversal && (dwStatus & XFA_WidgetStatus_Disabled))
85 return false;
86 if (bIgnorerelevant)
87 return !!(dwStatus & XFA_WidgetStatus_Visible);
88
89 dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable |
90 XFA_WidgetStatus_Printable);
91 return (dwFilter & dwStatus) == dwFilter;
92 }
93
72 } // namespace 94 } // namespace
95
73 CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) 96 CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea)
74 : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} 97 : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {}
75 98
76 CXFA_FFPageView::~CXFA_FFPageView() {} 99 CXFA_FFPageView::~CXFA_FFPageView() {}
77 100
78 CXFA_FFDocView* CXFA_FFPageView::GetDocView() const { 101 CXFA_FFDocView* CXFA_FFPageView::GetDocView() const {
79 return m_pDocView; 102 return m_pDocView;
80 } 103 }
81 104
82 int32_t CXFA_FFPageView::GetPageViewIndex() const { 105 int32_t CXFA_FFPageView::GetPageViewIndex() const {
(...skipping 20 matching lines...) Expand all
103 uint32_t dwWidgetFilter) { 126 uint32_t dwWidgetFilter) {
104 switch (dwTraverseWay) { 127 switch (dwTraverseWay) {
105 case XFA_TRAVERSEWAY_Tranvalse: 128 case XFA_TRAVERSEWAY_Tranvalse:
106 return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter); 129 return new CXFA_FFTabOrderPageWidgetIterator(this, dwWidgetFilter);
107 case XFA_TRAVERSEWAY_Form: 130 case XFA_TRAVERSEWAY_Form:
108 return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter); 131 return new CXFA_FFPageWidgetIterator(this, dwWidgetFilter);
109 } 132 }
110 return nullptr; 133 return nullptr;
111 } 134 }
112 135
113 static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget,
114 uint32_t dwFilter,
115 FX_BOOL bTraversal,
116 FX_BOOL bIgnorerelevant) {
117 CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc();
118 uint32_t dwType = dwFilter & XFA_WIDGETFILTER_AllType;
119 if ((dwType == XFA_WIDGETFILTER_Field) &&
120 (pWidgetAcc->GetClassID() != XFA_ELEMENT_Field)) {
121 return FALSE;
122 }
123 uint32_t dwStatus = pWidget->GetStatus();
124 if (bTraversal && (dwStatus & XFA_WIDGETSTATUS_Disabled)) {
125 return FALSE;
126 }
127 if (bIgnorerelevant) {
128 return (dwStatus & XFA_WIDGETFILTER_Visible) != 0;
129 }
130 dwFilter &= (XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable |
131 XFA_WIDGETFILTER_Printable);
132 return (dwFilter & dwStatus) == dwFilter;
133 }
134 CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, 136 CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView,
135 uint32_t dwFilter) { 137 uint32_t dwFilter) {
136 m_pPageView = pPageView; 138 m_pPageView = pPageView;
137 m_dwFilter = dwFilter; 139 m_dwFilter = dwFilter;
138 m_sIterator.Init(pPageView); 140 m_sIterator.Init(pPageView);
139 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) 141 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc())
140 ->GetXFADoc() 142 ->GetXFADoc()
141 ->GetCurVersionMode() < XFA_VERSION_205; 143 ->GetCurVersionMode() < XFA_VERSION_205;
142 } 144 }
143 CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} 145 CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {}
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { 181 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() {
180 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); 182 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent();
181 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; 183 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL;
182 } 184 }
183 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { 185 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) {
184 return hWidget && m_sIterator.SetCurrent(hWidget); 186 return hWidget && m_sIterator.SetCurrent(hWidget);
185 } 187 }
186 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( 188 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget(
187 CXFA_LayoutItem* pLayoutItem) { 189 CXFA_LayoutItem* pLayoutItem) {
188 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { 190 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) {
189 if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { 191 if (!PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) {
190 return NULL; 192 return NULL;
191 } 193 }
192 if (!pWidget->IsLoaded() && 194 if (!pWidget->IsLoaded() &&
193 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { 195 (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) {
194 pWidget->LoadWidget(); 196 pWidget->LoadWidget();
195 } 197 }
196 return pWidget; 198 return pWidget;
197 } 199 }
198 return NULL; 200 return NULL;
199 } 201 }
200 202
201 CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( 203 CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator(
202 CXFA_FFPageView* pPageView, 204 CXFA_FFPageView* pPageView,
203 uint32_t dwFilter) 205 uint32_t dwFilter)
204 : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { 206 : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) {
205 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) 207 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc())
206 ->GetXFADoc() 208 ->GetXFADoc()
207 ->GetCurVersionMode() < XFA_VERSION_205; 209 ->GetCurVersionMode() < XFA_VERSION_205;
208 Reset(); 210 Reset();
209 } 211 }
210 212
211 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} 213 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {}
212 214
213 void CXFA_FFTabOrderPageWidgetIterator::Reset() { 215 void CXFA_FFTabOrderPageWidgetIterator::Reset() {
214 CreateTabOrderWidgetArray(); 216 CreateTabOrderWidgetArray();
215 m_iCurWidget = -1; 217 m_iCurWidget = -1;
216 } 218 }
217 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { 219 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() {
218 if (m_TabOrderWidgetArray.GetSize() > 0) { 220 if (m_TabOrderWidgetArray.GetSize() > 0) {
219 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { 221 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) {
220 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, 222 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
221 m_bIgnorerelevant)) { 223 m_bIgnorerelevant)) {
222 m_iCurWidget = i; 224 m_iCurWidget = i;
223 return m_TabOrderWidgetArray[m_iCurWidget]; 225 return m_TabOrderWidgetArray[m_iCurWidget];
224 } 226 }
225 } 227 }
226 } 228 }
227 return NULL; 229 return NULL;
228 } 230 }
229 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { 231 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() {
230 if (m_TabOrderWidgetArray.GetSize() > 0) { 232 if (m_TabOrderWidgetArray.GetSize() > 0) {
231 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { 233 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) {
232 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, 234 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
233 m_bIgnorerelevant)) { 235 m_bIgnorerelevant)) {
234 m_iCurWidget = i; 236 m_iCurWidget = i;
235 return m_TabOrderWidgetArray[m_iCurWidget]; 237 return m_TabOrderWidgetArray[m_iCurWidget];
236 } 238 }
237 } 239 }
238 } 240 }
239 return NULL; 241 return NULL;
240 } 242 }
241 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { 243 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() {
242 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { 244 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) {
243 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, 245 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
244 m_bIgnorerelevant)) { 246 m_bIgnorerelevant)) {
245 m_iCurWidget = i; 247 m_iCurWidget = i;
246 return m_TabOrderWidgetArray[m_iCurWidget]; 248 return m_TabOrderWidgetArray[m_iCurWidget];
247 } 249 }
248 } 250 }
249 m_iCurWidget = -1; 251 m_iCurWidget = -1;
250 return NULL; 252 return NULL;
251 } 253 }
252 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { 254 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() {
253 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { 255 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) {
254 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, 256 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE,
255 m_bIgnorerelevant)) { 257 m_bIgnorerelevant)) {
256 m_iCurWidget = i; 258 m_iCurWidget = i;
257 return m_TabOrderWidgetArray[m_iCurWidget]; 259 return m_TabOrderWidgetArray[m_iCurWidget];
258 } 260 }
259 } 261 }
260 m_iCurWidget = -1; 262 m_iCurWidget = -1;
261 return NULL; 263 return NULL;
262 } 264 }
263 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { 265 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() {
264 if (m_iCurWidget >= 0) { 266 if (m_iCurWidget >= 0) {
265 return m_TabOrderWidgetArray[m_iCurWidget]; 267 return m_TabOrderWidgetArray[m_iCurWidget];
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea, TRUE); 422 OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea, TRUE);
421 if (pParam->m_Children.GetSize() > 0) { 423 if (pParam->m_Children.GetSize() > 0) {
422 WidgetArray.Append(pParam->m_Children); 424 WidgetArray.Append(pParam->m_Children);
423 } 425 }
424 delete pParam; 426 delete pParam;
425 } 427 }
426 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( 428 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget(
427 CXFA_LayoutItem* pLayoutItem) { 429 CXFA_LayoutItem* pLayoutItem) {
428 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { 430 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) {
429 if (!pWidget->IsLoaded() && 431 if (!pWidget->IsLoaded() &&
430 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { 432 (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) {
431 pWidget->LoadWidget(); 433 pWidget->LoadWidget();
432 } 434 }
433 return pWidget; 435 return pWidget;
434 } 436 }
435 return NULL; 437 return NULL;
436 } 438 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_ffnotify.cpp ('k') | xfa/fxfa/app/xfa_fftextedit.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698