| OLD | NEW |
| 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/RenderRemote.h" | 12 #include "core/rendering/RenderRemote.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 { | 24 { |
| 24 } | 25 } |
| 25 | 26 |
| 26 HTMLIFrameElement::~HTMLIFrameElement() | 27 HTMLIFrameElement::~HTMLIFrameElement() |
| 27 { | 28 { |
| 28 } | 29 } |
| 29 | 30 |
| 30 Node::InsertionNotificationRequest HTMLIFrameElement::insertedInto(ContainerNode
* insertionPoint) | 31 Node::InsertionNotificationRequest HTMLIFrameElement::insertedInto(ContainerNode
* insertionPoint) |
| 31 { | 32 { |
| 32 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); | 33 InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoi
nt); |
| 33 if (insertionPoint->inDocument()) | 34 if (insertionPoint->inDocument()) |
| 34 createView(); | 35 createView(); |
| 35 return result; | 36 return result; |
| 36 } | 37 } |
| 37 | 38 |
| 38 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) | 39 void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint) |
| 39 { | 40 { |
| 40 HTMLElement::removedFrom(insertionPoint); | 41 HTMLElement::removedFrom(insertionPoint); |
| 41 if (insertionPoint->inDocument()) { | 42 if (insertionPoint->inDocument()) { |
| 42 // TODO(mpcomplete): Tear down the mojo View. | 43 // TODO(mpcomplete): Tear down the mojo View. |
| 43 } | 44 } |
| 44 } | 45 } |
| 45 | 46 |
| 46 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) | 47 RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style) |
| 47 { | 48 { |
| 48 return new RenderRemote(this); | 49 return new RenderRemote(this); |
| 49 } | 50 } |
| 50 | 51 |
| 52 void HTMLIFrameElement::OnViewDestroyed(mojo::View* view) |
| 53 { |
| 54 DCHECK_EQ(view, m_contentView); |
| 55 m_contentView = nullptr; |
| 56 } |
| 57 |
| 51 void HTMLIFrameElement::createView() | 58 void HTMLIFrameElement::createView() |
| 52 { | 59 { |
| 53 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames:
:srcAttr)); | 60 String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames:
:srcAttr)); |
| 54 if (urlString.isEmpty()) | 61 if (urlString.isEmpty()) |
| 55 urlString = blankURL().string(); | 62 urlString = blankURL().string(); |
| 56 | 63 |
| 57 LocalFrame* parentFrame = document().frame(); | 64 LocalFrame* parentFrame = document().frame(); |
| 58 if (!parentFrame) | 65 if (!parentFrame) |
| 59 return; | 66 return; |
| 60 | 67 |
| 61 KURL url = document().completeURL(urlString); | 68 KURL url = document().completeURL(urlString); |
| 62 parentFrame->loaderClient()->createView(url); | 69 m_contentView = parentFrame->loaderClient()->createChildFrame(url); |
| 63 } | 70 } |
| 64 | 71 |
| 65 } | 72 } |
| OLD | NEW |