Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebRemoteFrameImpl.cpp
index 13db654..ff3dad8 100644 (file)
@@ -6,8 +6,11 @@
 #include "web/WebRemoteFrameImpl.h"
 
 #include "core/frame/FrameOwner.h"
+#include "core/frame/FrameView.h"
 #include "core/frame/RemoteFrame.h"
+#include "core/frame/Settings.h"
 #include "core/page/Page.h"
+#include "platform/heap/Handle.h"
 #include "public/platform/WebFloatRect.h"
 #include "public/platform/WebRect.h"
 #include "public/web/WebDocument.h"
@@ -26,23 +29,37 @@ namespace {
 // 1. Allows the local frame's loader to retrieve sandbox flags associated with
 //    its owner element in another process.
 // 2. Trigger a load event on its owner element once it finishes a load.
-class RemoteBridgeFrameOwner : public FrameOwner {
+class RemoteBridgeFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<RemoteBridgeFrameOwner>, public FrameOwner {
+    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(RemoteBridgeFrameOwner);
 public:
-    explicit RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl>);
+    static PassOwnPtrWillBeRawPtr<RemoteBridgeFrameOwner> create(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame)
+    {
+        return adoptPtrWillBeNoop(new RemoteBridgeFrameOwner(frame));
+    }
 
     virtual bool isLocal() const OVERRIDE;
     virtual SandboxFlags sandboxFlags() const OVERRIDE;
     virtual void dispatchLoad() OVERRIDE;
 
+    virtual void trace(Visitor*);
+
 private:
-    RefPtr<WebLocalFrameImpl> m_frame;
+    explicit RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl>);
+
+    RefPtrWillBeMember<WebLocalFrameImpl> m_frame;
 };
 
-RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtr<WebLocalFrameImpl> frame)
+RemoteBridgeFrameOwner::RemoteBridgeFrameOwner(PassRefPtrWillBeRawPtr<WebLocalFrameImpl> frame)
     : m_frame(frame)
 {
 }
 
+void RemoteBridgeFrameOwner::trace(Visitor* visitor)
+{
+    visitor->trace(m_frame);
+    FrameOwner::trace(visitor);
+}
+
 bool RemoteBridgeFrameOwner::isLocal() const
 {
     return false;
@@ -66,7 +83,8 @@ void RemoteBridgeFrameOwner::dispatchLoad()
 // the RemoteFrame itself load a document). In most circumstances, the check for
 // frame->owner() can be replaced with a check for frame->tree().parent(). Once
 // that's done, this class can be removed.
-class PlaceholderFrameOwner : public FrameOwner {
+class PlaceholderFrameOwner : public NoBaseWillBeGarbageCollectedFinalized<PlaceholderFrameOwner>, public FrameOwner {
+    WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PlaceholderFrameOwner);
 public:
     virtual bool isLocal() const OVERRIDE;
     virtual SandboxFlags sandboxFlags() const OVERRIDE;
@@ -91,13 +109,22 @@ void PlaceholderFrameOwner::dispatchLoad()
 
 } // namespace
 
-WebRemoteFrame* WebRemoteFrame::create(WebFrameClient*)
+WebRemoteFrame* WebRemoteFrame::create(WebRemoteFrameClient* client)
 {
-    return adoptRef(new WebRemoteFrameImpl()).leakRef();
+    WebRemoteFrameImpl* frame = new WebRemoteFrameImpl(client);
+#if ENABLE(OILPAN)
+    return frame;
+#else
+    return adoptRef(frame).leakRef();
+#endif
 }
 
-WebRemoteFrameImpl::WebRemoteFrameImpl()
+WebRemoteFrameImpl::WebRemoteFrameImpl(WebRemoteFrameClient* client)
     : m_frameClient(this)
+    , m_client(client)
+#if ENABLE(OILPAN)
+    , m_selfKeepAlive(this)
+#endif
 {
 }
 
@@ -105,6 +132,16 @@ WebRemoteFrameImpl::~WebRemoteFrameImpl()
 {
 }
 
+void WebRemoteFrameImpl::trace(Visitor* visitor)
+{
+#if ENABLE(OILPAN)
+    visitor->trace(m_frame);
+    visitor->trace(m_ownersForChildren);
+
+    WebFrame::traceChildren(visitor, this);
+#endif
+}
+
 bool WebRemoteFrameImpl::isWebLocalFrame() const
 {
     return false;
@@ -128,7 +165,11 @@ WebRemoteFrame* WebRemoteFrameImpl::toWebRemoteFrame()
 
 void WebRemoteFrameImpl::close()
 {
+#if ENABLE(OILPAN)
+    m_selfKeepAlive.clear();
+#else
     deref();
+#endif
 }
 
 WebString WebRemoteFrameImpl::uniqueName() const
@@ -242,6 +283,13 @@ WebView* WebRemoteFrameImpl::view() const
     return WebViewImpl::fromPage(frame()->page());
 }
 
+WebViewImpl* WebRemoteFrameImpl::viewImpl() const
+{
+    if (!frame())
+        return 0;
+    return WebViewImpl::fromPage(frame()->page());
+}
+
 void WebRemoteFrameImpl::removeChild(WebFrame* frame)
 {
     WebFrame::removeChild(frame);
@@ -388,12 +436,6 @@ void WebRemoteFrameImpl::loadHTMLString(
     ASSERT_NOT_REACHED();
 }
 
-bool WebRemoteFrameImpl::isLoading() const
-{
-    ASSERT_NOT_REACHED();
-    return false;
-}
-
 void WebRemoteFrameImpl::stopLoading()
 {
     ASSERT_NOT_REACHED();
@@ -734,11 +776,6 @@ void WebRemoteFrameImpl::setTickmarks(const WebVector<WebRect>&)
     ASSERT_NOT_REACHED();
 }
 
-void WebRemoteFrameImpl::sendOrientationChangeEvent()
-{
-    ASSERT_NOT_REACHED();
-}
-
 void WebRemoteFrameImpl::dispatchMessageEventWithOriginCheck(
     const WebSecurityOrigin& intendedTargetOrigin,
     const WebDOMEvent&)
@@ -791,8 +828,8 @@ WebString WebRemoteFrameImpl::layerTreeAsText(bool showDebugInfo) const
 WebLocalFrame* WebRemoteFrameImpl::createLocalChild(const WebString& name, WebFrameClient* client)
 {
     WebLocalFrameImpl* child = toWebLocalFrameImpl(WebLocalFrame::create(client));
-    HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result =
-        m_ownersForChildren.add(child, adoptPtr(new RemoteBridgeFrameOwner(child)));
+    WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result =
+        m_ownersForChildren.add(child, RemoteBridgeFrameOwner::create(child));
     appendChild(child);
     // FIXME: currently this calls LocalFrame::init() on the created LocalFrame, which may
     // result in the browser observing two navigations to about:blank (one from the initial
@@ -811,17 +848,17 @@ void WebRemoteFrameImpl::initializeCoreFrame(FrameHost* host, FrameOwner* owner,
     m_frame->tree().setName(name, nullAtom);
 }
 
-WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, WebFrameClient* client)
+WebRemoteFrame* WebRemoteFrameImpl::createRemoteChild(const WebString& name, WebRemoteFrameClient* client)
 {
     WebRemoteFrameImpl* child = toWebRemoteFrameImpl(WebRemoteFrame::create(client));
-    HashMap<WebFrame*, OwnPtr<FrameOwner> >::AddResult result =
-        m_ownersForChildren.add(child, adoptPtr(new PlaceholderFrameOwner));
+    WillBeHeapHashMap<WebFrame*, OwnPtrWillBeMember<FrameOwner> >::AddResult result =
+        m_ownersForChildren.add(child, adoptPtrWillBeNoop(new PlaceholderFrameOwner));
     appendChild(child);
     child->initializeCoreFrame(frame()->host(), result.storedValue->value.get(), name);
     return child;
 }
 
-void WebRemoteFrameImpl::setCoreFrame(PassRefPtr<RemoteFrame> frame)
+void WebRemoteFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<RemoteFrame> frame)
 {
     m_frame = frame;
 }
@@ -833,5 +870,13 @@ WebRemoteFrameImpl* WebRemoteFrameImpl::fromFrame(RemoteFrame& frame)
     return static_cast<RemoteFrameClient*>(frame.client())->webFrame();
 }
 
-} // namespace blink
+void WebRemoteFrameImpl::initializeFromFrame(WebLocalFrame* source) const
+{
+    ASSERT(source);
+    WebLocalFrameImpl* localFrameImpl = toWebLocalFrameImpl(source);
+    client()->initializeChildFrame(
+        localFrameImpl->frame()->view()->frameRect(),
+        localFrameImpl->frame()->view()->visibleContentScaleFactor());
+}
 
+} // namespace blink