OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 void WebPagePopupImpl::close() { | 511 void WebPagePopupImpl::close() { |
512 m_closing = true; | 512 m_closing = true; |
513 // In case closePopup() was not called. | 513 // In case closePopup() was not called. |
514 if (m_page) | 514 if (m_page) |
515 cancel(); | 515 cancel(); |
516 m_widgetClient = nullptr; | 516 m_widgetClient = nullptr; |
517 deref(); | 517 deref(); |
518 } | 518 } |
519 | 519 |
520 void WebPagePopupImpl::closePopup() { | 520 void WebPagePopupImpl::closePopup() { |
521 // This function can be called in EventDispatchForbiddenScope for the main | 521 { |
522 // document, and the following operations dispatch some events. It's safe | 522 // This function can be called in EventDispatchForbiddenScope for the main |
523 // because web authors can't listen the events. | 523 // document, and the following operations dispatch some events. It's safe |
524 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; | 524 // because web authors can't listen the events. |
| 525 EventDispatchForbiddenScope::AllowUserAgentEvents allowEvents; |
525 | 526 |
526 if (m_page) { | 527 if (m_page) { |
527 toLocalFrame(m_page->mainFrame())->loader().stopAllLoaders(); | 528 toLocalFrame(m_page->mainFrame())->loader().stopAllLoaders(); |
528 PagePopupSupplement::uninstall(*toLocalFrame(m_page->mainFrame())); | 529 PagePopupSupplement::uninstall(*toLocalFrame(m_page->mainFrame())); |
| 530 } |
| 531 bool closeAlreadyCalled = m_closing; |
| 532 m_closing = true; |
| 533 |
| 534 destroyPage(); |
| 535 |
| 536 // m_widgetClient might be 0 because this widget might be already closed. |
| 537 if (m_widgetClient && !closeAlreadyCalled) { |
| 538 // closeWidgetSoon() will call this->close() later. |
| 539 m_widgetClient->closeWidgetSoon(); |
| 540 } |
529 } | 541 } |
530 bool closeAlreadyCalled = m_closing; | |
531 m_closing = true; | |
532 | |
533 destroyPage(); | |
534 | |
535 // m_widgetClient might be 0 because this widget might be already closed. | |
536 if (m_widgetClient && !closeAlreadyCalled) { | |
537 // closeWidgetSoon() will call this->close() later. | |
538 m_widgetClient->closeWidgetSoon(); | |
539 } | |
540 | |
541 m_popupClient->didClosePopup(); | 542 m_popupClient->didClosePopup(); |
542 m_webView->cleanupPagePopup(); | 543 m_webView->cleanupPagePopup(); |
543 } | 544 } |
544 | 545 |
545 LocalDOMWindow* WebPagePopupImpl::window() { | 546 LocalDOMWindow* WebPagePopupImpl::window() { |
546 return m_page->deprecatedLocalMainFrame()->localDOMWindow(); | 547 return m_page->deprecatedLocalMainFrame()->localDOMWindow(); |
547 } | 548 } |
548 | 549 |
549 void WebPagePopupImpl::layoutAndPaintAsync( | 550 void WebPagePopupImpl::layoutAndPaintAsync( |
550 WebLayoutAndPaintAsyncCallback* callback) { | 551 WebLayoutAndPaintAsyncCallback* callback) { |
(...skipping 30 matching lines...) Expand all Loading... |
581 // A WebPagePopupImpl instance usually has two references. | 582 // A WebPagePopupImpl instance usually has two references. |
582 // - One owned by the instance itself. It represents the visible widget. | 583 // - One owned by the instance itself. It represents the visible widget. |
583 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the | 584 // - One owned by a WebViewImpl. It's released when the WebViewImpl ask the |
584 // WebPagePopupImpl to close. | 585 // WebPagePopupImpl to close. |
585 // We need them because the closing operation is asynchronous and the widget | 586 // We need them because the closing operation is asynchronous and the widget |
586 // can be closed while the WebViewImpl is unaware of it. | 587 // can be closed while the WebViewImpl is unaware of it. |
587 return adoptRef(new WebPagePopupImpl(client)).leakRef(); | 588 return adoptRef(new WebPagePopupImpl(client)).leakRef(); |
588 } | 589 } |
589 | 590 |
590 } // namespace blink | 591 } // namespace blink |
OLD | NEW |