OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 23 matching lines...) Expand all Loading... |
34 #include "core/fetch/ResourceFetcher.h" | 34 #include "core/fetch/ResourceFetcher.h" |
35 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
36 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
37 #include "core/html/imports/HTMLImportChild.h" | 37 #include "core/html/imports/HTMLImportChild.h" |
38 #include "core/html/imports/HTMLImportChildClient.h" | 38 #include "core/html/imports/HTMLImportChildClient.h" |
39 #include "core/html/imports/HTMLImportLoader.h" | 39 #include "core/html/imports/HTMLImportLoader.h" |
40 #include "core/html/imports/HTMLImportTreeRoot.h" | 40 #include "core/html/imports/HTMLImportTreeRoot.h" |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 const char* HTMLImportsController::supplementName() | |
45 { | |
46 return "HTMLImportsController"; | |
47 } | |
48 | |
49 void HTMLImportsController::provideTo(Document& master) | |
50 { | |
51 HTMLImportsController* controller = new HTMLImportsController(master); | |
52 master.setImportsController(controller); | |
53 Supplement<Document>::provideTo(master, supplementName(), controller); | |
54 } | |
55 | |
56 void HTMLImportsController::removeFrom(Document& master) | |
57 { | |
58 HTMLImportsController* controller = master.importsController(); | |
59 ASSERT(controller); | |
60 controller->dispose(); | |
61 static_cast<Supplementable<Document>&>(master).removeSupplement(supplementNa
me()); | |
62 master.setImportsController(nullptr); | |
63 } | |
64 | |
65 HTMLImportsController::HTMLImportsController(Document& master) | 44 HTMLImportsController::HTMLImportsController(Document& master) |
66 : m_root(HTMLImportTreeRoot::create(&master)) | 45 : m_root(HTMLImportTreeRoot::create(&master)) |
67 { | 46 { |
68 UseCounter::count(master, UseCounter::HTMLImports); | 47 UseCounter::count(master, UseCounter::HTMLImports); |
69 } | 48 } |
70 | 49 |
71 HTMLImportsController::~HTMLImportsController() | |
72 { | |
73 } | |
74 | |
75 void HTMLImportsController::dispose() | 50 void HTMLImportsController::dispose() |
76 { | 51 { |
77 if (m_root) { | 52 if (m_root) { |
78 m_root->dispose(); | 53 m_root->dispose(); |
79 m_root.clear(); | 54 m_root.clear(); |
80 } | 55 } |
81 | 56 |
82 for (size_t i = 0; i < m_loaders.size(); ++i) | 57 for (size_t i = 0; i < m_loaders.size(); ++i) |
83 m_loaders[i]->dispose(); | 58 m_loaders[i]->dispose(); |
84 m_loaders.clear(); | 59 m_loaders.clear(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 140 |
166 Document* HTMLImportsController::loaderDocumentAt(size_t i) const | 141 Document* HTMLImportsController::loaderDocumentAt(size_t i) const |
167 { | 142 { |
168 return loaderAt(i)->document(); | 143 return loaderAt(i)->document(); |
169 } | 144 } |
170 | 145 |
171 DEFINE_TRACE(HTMLImportsController) | 146 DEFINE_TRACE(HTMLImportsController) |
172 { | 147 { |
173 visitor->trace(m_root); | 148 visitor->trace(m_root); |
174 visitor->trace(m_loaders); | 149 visitor->trace(m_loaders); |
175 Supplement<Document>::trace(visitor); | |
176 } | 150 } |
177 | 151 |
178 } // namespace blink | 152 } // namespace blink |
OLD | NEW |