Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: sky/engine/core/html/HTMLImportElement.cpp

Issue 681983005: Basic implementation of <import> (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Works Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/html/HTMLImportElement.h ('k') | sky/engine/core/html/HTMLImportElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 "config.h"
6 #include "core/html/HTMLImportElement.h"
7
8 #include "base/debug/stack_trace.h"
ojan 2014/11/03 18:08:29 leftover?
abarth-chromium 2014/11/03 20:37:02 Fixed!
9 #include "core/dom/Document.h"
10 #include "core/html/imports/HTMLImportsController.h"
11 #include "core/html/imports/HTMLImportChild.h"
12
13 namespace blink {
14
15 HTMLImportElement::HTMLImportElement(Document& document)
16 : HTMLElement(HTMLNames::importTag, document)
17 , m_child(nullptr)
18 {
19 ScriptWrappable::init(this);
20 }
21
22 PassRefPtr<HTMLImportElement> HTMLImportElement::create(Document& document)
23 {
24 return adoptRef(new HTMLImportElement(document));
25 }
26
27 Node::InsertionNotificationRequest HTMLImportElement::insertedInto(ContainerNode * insertionPoint)
28 {
29 HTMLElement::insertedInto(insertionPoint);
30 if (!insertionPoint->inDocument() || isInShadowTree())
31 return InsertionDone;
32
33 if (shouldLoad())
34 load();
35
36 return InsertionDone;
37 }
38
39 bool HTMLImportElement::shouldLoad() const
40 {
41 return document().frame() || document().importsController();
42 }
43
44 void HTMLImportElement::load()
45 {
46 if (m_child || !hasAttribute(HTMLNames::srcAttr))
47 return;
48 KURL url = document().completeURL(getAttribute(HTMLNames::srcAttr));
49 m_child = document().ensureImportsController().load(document().import(), thi s, FetchRequest(ResourceRequest(url)));
50
51 if (m_child)
52 m_child->ownerInserted();
53 }
54
55 void HTMLImportElement::didFinish()
56 {
57 }
58
59 void HTMLImportElement::importChildWasDestroyed(HTMLImportChild* child)
60 {
61 ASSERT(m_child == child);
62 m_child = nullptr;
63 }
64
65 bool HTMLImportElement::isSync() const
66 {
67 return true;
68 }
69
70 Element* HTMLImportElement::link()
71 {
72 return this;
73 }
74
75 }
OLDNEW
« no previous file with comments | « sky/engine/core/html/HTMLImportElement.h ('k') | sky/engine/core/html/HTMLImportElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698