OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 ASSERT_ARG(window, window); | 220 ASSERT_ARG(window, window); |
221 Frame* frame = window->frame(); | 221 Frame* frame = window->frame(); |
222 if (!frame) | 222 if (!frame) |
223 return false; | 223 return false; |
224 Page* page = frame->page(); | 224 Page* page = frame->page(); |
225 if (!page) | 225 if (!page) |
226 return false; | 226 return false; |
227 return frame == page->mainFrame(); | 227 return frame == page->mainFrame(); |
228 } | 228 } |
229 | 229 |
230 bool DOMWindow::dispatchAllPendingBeforeUnloadEvents() | |
231 { | |
232 DOMWindowSet& set = windowsWithBeforeUnloadEventListeners(); | |
233 if (set.isEmpty()) | |
234 return true; | |
235 | |
236 static bool alreadyDispatched = false; | |
237 ASSERT(!alreadyDispatched); | |
238 if (alreadyDispatched) | |
239 return true; | |
240 | |
241 Vector<RefPtr<DOMWindow> > windows; | |
242 DOMWindowSet::iterator end = set.end(); | |
243 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it) | |
244 windows.append(it->key); | |
245 | |
246 size_t size = windows.size(); | |
247 for (size_t i = 0; i < size; ++i) { | |
248 DOMWindow* window = windows[i].get(); | |
249 if (!set.contains(window)) | |
250 continue; | |
251 | |
252 Frame* frame = window->frame(); | |
253 if (!frame) | |
254 continue; | |
255 | |
256 if (!frame->loader()->shouldClose()) | |
257 return false; | |
258 } | |
259 | |
260 enableSuddenTermination(); | |
261 | |
262 alreadyDispatched = true; | |
263 | |
264 return true; | |
265 } | |
266 | |
267 unsigned DOMWindow::pendingUnloadEventListeners() const | 230 unsigned DOMWindow::pendingUnloadEventListeners() const |
268 { | 231 { |
269 return windowsWithUnloadEventListeners().count(const_cast<DOMWindow*>(this))
; | 232 return windowsWithUnloadEventListeners().count(const_cast<DOMWindow*>(this))
; |
270 } | 233 } |
271 | 234 |
272 void DOMWindow::dispatchAllPendingUnloadEvents() | |
273 { | |
274 DOMWindowSet& set = windowsWithUnloadEventListeners(); | |
275 if (set.isEmpty()) | |
276 return; | |
277 | |
278 static bool alreadyDispatched = false; | |
279 ASSERT(!alreadyDispatched); | |
280 if (alreadyDispatched) | |
281 return; | |
282 | |
283 Vector<RefPtr<DOMWindow> > windows; | |
284 DOMWindowSet::iterator end = set.end(); | |
285 for (DOMWindowSet::iterator it = set.begin(); it != end; ++it) | |
286 windows.append(it->key); | |
287 | |
288 size_t size = windows.size(); | |
289 for (size_t i = 0; i < size; ++i) { | |
290 DOMWindow* window = windows[i].get(); | |
291 if (!set.contains(window)) | |
292 continue; | |
293 | |
294 window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideE
vent, false), window->document()); | |
295 window->dispatchEvent(Event::create(eventNames().unloadEvent, false, fal
se), window->document()); | |
296 } | |
297 | |
298 enableSuddenTermination(); | |
299 | |
300 alreadyDispatched = true; | |
301 } | |
302 | |
303 // This function: | 235 // This function: |
304 // 1) Validates the pending changes are not changing any value to NaN; in that c
ase keep original value. | 236 // 1) Validates the pending changes are not changing any value to NaN; in that c
ase keep original value. |
305 // 2) Constrains the window rect to the minimum window size and no bigger than t
he float rect's dimensions. | 237 // 2) Constrains the window rect to the minimum window size and no bigger than t
he float rect's dimensions. |
306 // 3) Constrains the window rect to within the top and left boundaries of the av
ailable screen rect. | 238 // 3) Constrains the window rect to within the top and left boundaries of the av
ailable screen rect. |
307 // 4) Constrains the window rect to within the bottom and right boundaries of th
e available screen rect. | 239 // 4) Constrains the window rect to within the bottom and right boundaries of th
e available screen rect. |
308 // 5) Translate the window rect coordinates to be within the coordinate space of
the screen. | 240 // 5) Translate the window rect coordinates to be within the coordinate space of
the screen. |
309 FloatRect DOMWindow::adjustWindowRect(Page* page, const FloatRect& pendingChange
s) | 241 FloatRect DOMWindow::adjustWindowRect(Page* page, const FloatRect& pendingChange
s) |
310 { | 242 { |
311 ASSERT(page); | 243 ASSERT(page); |
312 | 244 |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 | 1803 |
1872 Frame* child = frame->tree()->scopedChild(index); | 1804 Frame* child = frame->tree()->scopedChild(index); |
1873 if (child) | 1805 if (child) |
1874 return child->document()->domWindow(); | 1806 return child->document()->domWindow(); |
1875 | 1807 |
1876 return 0; | 1808 return 0; |
1877 } | 1809 } |
1878 | 1810 |
1879 | 1811 |
1880 } // namespace WebCore | 1812 } // namespace WebCore |
OLD | NEW |