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

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

Issue 1215103007: Remove remaining HTML elements (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months 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 "sky/engine/core/html/HTMLImportElement.h"
6
7 #include "gen/sky/core/EventTypeNames.h"
8 #include "sky/engine/core/dom/Document.h"
9 #include "sky/engine/core/events/Event.h"
10 #include "sky/engine/core/fetch/FetchRequest.h"
11 #include "sky/engine/core/html/imports/HTMLImportChild.h"
12 #include "sky/engine/core/html/imports/HTMLImportsController.h"
13
14 namespace blink {
15
16 HTMLImportElement::HTMLImportElement(Document& document)
17 : HTMLElement(HTMLNames::importTag, document)
18 , m_child(nullptr)
19 {
20 }
21
22 HTMLImportElement::~HTMLImportElement()
23 {
24 if (m_child) {
25 m_child->clearClient();
26 m_child = nullptr;
27 }
28 }
29
30 PassRefPtr<HTMLImportElement> HTMLImportElement::create(Document& document)
31 {
32 return adoptRef(new HTMLImportElement(document));
33 }
34
35 void HTMLImportElement::insertedInto(ContainerNode* insertionPoint)
36 {
37 HTMLElement::insertedInto(insertionPoint);
38 if (!insertionPoint->inDocument() || isInShadowTree())
39 return;
40
41 if (shouldLoad())
42 load();
43 }
44
45 bool HTMLImportElement::shouldLoad() const
46 {
47 return document().frame() || document().importsController();
48 }
49
50 void HTMLImportElement::load()
51 {
52 if (m_child || !hasAttribute(HTMLNames::srcAttr))
53 return;
54 KURL url = document().completeURL(getAttribute(HTMLNames::srcAttr));
55 m_child = document().ensureImportsController().load(document().import(), thi s, FetchRequest(ResourceRequest(url)));
56
57 if (m_child)
58 m_child->ownerInserted();
59 }
60
61 void HTMLImportElement::didFinish()
62 {
63 dispatchEvent(Event::create(EventTypeNames::load));
64 }
65
66 void HTMLImportElement::importChildWasDestroyed(HTMLImportChild* child)
67 {
68 ASSERT(m_child == child);
69 m_child = nullptr;
70 }
71
72 bool HTMLImportElement::isSync() const
73 {
74 return !hasAttribute(HTMLNames::asyncAttr);
75 }
76
77 Element* HTMLImportElement::link()
78 {
79 return this;
80 }
81
82 }
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