Commit b7c61160 authored by abarth@webkit.org's avatar abarth@webkit.org

Delete Frame::domWindow() and Frame::existingDOMWindow()

https://bugs.webkit.org/show_bug.cgi?id=93990

Reviewed by Eric Seidel.

Source/WebCore: 

These functions just call through to document()->domWindow(). This
patch updates the callers so it's clearer what's going on.

* bindings/js/JSDOMBinding.cpp:
(WebCore::shouldAllowAccessToFrame):
(WebCore::printErrorMessageForFrame):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::location):
(WebCore::JSDocument::setLocation):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/ScriptCachedFrameData.cpp:
(WebCore::ScriptCachedFrameData::restore):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::createWindowShell):
* bindings/objc/DOMAbstractView.mm:
(core):
* bindings/v8/NPV8Object.cpp:
(WebCore::toV8Context):
* bindings/v8/ScriptController.cpp:
(WebCore::createScriptObject):
(WebCore::ScriptController::createScriptObjectForPluginElement):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::initContextIfNeeded):
* bindings/v8/V8IsolatedContext.cpp:
(WebCore::V8IsolatedContext::V8IsolatedContext):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::retrieveFrame):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::indexedPropertyGetter):
(WebCore::V8DOMWindow::namedPropertyGetter):
* bindings/v8/custom/V8DocumentLocationCustom.cpp:
(WebCore::V8Document::locationAccessorGetter):
(WebCore::V8Document::locationAccessorSetter):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::GetNamedProperty):
* bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp:
(WebCore::V8HTMLFrameSetElement::namedPropertyGetter):
* dom/Document.cpp:
(WebCore::printNavigationErrorMessage):
* dom/ViewportArguments.cpp:
(WebCore::reportViewportWarning):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::insertDictatedText):
* editing/Editor.cpp:
(WebCore::Editor::pasteAsPlainText):
(WebCore::Editor::pasteAsFragment):
(WebCore::Editor::setComposition):
* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):
(WebCore::PageCache::canCachePageContainingThisFrame):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::contentWindow):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::printWarningToConsole):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::storageId):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::checkLoadComplete):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::begin):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
(WebCore::FrameLoader::didOpenURL):
(WebCore::FrameLoader::checkIfDisplayInsecureContent):
(WebCore::FrameLoader::checkIfRunInsecureContent):
(WebCore::FrameLoader::reportLocalLoadFailed):
(WebCore::FrameLoader::prepareForCachedPageRestore):
(WebCore::FrameLoader::open):
(WebCore::FrameLoader::fireBeforeUnloadEvent):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::didReceiveResponse):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::abort):
(WebCore::ApplicationCacheGroup::didReceiveResponse):
(WebCore::ApplicationCacheGroup::didFinishLoading):
(WebCore::ApplicationCacheGroup::didFail):
(WebCore::ApplicationCacheGroup::didReceiveManifestResponse):
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::isCurrentlyDisplayedInFrame):
(WebCore::DOMWindow::self):
(WebCore::DOMWindow::opener):
(WebCore::DOMWindow::parent):
(WebCore::DOMWindow::top):
(WebCore::DOMWindow::createWindow):
(WebCore::DOMWindow::open):
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::DOMWindowProperty):
(WebCore::DOMWindowProperty::reconnectFrameFromPageCache):
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleTextInputEvent):
* page/Frame.cpp:
* page/Frame.h:
(Frame):
* page/Location.cpp:
(WebCore::Location::replace):
(WebCore::Location::reload):
(WebCore::Location::setLocation):
* storage/StorageEventDispatcher.cpp:
(WebCore::StorageEventDispatcher::dispatch):
* svg/SVGDocumentExtensions.cpp:
(WebCore::reportMessage):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::docLoaderFunc):
* xml/XSLTProcessorQt.cpp:
(WebCore::XSLTMessageHandler::handleMessage):

Source/WebKit/blackberry: 

* WebCoreSupport/ChromeClientBlackBerry.cpp:
(WebCore::toOriginString):
(WebCore::ChromeClientBlackBerry::runJavaScriptAlert):
(WebCore::ChromeClientBlackBerry::runJavaScriptConfirm):
(WebCore::ChromeClientBlackBerry::runJavaScriptPrompt):
(WebCore::ChromeClientBlackBerry::runBeforeUnloadConfirmPanel):
(WebCore::ChromeClientBlackBerry::requestWebGLPermission):

Source/WebKit/chromium: 

* src/StorageAreaProxy.cpp:
(WebCore::StorageAreaProxy::dispatchLocalStorageEvent):
(WebCore::StorageAreaProxy::dispatchSessionStorageEvent):
* src/WebDOMMessageEvent.cpp:
(WebKit::WebDOMMessageEvent::initMessageEvent):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::performance):
(WebKit::WebFrameImpl::addMessageToConsole):
(WebKit::WebFrameImpl::unloadListenerCount):
(WebKit::WebFrameImpl::addEventListener):
(WebKit::WebFrameImpl::removeEventListener):
(WebKit::WebFrameImpl::dispatchEvent):
(WebKit::WebFrameImpl::dispatchMessageEventWithOriginCheck):
(WebKit::WebFrameImpl::deliverIntent):
* src/WebPagePopupImpl.cpp:
(WebKit::WebPagePopupImpl::initPage):

Source/WebKit/efl: 

* WebCoreSupport/DumpRenderTreeSupportEfl.cpp:
(DumpRenderTreeSupportEfl::pendingUnloadEventCount):
* ewk/ewk_frame.cpp:
(ewk_frame_intent_deliver):

Source/WebKit/gtk: 

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::getPendingUnloadEventCount):

Source/WebKit/mac: 

* WebView/WebFrame.mm:
(-[WebFrame _pendingFrameUnloadEventCount]):
(-[WebFrame _cacheabilityDictionary]):

Source/WebKit/qt: 

* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::dispatchDidFinishDocumentLoad):

Source/WebKit/win: 

* WebFrame.cpp:
(WebFrame::DOMWindow):
(WebFrame::pendingFrameUnloadEventCount):

Source/WebKit2: 

* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::deliverIntent):
(WebKit::WebFrame::pendingUnloadCount):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125615 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e021aae9
2012-08-14 Adam Barth <abarth@webkit.org>
Delete Frame::domWindow() and Frame::existingDOMWindow()
https://bugs.webkit.org/show_bug.cgi?id=93990
Reviewed by Eric Seidel.
These functions just call through to document()->domWindow(). This
patch updates the callers so it's clearer what's going on.
* bindings/js/JSDOMBinding.cpp:
(WebCore::shouldAllowAccessToFrame):
(WebCore::printErrorMessageForFrame):
* bindings/js/JSDocumentCustom.cpp:
(WebCore::JSDocument::location):
(WebCore::JSDocument::setLocation):
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::handleEvent):
* bindings/js/ScriptCachedFrameData.cpp:
(WebCore::ScriptCachedFrameData::restore):
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::createWindowShell):
* bindings/objc/DOMAbstractView.mm:
(core):
* bindings/v8/NPV8Object.cpp:
(WebCore::toV8Context):
* bindings/v8/ScriptController.cpp:
(WebCore::createScriptObject):
(WebCore::ScriptController::createScriptObjectForPluginElement):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::initContextIfNeeded):
* bindings/v8/V8IsolatedContext.cpp:
(WebCore::V8IsolatedContext::V8IsolatedContext):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::retrieveFrame):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::indexedPropertyGetter):
(WebCore::V8DOMWindow::namedPropertyGetter):
* bindings/v8/custom/V8DocumentLocationCustom.cpp:
(WebCore::V8Document::locationAccessorGetter):
(WebCore::V8Document::locationAccessorSetter):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::GetNamedProperty):
* bindings/v8/custom/V8HTMLFrameSetElementCustom.cpp:
(WebCore::V8HTMLFrameSetElement::namedPropertyGetter):
* dom/Document.cpp:
(WebCore::printNavigationErrorMessage):
* dom/ViewportArguments.cpp:
(WebCore::reportViewportWarning):
* editing/AlternativeTextController.cpp:
(WebCore::AlternativeTextController::insertDictatedText):
* editing/Editor.cpp:
(WebCore::Editor::pasteAsPlainText):
(WebCore::Editor::pasteAsFragment):
(WebCore::Editor::setComposition):
* history/PageCache.cpp:
(WebCore::logCanCacheFrameDecision):
(WebCore::PageCache::canCachePageContainingThisFrame):
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::validateInteractively):
* html/HTMLFrameOwnerElement.cpp:
(WebCore::HTMLFrameOwnerElement::contentWindow):
* html/canvas/WebGLRenderingContext.cpp:
(WebCore):
(WebCore::WebGLRenderingContext::printWarningToConsole):
* inspector/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::storageId):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::checkLoadComplete):
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::begin):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::stopLoading):
(WebCore::FrameLoader::didOpenURL):
(WebCore::FrameLoader::checkIfDisplayInsecureContent):
(WebCore::FrameLoader::checkIfRunInsecureContent):
(WebCore::FrameLoader::reportLocalLoadFailed):
(WebCore::FrameLoader::prepareForCachedPageRestore):
(WebCore::FrameLoader::open):
(WebCore::FrameLoader::fireBeforeUnloadEvent):
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::didReceiveResponse):
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::abort):
(WebCore::ApplicationCacheGroup::didReceiveResponse):
(WebCore::ApplicationCacheGroup::didFinishLoading):
(WebCore::ApplicationCacheGroup::didFail):
(WebCore::ApplicationCacheGroup::didReceiveManifestResponse):
(WebCore::ApplicationCacheGroup::didFinishLoadingManifest):
(WebCore::ApplicationCacheGroup::checkIfLoadIsComplete):
* loader/cache/CachedResourceLoader.cpp:
(WebCore::CachedResourceLoader::printAccessDeniedMessage):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::isCurrentlyDisplayedInFrame):
(WebCore::DOMWindow::self):
(WebCore::DOMWindow::opener):
(WebCore::DOMWindow::parent):
(WebCore::DOMWindow::top):
(WebCore::DOMWindow::createWindow):
(WebCore::DOMWindow::open):
* page/DOMWindowProperty.cpp:
(WebCore::DOMWindowProperty::DOMWindowProperty):
(WebCore::DOMWindowProperty::reconnectFrameFromPageCache):
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor):
* page/EventHandler.cpp:
(WebCore::EventHandler::handleTextInputEvent):
* page/Frame.cpp:
* page/Frame.h:
(Frame):
* page/Location.cpp:
(WebCore::Location::replace):
(WebCore::Location::reload):
(WebCore::Location::setLocation):
* storage/StorageEventDispatcher.cpp:
(WebCore::StorageEventDispatcher::dispatch):
* svg/SVGDocumentExtensions.cpp:
(WebCore::reportMessage):
* xml/XSLStyleSheetLibxslt.cpp:
(WebCore::XSLStyleSheet::parseString):
* xml/XSLTProcessorLibxslt.cpp:
(WebCore::docLoaderFunc):
* xml/XSLTProcessorQt.cpp:
(WebCore::XSLTMessageHandler::handleMessage):
2012-08-14 Mike West <mkwst@chromium.org>
Tighten up parsing the 'script-nonce' CSP directive value.
......@@ -1297,7 +1297,6 @@ __ZNK7WebCore5Frame16frameScaleFactorEv
__ZNK7WebCore5Frame18documentTypeStringEv
__ZNK7WebCore5Frame31displayStringModifiedByEncodingERKN3WTF6StringE
__ZNK7WebCore5Frame8settingsEv
__ZNK7WebCore5Frame9domWindowEv
__ZNK7WebCore5Range11startOffsetERi
__ZNK7WebCore5Range12endContainerERi
__ZNK7WebCore5Range12pastLastNodeEv
......
......@@ -224,7 +224,7 @@ bool shouldAllowAccessToFrame(ExecState* exec, Frame* frame, String& message)
return false;
bool result = BindingSecurity::shouldAllowAccessToFrame(exec, frame, DoNotReportSecurityError);
// FIXME: The following line of code should move somewhere that it can be shared with immediatelyReportUnsafeAccessTo.
message = frame->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(exec));
message = frame->document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(exec));
return result;
}
......@@ -232,7 +232,7 @@ void printErrorMessageForFrame(Frame* frame, const String& message)
{
if (!frame)
return;
frame->domWindow()->printErrorMessage(message);
frame->document()->domWindow()->printErrorMessage(message);
}
JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
......
......@@ -99,12 +99,12 @@ JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, PropertyName pr
static JSValue childFrameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
{
return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))->domWindow());
return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(propertyNameToAtomicString(propertyName))->document()->domWindow());
}
static JSValue indexGetter(ExecState* exec, JSValue slotBase, unsigned index)
{
return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(index)->domWindow());
return toJS(exec, jsCast<JSDOMWindow*>(asObject(slotBase))->impl()->frame()->tree()->scopedChild(index)->document()->domWindow());
}
static JSValue namedItemGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
......
......@@ -54,7 +54,7 @@ JSValue JSDocument::location(ExecState* exec) const
if (!frame)
return jsNull();
Location* location = frame->domWindow()->location();
Location* location = frame->document()->domWindow()->location();
if (JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), location))
return wrapper;
......@@ -73,7 +73,7 @@ void JSDocument::setLocation(ExecState* exec, JSValue value)
if (exec->hadException())
return;
if (Location* location = frame->domWindow()->location())
if (Location* location = frame->document()->domWindow()->location())
location->setHref(ustringToString(locationString), activeDOMWindow(exec), firstDOMWindow(exec));
}
......
......@@ -85,18 +85,12 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
if (!globalObject)
return;
Frame* frame = 0;
if (scriptExecutionContext->isDocument()) {
JSDOMWindow* window = jsCast<JSDOMWindow*>(globalObject);
frame = window->impl()->frame();
if (!frame)
return;
// The window must still be active in its frame. See <https://bugs.webkit.org/show_bug.cgi?id=21921>.
// FIXME: A better fix for this may be to change DOMWindow::frame() to not return a frame the detached window used to be in.
if (frame->domWindow() != window->impl())
if (!window->impl()->isCurrentlyDisplayedInFrame())
return;
// FIXME: Is this check needed for other contexts?
ScriptController* script = frame->script();
ScriptController* script = window->impl()->frame()->script();
if (!script->canExecuteScripts(AboutToExecuteScript) || script->isPaused())
return;
}
......
......@@ -80,7 +80,7 @@ void ScriptCachedFrameData::restore(Frame* frame)
if (JSDOMWindow* window = m_windows.get(world).get())
windowShell->setWindow(window->globalData(), window);
else {
windowShell->setWindow(frame->domWindow());
windowShell->setWindow(frame->document()->domWindow());
if (Page* page = frame->page()) {
scriptController->attachDebugger(windowShell, page->debugger());
......
......@@ -111,7 +111,7 @@ JSDOMWindowShell* ScriptController::createWindowShell(DOMWrapperWorld* world)
{
ASSERT(!m_windowShells.contains(world));
Structure* structure = JSDOMWindowShell::createStructure(*world->globalData(), jsNull());
Strong<JSDOMWindowShell> windowShell(*world->globalData(), JSDOMWindowShell::create(m_frame->domWindow(), structure, world));
Strong<JSDOMWindowShell> windowShell(*world->globalData(), JSDOMWindowShell::create(m_frame->document()->domWindow(), structure, world));
Strong<JSDOMWindowShell> windowShell2(windowShell);
m_windowShells.add(world, windowShell);
world->didCreateWindowShell(this);
......
......@@ -50,7 +50,7 @@
{
if (!_internal)
return nil;
return kit(IMPL->domWindow()->document());
return kit(IMPL->document());
}
@end
......@@ -72,7 +72,7 @@ WebCore::DOMWindow* core(DOMAbstractView *wrapper)
return 0;
if (!wrapper->_internal)
return 0;
return reinterpret_cast<WebCore::Frame*>(wrapper->_internal)->domWindow();
return reinterpret_cast<WebCore::Frame*>(wrapper->_internal)->document()->domWindow();
}
DOMAbstractView *kit(WebCore::DOMWindow* value)
......
......@@ -63,8 +63,8 @@ typedef HashMap<int, V8NPObjectVector> V8NPObjectMap;
static v8::Local<v8::Context> toV8Context(NPP npp, NPObject* npObject)
{
V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject);
DOMWindow* domWindow = object->rootObject;
if (!domWindow || !domWindow->frame() || domWindow != domWindow->frame()->domWindow())
DOMWindow* window = object->rootObject;
if (!window || !window->isCurrentlyDisplayedInFrame())
return v8::Local<v8::Context>();
return V8Proxy::mainWorldContext(object->rootObject->frame());
}
......
......@@ -428,7 +428,7 @@ static NPObject* createScriptObject(Frame* frame)
return createNoScriptObject();
v8::Context::Scope scope(v8Context);
DOMWindow* window = frame->domWindow();
DOMWindow* window = frame->document()->domWindow();
v8::Handle<v8::Value> global = toV8(window);
ASSERT(global->IsObject());
return npCreateV8ScriptObject(0, v8::Handle<v8::Object>::Cast(global), window);
......@@ -468,7 +468,7 @@ NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement
return createNoScriptObject();
v8::Context::Scope scope(v8Context);
DOMWindow* window = m_frame->domWindow();
DOMWindow* window = m_frame->document()->domWindow();
v8::Handle<v8::Value> v8plugin = toV8(static_cast<HTMLEmbedElement*>(plugin));
if (!v8plugin->IsObject())
return createNoScriptObject();
......
......@@ -334,7 +334,7 @@ bool V8DOMWindowShell::initContextIfNeeded()
return false;
}
if (!installDOMWindow(v8Context, m_frame->domWindow())) {
if (!installDOMWindow(v8Context, m_frame->document()->domWindow())) {
disposeContextHandles();
return false;
}
......
......@@ -91,7 +91,7 @@ V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int wor
m_perContextData->init();
// FIXME: This will go away once we have a windowShell for the isolated world.
proxy->windowShell()->installDOMWindow(m_context->get(), m_frame->domWindow());
proxy->windowShell()->installDOMWindow(m_context->get(), m_frame->document()->domWindow());
// Using the default security token means that the canAccess is always
// called, which is slow.
......
......@@ -367,9 +367,8 @@ DOMWindow* V8Proxy::retrieveWindow(v8::Handle<v8::Context> context)
Frame* V8Proxy::retrieveFrame(v8::Handle<v8::Context> context)
{
DOMWindow* window = retrieveWindow(context);
Frame* frame = window->frame();
if (frame && frame->domWindow() == window)
return frame;
if (window->isCurrentlyDisplayedInFrame())
return window->frame();
// We return 0 here because |context| is detached from the Frame. If we
// did return |frame| we could get in trouble because the frame could be
// navigated to another security origin.
......
......@@ -479,7 +479,7 @@ v8::Handle<v8::Value> V8DOMWindow::indexedPropertyGetter(uint32_t index, const v
Frame* child = frame->tree()->scopedChild(index);
if (child)
return toV8(child->domWindow(), info.GetIsolate());
return toV8(child->document()->domWindow(), info.GetIsolate());
return v8Undefined();
}
......@@ -502,7 +502,7 @@ v8::Handle<v8::Value> V8DOMWindow::namedPropertyGetter(v8::Local<v8::String> nam
AtomicString propName = toWebCoreAtomicString(name);
Frame* child = frame->tree()->scopedChild(propName);
if (child)
return toV8(child->domWindow(), info.GetIsolate());
return toV8(child->document()->domWindow(), info.GetIsolate());
// Search IDL functions defined in the prototype
if (!info.Holder()->GetRealNamedProperty(name).IsEmpty())
......
......@@ -40,7 +40,7 @@ v8::Handle<v8::Value> V8Document::locationAccessorGetter(v8::Local<v8::String> n
if (!document->frame())
return v8::Null(info.GetIsolate());
DOMWindow* window = document->frame()->domWindow();
DOMWindow* window = document->domWindow();
return toV8(window->location(), info.GetIsolate());
}
......@@ -60,7 +60,7 @@ void V8Document::locationAccessorSetter(v8::Local<v8::String> name, v8::Local<v8
if (!first)
return;
DOMWindow* window = document->frame()->domWindow();
DOMWindow* window = document->domWindow();
if (Location* location = window->location())
location->setHref(toWebCoreString(value), active, first);
}
......
......@@ -94,7 +94,7 @@ v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocumen
Node* node = items->item(0);
Frame* frame = 0;
if (node->hasTagName(HTMLNames::iframeTag) && (frame = static_cast<HTMLIFrameElement*>(node)->contentFrame()))
return toV8(frame->domWindow(), isolate);
return toV8(frame->document()->domWindow(), isolate);
return toV8(node, isolate);
}
......
......@@ -50,14 +50,16 @@ v8::Handle<v8::Value> V8HTMLFrameSetElement::namedPropertyGetter(v8::Local<v8::S
INC_STATS("DOM.HTMLFrameSetElement.NamedPropertyGetter");
HTMLFrameSetElement* imp = V8HTMLFrameSetElement::toNative(info.Holder());
Node* frameNode = imp->children()->namedItem(toWebCoreAtomicString(name));
if (frameNode && frameNode->hasTagName(HTMLNames::frameTag)) {
Document* doc = static_cast<HTMLFrameElement*>(frameNode)->contentDocument();
if (!doc)
return v8::Undefined();
if (Frame* frame = doc->frame())
return toV8(frame->domWindow(), info.GetIsolate());
}
return v8Undefined();
if (!frameNode)
return v8Undefined();
if (!frameNode->hasTagName(HTMLNames::frameTag))
return v8Undefined();
Document* document = static_cast<HTMLFrameElement*>(frameNode)->contentDocument();
if (!document)
return v8Undefined();
if (!document->frame())
return v8Undefined();
return toV8(document->domWindow(), info.GetIsolate());
}
} // namespace WebCore
......@@ -385,7 +385,7 @@ static void printNavigationErrorMessage(Frame* frame, const KURL& activeURL)
frame->document()->url().string() + " from frame with URL " + activeURL.string() + ".\n";
// FIXME: should we print to the console of the document performing the navigation instead?
frame->domWindow()->printErrorMessage(message);
frame->document()->domWindow()->printErrorMessage(message);
}
static HashSet<Document*>* documentsThatNeedStyleRecalc = 0;
......
......@@ -363,7 +363,7 @@ void reportViewportWarning(Document* document, ViewportErrorCode errorCode, cons
if (!replacement2.isNull())
message.replace("%replacement2", replacement2);
frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, document->url().string(), parserLineNumber(document));
document->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, viewportErrorMessageLevel(errorCode), message, document->url().string(), parserLineNumber(document));
}
} // namespace WebCore
......@@ -704,7 +704,7 @@ bool AlternativeTextController::insertDictatedText(const String& text, const Vec
if (FrameView* view = m_frame->view())
view->resetDeferredRepaintDelay();
RefPtr<TextEvent> event = TextEvent::createForDictation(m_frame->domWindow(), text, dictationAlternatives);
RefPtr<TextEvent> event = TextEvent::createForDictation(m_frame->document()->domWindow(), text, dictationAlternatives);
event->setUnderlyingEvent(triggeringEvent);
ExceptionCode ec;
......
......@@ -346,7 +346,7 @@ void Editor::pasteAsPlainText(const String& pastingText, bool smartReplace)
if (!target)
return;
ExceptionCode ec = 0;
target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame->domWindow(), pastingText, smartReplace), ec);
target->dispatchEvent(TextEvent::createForPlainTextPaste(m_frame->document()->domWindow(), pastingText, smartReplace), ec);
}
void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool smartReplace, bool matchStyle)
......@@ -355,7 +355,7 @@ void Editor::pasteAsFragment(PassRefPtr<DocumentFragment> pastingFragment, bool
if (!target)
return;
ExceptionCode ec = 0;
target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame->domWindow(), pastingFragment, smartReplace, matchStyle), ec);
target->dispatchEvent(TextEvent::createForFragmentPaste(m_frame->document()->domWindow(), pastingFragment, smartReplace, matchStyle), ec);
}
void Editor::pasteAsPlainTextBypassingDHTML()
......@@ -1363,7 +1363,7 @@ void Editor::setComposition(const String& text, SetCompositionMode mode)
// the DOM Event specification.
Node* target = m_frame->document()->focusedNode();
if (target) {
RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->domWindow(), text);
RefPtr<CompositionEvent> event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
ExceptionCode ec = 0;
target->dispatchEvent(event, ec);
}
......@@ -1426,14 +1426,14 @@ void Editor::setComposition(const String& text, const Vector<CompositionUnderlin
// We should send a compositionstart event only when the given text is not empty because this
// function doesn't create a composition node when the text is empty.
if (!text.isEmpty()) {
target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->domWindow(), text));
event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->domWindow(), text);
target->dispatchEvent(CompositionEvent::create(eventNames().compositionstartEvent, m_frame->document()->domWindow(), text));
event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
}
} else {
if (!text.isEmpty())
event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->domWindow(), text);
event = CompositionEvent::create(eventNames().compositionupdateEvent, m_frame->document()->domWindow(), text);
else
event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->domWindow(), text);
event = CompositionEvent::create(eventNames().compositionendEvent, m_frame->document()->domWindow(), text);
}
ExceptionCode ec = 0;
if (event.get())
......
......@@ -137,7 +137,7 @@ static unsigned logCanCacheFrameDecision(Frame* frame, int indentLevel)
PCLOG(" -Frame is HTTPS, and cache control prohibits caching or storing");
rejectReasons |= 1 << IsHttpsAndCacheControlled;
}
if (frame->domWindow() && frame->domWindow()->hasEventListeners(eventNames().unloadEvent)) {
if (frame->document()->domWindow() && frame->document()->domWindow()->hasEventListeners(eventNames().unloadEvent)) {
PCLOG(" -Frame has an unload event listener");
rejectReasons |= 1 << HasUnloadListener;
}
......@@ -343,7 +343,7 @@ bool PageCache::canCachePageContainingThisFrame(Frame* frame)
&& !(documentLoader->substituteData().isValid() && !documentLoader->substituteData().failingURL().isEmpty())
&& (!frameLoader->subframeLoader()->containsPlugins() || frame->page()->settings()->pageCacheSupportsPlugins())
&& (!document->url().protocolIs("https") || (!documentLoader->response().cacheControlContainsNoCache() && !documentLoader->response().cacheControlContainsNoStore()))
&& (!frame->domWindow() || !frame->domWindow()->hasEventListeners(eventNames().unloadEvent))
&& (!document->domWindow() || !document->domWindow()->hasEventListeners(eventNames().unloadEvent))
#if ENABLE(SQL_DATABASE)
&& !DatabaseContext::hasOpenDatabases(document)
#endif
......
......@@ -252,7 +252,7 @@ bool HTMLFormElement::validateInteractively(Event* event)
}
}
// Warn about all of unfocusable controls.
if (Frame* frame = document()->frame()) {
if (document()->frame()) {
for (unsigned i = 0; i < unhandledInvalidControls.size(); ++i) {
FormAssociatedElement* unhandledAssociatedElement = unhandledInvalidControls[i].get();
HTMLElement* unhandled = toHTMLElement(unhandledAssociatedElement);
......@@ -260,7 +260,7 @@ bool HTMLFormElement::validateInteractively(Event* event)
continue;
String message("An invalid form control with name='%name' is not focusable.");
message.replace("%name", unhandledAssociatedElement->name());
frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, ErrorMessageLevel, message, document()->url().string());
document()->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, ErrorMessageLevel, message, document()->url().string());
}
}
return false;
......
......@@ -73,7 +73,7 @@ Document* HTMLFrameOwnerElement::contentDocument() const
DOMWindow* HTMLFrameOwnerElement::contentWindow() const
{
return m_contentFrame ? m_contentFrame->domWindow() : 0;
return m_contentFrame ? m_contentFrame->document()->domWindow() : 0;
}
void HTMLFrameOwnerElement::setSandboxFlags(SandboxFlags flags)
......
......@@ -5173,13 +5173,14 @@ void WebGLRenderingContext::printWarningToConsole(const String& message)
{
if (!canvas())
return;
// FIXME: This giant cascade of null checks seems a bit paranoid.
Document* document = canvas()->document();
if (!document)
return;
Frame* frame = document->frame();
if (!frame)
return;
DOMWindow* window = frame->domWindow();
DOMWindow* window = document->domWindow();
if (!window)
return;
Console* console = window->console();
......
......@@ -156,7 +156,7 @@ String InspectorDOMStorageAgent::storageId(Storage* storage)
ASSERT(storage);
Frame* frame = storage->frame();
ExceptionCode ec = 0;
bool isLocalStorage = (frame->domWindow()->localStorage(ec) == storage && !ec);
bool isLocalStorage = (frame->document()->domWindow()->localStorage(ec) == storage && !ec);
return storageId(frame->document()->securityOrigin(), isLocalStorage);
}
......
......@@ -422,7 +422,7 @@ void DocumentLoader::checkLoadComplete()
return;
ASSERT(this == frameLoader()->activeDocumentLoader());
if (DOMWindow* window = m_frame->existingDOMWindow())
if (DOMWindow* window = m_frame->document()->domWindow())
window->finishedLoading();
}
......
......@@ -357,10 +357,10 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy)
Node* currentFocusedNode = m_frame->document()->focusedNode();
if (currentFocusedNode)
currentFocusedNode->aboutToUnload();
if (m_frame->domWindow() && m_pageDismissalEventBeingDispatched == NoDismissal) {
if (m_frame->document()->domWindow() && m_pageDismissalEventBeingDispatched == NoDismissal) {
if (unloadEventPolicy == UnloadEventPolicyUnloadAndPageHide) {
m_pageDismissalEventBeingDispatched = PageHideDismissal;
m_frame->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame->document());
m_frame->document()->domWindow()->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, m_frame->document()->inPageCache()), m_frame->document());
}
if (!m_frame->document()->inPageCache()) {
RefPtr<Event> unloadEvent(Event::create(eventNames().unloadEvent, false, false));
......@@ -373,10 +373,10 @@ void FrameLoader::stopLoading(UnloadEventPolicy unloadEventPolicy)
DocumentLoadTiming* timing = documentLoader->timing();
ASSERT(timing->navigationStart());
timing->markUnloadEventStart();
m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
timing->markUnloadEventEnd();
} else
m_frame->domWindow()->dispatchEvent(unloadEvent, m_frame->domWindow()->document());
m_frame->document()->domWindow()->dispatchEvent(unloadEvent, m_frame->document());
}
}
m_pageDismissalEventBeingDispatched = NoDismissal;
......@@ -464,7 +464,7 @@ bool FrameLoader::didOpenURL()
// its frame is not in a consistent state for rendering, so avoid setJSStatusBarText
// since it may cause clients to attempt to render the frame.
if (!m_stateMachine.creatingInitialEmptyDocument()) {
if (DOMWindow* window = m_frame->existingDOMWindow()) {
if (DOMWindow* window = m_frame->document()->domWindow()) {
window->setStatus(String());
window->setDefaultStatus(String());
}
......@@ -886,7 +886,7 @@ bool FrameLoader::checkIfDisplayInsecureContent(SecurityOrigin* context, const K
String message = (allowed ? emptyString() : "[blocked] ") + "The page at " +
m_frame->document()->url().string() + " displayed insecure content from " + url.string() + ".\n";
m_frame->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);
m_frame->document()->domWindow()->console()->addMessage(HTMLMessageSource, LogMessageType, WarningMessageLevel, message);