Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
| 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 #include "platform/graphics/ImageObserver.h" | 50 #include "platform/graphics/ImageObserver.h" |
| 51 #include "wtf/PassRefPtr.h" | 51 #include "wtf/PassRefPtr.h" |
| 52 | 52 |
| 53 namespace WebCore { | 53 namespace WebCore { |
| 54 | 54 |
| 55 SVGImage::SVGImage(ImageObserver* observer) | 55 SVGImage::SVGImage(ImageObserver* observer) |
| 56 : Image(observer) | 56 : Image(observer) |
| 57 { | 57 { |
| 58 } | 58 } |
| 59 | 59 |
| 60 class DelayedSVGImageDestructor { | |
|
haraken
2014/03/05 08:13:10
Would you add a comment why you need this?
kouhei (in TOK)
2014/03/05 08:27:33
Done.
| |
| 61 public: | |
| 62 void add(PassOwnPtr<SVGImageChromeClient> chromeClient, PassOwnPtr<Page> pag e) | |
| 63 { | |
| 64 Entry entry; | |
| 65 entry.chromeClient = chromeClient.leakPtr(); | |
| 66 entry.page = page.leakPtr(); | |
| 67 | |
| 68 m_entries.append(entry); | |
| 69 m_detachTimer.startOneShot(0.0); | |
| 70 } | |
| 71 | |
| 72 static DelayedSVGImageDestructor* get() | |
| 73 { | |
| 74 DEFINE_STATIC_LOCAL(DelayedSVGImageDestructor, delayed, ()); | |
| 75 return &delayed; | |
| 76 } | |
| 77 | |
| 78 private: | |
| 79 DelayedSVGImageDestructor() | |
| 80 : m_detachTimer(this, &DelayedSVGImageDestructor::detachTimerFired) | |
| 81 { | |
| 82 } | |
| 83 | |
| 84 void detachTimerFired(Timer<DelayedSVGImageDestructor>*) | |
| 85 { | |
| 86 Vector<Entry>::const_iterator it = m_entries.begin(); | |
| 87 Vector<Entry>::const_iterator itEnd = m_entries.end(); | |
| 88 for (; it != itEnd; ++it) { | |
| 89 it->page->mainFrame()->loader().frameDetached(); | |
| 90 delete it->page; | |
| 91 delete it->chromeClient; | |
| 92 } | |
| 93 | |
| 94 m_entries.clear(); | |
| 95 } | |
| 96 | |
| 97 struct Entry { | |
| 98 SVGImageChromeClient* chromeClient; | |
| 99 Page* page; | |
| 100 }; | |
| 101 Vector<Entry> m_entries; | |
| 102 Timer<DelayedSVGImageDestructor> m_detachTimer; | |
| 103 }; | |
| 104 | |
| 60 SVGImage::~SVGImage() | 105 SVGImage::~SVGImage() |
| 61 { | 106 { |
| 62 if (m_page) { | 107 m_chromeClient->clearImage(); |
| 63 // Store m_page in a local variable, clearing m_page, so that SVGImageCh romeClient knows we're destructed. | 108 DelayedSVGImageDestructor::get()->add(m_chromeClient.release(), m_page.relea se()); |
| 64 OwnPtr<Page> currentPage = m_page.release(); | |
| 65 currentPage->mainFrame()->loader().frameDetached(); // Break both the lo ader and view references to the frame | |
| 66 } | |
| 67 | |
| 68 // Verify that page teardown destroyed the Chrome | |
| 69 ASSERT(!m_chromeClient || !m_chromeClient->image()); | |
| 70 } | 109 } |
| 71 | 110 |
| 72 bool SVGImage::isInSVGImage(const Element* element) | 111 bool SVGImage::isInSVGImage(const Element* element) |
| 73 { | 112 { |
| 74 ASSERT(element); | 113 ASSERT(element); |
| 75 | 114 |
| 76 Page* page = element->document().page(); | 115 Page* page = element->document().page(); |
| 77 if (!page) | 116 if (!page) |
| 78 return false; | 117 return false; |
| 79 | 118 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 415 | 454 |
| 416 return m_page; | 455 return m_page; |
| 417 } | 456 } |
| 418 | 457 |
| 419 String SVGImage::filenameExtension() const | 458 String SVGImage::filenameExtension() const |
| 420 { | 459 { |
| 421 return "svg"; | 460 return "svg"; |
| 422 } | 461 } |
| 423 | 462 |
| 424 } | 463 } |
| OLD | NEW |