| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/html/imports/HTMLImportTreeRoot.h" | |
| 6 | |
| 7 #include "sky/engine/core/dom/Document.h" | |
| 8 #include "sky/engine/core/dom/StyleEngine.h" | |
| 9 #include "sky/engine/core/frame/LocalFrame.h" | |
| 10 #include "sky/engine/core/html/imports/HTMLImportChild.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 PassOwnPtr<HTMLImportTreeRoot> HTMLImportTreeRoot::create(Document* document) | |
| 15 { | |
| 16 return adoptPtr(new HTMLImportTreeRoot(document)); | |
| 17 } | |
| 18 | |
| 19 HTMLImportTreeRoot::HTMLImportTreeRoot(Document* document) | |
| 20 : HTMLImport(HTMLImport::Sync) | |
| 21 , m_document(document) | |
| 22 , m_recalcTimer(this, &HTMLImportTreeRoot::recalcTimerFired) | |
| 23 { | |
| 24 scheduleRecalcState(); // This recomputes initial state. | |
| 25 } | |
| 26 | |
| 27 HTMLImportTreeRoot::~HTMLImportTreeRoot() | |
| 28 { | |
| 29 #if !ENABLE(OILPAN) | |
| 30 for (size_t i = 0; i < m_imports.size(); ++i) | |
| 31 m_imports[i]->importDestroyed(); | |
| 32 m_imports.clear(); | |
| 33 m_document = nullptr; | |
| 34 #endif | |
| 35 } | |
| 36 | |
| 37 Document* HTMLImportTreeRoot::document() const | |
| 38 { | |
| 39 return m_document; | |
| 40 } | |
| 41 | |
| 42 bool HTMLImportTreeRoot::isDone() const | |
| 43 { | |
| 44 return !m_document->parsing(); | |
| 45 } | |
| 46 | |
| 47 void HTMLImportTreeRoot::stateWillChange() | |
| 48 { | |
| 49 scheduleRecalcState(); | |
| 50 } | |
| 51 | |
| 52 void HTMLImportTreeRoot::stateDidChange() | |
| 53 { | |
| 54 HTMLImport::stateDidChange(); | |
| 55 | |
| 56 if (!state().isReady()) | |
| 57 return; | |
| 58 m_document->checkCompleted(); | |
| 59 } | |
| 60 | |
| 61 void HTMLImportTreeRoot::scheduleRecalcState() | |
| 62 { | |
| 63 #if ENABLE(OILPAN) | |
| 64 ASSERT(m_document); | |
| 65 if (m_recalcTimer.isActive() || !m_document->isActive()) | |
| 66 return; | |
| 67 #else | |
| 68 if (m_recalcTimer.isActive() || !m_document) | |
| 69 return; | |
| 70 #endif | |
| 71 m_recalcTimer.startOneShot(0, FROM_HERE); | |
| 72 } | |
| 73 | |
| 74 HTMLImportChild* HTMLImportTreeRoot::add(PassOwnPtr<HTMLImportChild> child) | |
| 75 { | |
| 76 m_imports.append(child); | |
| 77 return m_imports.last().get(); | |
| 78 } | |
| 79 | |
| 80 HTMLImportChild* HTMLImportTreeRoot::find(const KURL& url) const | |
| 81 { | |
| 82 for (size_t i = 0; i < m_imports.size(); ++i) { | |
| 83 HTMLImportChild* candidate = m_imports[i].get(); | |
| 84 if (equalIgnoringFragmentIdentifier(candidate->url(), url)) | |
| 85 return candidate; | |
| 86 } | |
| 87 | |
| 88 return 0; | |
| 89 } | |
| 90 | |
| 91 void HTMLImportTreeRoot::recalcTimerFired(Timer<HTMLImportTreeRoot>*) | |
| 92 { | |
| 93 ASSERT(m_document); | |
| 94 | |
| 95 do { | |
| 96 m_recalcTimer.stop(); | |
| 97 HTMLImport::recalcTreeState(this); | |
| 98 } while (m_recalcTimer.isActive()); | |
| 99 } | |
| 100 | |
| 101 } | |
| OLD | NEW |