Add WebFrameProxy::loadData
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 00:36:02 +0000 (00:36 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Mar 2019 00:36:02 +0000 (00:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195647
<rdar://problem/48826856>

Reviewed by Youenn Fablet.

This patch adds WebFrameProxy::loadData which is a simplified version of WebPageProxy::loadData that
loads substitute data to an iframe. This is needed by the Load Optimizer.

* UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::loadData):
* UIProcess/WebFrameProxy.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::loadDataInFrame):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242836 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebFrameProxy.cpp
Source/WebKit/UIProcess/WebFrameProxy.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.h
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index c990d3e..f4661ed 100644 (file)
@@ -1,3 +1,22 @@
+2019-03-12  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add WebFrameProxy::loadData
+        https://bugs.webkit.org/show_bug.cgi?id=195647
+        <rdar://problem/48826856>
+
+        Reviewed by Youenn Fablet.
+
+        This patch adds WebFrameProxy::loadData which is a simplified version of WebPageProxy::loadData that
+        loads substitute data to an iframe. This is needed by the Load Optimizer.
+
+        * UIProcess/WebFrameProxy.cpp:
+        (WebKit::WebFrameProxy::loadData):
+        * UIProcess/WebFrameProxy.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::loadDataInFrame):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2019-03-12  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Input view sometimes flickers when blurring and refocusing an element
index 9f46846..4dfe1c3 100644 (file)
@@ -86,6 +86,14 @@ void WebFrameProxy::loadURL(const URL& url)
     m_page->process().send(Messages::WebPage::LoadURLInFrame(url, m_frameID), m_page->pageID());
 }
 
+void WebFrameProxy::loadData(const IPC::DataReference& data, const String& MIMEType, const String& encodingName, const URL& baseURL)
+{
+    if (!m_page)
+        return;
+
+    m_page->process().send(Messages::WebPage::LoadDataInFrame(data, MIMEType, encodingName, baseURL, m_frameID), m_page->pageID());
+}
+
 void WebFrameProxy::stopLoading() const
 {
     if (!m_page)
index 66238d1..ad9af92 100644 (file)
@@ -81,6 +81,7 @@ public:
     FrameLoadState& frameLoadState() { return m_frameLoadState; }
 
     void loadURL(const URL&);
+    void loadData(const IPC::DataReference&, const String& MIMEType, const String& encodingName, const URL& baseURL);
     void stopLoading() const;
 
     const URL& url() const { return m_frameLoadState.url(); }
index df088e6..ca50975 100644 (file)
@@ -1390,6 +1390,18 @@ void WebPage::loadURLInFrame(URL&& url, uint64_t frameID)
     frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(url), ShouldOpenExternalURLsPolicy::ShouldNotAllow));
 }
 
+void WebPage::loadDataInFrame(IPC::DataReference&& data, String&& MIMEType, String&& encodingName, URL&& baseURL, uint64_t frameID)
+{
+    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
+    if (!frame)
+        return;
+
+    auto sharedBuffer = SharedBuffer::create(reinterpret_cast<const char*>(data.data()), data.size());
+    ResourceResponse response(baseURL, MIMEType, sharedBuffer->size(), encodingName);
+    SubstituteData substituteData(WTFMove(sharedBuffer), baseURL, WTFMove(response), SubstituteData::SessionHistoryVisibility::Hidden);
+    frame->coreFrame()->loader().load(FrameLoadRequest(*frame->coreFrame(), ResourceRequest(baseURL), ShouldOpenExternalURLsPolicy::ShouldNotAllow, WTFMove(substituteData)));
+}
+
 #if !PLATFORM(COCOA)
 void WebPage::platformDidReceiveLoadParameters(const LoadParameters& loadParameters)
 {
index f841aa3..49ba935 100644 (file)
@@ -1289,6 +1289,7 @@ private:
     static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
 
     void loadURLInFrame(URL&&, uint64_t frameID);
+    void loadDataInFrame(IPC::DataReference&&, String&& MIMEType, String&& encodingName, URL&& baseURL, uint64_t frameID);
 
     enum class WasRestoredByAPIRequest { No, Yes };
     void restoreSessionInternal(const Vector<BackForwardListItemState>&, WasRestoredByAPIRequest, WebBackForwardListProxy::OverwriteExistingItem);
index 3a93d26..099ae56 100644 (file)
@@ -155,6 +155,7 @@ messages -> WebPage LegacyReceiver {
     TryRestoreScrollPosition()
 
     LoadURLInFrame(URL url, uint64_t frameID)
+    LoadDataInFrame(IPC::DataReference data, String MIMEType, String encodingName, URL baseURL, uint64_t frameID)
     LoadRequest(struct WebKit::LoadParameters loadParameters)
     LoadData(struct WebKit::LoadParameters loadParameters)
     LoadAlternateHTML(struct WebKit::LoadParameters loadParameters)