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

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

Issue 740773002: Revert "Sky: When an iframe element is removed, delete its mojo View." (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 | « no previous file | sky/tests/lowlevel/iframe.sky » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/html/HTMLIFrameElement.h" 6 #include "core/html/HTMLIFrameElement.h"
7 7
8 #include "core/HTMLNames.h" 8 #include "core/HTMLNames.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/html/parser/HTMLParserIdioms.h" 10 #include "core/html/parser/HTMLParserIdioms.h"
11 #include "core/loader/FrameLoaderClient.h" 11 #include "core/loader/FrameLoaderClient.h"
12 #include "core/rendering/RenderIFrame.h" 12 #include "core/rendering/RenderIFrame.h"
13 13
14 namespace blink { 14 namespace blink {
15 15
16 PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(Document& document) 16 PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(Document& document)
17 { 17 {
18 return adoptRef(new HTMLIFrameElement(document)); 18 return adoptRef(new HTMLIFrameElement(document));
19 } 19 }
20 20
21 HTMLIFrameElement::HTMLIFrameElement(Document& document) 21 HTMLIFrameElement::HTMLIFrameElement(Document& document)
22 : HTMLElement(HTMLNames::iframeTag, document), 22 : HTMLElement(HTMLNames::iframeTag, document),
23 m_contentView(nullptr) 23 m_contentView(nullptr)
24 { 24 {
25 } 25 }
26 26
27 HTMLIFrameElement::~HTMLIFrameElement() 27 HTMLIFrameElement::~HTMLIFrameElement()
28 { 28 {
29 if (m_contentView)
30 m_contentView->RemoveObserver(this);
31 } 29 }
32 30
33 Node::InsertionNotificationRequest HTMLIFrameElement::insertedInto(ContainerNode * insertionPoint) 31 Node::InsertionNotificationRequest HTMLIFrameElement::insertedInto(ContainerNode * insertionPoint)
34 { 32 {
35 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi nt); 33 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi nt);
36 if (insertionPoint->inDocument()) 34 if (insertionPoint->inDocument())
37 createView(); 35 createView();
38 return result; 36 return result;
39 } 37 }
40 38
41 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) 39 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint)
42 { 40 {
43 HTMLElement::removedFrom(insertionPoint); 41 HTMLElement::removedFrom(insertionPoint);
44 if (m_contentView) 42 if (insertionPoint->inDocument()) {
45 m_contentView->Destroy(); 43 // TODO(mpcomplete): Tear down the mojo View.
44 }
46 } 45 }
47 46
48 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) 47 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style)
49 { 48 {
50 return new RenderIFrame(this); 49 return new RenderIFrame(this);
51 } 50 }
52 51
53 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view) 52 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view)
54 { 53 {
55 DCHECK_EQ(view, m_contentView); 54 DCHECK_EQ(view, m_contentView);
56 m_contentView = nullptr; 55 m_contentView = nullptr;
57 } 56 }
58 57
59 void HTMLIFrameElement::createView() 58 void HTMLIFrameElement::createView()
60 { 59 {
61 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames: :srcAttr)); 60 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames: :srcAttr));
62 if (urlString.isEmpty()) 61 if (urlString.isEmpty())
63 urlString = blankURL().string(); 62 urlString = blankURL().string();
64 63
65 LocalFrame* parentFrame = document().frame(); 64 LocalFrame* parentFrame = document().frame();
66 if (!parentFrame) 65 if (!parentFrame)
67 return; 66 return;
68 67
69 KURL url = document().completeURL(urlString); 68 KURL url = document().completeURL(urlString);
70 m_contentView = parentFrame->loaderClient()->createChildFrame(url); 69 m_contentView = parentFrame->loaderClient()->createChildFrame(url);
71 if (m_contentView)
72 m_contentView->AddObserver(this);
73 } 70 }
74 71
75 } 72 }
OLDNEW
« no previous file with comments | « no previous file | sky/tests/lowlevel/iframe.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698