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

Side by Side Diff: xfa/fwl/core/cfwl_widgetmgr.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Rebase to master Created 4 years 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/fwl/core/cfwl_widgetmgr.h ('k') | xfa/fwl/core/ifwl_widgetdelegate.h » ('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/fwl/core/cfwl_widgetmgr.h" 7 #include "xfa/fwl/core/cfwl_widgetmgr.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 CFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(CFWL_Widget* pWidget) const { 97 CFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(CFWL_Widget* pWidget) const {
98 Item* pItem = GetWidgetMgrItem(pWidget); 98 Item* pItem = GetWidgetMgrItem(pWidget);
99 while (pItem) { 99 while (pItem) {
100 if (IsAbleNative(pItem->pWidget)) 100 if (IsAbleNative(pItem->pWidget))
101 return pItem->pWidget; 101 return pItem->pWidget;
102 pItem = pItem->pParent; 102 pItem = pItem->pParent;
103 } 103 }
104 return nullptr; 104 return nullptr;
105 } 105 }
106 106
107 void CFWL_WidgetMgr::SetWidgetIndex(CFWL_Widget* pWidget, int32_t nIndex) { 107 void CFWL_WidgetMgr::AppendWidget(CFWL_Widget* pWidget) {
108 Item* pItem = GetWidgetMgrItem(pWidget); 108 Item* pItem = GetWidgetMgrItem(pWidget);
109 if (!pItem) 109 if (!pItem)
110 return; 110 return;
111 if (!pItem->pParent) 111 if (!pItem->pParent)
112 return; 112 return;
113 113
114 Item* pChild = pItem->pParent->pChild; 114 Item* pChild = pItem->pParent->pChild;
115 int32_t i = 0; 115 int32_t i = 0;
116 while (pChild) { 116 while (pChild) {
117 if (pChild == pItem) { 117 if (pChild == pItem) {
118 if (i == nIndex)
119 return;
120 if (pChild->pPrevious) 118 if (pChild->pPrevious)
121 pChild->pPrevious->pNext = pChild->pNext; 119 pChild->pPrevious->pNext = pChild->pNext;
122 if (pChild->pNext) 120 if (pChild->pNext)
123 pChild->pNext->pPrevious = pChild->pPrevious; 121 pChild->pNext->pPrevious = pChild->pPrevious;
124 if (pItem->pParent->pChild == pItem) 122 if (pItem->pParent->pChild == pItem)
125 pItem->pParent->pChild = pItem->pNext; 123 pItem->pParent->pChild = pItem->pNext;
126 124
127 pItem->pNext = nullptr; 125 pItem->pNext = nullptr;
128 pItem->pPrevious = nullptr; 126 pItem->pPrevious = nullptr;
129 break; 127 break;
130 } 128 }
131 if (!pChild->pNext) 129 if (!pChild->pNext)
132 break; 130 break;
133 131
134 pChild = pChild->pNext; 132 pChild = pChild->pNext;
135 ++i; 133 ++i;
136 } 134 }
137 135
138 pChild = pItem->pParent->pChild; 136 pChild = pItem->pParent->pChild;
139 if (pChild) { 137 if (pChild) {
140 if (nIndex < 0) { 138 while (pChild->pNext)
141 while (pChild->pNext) 139 pChild = pChild->pNext;
142 pChild = pChild->pNext;
143 140
144 pChild->pNext = pItem; 141 pChild->pNext = pItem;
145 pItem->pPrevious = pChild; 142 pItem->pPrevious = pChild;
146 pItem->pNext = nullptr;
147 return;
148 }
149
150 i = 0;
151 while (i < nIndex && pChild->pNext) {
152 pChild = pChild->pNext;
153 ++i;
154 }
155 if (!pChild->pNext) {
156 pChild->pNext = pItem;
157 pItem->pPrevious = pChild;
158 pItem->pNext = nullptr;
159 return;
160 }
161 if (pChild->pPrevious) {
162 pItem->pPrevious = pChild->pPrevious;
163 pChild->pPrevious->pNext = pItem;
164 }
165 pChild->pPrevious = pItem;
166 pItem->pNext = pChild;
167 if (pItem->pParent->pChild == pChild)
168 pItem->pParent->pChild = pItem;
169 } else { 143 } else {
170 pItem->pParent->pChild = pItem; 144 pItem->pParent->pChild = pItem;
171 pItem->pPrevious = nullptr; 145 pItem->pPrevious = nullptr;
172 pItem->pNext = nullptr;
173 } 146 }
147 pItem->pNext = nullptr;
174 } 148 }
175 149
176 void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget, 150 void CFWL_WidgetMgr::RepaintWidget(CFWL_Widget* pWidget,
177 const CFX_RectF* pRect) { 151 const CFX_RectF* pRect) {
178 if (!m_pAdapter) 152 if (!m_pAdapter)
179 return; 153 return;
180 154
181 CFWL_Widget* pNative = pWidget; 155 CFWL_Widget* pNative = pWidget;
182 CFX_RectF rect(*pRect); 156 CFX_RectF rect(*pRect);
183 if (IsFormDisabled()) { 157 if (IsFormDisabled()) {
(...skipping 10 matching lines...) Expand all
194 pNative = GetSystemFormWidget(pWidget); 168 pNative = GetSystemFormWidget(pWidget);
195 if (!pNative) 169 if (!pNative)
196 return; 170 return;
197 171
198 pWidget->TransformTo(pNative, rect.left, rect.top); 172 pWidget->TransformTo(pNative, rect.left, rect.top);
199 } 173 }
200 AddRedrawCounts(pNative); 174 AddRedrawCounts(pNative);
201 m_pAdapter->RepaintWidget(pNative, &rect); 175 m_pAdapter->RepaintWidget(pNative, &rect);
202 } 176 }
203 177
204 void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, 178 void CFWL_WidgetMgr::InsertWidget(CFWL_Widget* pParent, CFWL_Widget* pChild) {
205 CFWL_Widget* pChild,
206 int32_t nIndex) {
207 Item* pParentItem = GetWidgetMgrItem(pParent); 179 Item* pParentItem = GetWidgetMgrItem(pParent);
208 if (!pParentItem) { 180 if (!pParentItem) {
209 auto item = pdfium::MakeUnique<Item>(pParent); 181 auto item = pdfium::MakeUnique<Item>(pParent);
210 pParentItem = item.get(); 182 pParentItem = item.get();
211 m_mapWidgetItem[pParent] = std::move(item); 183 m_mapWidgetItem[pParent] = std::move(item);
212 184
213 pParentItem->pParent = GetWidgetMgrItem(nullptr); 185 pParentItem->pParent = GetWidgetMgrItem(nullptr);
214 SetWidgetIndex(pParent, -1); 186 AppendWidget(pParent);
215 } 187 }
216 188
217 Item* pItem = GetWidgetMgrItem(pChild); 189 Item* pItem = GetWidgetMgrItem(pChild);
218 if (!pItem) { 190 if (!pItem) {
219 auto item = pdfium::MakeUnique<Item>(pChild); 191 auto item = pdfium::MakeUnique<Item>(pChild);
220 pItem = item.get(); 192 pItem = item.get();
221 m_mapWidgetItem[pChild] = std::move(item); 193 m_mapWidgetItem[pChild] = std::move(item);
222 } 194 }
223 if (pItem->pParent && pItem->pParent != pParentItem) { 195 if (pItem->pParent && pItem->pParent != pParentItem) {
224 if (pItem->pPrevious) 196 if (pItem->pPrevious)
225 pItem->pPrevious->pNext = pItem->pNext; 197 pItem->pPrevious->pNext = pItem->pNext;
226 if (pItem->pNext) 198 if (pItem->pNext)
227 pItem->pNext->pPrevious = pItem->pPrevious; 199 pItem->pNext->pPrevious = pItem->pPrevious;
228 if (pItem->pParent->pChild == pItem) 200 if (pItem->pParent->pChild == pItem)
229 pItem->pParent->pChild = pItem->pNext; 201 pItem->pParent->pChild = pItem->pNext;
230 } 202 }
231 pItem->pParent = pParentItem; 203 pItem->pParent = pParentItem;
232 SetWidgetIndex(pChild, nIndex); 204 AppendWidget(pChild);
233 } 205 }
234 206
235 void CFWL_WidgetMgr::RemoveWidget(CFWL_Widget* pWidget) { 207 void CFWL_WidgetMgr::RemoveWidget(CFWL_Widget* pWidget) {
236 Item* pItem = GetWidgetMgrItem(pWidget); 208 Item* pItem = GetWidgetMgrItem(pWidget);
237 if (!pItem) 209 if (!pItem)
238 return; 210 return;
239 if (pItem->pPrevious) 211 if (pItem->pPrevious)
240 pItem->pPrevious->pNext = pItem->pNext; 212 pItem->pPrevious->pNext = pItem->pNext;
241 if (pItem->pNext) 213 if (pItem->pNext)
242 pItem->pNext->pPrevious = pItem->pPrevious; 214 pItem->pNext->pPrevious = pItem->pPrevious;
(...skipping 10 matching lines...) Expand all
253 } 225 }
254 226
255 void CFWL_WidgetMgr::SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned) { 227 void CFWL_WidgetMgr::SetOwner(CFWL_Widget* pOwner, CFWL_Widget* pOwned) {
256 Item* pParentItem = GetWidgetMgrItem(pOwner); 228 Item* pParentItem = GetWidgetMgrItem(pOwner);
257 if (!pParentItem) { 229 if (!pParentItem) {
258 auto item = pdfium::MakeUnique<Item>(pOwner); 230 auto item = pdfium::MakeUnique<Item>(pOwner);
259 pParentItem = item.get(); 231 pParentItem = item.get();
260 m_mapWidgetItem[pOwner] = std::move(item); 232 m_mapWidgetItem[pOwner] = std::move(item);
261 233
262 pParentItem->pParent = GetWidgetMgrItem(nullptr); 234 pParentItem->pParent = GetWidgetMgrItem(nullptr);
263 SetWidgetIndex(pOwner, -1); 235 AppendWidget(pOwner);
264 } 236 }
265 237
266 Item* pItem = GetWidgetMgrItem(pOwned); 238 Item* pItem = GetWidgetMgrItem(pOwned);
267 if (!pItem) { 239 if (!pItem) {
268 auto item = pdfium::MakeUnique<Item>(pOwned); 240 auto item = pdfium::MakeUnique<Item>(pOwned);
269 pItem = item.get(); 241 pItem = item.get();
270 m_mapWidgetItem[pOwned] = std::move(item); 242 m_mapWidgetItem[pOwned] = std::move(item);
271 } 243 }
272 pItem->pOwner = pParentItem; 244 pItem->pOwner = pParentItem;
273 } 245 }
274 void CFWL_WidgetMgr::SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild) { 246 void CFWL_WidgetMgr::SetParent(CFWL_Widget* pParent, CFWL_Widget* pChild) {
275 Item* pParentItem = GetWidgetMgrItem(pParent); 247 Item* pParentItem = GetWidgetMgrItem(pParent);
276 Item* pItem = GetWidgetMgrItem(pChild); 248 Item* pItem = GetWidgetMgrItem(pChild);
277 if (!pItem) 249 if (!pItem)
278 return; 250 return;
279 if (pItem->pParent && pItem->pParent != pParentItem) { 251 if (pItem->pParent && pItem->pParent != pParentItem) {
280 if (pItem->pPrevious) 252 if (pItem->pPrevious)
281 pItem->pPrevious->pNext = pItem->pNext; 253 pItem->pPrevious->pNext = pItem->pNext;
282 if (pItem->pNext) 254 if (pItem->pNext)
283 pItem->pNext->pPrevious = pItem->pPrevious; 255 pItem->pNext->pPrevious = pItem->pPrevious;
284 if (pItem->pParent->pChild == pItem) 256 if (pItem->pParent->pChild == pItem)
285 pItem->pParent->pChild = pItem->pNext; 257 pItem->pParent->pChild = pItem->pNext;
286 258
287 pItem->pNext = nullptr; 259 pItem->pNext = nullptr;
288 pItem->pPrevious = nullptr; 260 pItem->pPrevious = nullptr;
289 } 261 }
290 pItem->pParent = pParentItem; 262 pItem->pParent = pParentItem;
291 SetWidgetIndex(pChild, -1); 263 AppendWidget(pChild);
292 } 264 }
293 265
294 void CFWL_WidgetMgr::SetWidgetRect_Native(CFWL_Widget* pWidget, 266 void CFWL_WidgetMgr::SetWidgetRect_Native(CFWL_Widget* pWidget,
295 const CFX_RectF& rect) { 267 const CFX_RectF& rect) {
296 if (!FWL_UseOffscreen(pWidget)) 268 if (!FWL_UseOffscreen(pWidget))
297 return; 269 return;
298 270
299 Item* pItem = GetWidgetMgrItem(pWidget); 271 Item* pItem = GetWidgetMgrItem(pWidget);
300 pItem->iRedrawCounter++; 272 pItem->iRedrawCounter++;
301 if (pItem->pOffscreen) { 273 if (pItem->pOffscreen) {
(...skipping 18 matching lines...) Expand all
320 return nullptr; 292 return nullptr;
321 293
322 FX_FLOAT x1; 294 FX_FLOAT x1;
323 FX_FLOAT y1; 295 FX_FLOAT y1;
324 CFWL_Widget* child = GetLastChildWidget(parent); 296 CFWL_Widget* child = GetLastChildWidget(parent);
325 while (child) { 297 while (child) {
326 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { 298 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
327 x1 = x; 299 x1 = x;
328 y1 = y; 300 y1 = y;
329 CFX_Matrix matrixOnParent; 301 CFX_Matrix matrixOnParent;
330 child->GetMatrix(matrixOnParent); 302 child->GetMatrix(matrixOnParent, false);
331 CFX_Matrix m; 303 CFX_Matrix m;
332 m.SetIdentity(); 304 m.SetIdentity();
333 m.SetReverse(matrixOnParent); 305 m.SetReverse(matrixOnParent);
334 m.TransformPoint(x1, y1); 306 m.TransformPoint(x1, y1);
335 CFX_RectF bounds; 307 CFX_RectF bounds;
336 child->GetWidgetRect(bounds, false); 308 child->GetWidgetRect(bounds, false);
337 if (bounds.Contains(x1, y1)) { 309 if (bounds.Contains(x1, y1)) {
338 x1 -= bounds.left; 310 x1 -= bounds.left;
339 y1 -= bounds.top; 311 y1 -= bounds.top;
340 return GetWidgetAtPoint(child, x1, y1); 312 return GetWidgetAtPoint(child, x1, y1);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 pWidget(widget), 731 pWidget(widget),
760 iRedrawCounter(0) 732 iRedrawCounter(0)
761 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 733 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
762 , 734 ,
763 bOutsideChanged(false) 735 bOutsideChanged(false)
764 #endif 736 #endif
765 { 737 {
766 } 738 }
767 739
768 CFWL_WidgetMgr::Item::~Item() {} 740 CFWL_WidgetMgr::Item::~Item() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_widgetmgr.h ('k') | xfa/fwl/core/ifwl_widgetdelegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698