summaryrefslogtreecommitdiffstats
path: root/WebKit/win/WebFrame.cpp
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:05:15 -0800
commit1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch)
tree4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebKit/win/WebFrame.cpp
parent9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff)
downloadexternal_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz
external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebKit/win/WebFrame.cpp')
-rw-r--r--WebKit/win/WebFrame.cpp1251
1 files changed, 198 insertions, 1053 deletions
diff --git a/WebKit/win/WebFrame.cpp b/WebKit/win/WebFrame.cpp
index ebaa7b3..701d1ab 100644
--- a/WebKit/win/WebFrame.cpp
+++ b/WebKit/win/WebFrame.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,18 +29,12 @@
#include "CFDictionaryPropertyBag.h"
#include "COMPtr.h"
+#include "COMPropertyBag.h"
#include "DefaultPolicyDelegate.h"
#include "DOMCoreClasses.h"
-#include "IWebError.h"
-#include "IWebErrorPrivate.h"
-#include "IWebHistory.h"
-#include "IWebHistoryItemPrivate.h"
-#include "IWebFrameLoadDelegatePrivate.h"
-#include "IWebFormDelegate.h"
-#include "IWebUIDelegatePrivate.h"
+#include "HTMLFrameOwnerElement.h"
#include "MarshallingHelpers.h"
#include "WebActionPropertyBag.h"
-#include "WebCachedPagePlatformData.h"
#include "WebChromeClient.h"
#include "WebDocumentLoader.h"
#include "WebDownload.h"
@@ -49,18 +43,15 @@
#include "WebEditorClient.h"
#include "WebFramePolicyListener.h"
#include "WebHistory.h"
+#include "WebIconFetcher.h"
#include "WebKit.h"
#include "WebKitStatisticsPrivate.h"
#include "WebNotificationCenter.h"
#include "WebView.h"
#include "WebDataSource.h"
#include "WebHistoryItem.h"
-#include "WebScriptDebugger.h"
-#include "WebScriptDebugServer.h"
-#include "WebURLAuthenticationChallenge.h"
#include "WebURLResponse.h"
#pragma warning( push, 0 )
-#include <WebCore/AuthenticationChallenge.h>
#include <WebCore/BString.h>
#include <WebCore/Cache.h>
#include <WebCore/Document.h>
@@ -68,6 +59,7 @@
#include <WebCore/DOMImplementation.h>
#include <WebCore/DOMWindow.h>
#include <WebCore/Event.h>
+#include <WebCore/EventHandler.h>
#include <WebCore/FormState.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/FrameLoadRequest.h>
@@ -78,9 +70,10 @@
#include <WebCore/GraphicsContext.h>
#include <WebCore/HistoryItem.h>
#include <WebCore/HTMLFormElement.h>
-#include <WebCore/HTMLGenericFormElement.h>
+#include <WebCore/HTMLFormControlElement.h>
#include <WebCore/HTMLInputElement.h>
#include <WebCore/HTMLNames.h>
+#include <WebCore/JSDOMWindow.h>
#include <WebCore/KeyboardEvent.h>
#include <WebCore/MIMETypeRegistry.h>
#include <WebCore/MouseRelatedEvent.h>
@@ -93,13 +86,12 @@
#include <WebCore/ResourceHandle.h>
#include <WebCore/ResourceHandleWin.h>
#include <WebCore/ResourceRequest.h>
-#include <WebCore/RenderFrame.h>
+#include <WebCore/RenderView.h>
#include <WebCore/RenderTreeAsText.h>
#include <WebCore/Settings.h>
#include <WebCore/TextIterator.h>
-#include <WebCore/kjs_binding.h>
-#include <WebCore/kjs_proxy.h>
-#include <WebCore/kjs_window.h>
+#include <WebCore/JSDOMBinding.h>
+#include <WebCore/ScriptController.h>
#include <JavaScriptCore/APICast.h>
#include <wtf/MathExtras.h>
#pragma warning(pop)
@@ -131,12 +123,6 @@ const float PrintingMinimumShrinkFactor = 1.25f;
// behavior matches MacIE and Mozilla, at least)
const float PrintingMaximumShrinkFactor = 2.0f;
-
-// {A3676398-4485-4a9d-87DC-CB5A40E6351D}
-const GUID IID_WebFrame =
-{ 0xa3676398, 0x4485, 0x4a9d, { 0x87, 0xdc, 0xcb, 0x5a, 0x40, 0xe6, 0x35, 0x1d } };
-
-
//-----------------------------------------------------------------------------
// Helpers to convert from WebCore to WebKit type
WebFrame* kit(Frame* frame)
@@ -165,202 +151,6 @@ Frame* core(const WebFrame* webFrame)
return const_cast<WebFrame*>(webFrame)->impl();
}
-WebView* kit(Page* page)
-{
- return page ? static_cast<WebChromeClient*>(page->chrome()->client())->webView() : 0;
-}
-
-//-----------------------------------------------------------------------------
-
-class FormValuesPropertyBag : public IPropertyBag, public IPropertyBag2
-{
-public:
- FormValuesPropertyBag(HashMap<String, String>* formValues) : m_formValues(formValues) {}
-
- // IUnknown
- virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
- virtual ULONG STDMETHODCALLTYPE AddRef(void);
- virtual ULONG STDMETHODCALLTYPE Release(void);
-
- // IPropertyBag
- virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read(
- /* [in] */ LPCOLESTR pszPropName,
- /* [out][in] */ VARIANT* pVar,
- /* [in] */ IErrorLog* pErrorLog);
-
- virtual HRESULT STDMETHODCALLTYPE Write(
- /* [in] */ LPCOLESTR pszPropName,
- /* [in] */ VARIANT* pVar);
-
- // IPropertyBag2
- virtual HRESULT STDMETHODCALLTYPE Read(
- /* [in] */ ULONG cProperties,
- /* [in] */ PROPBAG2 *pPropBag,
- /* [in] */ IErrorLog *pErrLog,
- /* [out] */ VARIANT *pvarValue,
- /* [out] */ HRESULT *phrError);
-
- virtual HRESULT STDMETHODCALLTYPE Write(
- /* [in] */ ULONG cProperties,
- /* [in] */ PROPBAG2 *pPropBag,
- /* [in] */ VARIANT *pvarValue);
-
- virtual HRESULT STDMETHODCALLTYPE CountProperties(
- /* [out] */ ULONG *pcProperties);
-
- virtual HRESULT STDMETHODCALLTYPE GetPropertyInfo(
- /* [in] */ ULONG iProperty,
- /* [in] */ ULONG cProperties,
- /* [out] */ PROPBAG2 *pPropBag,
- /* [out] */ ULONG *pcProperties);
-
- virtual HRESULT STDMETHODCALLTYPE LoadObject(
- /* [in] */ LPCOLESTR pstrName,
- /* [in] */ DWORD dwHint,
- /* [in] */ IUnknown *pUnkObject,
- /* [in] */ IErrorLog *pErrLog);
-
-protected:
- HashMap<String, String>* m_formValues;
-};
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::QueryInterface(REFIID riid, void** ppvObject)
-{
- *ppvObject = 0;
- if (IsEqualGUID(riid, IID_IUnknown))
- *ppvObject = this;
- else if (IsEqualGUID(riid, IID_IPropertyBag))
- *ppvObject = static_cast<IPropertyBag*>(this);
- else if (IsEqualGUID(riid, IID_IPropertyBag2))
- *ppvObject = static_cast<IPropertyBag2*>(this);
- else
- return E_NOINTERFACE;
-
- AddRef();
- return S_OK;
-}
-
-ULONG STDMETHODCALLTYPE FormValuesPropertyBag::AddRef(void)
-{
- return 1;
-}
-
-ULONG STDMETHODCALLTYPE FormValuesPropertyBag::Release(void)
-{
- return 0;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* /*pErrorLog*/)
-{
- HRESULT hr = S_OK;
-
- if (!pszPropName || !pVar)
- return E_POINTER;
-
- String key(pszPropName);
- if (!m_formValues->contains(key))
- return E_INVALIDARG;
-
- String value = m_formValues->get(key);
-
- VARTYPE requestedType = V_VT(pVar);
- VariantClear(pVar);
- V_VT(pVar) = VT_BSTR;
- V_BSTR(pVar) = SysAllocStringLen(value.characters(), value.length());
- if (value.length() && !V_BSTR(pVar))
- return E_OUTOFMEMORY;
-
- if (requestedType != VT_BSTR && requestedType != VT_EMPTY)
- hr = VariantChangeType(pVar, pVar, VARIANT_NOUSEROVERRIDE | VARIANT_ALPHABOOL, requestedType);
-
- return hr;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write(LPCOLESTR pszPropName, VARIANT* pVar)
-{
- if (!pszPropName || !pVar)
- return E_POINTER;
- VariantClear(pVar);
- return E_FAIL;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Read(
- /* [in] */ ULONG cProperties,
- /* [in] */ PROPBAG2* pPropBag,
- /* [in] */ IErrorLog* pErrLog,
- /* [out] */ VARIANT* pvarValue,
- /* [out] */ HRESULT* phrError)
-{
- if (cProperties > (size_t)m_formValues->size())
- return E_INVALIDARG;
- if (!pPropBag || !pvarValue || !phrError)
- return E_POINTER;
-
- for (ULONG i=0; i<cProperties; i++) {
- VariantInit(&pvarValue[i]);
- phrError[i] = Read(pPropBag->pstrName, &pvarValue[i], pErrLog);
- }
-
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::Write(
- /* [in] */ ULONG /*cProperties*/,
- /* [in] */ PROPBAG2* pPropBag,
- /* [in] */ VARIANT* pvarValue)
-{
- if (!pPropBag || !pvarValue)
- return E_POINTER;
- return E_FAIL;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::CountProperties(
- /* [out] */ ULONG* pcProperties)
-{
- *pcProperties = m_formValues->size();
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::GetPropertyInfo(
- /* [in] */ ULONG iProperty,
- /* [in] */ ULONG cProperties,
- /* [out] */ PROPBAG2* pPropBag,
- /* [out] */ ULONG* pcProperties)
-{
- if (iProperty > (size_t)m_formValues->size() || iProperty+cProperties > (size_t)m_formValues->size())
- return E_INVALIDARG;
- if (!pPropBag || !pcProperties)
- return E_POINTER;
-
- *pcProperties = 0;
- ULONG i = 0;
- ULONG endProperty = iProperty + cProperties;
- for (HashMap<String, String>::iterator it = m_formValues->begin(); i<endProperty; i++) {
- if (i >= iProperty) {
- int storeIndex = (*pcProperties)++;
- pPropBag[storeIndex].dwType = PROPBAG2_TYPE_DATA;
- pPropBag[storeIndex].vt = VT_BSTR;
- pPropBag[storeIndex].cfType = CF_TEXT;
- pPropBag[storeIndex].dwHint = 0;
- pPropBag[storeIndex].pstrName = const_cast<LPOLESTR>(it->first.charactersWithNullTermination());
- }
- ++it;
- }
-
- return S_OK;
-}
-
-HRESULT STDMETHODCALLTYPE FormValuesPropertyBag::LoadObject(
- /* [in] */ LPCOLESTR pstrName,
- /* [in] */ DWORD /*dwHint*/,
- /* [in] */ IUnknown* pUnkObject,
- /* [in] */ IErrorLog* /*pErrLog*/)
-{
- if (!pstrName || !pUnkObject)
- return E_POINTER;
- return E_FAIL;
-}
-
//-----------------------------------------------------------------------------
static Element *elementFromDOMElement(IDOMElement *element)
@@ -421,8 +211,6 @@ public:
: frame(0)
, webView(0)
, m_policyFunction(0)
- , m_pluginView(0)
- , m_hasSentResponseToPlugin(false)
{
}
@@ -433,24 +221,21 @@ public:
WebView* webView;
FramePolicyFunction m_policyFunction;
COMPtr<WebFramePolicyListener> m_policyListener;
-
- // Points to the plugin view that data should be redirected to.
- PluginView* m_pluginView;
- bool m_hasSentResponseToPlugin;
};
// WebFrame ----------------------------------------------------------------
WebFrame::WebFrame()
- : m_refCount(0)
+ : WebFrameLoaderClient(this)
+ , m_refCount(0)
, d(new WebFrame::WebFramePrivate)
, m_quickRedirectComing(false)
, m_inPrintingMode(false)
, m_pageHeight(0)
- , m_scriptDebugger(0)
{
WebFrameCount++;
gClassCount++;
+ gClassNameCount.add("WebFrame");
}
WebFrame::~WebFrame()
@@ -458,6 +243,7 @@ WebFrame::~WebFrame()
delete d;
WebFrameCount--;
gClassCount--;
+ gClassNameCount.remove("WebFrame");
}
WebFrame* WebFrame::createInstance()
@@ -472,7 +258,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::setAllowsScrolling(
{
if (Frame* frame = core(this))
if (FrameView* view = frame->view())
- view->setAllowsScrolling(!!flag);
+ view->setCanHaveScrollbars(!!flag);
return S_OK;
}
@@ -483,18 +269,70 @@ HRESULT STDMETHODCALLTYPE WebFrame::allowsScrolling(
if (flag)
if (Frame* frame = core(this))
if (FrameView* view = frame->view())
- *flag = view->allowsScrolling();
+ *flag = view->canHaveScrollbars();
return S_OK;
}
+HRESULT STDMETHODCALLTYPE WebFrame::setIsDisconnected(
+ /* [in] */ BOOL flag)
+{
+ if (Frame* frame = core(this)) {
+ frame->setIsDisconnected(flag);
+ return S_OK;
+ }
+
+ return E_FAIL;
+}
+
+HRESULT STDMETHODCALLTYPE WebFrame::setExcludeFromTextSearch(
+ /* [in] */ BOOL flag)
+{
+ if (Frame* frame = core(this)) {
+ frame->setExcludeFromTextSearch(flag);
+ return S_OK;
+ }
+
+ return E_FAIL;
+}
+
+HRESULT STDMETHODCALLTYPE WebFrame::paintDocumentRectToContext(
+ /* [in] */ RECT rect,
+ /* [in] */ OLE_HANDLE deviceContext)
+{
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return E_FAIL;
+
+ // We can't paint with a layout still pending.
+ view->layoutIfNeededRecursive();
+
+ HDC dc = (HDC)(ULONG64)deviceContext;
+ GraphicsContext gc(dc);
+ gc.save();
+ LONG width = rect.right - rect.left;
+ LONG height = rect.bottom - rect.top;
+ FloatRect dirtyRect;
+ dirtyRect.setWidth(width);
+ dirtyRect.setHeight(height);
+ gc.clip(dirtyRect);
+ gc.translate(-rect.left, -rect.top);
+ view->paintContents(&gc, rect);
+ gc.restore();
+
+ return S_OK;
+}
// IUnknown -------------------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebFrame::QueryInterface(REFIID riid, void** ppvObject)
{
*ppvObject = 0;
- if (IsEqualGUID(riid, IID_WebFrame))
+ if (IsEqualGUID(riid, __uuidof(WebFrame)))
*ppvObject = this;
else if (IsEqualGUID(riid, IID_IUnknown))
*ppvObject = static_cast<IWebFrame*>(this);
@@ -581,10 +419,21 @@ HRESULT STDMETHODCALLTYPE WebFrame::DOMDocument(
}
HRESULT STDMETHODCALLTYPE WebFrame::frameElement(
- /* [retval][out] */ IDOMHTMLElement** /*frameElement*/)
+ /* [retval][out] */ IDOMHTMLElement** frameElement)
{
- ASSERT_NOT_REACHED();
- return E_NOTIMPL;
+ if (!frameElement)
+ return E_POINTER;
+
+ *frameElement = 0;
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ COMPtr<IDOMElement> domElement(AdoptCOM, DOMElement::createInstance(coreFrame->ownerElement()));
+ COMPtr<IDOMHTMLElement> htmlElement(Query, domElement);
+ if (!htmlElement)
+ return E_FAIL;
+ return htmlElement.copyRefTo(frameElement);
}
HRESULT STDMETHODCALLTYPE WebFrame::currentForm(
@@ -610,7 +459,7 @@ JSGlobalContextRef STDMETHODCALLTYPE WebFrame::globalContext()
if (!coreFrame)
return 0;
- return toGlobalRef(coreFrame->scriptProxy()->globalObject()->globalExec());
+ return toGlobalRef(coreFrame->script()->globalObject()->globalExec());
}
HRESULT STDMETHODCALLTYPE WebFrame::loadRequest(
@@ -637,8 +486,8 @@ void WebFrame::loadData(PassRefPtr<WebCore::SharedBuffer> data, BSTR mimeType, B
mimeTypeString = "text/html";
String encodingString(textEncodingName, SysStringLen(textEncodingName));
- KURL baseKURL = DeprecatedString((DeprecatedChar*)baseURL, SysStringLen(baseURL));
- KURL failingKURL = DeprecatedString((DeprecatedChar*)failingURL, SysStringLen(failingURL));
+ KURL baseKURL(String(baseURL ? baseURL : L"", SysStringLen(baseURL)));
+ KURL failingKURL(String(failingURL, SysStringLen(failingURL)));
ResourceRequest request(baseKURL);
SubstituteData substituteData(data, mimeTypeString, encodingString, failingKURL);
@@ -655,7 +504,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::loadData(
/* [in] */ BSTR textEncodingName,
/* [in] */ BSTR url)
{
- RefPtr<SharedBuffer> sharedBuffer = new SharedBuffer();
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create();
STATSTG stat;
if (SUCCEEDED(data->Stat(&stat, STATFLAG_NONAME))) {
@@ -675,7 +524,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::loadData(
void WebFrame::loadHTMLString(BSTR string, BSTR baseURL, BSTR unreachableURL)
{
- RefPtr<SharedBuffer> sharedBuffer = new SharedBuffer(reinterpret_cast<char*>(string), sizeof(UChar) * SysStringLen(string));
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(reinterpret_cast<char*>(string), sizeof(UChar) * SysStringLen(string));
BString utf16Encoding(TEXT("utf-16"), 6);
loadData(sharedBuffer.release(), 0, utf16Encoding, baseURL, unreachableURL);
}
@@ -766,17 +615,6 @@ KURL WebFrame::url() const
return coreFrame->loader()->url();
}
-void WebFrame::attachScriptDebugger()
-{
- if (!m_scriptDebugger && core(this)->scriptProxy()->haveGlobalObject())
- m_scriptDebugger.set(new WebScriptDebugger(this));
-}
-
-void WebFrame::detachScriptDebugger()
-{
- m_scriptDebugger.clear();
-}
-
HRESULT STDMETHODCALLTYPE WebFrame::stopLoading( void)
{
if (Frame* coreFrame = core(this))
@@ -932,21 +770,14 @@ HRESULT STDMETHODCALLTYPE WebFrame::childFrames(
HRESULT STDMETHODCALLTYPE WebFrame::renderTreeAsExternalRepresentation(
/* [retval][out] */ BSTR *result)
{
- if (!result) {
- ASSERT_NOT_REACHED();
+ if (!result)
return E_POINTER;
- }
-
- *result = 0;
Frame* coreFrame = core(this);
if (!coreFrame)
return E_FAIL;
- DeprecatedString representation = externalRepresentation(coreFrame->renderer());
-
- *result = SysAllocStringLen((LPCOLESTR)representation.unicode(), representation.length());
-
+ *result = BString(externalRepresentation(coreFrame->contentRenderer())).release();
return S_OK;
}
@@ -1020,6 +851,47 @@ HRESULT STDMETHODCALLTYPE WebFrame::loadType(
return S_OK;
}
+HRESULT STDMETHODCALLTYPE WebFrame::pendingFrameUnloadEventCount(
+ /* [retval][out] */ UINT* result)
+{
+ if (!result) {
+ ASSERT_NOT_REACHED();
+ return E_POINTER;
+ }
+
+ *result = 0;
+
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ *result = coreFrame->eventHandler()->pendingFrameUnloadEventCount();
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebFrame::fetchApplicationIcon(
+ /* [in] */ IWebIconFetcherDelegate *delegate,
+ /* [retval][out] */ IWebIconFetcher **result)
+{
+ if (!result)
+ return E_POINTER;
+
+ *result = 0;
+
+ if (!delegate)
+ return E_FAIL;
+
+ Frame* coreFrame = core(this);
+ if (!coreFrame)
+ return E_FAIL;
+
+ *result = WebIconFetcher::fetchApplicationIcon(coreFrame, delegate);
+ if (!*result)
+ return E_FAIL;
+
+ return S_OK;
+}
+
// IWebDocumentText -----------------------------------------------------------
HRESULT STDMETHODCALLTYPE WebFrame::supportsTextEncoding(
@@ -1057,18 +929,18 @@ HRESULT STDMETHODCALLTYPE WebFrame::deselectAll()
// WebFrame ---------------------------------------------------------------
-void WebFrame::initWithWebFrameView(IWebFrameView* /*view*/, IWebView* webView, Page* page, HTMLFrameOwnerElement* ownerElement)
+PassRefPtr<Frame> WebFrame::init(IWebView* webView, Page* page, HTMLFrameOwnerElement* ownerElement)
{
- if (FAILED(webView->QueryInterface(&d->webView)))
- return;
+ webView->QueryInterface(&d->webView);
d->webView->Release(); // don't hold the extra ref
HWND viewWindow;
d->webView->viewWindow((OLE_HANDLE*)&viewWindow);
this->AddRef(); // We release this ref in frameLoaderDestroyed()
- Frame* frame = new Frame(page, ownerElement, this);
- d->frame = frame;
+ RefPtr<Frame> frame = Frame::create(page, ownerElement, this);
+ d->frame = frame.get();
+ return frame.release();
}
Frame* WebFrame::impl()
@@ -1087,14 +959,9 @@ void WebFrame::invalidate()
void WebFrame::setTextSizeMultiplier(float multiplier)
{
- int newZoomFactor = (int)round(multiplier * 100);
Frame* coreFrame = core(this);
ASSERT(coreFrame);
-
- if (coreFrame->zoomFactor() == newZoomFactor)
- return;
-
- coreFrame->setZoomFactor(newZoomFactor);
+ coreFrame->setZoomFactor(multiplier, true);
}
HRESULT WebFrame::inViewSourceMode(BOOL* flag)
@@ -1131,10 +998,10 @@ HRESULT WebFrame::elementWithName(BSTR name, IDOMElement* form, IDOMElement** el
HTMLFormElement *formElement = formElementFromDOMElement(form);
if (formElement) {
- Vector<HTMLGenericFormElement*>& elements = formElement->formElements;
+ Vector<HTMLFormControlElement*>& elements = formElement->formElements;
AtomicString targetName((UChar*)name, SysStringLen(name));
for (unsigned int i = 0; i < elements.size(); i++) {
- HTMLGenericFormElement *elt = elements[i];
+ HTMLFormControlElement *elt = elements[i];
// Skip option elements, other duds
if (elt->name() == targetName) {
*element = DOMElement::createInstance(elt);
@@ -1162,7 +1029,7 @@ HRESULT WebFrame::formForElement(IDOMElement* element, IDOMElement** form)
return S_OK;
}
-HRESULT WebFrame::elementDoesAutoComplete(IDOMElement *element, bool *result)
+HRESULT WebFrame::elementDoesAutoComplete(IDOMElement *element, BOOL *result)
{
*result = false;
if (!element)
@@ -1195,7 +1062,7 @@ HRESULT WebFrame::controlsInForm(IDOMElement* form, IDOMElement** controls, int*
return E_FAIL;
*cControls = 0;
- Vector<HTMLGenericFormElement*>& elements = formElement->formElements;
+ Vector<HTMLFormControlElement*>& elements = formElement->formElements;
for (int i = 0; i < count; i++) {
if (elements.at(i)->isEnumeratable()) { // Skip option elements, other duds
controls[*cControls] = DOMElement::createInstance(elements.at(i));
@@ -1302,18 +1169,6 @@ HRESULT WebFrame::canProvideDocumentSource(bool* result)
return hr;
}
-// FrameWinClient
-
-void WebFrame::ref()
-{
- this->AddRef();
-}
-
-void WebFrame::deref()
-{
- this->Release();
-}
-
void WebFrame::frameLoaderDestroyed()
{
// The FrameLoader going away is equivalent to the Frame going away,
@@ -1323,180 +1178,11 @@ 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->originalURLString().deprecatedString();
- // 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);
-}
-
-void WebFrame::openURL(const String& URL, const Event* triggeringEvent, bool newWindow, bool lockHistory)
-{
- bool ctrlPressed = false;
- bool shiftPressed = false;
- if (triggeringEvent) {
- if (triggeringEvent->isMouseEvent()) {
- const MouseRelatedEvent* mouseEvent = static_cast<const MouseRelatedEvent*>(triggeringEvent);
- ctrlPressed = mouseEvent->ctrlKey();
- shiftPressed = mouseEvent->shiftKey();
- } else if (triggeringEvent->isKeyboardEvent()) {
- const KeyboardEvent* keyEvent = static_cast<const KeyboardEvent*>(triggeringEvent);
- ctrlPressed = keyEvent->ctrlKey();
- shiftPressed = keyEvent->shiftKey();
- }
- }
-
- if (ctrlPressed)
- newWindow = true;
-
- BString urlBStr = URL;
-
- IWebMutableURLRequest* request = WebMutableURLRequest::createInstance();
- if (FAILED(request->initWithURL(urlBStr, WebURLRequestUseProtocolCachePolicy, 0)))
- goto exit;
-
- if (newWindow) {
- // new tab/window
- IWebUIDelegate* ui;
- IWebView* newWebView;
- if (SUCCEEDED(d->webView->uiDelegate(&ui)) && ui) {
- if (SUCCEEDED(ui->createWebViewWithRequest(d->webView, request, &newWebView))) {
- if (shiftPressed) {
- // Ctrl-Option-Shift-click: Opens a link in a new window and selects it.
- // Ctrl-Shift-click: Opens a link in a new tab and selects it.
- ui->webViewShow(d->webView);
- }
- newWebView->Release();
- newWebView = 0;
- }
- ui->Release();
- }
- } else {
- m_quickRedirectComing = lockHistory;
- loadRequest(request);
- }
-
-exit:
- request->Release();
-}
-
-void WebFrame::dispatchDidHandleOnloadEvents()
-{
- IWebFrameLoadDelegatePrivate* frameLoadDelegatePriv;
- if (SUCCEEDED(d->webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) && frameLoadDelegatePriv) {
- frameLoadDelegatePriv->didHandleOnloadEventsForFrame(d->webView, this);
- frameLoadDelegatePriv->Release();
- }
-}
-
-void WebFrame::windowScriptObjectAvailable(JSContextRef context, JSObjectRef windowObject)
-{
- IWebFrameLoadDelegate* frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)) && frameLoadDelegate) {
- frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
- frameLoadDelegate->Release();
- }
-}
-
-WebHistory* WebFrame::webHistory()
-{
- if (this != d->webView->topLevelFrame())
- return 0;
-
- IWebHistoryPrivate* historyInternal = WebHistory::optionalSharedHistoryInternal(); // does not add a ref
- if (!historyInternal)
- return 0;
-
- WebHistory* webHistory;
- if (FAILED(historyInternal->QueryInterface(&webHistory)))
- return 0;
-
- return webHistory;
-}
-
-bool WebFrame::hasWebView() const
-{
- return !!d->webView;
-}
-
-bool WebFrame::hasFrameView() const
-{
- return !!d->frameView();
-}
-
void WebFrame::makeRepresentation(DocumentLoader*)
{
notImplemented();
}
-void WebFrame::forceLayout()
-{
- core(this)->forceLayout(true);
-}
-
void WebFrame::forceLayoutForNonHTML()
{
notImplemented();
@@ -1507,11 +1193,6 @@ void WebFrame::setCopiesOnScroll()
notImplemented();
}
-void WebFrame::detachedFromParent1()
-{
- notImplemented();
-}
-
void WebFrame::detachedFromParent2()
{
notImplemented();
@@ -1522,101 +1203,6 @@ void WebFrame::detachedFromParent3()
notImplemented();
}
-void WebFrame::detachedFromParent4()
-{
- notImplemented();
-}
-
-void WebFrame::dispatchDidReceiveServerRedirectForProvisionalLoad()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didReceiveServerRedirectForProvisionalLoadForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidCancelClientRedirect()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didCancelClientRedirectForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchWillPerformClientRedirect(const KURL& url, double delay, double fireDate)
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->willPerformClientRedirectToURL(d->webView, BString(url.string()), delay, MarshallingHelpers::CFAbsoluteTimeToDATE(fireDate), this);
-}
-
-void WebFrame::dispatchDidChangeLocationWithinPage()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didChangeLocationWithinPageForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchWillClose()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->willCloseFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidReceiveIcon()
-{
- d->webView->dispatchDidReceiveIconFromWebFrame(this);
-}
-
-void WebFrame::dispatchDidStartProvisionalLoad()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didStartProvisionalLoadForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidReceiveTitle(const String& title)
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didReceiveTitle(d->webView, BString(title), this);
-}
-
-void WebFrame::dispatchDidCommitLoad()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didCommitLoadForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidFinishDocumentLoad()
-{
- COMPtr<IWebFrameLoadDelegatePrivate> frameLoadDelegatePriv;
- if (SUCCEEDED(d->webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) && frameLoadDelegatePriv)
- frameLoadDelegatePriv->didFinishDocumentLoadForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidFinishLoad()
-{
- COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
- if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate)))
- frameLoadDelegate->didFinishLoadForFrame(d->webView, this);
-}
-
-void WebFrame::dispatchDidFirstLayout()
-{
- COMPtr<IWebFrameLoadDelegatePrivate> frameLoadDelegatePriv;
- if (SUCCEEDED(d->webView->frameLoadDelegatePrivate(&frameLoadDelegatePriv)) && frameLoadDelegatePriv)
- frameLoadDelegatePriv->didFirstLayoutInFrame(d->webView, this);
-}
-
-void WebFrame::dispatchShow()
-{
- COMPtr<IWebUIDelegate> ui;
-
- if (SUCCEEDED(d->webView->uiDelegate(&ui)))
- ui->webViewShow(d->webView);
-}
-
void WebFrame::cancelPolicyCheck()
{
if (d->m_policyListener) {
@@ -1641,40 +1227,21 @@ void WebFrame::dispatchWillSubmitForm(FramePolicyFunction function, PassRefPtr<F
COMPtr<IDOMElement> formElement(AdoptCOM, DOMElement::createInstance(formState->form()));
- // FIXME: The FormValuesPropertyBag constructor should take a const pointer
- FormValuesPropertyBag formValuesPropBag(const_cast<HashMap<String, String>*>(&formState->values()));
+ COMPtr<IPropertyBag> formValuesPropertyBag(AdoptCOM, COMPropertyBag<String>::createInstance(formState->values()));
COMPtr<WebFrame> sourceFrame(kit(formState->sourceFrame()));
- if (SUCCEEDED(formDelegate->willSubmitForm(this, sourceFrame.get(), formElement.get(), &formValuesPropBag, setUpPolicyListener(function).get())))
+ if (SUCCEEDED(formDelegate->willSubmitForm(this, sourceFrame.get(), formElement.get(), formValuesPropertyBag.get(), setUpPolicyListener(function).get())))
return;
// FIXME: Add a sane default implementation
(coreFrame->loader()->*function)(PolicyUse);
}
-void WebFrame::dispatchDidLoadMainResource(DocumentLoader* loader)
-{
- if (WebScriptDebugServer::listenerCount() > 0) {
- Frame* coreFrame = core(this);
- if (!coreFrame)
- return;
-
- WebScriptDebugServer::sharedWebScriptDebugServer()->didLoadMainResourceForDataSource(
- kit(coreFrame->page()),
- loader ? static_cast<WebDocumentLoader*>(loader)->dataSource() : 0);
- }
-}
-
void WebFrame::revertToProvisionalState(DocumentLoader*)
{
notImplemented();
}
-void WebFrame::clearUnarchivingState(DocumentLoader*)
-{
- notImplemented();
-}
-
void WebFrame::setMainFrameDocumentReady(bool)
{
notImplemented();
@@ -1690,47 +1257,6 @@ void WebFrame::didChangeTitle(DocumentLoader*)
notImplemented();
}
-void WebFrame::finishedLoading(DocumentLoader* loader)
-{
- // Telling the frame we received some data and passing 0 as the data is our
- // way to get work done that is normally done when the first bit of data is
- // received, even for the case of a document with no data (like about:blank)
- if (!d->m_pluginView)
- committedLoad(loader, 0, 0);
- else {
- if (d->m_pluginView->status() == PluginStatusLoadedSuccessfully)
- d->m_pluginView->didFinishLoading();
- d->m_pluginView = 0;
- d->m_hasSentResponseToPlugin = false;
- }
-}
-
-void WebFrame::finalSetupForReplace(DocumentLoader*)
-{
- notImplemented();
-}
-
-void WebFrame::setDefersLoading(bool)
-{
- notImplemented();
-}
-
-bool WebFrame::isArchiveLoadPending(ResourceLoader*) const
-{
- notImplemented();
- return false;
-}
-
-void WebFrame::cancelPendingArchiveLoad(ResourceLoader*)
-{
- notImplemented();
-}
-
-void WebFrame::clearArchivedResources()
-{
- notImplemented();
-}
-
bool WebFrame::canHandleRequest(const ResourceRequest& request) const
{
return WebView::canHandleRequest(request);
@@ -1791,159 +1317,19 @@ void WebFrame::prepareForDataSourceReplacement()
notImplemented();
}
-void WebFrame::setTitle(const String& title, const KURL& url)
-{
- BOOL privateBrowsingEnabled = FALSE;
- COMPtr<IWebPreferences> preferences;
- if (SUCCEEDED(d->webView->preferences(&preferences)))
- preferences->privateBrowsingEnabled(&privateBrowsingEnabled);
- if (!privateBrowsingEnabled) {
- // update title in global history
- COMPtr<WebHistory> history;
- history.adoptRef(webHistory());
- if (history) {
- COMPtr<IWebHistoryItem> item;
- if (SUCCEEDED(history->itemForURL(BString(url.string()), &item))) {
- COMPtr<IWebHistoryItemPrivate> itemPrivate;
- if (SUCCEEDED(item->QueryInterface(IID_IWebHistoryItemPrivate, (void**)&itemPrivate)))
- itemPrivate->setTitle(BString(title));
- }
- }
- }
-}
-
String WebFrame::userAgent(const KURL& url)
{
return d->webView->userAgentForKURL(url);
}
-void WebFrame::savePlatformDataToCachedPage(CachedPage* cachedPage)
-{
- Frame* coreFrame = core(this);
- if (!coreFrame)
- return;
-
- ASSERT(coreFrame->loader()->documentLoader() == cachedPage->documentLoader());
-
- WebCachedPagePlatformData* webPlatformData = new WebCachedPagePlatformData(static_cast<IWebDataSource*>(getWebDataSource(coreFrame->loader()->documentLoader())));
- cachedPage->setCachedPagePlatformData(webPlatformData);
-}
-
void WebFrame::transitionToCommittedFromCachedPage(CachedPage*)
{
}
-void WebFrame::transitionToCommittedForNewPage()
-{
- Frame* frame = core(this);
- ASSERT(frame);
-
- Page* page = frame->page();
- ASSERT(page);
-
- bool isMainFrame = frame == page->mainFrame();
-
- if (isMainFrame && frame->view())
- frame->view()->detachFromWindow();
-
- frame->setView(0);
-
- FrameView* frameView;
- if (isMainFrame) {
- RECT rect;
- d->webView->frameRect(&rect);
- frameView = new FrameView(frame, IntRect(rect).size());
- } else
- frameView = new FrameView(frame);
-
- frame->setView(frameView);
- frameView->deref(); // FrameViews are created with a ref count of 1. Release this ref since we've assigned it to frame.
-
- HWND viewWindow;
- if (SUCCEEDED(d->webView->viewWindow(reinterpret_cast<OLE_HANDLE*>(&viewWindow))))
- frameView->setContainingWindow(viewWindow);
-
- if (isMainFrame)
- frameView->attachToWindow();
-
- if (frame->ownerRenderer())
- frame->ownerRenderer()->setWidget(frameView);
-
- if (HTMLFrameOwnerElement* owner = frame->ownerElement())
- frame->view()->setScrollbarsMode(owner->scrollingMode());
-}
-
-void WebFrame::updateGlobalHistoryForStandardLoad(const KURL& url)
-{
- COMPtr<WebHistory> history;
- history.adoptRef(webHistory());
-
- if (!history)
- return;
-
- history->addItemForURL(BString(url.string()), 0);
-}
-
-void WebFrame::updateGlobalHistoryForReload(const KURL& url)
-{
- BString urlBStr(url.string());
-
- COMPtr<WebHistory> history;
- history.adoptRef(webHistory());
-
- if (!history)
- return;
-
- COMPtr<IWebHistoryItem> item;
- if (SUCCEEDED(history->itemForURL(urlBStr, &item))) {
- COMPtr<IWebHistoryItemPrivate> itemPrivate;
- if (SUCCEEDED(item->QueryInterface(IID_IWebHistoryItemPrivate, (void**)&itemPrivate))) {
- SYSTEMTIME currentTime;
- GetSystemTime(&currentTime);
- DATE visitedTime = 0;
- SystemTimeToVariantTime(&currentTime, &visitedTime);
-
- // FIXME - bumping the last visited time doesn't mark the history as changed
- itemPrivate->setLastVisitedTimeInterval(visitedTime);
- }
- }
-}
-
-bool WebFrame::shouldGoToHistoryItem(HistoryItem*) const
-{
- return true;
-}
-
void WebFrame::saveViewStateToItem(HistoryItem*)
{
}
-bool WebFrame::canCachePage() const
-{
- return true;
-}
-
-PassRefPtr<DocumentLoader> WebFrame::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
-{
- RefPtr<WebDocumentLoader> loader = new WebDocumentLoader(request, substituteData);
-
- COMPtr<WebDataSource> dataSource;
- dataSource.adoptRef(WebDataSource::createInstance(loader.get()));
-
- loader->setDataSource(dataSource.get());
- return loader.release();
-}
-
-void WebFrame::setMainDocumentError(DocumentLoader*, const ResourceError& error)
-{
- if (d->m_pluginView) {
- if (d->m_pluginView->status() == PluginStatusLoadedSuccessfully)
- d->m_pluginView->didFail(error);
- d->m_pluginView = 0;
- d->m_hasSentResponseToPlugin = false;
- }
-}
-
ResourceError WebFrame::cancelledError(const ResourceRequest& request)
{
// FIXME: Need ChickenCat to include CFNetwork/CFURLError.h to get these values
@@ -1981,25 +1367,14 @@ ResourceError WebFrame::fileDoesNotExistError(const ResourceResponse&)
return ResourceError();
}
-bool WebFrame::shouldFallBack(const ResourceError& error)
+ResourceError WebFrame::pluginWillHandleLoadError(const ResourceResponse& response)
{
- return error.errorCode() != WebURLErrorCancelled;
+ return ResourceError(String(WebKitErrorDomain), WebKitErrorPlugInWillHandleLoad, response.url().string(), String());
}
-void WebFrame::receivedData(const char* data, int length, const String& textEncoding)
+bool WebFrame::shouldFallBack(const ResourceError& error)
{
- Frame* coreFrame = core(this);
- if (!coreFrame)
- return;
-
- // Set the encoding. This only needs to be done once, but it's harmless to do it again later.
- String encoding = coreFrame->loader()->documentLoader()->overrideEncoding();
- bool userChosen = !encoding.isNull();
- if (encoding.isNull())
- encoding = textEncoding;
- coreFrame->loader()->setEncoding(encoding, userChosen);
-
- coreFrame->loader()->addData(data, length);
+ return error.errorCode() != WebURLErrorCancelled;
}
COMPtr<WebFramePolicyListener> WebFrame::setUpPolicyListener(WebCore::FramePolicyFunction function)
@@ -2034,28 +1409,6 @@ void WebFrame::receivedPolicyDecision(PolicyAction action)
(coreFrame->loader()->*function)(action);
}
-void WebFrame::committedLoad(DocumentLoader* loader, const char* data, int length)
-{
- // FIXME: This should probably go through the data source.
- const String& textEncoding = loader->response().textEncodingName();
-
- if (!d->m_pluginView)
- receivedData(data, length, textEncoding);
-
- if (d->m_pluginView && d->m_pluginView->status() == PluginStatusLoadedSuccessfully) {
- if (!d->m_hasSentResponseToPlugin) {
- d->m_pluginView->didReceiveResponse(d->frame->loader()->documentLoader()->response());
- // didReceiveResponse sets up a new stream to the plug-in. on a full-page plug-in, a failure in
- // setting up this stream can cause the main document load to be cancelled, setting m_pluginView
- // to null
- if (!d->m_pluginView)
- return;
- d->m_hasSentResponseToPlugin = true;
- }
- d->m_pluginView->didReceiveData(data, length);
- }
-}
-
void WebFrame::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& mimeType, const ResourceRequest& request)
{
Frame* coreFrame = core(this);
@@ -2073,7 +1426,7 @@ void WebFrame::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, con
(coreFrame->loader()->*function)(PolicyUse);
}
-void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, const String& frameName)
+void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName)
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
@@ -2083,7 +1436,7 @@ void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction functi
policyDelegate = DefaultPolicyDelegate::sharedInstance();
COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
- COMPtr<WebActionPropertyBag> actionInformation(AdoptCOM, WebActionPropertyBag::createInstance(action, coreFrame));
+ COMPtr<WebActionPropertyBag> actionInformation(AdoptCOM, WebActionPropertyBag::createInstance(action, formState ? formState->form() : 0, coreFrame));
if (SUCCEEDED(policyDelegate->decidePolicyForNewWindowAction(d->webView, actionInformation.get(), urlRequest.get(), BString(frameName), setUpPolicyListener(function).get())))
return;
@@ -2091,7 +1444,7 @@ void WebFrame::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction functi
(coreFrame->loader()->*function)(PolicyUse);
}
-void WebFrame::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request)
+void WebFrame::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState)
{
Frame* coreFrame = core(this);
ASSERT(coreFrame);
@@ -2101,7 +1454,7 @@ void WebFrame::dispatchDecidePolicyForNavigationAction(FramePolicyFunction funct
policyDelegate = DefaultPolicyDelegate::sharedInstance();
COMPtr<IWebURLRequest> urlRequest(AdoptCOM, WebMutableURLRequest::createInstance(request));
- COMPtr<WebActionPropertyBag> actionInformation(AdoptCOM, WebActionPropertyBag::createInstance(action, coreFrame));
+ COMPtr<WebActionPropertyBag> actionInformation(AdoptCOM, WebActionPropertyBag::createInstance(action, formState ? formState->form() : 0, coreFrame));
if (SUCCEEDED(policyDelegate->decidePolicyForNavigationAction(d->webView, actionInformation.get(), urlRequest.get(), this, setUpPolicyListener(function).get())))
return;
@@ -2138,82 +1491,6 @@ void WebFrame::download(ResourceHandle* handle, const ResourceRequest& request,
download.adoptRef(WebDownload::createInstance(handle, request, response, downloadDelegate.get()));
}
-bool WebFrame::willUseArchive(ResourceLoader*, const ResourceRequest&, const KURL&) const
-{
- notImplemented();
- return false;
-}
-
-void WebFrame::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebURLRequest> webURLRequest;
- webURLRequest.adoptRef(WebMutableURLRequest::createInstance(request));
-
- resourceLoadDelegate->identifierForInitialRequest(d->webView, webURLRequest.get(), getWebDataSource(loader), identifier);
- }
-}
-
-void WebFrame::dispatchWillSendRequest(DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, const ResourceResponse& redirectResponse)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebURLRequest> webURLRequest;
- webURLRequest.adoptRef(WebMutableURLRequest::createInstance(request));
- COMPtr<IWebURLResponse> webURLRedirectResponse;
- webURLRedirectResponse.adoptRef(WebURLResponse::createInstance(redirectResponse));
- COMPtr<IWebURLRequest> newWebURLRequest;
-
- if (FAILED(resourceLoadDelegate->willSendRequest(d->webView, identifier, webURLRequest.get(), webURLRedirectResponse.get(), getWebDataSource(loader), &newWebURLRequest)))
- return;
-
- if (webURLRequest == newWebURLRequest)
- return;
-
- COMPtr<WebMutableURLRequest> newWebURLRequestImpl;
- if (FAILED(newWebURLRequest->QueryInterface(&newWebURLRequestImpl)))
- return;
-
- request = newWebURLRequestImpl->resourceRequest();
- }
-}
-
-void WebFrame::dispatchDidReceiveResponse(DocumentLoader* loader, unsigned long identifier, const ResourceResponse& response)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebURLResponse> webURLResponse;
- webURLResponse.adoptRef(WebURLResponse::createInstance(response));
-
- resourceLoadDelegate->didReceiveResponse(d->webView, identifier, webURLResponse.get(), getWebDataSource(loader));
- }
-}
-
-void WebFrame::dispatchDidReceiveContentLength(DocumentLoader* loader, unsigned long identifier, int length)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate)))
- resourceLoadDelegate->didReceiveContentLength(d->webView, identifier, length, getWebDataSource(loader));
-}
-
-void WebFrame::dispatchDidFinishLoading(DocumentLoader* loader, unsigned long identifier)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate)))
- resourceLoadDelegate->didFinishLoadingFromDataSource(d->webView, identifier, getWebDataSource(loader));
-}
-
-void WebFrame::dispatchDidFailLoading(DocumentLoader* loader, unsigned long identifier, const ResourceError& error)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebError> webError;
- webError.adoptRef(WebError::createInstance(error));
- resourceLoadDelegate->didFailLoadingWithError(d->webView, identifier, webError.get(), getWebDataSource(loader));
- }
-}
-
bool WebFrame::dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int /*length*/)
{
notImplemented();
@@ -2240,178 +1517,14 @@ void WebFrame::dispatchDidFailLoad(const ResourceError& error)
}
}
-Frame* WebFrame::dispatchCreatePage()
-{
- COMPtr<IWebUIDelegate> ui;
-
- if (SUCCEEDED(d->webView->uiDelegate(&ui))) {
- COMPtr<IWebView> newWebView;
-
- if (SUCCEEDED(ui->createWebViewWithRequest(d->webView, 0, &newWebView))) {
- COMPtr<IWebFrame> mainFrame;
-
- if (SUCCEEDED(newWebView->mainFrame(&mainFrame))) {
- COMPtr<WebFrame> mainFrameImpl;
-
- if (SUCCEEDED(mainFrame->QueryInterface(IID_WebFrame, (void**)&mainFrameImpl)))
- return core(mainFrameImpl.get());
- }
- }
- }
- return 0;
-}
-
-void WebFrame::postProgressStartedNotification()
-{
- static BSTR progressStartedName = SysAllocString(WebViewProgressStartedNotification);
- IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
- notifyCenter->postNotificationName(progressStartedName, static_cast<IWebView*>(d->webView), 0);
-}
-
-void WebFrame::postProgressEstimateChangedNotification()
-{
- static BSTR progressEstimateChangedName = SysAllocString(WebViewProgressEstimateChangedNotification);
- IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
- notifyCenter->postNotificationName(progressEstimateChangedName, static_cast<IWebView*>(d->webView), 0);
-}
-
-void WebFrame::postProgressFinishedNotification()
-{
- static BSTR progressFinishedName = SysAllocString(WebViewProgressFinishedNotification);
- IWebNotificationCenter* notifyCenter = WebNotificationCenter::defaultCenterInternal();
- notifyCenter->postNotificationName(progressFinishedName, static_cast<IWebView*>(d->webView), 0);
-}
-
void WebFrame::startDownload(const ResourceRequest&)
{
notImplemented();
}
-void WebFrame::dispatchDidReceiveAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge& challenge)
-{
- ASSERT(challenge.sourceHandle());
-
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
-
- if (SUCCEEDED(resourceLoadDelegate->didReceiveAuthenticationChallenge(d->webView, identifier, webChallenge.get(), getWebDataSource(loader))))
- return;
- }
-
- // If the ResourceLoadDelegate doesn't exist or fails to handle the call, we tell the ResourceHandle
- // to continue without credential - this is the best approximation of Mac behavior
- challenge.sourceHandle()->receivedRequestToContinueWithoutCredential(challenge);
-}
-
-void WebFrame::dispatchDidCancelAuthenticationChallenge(DocumentLoader* loader, unsigned long identifier, const AuthenticationChallenge& challenge)
-{
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
- if (SUCCEEDED(d->webView->resourceLoadDelegate(&resourceLoadDelegate))) {
- COMPtr<IWebURLAuthenticationChallenge> webChallenge(AdoptCOM, WebURLAuthenticationChallenge::createInstance(challenge));
-
- if (SUCCEEDED(resourceLoadDelegate->didCancelAuthenticationChallenge(d->webView, identifier, webChallenge.get(), getWebDataSource(loader))))
- return;
- }
-}
-
-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 = PluginDatabase::installedPlugins()->createPluginView(core(this), pluginSize, element, url, paramNames, paramValues, mimeType, loadManually);
-
- if (pluginView->status() == PluginStatusLoadedSuccessfully)
- return pluginView;
-
- COMPtr<IWebResourceLoadDelegate> resourceLoadDelegate;
-
- if (FAILED(d->webView->resourceLoadDelegate(&resourceLoadDelegate)))
- return pluginView;
-
- RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
-
- unsigned count = (unsigned)paramNames.size();
- for (unsigned i = 0; i < count; i++) {
- if (paramNames[i] == "pluginspage") {
- static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInPageURLStringKey);
- RetainPtr<CFStringRef> str(AdoptCF, paramValues[i].createCFString());
- CFDictionarySetValue(userInfo.get(), key, str.get());
- break;
- }
- }
-
- if (!mimeType.isNull()) {
- static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorMIMETypeKey);
-
- RetainPtr<CFStringRef> str(AdoptCF, mimeType.createCFString());
- CFDictionarySetValue(userInfo.get(), key, str.get());
- }
-
- String pluginName;
- if (pluginView->plugin())
- pluginName = pluginView->plugin()->name();
- if (!pluginName.isNull()) {
- static CFStringRef key = MarshallingHelpers::LPCOLESTRToCFStringRef(WebKitErrorPlugInNameKey);
- RetainPtr<CFStringRef> str(AdoptCF, pluginName.createCFString());
- CFDictionarySetValue(userInfo.get(), key, str.get());
- }
-
- COMPtr<CFDictionaryPropertyBag> userInfoBag(AdoptCOM, CFDictionaryPropertyBag::createInstance());
- userInfoBag->setDictionary(userInfo.get());
-
- int errorCode = 0;
- switch (pluginView->status()) {
- case PluginStatusCanNotFindPlugin:
- errorCode = WebKitErrorCannotFindPlugIn;
- break;
- case PluginStatusCanNotLoadPlugin:
- errorCode = WebKitErrorCannotLoadPlugIn;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-
- ResourceError resourceError(String(WebKitErrorDomain), errorCode, url.string(), String());
- COMPtr<IWebError> error(AdoptCOM, WebError::createInstance(resourceError, userInfoBag.get()));
-
- resourceLoadDelegate->plugInFailedWithError(d->webView, error.get(), getWebDataSource(d->frame->loader()->documentLoader()));
-
- return pluginView;
-}
-
-void WebFrame::redirectDataToPlugin(Widget* pluginWidget)
-{
- // Ideally, this function shouldn't be necessary, see <rdar://problem/4852889>
-
- d->m_pluginView = static_cast<PluginView*>(pluginWidget);
-}
-
Widget* WebFrame::createJavaAppletWidget(const IntSize& pluginSize, Element* element, const KURL& /*baseURL*/, const Vector<String>& paramNames, const Vector<String>& paramValues)
{
- PluginView* pluginView = PluginDatabase::installedPlugins()->
- createPluginView(core(this), pluginSize, element, KURL(), paramNames, paramValues, "application/x-java-applet", false);
+ PluginView* pluginView = PluginView::create(core(this), pluginSize, element, KURL(), paramNames, paramValues, "application/x-java-applet", false);
// Check if the plugin can be loaded successfully
if (pluginView->plugin() && pluginView->plugin()->load())
@@ -2435,7 +1548,7 @@ ObjectContentType WebFrame::objectContentType(const KURL& url, const String& mim
{
String mimeType = mimeTypeIn;
if (mimeType.isEmpty())
- mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().mid(url.path().findRev('.')+1));
+ mimeType = MIMETypeRegistry::getMIMETypeForExtension(url.path().substring(url.path().reverseFind('.') + 1));
if (mimeType.isEmpty())
return ObjectContentFrame; // Go ahead and hope that we can display the content.
@@ -2471,19 +1584,14 @@ void WebFrame::windowObjectCleared()
if (SUCCEEDED(d->webView->frameLoadDelegate(&frameLoadDelegate))) {
COMPtr<IWebFrameLoadDelegate2> frameLoadDelegate2(Query, frameLoadDelegate);
- JSContextRef context = toRef(coreFrame->scriptProxy()->globalObject()->globalExec());
- JSObjectRef windowObject = toRef(KJS::Window::retrieve(coreFrame)->getObject());
+ JSContextRef context = toRef(coreFrame->script()->globalObject()->globalExec());
+ JSObjectRef windowObject = toRef(coreFrame->script()->globalObject());
ASSERT(windowObject);
if (!frameLoadDelegate2 ||
FAILED(frameLoadDelegate2->didClearWindowObject(d->webView, context, windowObject, this)))
frameLoadDelegate->windowScriptObjectAvailable(d->webView, context, windowObject);
}
-
- if (WebScriptDebugServer::listenerCount() > 0) {
- detachScriptDebugger();
- attachScriptDebugger();
- }
}
void WebFrame::didPerformFirstNavigation() const
@@ -2726,7 +1834,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::spoolPages(
CGContextTranslateCTM(pctx, CGFloat(-pageRect.x()), CGFloat(-pageRect.y()+headerHeight)); // reserves space for header
CGContextSetBaseCTM(pctx, ctm);
- coreFrame->paint(&spoolCtx, pageRect);
+ coreFrame->view()->paintContents(&spoolCtx, pageRect);
if (ui2) {
CGContextTranslateCTM(pctx, CGFloat(pageRect.x()), CGFloat(pageRect.y())-headerHeight);
@@ -2813,8 +1921,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::hasScrollBars(
if (!view)
return E_FAIL;
- if (view->vScrollbarMode() == ScrollbarAlwaysOn || view->visibleHeight() < view->contentsHeight() ||
- view->hScrollbarMode() == ScrollbarAlwaysOn || view->visibleWidth() < view->contentsWidth())
+ if (view->horizontalScrollbar() || view->verticalScrollbar())
*result = TRUE;
return S_OK;
@@ -2855,7 +1962,7 @@ HRESULT STDMETHODCALLTYPE WebFrame::frameBounds(
if (!view)
return E_FAIL;
- FloatRect bounds = view->visibleContentRectConsideringExternalScrollers();
+ FloatRect bounds = view->visibleContentRect(true);
result->bottom = (LONG) bounds.height();
result->right = (LONG) bounds.width();
return S_OK;
@@ -2870,8 +1977,8 @@ HRESULT STDMETHODCALLTYPE WebFrame::isDescendantOfFrame(
*result = FALSE;
Frame* coreFrame = core(this);
- COMPtr<WebFrame> ancestorWebFrame;
- if (!ancestor || FAILED(ancestor->QueryInterface(IID_WebFrame, (void**)&ancestorWebFrame)))
+ COMPtr<WebFrame> ancestorWebFrame(Query, ancestor);
+ if (!ancestorWebFrame)
return S_OK;
*result = (coreFrame && coreFrame->tree()->isDescendantOf(core(ancestorWebFrame.get()))) ? TRUE : FALSE;
@@ -2901,3 +2008,41 @@ void WebFrame::unmarkAllBadGrammar()
doc->removeMarkers(DocumentMarker::Grammar);
}
}
+
+WebView* WebFrame::webView() const
+{
+ return d->webView;
+}
+
+COMPtr<IAccessible> WebFrame::accessible() const
+{
+ Frame* coreFrame = core(this);
+ ASSERT(coreFrame);
+
+ Document* currentDocument = coreFrame->document();
+ if (!currentDocument)
+ m_accessible = 0;
+ else if (!m_accessible || m_accessible->document() != currentDocument) {
+ // Either we've never had a wrapper for this frame's top-level Document,
+ // the Document renderer was destroyed and its wrapper was detached, or
+ // the previous Document is in the page cache, and the current document
+ // needs to be wrapped.
+ m_accessible = new AccessibleDocument(currentDocument);
+ }
+ return m_accessible.get();
+}
+
+void WebFrame::updateBackground()
+{
+ Color backgroundColor = webView()->transparent() ? Color::transparent : Color::white;
+ Frame* coreFrame = core(this);
+ for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) {
+ FrameView* view = frame->view();
+ if (!view)
+ continue;
+
+ view->setTransparent(webView()->transparent());
+ view->setBaseBackgroundColor(backgroundColor);
+ }
+}
+