flutter_flutter/engine/core/html/HTMLIFrameElement.cpp
Matt Perry 694cabc454 Initial work on a new <view> element backed by a mojo::View.
This CL introduces an HTMLViewElement which, when inserted into a document,
causes a mojo::View to be created and navigated to the provided URL. No
compositing is done, but the view manager handles the rendering (as I
understand it).

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/708903002
2014-11-07 14:34:07 -05:00

66 lines
1.7 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/HTMLNames.h"
#include "core/frame/LocalFrame.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/loader/FrameLoaderClient.h"
#include "core/rendering/RenderRemote.h"
namespace blink {
PassRefPtr<HTMLIFrameElement> HTMLIFrameElement::create(Document& document)
{
return adoptRef(new HTMLIFrameElement(document));
}
HTMLIFrameElement::HTMLIFrameElement(Document& document)
: HTMLElement(HTMLNames::iframeTag, document)
{
}
HTMLIFrameElement::~HTMLIFrameElement()
{
}
Node::InsertionNotificationRequest HTMLIFrameElement::insertedInto(ContainerNode* insertionPoint)
{
InsertionNotificationRequest result = HTMLElement::insertedInto(insertionPoint);
if (insertionPoint->inDocument())
createView();
return result;
}
void HTMLIFrameElement::removedFrom(ContainerNode* insertionPoint)
{
HTMLElement::removedFrom(insertionPoint);
if (insertionPoint->inDocument()) {
// TODO(mpcomplete): Tear down the mojo View.
}
}
RenderObject* HTMLIFrameElement::createRenderer(RenderStyle* style)
{
return new RenderRemote(this);
}
void HTMLIFrameElement::createView()
{
String urlString = stripLeadingAndTrailingHTMLSpaces(getAttribute(HTMLNames::srcAttr));
if (urlString.isEmpty())
urlString = blankURL().string();
LocalFrame* parentFrame = document().frame();
if (!parentFrame)
return;
KURL url = document().completeURL(urlString);
parentFrame->loaderClient()->createView(url);
}
}