Commit db07d227 authored by aroben@apple.com's avatar aroben@apple.com

Move createFrame to WebFrameLoaderClient

         Reviewed by Anders.

         * WebCoreSupport/WebFrameLoaderClient.cpp:
         (WebFrameLoaderClient::createFrame):
         (WebFrameLoaderClient::loadURLIntoChild):
         * WebCoreSupport/WebFrameLoaderClient.h:
         * WebFrame.cpp:
         * WebFrame.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4567e4f4
2008-02-25 Adam Roben <aroben@apple.com>
Move createFrame to WebFrameLoaderClient
Reviewed by Anders.
* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::createFrame):
(WebFrameLoaderClient::loadURLIntoChild):
* WebCoreSupport/WebFrameLoaderClient.h:
* WebFrame.cpp:
* WebFrame.h:
2008-02-25 Adam Roben <aroben@apple.com>
Move progress-related methods to WebFrameLoaderClient
......
......@@ -36,9 +36,17 @@
#include "WebView.h"
#pragma warning(push, 0)
#include <WebCore/DocumentLoader.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/FrameTree.h>
#include <WebCore/FrameView.h>
#include <WebCore/HTMLFrameElement.h>
#include <WebCore/HTMLFrameOwnerElement.h>
#include <WebCore/HTMLNames.h>
#include <WebCore/HistoryItem.h>
#pragma warning(pop)
using namespace WebCore;
using namespace HTMLNames;
WebFrameLoaderClient::WebFrameLoaderClient(WebFrame* webFrame)
: m_webFrame(webFrame)
......@@ -204,3 +212,95 @@ PassRefPtr<DocumentLoader> WebFrameLoaderClient::createDocumentLoader(const Reso
loader->setDataSource(dataSource.get());
return loader.release();
}
PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool /*allowsScrolling*/, int /*marginWidth*/, int /*marginHeight*/)
{
RefPtr<Frame> result = createFrame(url, name, ownerElement, referrer);
if (!result)
return 0;
// Propagate the marginwidth/height and scrolling modes to the view.
if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag)) {
HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
result->view()->setScrollbarsMode(ScrollbarAlwaysOff);
int marginWidth = frameElt->getMarginWidth();
int marginHeight = frameElt->getMarginHeight();
if (marginWidth != -1)
result->view()->setMarginWidth(marginWidth);
if (marginHeight != -1)
result->view()->setMarginHeight(marginHeight);
}
return result.release();
}
PassRefPtr<Frame> WebFrameLoaderClient::createFrame(const KURL& URL, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer)
{
Frame* coreFrame = core(m_webFrame);
ASSERT(coreFrame);
COMPtr<WebFrame> webFrame(AdoptCOM, WebFrame::createInstance());
webFrame->initWithWebFrameView(0, m_webFrame->webView(), coreFrame->page(), ownerElement);
RefPtr<Frame> childFrame(adoptRef(core(webFrame.get()))); // We have to adopt, because Frames start out with a refcount of 1.
ASSERT(childFrame);
coreFrame->tree()->appendChild(childFrame);
childFrame->tree()->setName(name);
childFrame->init();
loadURLIntoChild(URL, referrer, webFrame.get());
// The frame's onload handler may have removed it from the document.
if (!childFrame->tree()->parent())
return 0;
return childFrame.release();
}
void WebFrameLoaderClient::loadURLIntoChild(const KURL& originalURL, const String& referrer, WebFrame* childFrame)
{
ASSERT(childFrame);
ASSERT(core(childFrame));
Frame* coreFrame = core(m_webFrame);
ASSERT(coreFrame);
HistoryItem* parentItem = coreFrame->loader()->currentHistoryItem();
FrameLoadType loadType = coreFrame->loader()->loadType();
FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedHistory;
KURL url = originalURL;
// If we're moving in the backforward list, we might want to replace the content
// of this child frame with whatever was there at that point.
// Reload will maintain the frame contents, LoadSame will not.
if (parentItem && parentItem->children().size() &&
(isBackForwardLoadType(loadType)
|| loadType == FrameLoadTypeReload
|| loadType == FrameLoadTypeReloadAllowingStaleData))
{
if (HistoryItem* childItem = parentItem->childItemWithName(core(childFrame)->tree()->name())) {
// Use the original URL to ensure we get all the side-effects, such as
// onLoad handlers, of any redirects that happened. An example of where
// this is needed is Radar 3213556.
url = childItem->originalURL();
// These behaviors implied by these loadTypes should apply to the child frames
childLoadType = loadType;
if (isBackForwardLoadType(loadType))
// For back/forward, remember this item so we can traverse any child items as child frames load
core(childFrame)->loader()->setProvisionalHistoryItem(childItem);
else
// For reload, just reinstall the current item, since a new child frame was created but we won't be creating a new BF item
core(childFrame)->loader()->setCurrentHistoryItem(childItem);
}
}
// FIXME: Handle loading WebArchives here
core(childFrame)->loader()->load(url, referrer, childLoadType, String(), 0, 0);
}
......@@ -61,10 +61,17 @@ public:
virtual PassRefPtr<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&);
virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
protected:
WebFrameLoaderClient(WebFrame*);
~WebFrameLoaderClient();
private:
PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, const WebCore::String& referrer);
void loadURLIntoChild(const WebCore::KURL&, const WebCore::String& referrer, WebFrame* childFrame);
WebFrame* m_webFrame;
};
......
......@@ -1108,76 +1108,6 @@ void WebFrame::frameLoaderDestroyed()
this->Release();
}
PassRefPtr<Frame> WebFrame::createFrame(const KURL& URL, const String& name, HTMLFrameOwnerElement* ownerElement, const String& referrer)
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
COMPtr<WebFrame> webFrame;
webFrame.adoptRef(WebFrame::createInstance());
webFrame->initWithWebFrameView(0, d->webView, coreFrame->page(), ownerElement);
RefPtr<Frame> childFrame(adoptRef(core(webFrame.get()))); // We have to adopt, because Frames start out with a refcount of 1.
ASSERT(childFrame);
coreFrame->tree()->appendChild(childFrame);
childFrame->tree()->setName(name);
childFrame->init();
loadURLIntoChild(URL, referrer, webFrame.get());
// The frame's onload handler may have removed it from the document.
if (!childFrame->tree()->parent())
return 0;
return childFrame.release();
}
void WebFrame::loadURLIntoChild(const KURL& originalURL, const String& referrer, WebFrame* childFrame)
{
ASSERT(childFrame);
ASSERT(core(childFrame));
Frame* coreFrame = core(this);
ASSERT(coreFrame);
HistoryItem* parentItem = coreFrame->loader()->currentHistoryItem();
FrameLoadType loadType = coreFrame->loader()->loadType();
FrameLoadType childLoadType = FrameLoadTypeRedirectWithLockedHistory;
KURL url = originalURL;
// If we're moving in the backforward list, we might want to replace the content
// of this child frame with whatever was there at that point.
// Reload will maintain the frame contents, LoadSame will not.
if (parentItem && parentItem->children().size() &&
(isBackForwardLoadType(loadType)
|| loadType == FrameLoadTypeReload
|| loadType == FrameLoadTypeReloadAllowingStaleData))
{
if (HistoryItem* childItem = parentItem->childItemWithName(core(childFrame)->tree()->name())) {
// Use the original URL to ensure we get all the side-effects, such as
// onLoad handlers, of any redirects that happened. An example of where
// this is needed is Radar 3213556.
url = childItem->originalURL();
// These behaviors implied by these loadTypes should apply to the child frames
childLoadType = loadType;
if (isBackForwardLoadType(loadType))
// For back/forward, remember this item so we can traverse any child items as child frames load
core(childFrame)->loader()->setProvisionalHistoryItem(childItem);
else
// For reload, just reinstall the current item, since a new child frame was created but we won't be creating a new BF item
core(childFrame)->loader()->setCurrentHistoryItem(childItem);
}
}
// FIXME: Handle loading WebArchives here
core(childFrame)->loader()->load(url, referrer, childLoadType, String(), 0, 0);
}
WebHistory* WebFrame::webHistory()
{
if (this != d->webView->topLevelFrame())
......@@ -1863,29 +1793,6 @@ void WebFrame::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader,
}
}
PassRefPtr<Frame> WebFrame::createFrame(const KURL& url, const String& name, HTMLFrameOwnerElement* ownerElement,
const String& referrer, bool /*allowsScrolling*/, int /*marginWidth*/, int /*marginHeight*/)
{
RefPtr<Frame> result = createFrame(url, name, ownerElement, referrer);
if (!result)
return 0;
// Propagate the marginwidth/height and scrolling modes to the view.
if (ownerElement->hasTagName(frameTag) || ownerElement->hasTagName(iframeTag)) {
HTMLFrameElement* frameElt = static_cast<HTMLFrameElement*>(ownerElement);
if (frameElt->scrollingMode() == ScrollbarAlwaysOff)
result->view()->setScrollbarsMode(ScrollbarAlwaysOff);
int marginWidth = frameElt->getMarginWidth();
int marginHeight = frameElt->getMarginHeight();
if (marginWidth != -1)
result->view()->setMarginWidth(marginWidth);
if (marginHeight != -1)
result->view()->setMarginHeight(marginHeight);
}
return result.release();
}
Widget* WebFrame::createPlugin(const IntSize& pluginSize, Element* element, const KURL& url, const Vector<String>& paramNames, const Vector<String>& paramValues, const String& mimeType, bool loadManually)
{
PluginView* pluginView = PluginView::create(core(this), pluginSize, element, url, paramNames, paramValues, mimeType, loadManually);
......
......@@ -287,8 +287,6 @@ public:
virtual void dispatchDidReceiveAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
virtual void dispatchDidCancelAuthenticationChallenge(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::AuthenticationChallenge&);
virtual PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL& url, const WebCore::String& name, WebCore::HTMLFrameOwnerElement* ownerElement,
const WebCore::String& referrer, bool allowsScrolling, int marginWidth, int marginHeight);
virtual WebCore::Widget* createPlugin(const WebCore::IntSize&, WebCore::Element*, const WebCore::KURL&, const Vector<WebCore::String>&, const Vector<WebCore::String>&, const WebCore::String&, bool loadManually);
virtual void redirectDataToPlugin(WebCore::Widget* pluginWidget);
......@@ -335,10 +333,8 @@ public:
WebView* webView() const;
protected:
PassRefPtr<WebCore::Frame> createFrame(const WebCore::KURL&, const WebCore::String& name, WebCore::HTMLFrameOwnerElement*, const WebCore::String& referrer);
void loadHTMLString(BSTR string, BSTR baseURL, BSTR unreachableURL);
void loadData(PassRefPtr<WebCore::SharedBuffer>, BSTR mimeType, BSTR textEncodingName, BSTR baseURL, BSTR failingURL);
void loadURLIntoChild(const WebCore::KURL&, const WebCore::String& referrer, WebFrame* childFrame);
const Vector<WebCore::IntRect>& computePageRects(HDC printDC);
void setPrinting(bool printing, float minPageWidth, float maxPageWidth, bool adjustViewSize);
void headerAndFooterHeights(float*, float*);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment