diff options
author | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 17:56:39 +0000 |
---|---|---|
committer | dglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-10 17:56:39 +0000 |
commit | 9b451c0bce7c09d32a1f885f2b86fc388ecd8ee7 (patch) | |
tree | 258cddf035cb585b515ee8d69bc58b3e4e9d8620 /webkit/glue | |
parent | 81f3095725e27bc914f5ce85d99a929f76a347d3 (diff) | |
download | chromium_src-9b451c0bce7c09d32a1f885f2b86fc388ecd8ee7.zip chromium_src-9b451c0bce7c09d32a1f885f2b86fc388ecd8ee7.tar.gz chromium_src-9b451c0bce7c09d32a1f885f2b86fc388ecd8ee7.tar.bz2 |
Landing 37604:38097 merge
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/autocomplete_input_listener.cc | 8 | ||||
-rw-r--r-- | webkit/glue/autocomplete_input_listener_unittest.cc | 6 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.h | 6 | ||||
-rw-r--r-- | webkit/glue/cpp_bound_class.cc | 2 | ||||
-rw-r--r-- | webkit/glue/inspector_client_impl.cc | 17 | ||||
-rw-r--r-- | webkit/glue/inspector_client_impl.h | 6 | ||||
-rw-r--r-- | webkit/glue/npruntime_util.cc | 1 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 143 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 28 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 31 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.h | 1 | ||||
-rw-r--r-- | webkit/glue/webplugin_impl.cc | 14 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 186 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 16 |
15 files changed, 219 insertions, 254 deletions
diff --git a/webkit/glue/autocomplete_input_listener.cc b/webkit/glue/autocomplete_input_listener.cc index 02ac67f..25af5e9 100644 --- a/webkit/glue/autocomplete_input_listener.cc +++ b/webkit/glue/autocomplete_input_listener.cc @@ -172,9 +172,9 @@ void AutocompleteInputListener::handleEvent(WebCore::Event* event, bool /*is_window_event*/) { const WebCore::AtomicString& webcore_type = event->type(); const std::wstring& user_input = edit_delegate_->GetValue(); - if (webcore_type == WebCore::EventNames::DOMFocusOutEvent) { + if (webcore_type == WebCore::eventNames().DOMFocusOutEvent) { OnBlur(user_input); - } else if (webcore_type == WebCore::EventNames::inputEvent) { + } else if (webcore_type == WebCore::eventNames().inputEvent) { // Perform inline autocomplete if it is safe to do so. if (ShouldInlineAutocomplete(user_input)) OnInlineAutocompleteNeeded(user_input); @@ -186,10 +186,10 @@ void AutocompleteInputListener::handleEvent(WebCore::Event* event, void AttachForInlineAutocomplete( WebCore::HTMLInputElement* target, AutocompleteInputListener* listener) { - target->addEventListener(WebCore::EventNames::DOMFocusOutEvent, + target->addEventListener(WebCore::eventNames().DOMFocusOutEvent, listener, false); - target->addEventListener(WebCore::EventNames::inputEvent, + target->addEventListener(WebCore::eventNames().inputEvent, listener, false); } diff --git a/webkit/glue/autocomplete_input_listener_unittest.cc b/webkit/glue/autocomplete_input_listener_unittest.cc index 47b9ac5..b23fac8 100644 --- a/webkit/glue/autocomplete_input_listener_unittest.cc +++ b/webkit/glue/autocomplete_input_listener_unittest.cc @@ -23,6 +23,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "EventNames.h" #include "Event.h" #include "EventListener.h" +#include "wtf/Threading.h" MSVC_POP_WARNING(); #undef LOG @@ -107,11 +108,12 @@ namespace { class DomAutocompleteTests : public testing::Test { public: void SetUp() { + WTF::initializeThreading(); WebCore::EventNames::init(); } void FireAndHandleInputEvent(AutocompleteInputListener* listener) { - RefPtr<Event> event(Event::create(WebCore::EventNames::inputEvent, + RefPtr<Event> event(Event::create(WebCore::eventNames().inputEvent, false, false)); listener->handleEvent(event.get(), false); } @@ -130,7 +132,7 @@ TEST_F(DomAutocompleteTests, OnBlur) { // Simulate a blur event and ensure it is properly dispatched. // Listener takes ownership of its delegate. TestAutocompleteInputListener listener(new TestAutocompleteEditDelegate()); - RefPtr<Event> event(Event::create(WebCore::EventNames::DOMFocusOutEvent, + RefPtr<Event> event(Event::create(WebCore::eventNames().DOMFocusOutEvent, false, false)); listener.handleEvent(event.get(), false); EXPECT_TRUE(listener.blurred()); diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 081d4c7..4142548 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -438,13 +438,15 @@ void ChromeClientImpl::exceededDatabaseQuota(WebCore::Frame* frame, // TODO(tc): If we enable the storage API, we need to implement this function. } -void ChromeClientImpl::runFileChooser(const WebCore::String& default_path, - PassRefPtr<WebCore::FileChooser> fileChooser) { +void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, + PassRefPtr<WebCore::FileChooser> fileChooser) { WebViewDelegate* delegate = webview_->delegate(); if (!delegate) return; - std::wstring suggestion = webkit_glue::StringToStdWString(default_path); + std::wstring suggestion = webkit_glue::StringToStdWString( + fileChooser->filenames()[0]); + WebFileChooserCallbackImpl* chooser = new WebFileChooserCallbackImpl(fileChooser); delegate->RunFileChooser(suggestion, chooser); } diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h index 7bb132b..c8951ee 100644 --- a/webkit/glue/chrome_client_impl.h +++ b/webkit/glue/chrome_client_impl.h @@ -110,10 +110,10 @@ public: virtual void print(WebCore::Frame*); virtual void exceededDatabaseQuota(WebCore::Frame*, - const WebCore::String& databaseName); + const WebCore::String& databaseName); - virtual void runFileChooser(const WebCore::String&, - PassRefPtr<WebCore::FileChooser>); + virtual void runOpenPanel(WebCore::Frame*, + PassRefPtr<WebCore::FileChooser>); virtual void popupOpened(WebCore::FramelessScrollView* popup_view, const WebCore::IntRect& bounds, bool focus_on_show); diff --git a/webkit/glue/cpp_bound_class.cc b/webkit/glue/cpp_bound_class.cc index 95d67c0..3abb406 100644 --- a/webkit/glue/cpp_bound_class.cc +++ b/webkit/glue/cpp_bound_class.cc @@ -27,7 +27,7 @@ MSVC_POP_WARNING() #if USE(JSC) #pragma warning(push, 0) -#include <kjs/JSLock.h> +#include <runtime/JSLock.h> #pragma warning(pop) #endif diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index dfc89fb..03e6f3c 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -134,6 +134,7 @@ void WebInspectorClient::detachWindow() { void WebInspectorClient::setAttachedWindowHeight(unsigned int height) { // TODO(dglazkov): Implement this + NOTIMPLEMENTED(); } static void invalidateNodeBoundingRect(WebViewImpl* web_view) { @@ -166,10 +167,24 @@ void WebInspectorClient::hideHighlight() { void WebInspectorClient::inspectedURLChanged(const String& newURL) { // TODO(jackson): Implement this + NOTIMPLEMENTED(); } String WebInspectorClient::localizedStringsURL() { - notImplemented(); + NOTIMPLEMENTED(); return String(); } +void WebInspectorClient::populateSetting( + const String& key, InspectorController::Setting&) { + NOTIMPLEMENTED(); +} + +void WebInspectorClient::storeSetting( + const String& key, const InspectorController::Setting&) { + NOTIMPLEMENTED(); +} + +void WebInspectorClient::removeSetting(const String& key) { + NOTIMPLEMENTED(); +} diff --git a/webkit/glue/inspector_client_impl.h b/webkit/glue/inspector_client_impl.h index d34d0c7..5d3a817 100644 --- a/webkit/glue/inspector_client_impl.h +++ b/webkit/glue/inspector_client_impl.h @@ -34,6 +34,12 @@ public: virtual void inspectedURLChanged(const WebCore::String& newURL); + virtual void populateSetting( + const WebCore::String& key, WebCore::InspectorController::Setting&); + virtual void storeSetting( + const WebCore::String& key, const WebCore::InspectorController::Setting&); + virtual void removeSetting(const WebCore::String& key); + private: ~WebInspectorClient(); diff --git a/webkit/glue/npruntime_util.cc b/webkit/glue/npruntime_util.cc index 364401f..ced8f04 100644 --- a/webkit/glue/npruntime_util.cc +++ b/webkit/glue/npruntime_util.cc @@ -11,6 +11,7 @@ #include "webkit/port/bindings/v8/np_v8object.h" #elif USE(JAVASCRIPTCORE_BINDINGS) #include "bridge/c/c_utility.h" +#undef LOG using JSC::Bindings::PrivateIdentifier; #endif diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index dd85c47..b749df7 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -32,22 +32,18 @@ // WebView (for the toplevel frame only) // O // | -// O -// WebFrame <-------------------------- FrameLoader -// O (via WebFrameLoaderClient) || -// | || -// +------------------------------+ || -// | || -// FrameView O-------------------------O Frame +// Page O------- Frame (m_mainFrame) O-------O FrameView +// || +// || +// FrameLoader O-------- WebFrame (via FrameLoaderClient) // // FrameLoader and Frame are formerly one object that was split apart because // it got too big. They basically have the same lifetime, hence the double line. // -// WebFrame is refcounted and has one ref on behalf of the FrameLoader/Frame -// and, in the case of the toplevel frame, one more for the WebView. This is -// not a normal reference counted pointer because that would require changing -// WebKit code that we don't control. Instead, it is created with this ref -// initially and it is removed when the FrameLoader is getting destroyed. +// WebFrame is refcounted and has one ref on behalf of the FrameLoader/Frame. +// This is not a normal reference counted pointer because that would require +// changing WebKit code that we don't control. Instead, it is created with this +// ref initially and it is removed when the FrameLoader is getting destroyed. // // WebFrames are created in two places, first in WebViewImpl when the root // frame is created, and second in WebFrame::CreateChildFrame when sub-frames @@ -57,23 +53,16 @@ // How frames are destroyed // ------------------------ // -// The main frame is never destroyed and is re-used. The FrameLoader is -// re-used and a reference is also kept by the WebView, so the root frame will -// generally have a refcount of 2. +// The main frame is never destroyed and is re-used. The FrameLoader is re-used +// and a reference to the main frame is kept by the Page. // // When frame content is replaced, all subframes are destroyed. This happens -// in FrameLoader::detachFromParent for each suframe. Here, we first clear -// the view in the Frame, breaking the circular cycle between Frame and -// FrameView. Then it calls detachedFromParent4 on the FrameLoaderClient. -// -// The FrameLoaderClient is implemented by WebFrameLoaderClient, which is -// an object owned by WebFrame. It calls WebFrame::Closing which causes -// WebFrame to release its references to Frame, generally releasing it. +// in FrameLoader::detachFromParent for each subframe. // // Frame going away causes the FrameLoader to get deleted. In FrameLoader's -// destructor it notifies its client with frameLoaderDestroyed. This derefs -// WebView and will cause it to be deleted (unless an external someone is also -// holding a reference). +// destructor, it notifies its client with frameLoaderDestroyed. This calls +// WebFrame::Closing and then derefs the WebFrame and will cause it to be +// deleted (unless an external someone is also holding a reference). #include "config.h" @@ -286,9 +275,6 @@ MSVC_PUSH_DISABLE_WARNING(4355) MSVC_POP_WARNING() currently_loading_request_(NULL), plugin_delegate_(NULL), - allows_scrolling_(true), - margin_width_(-1), - margin_height_(-1), inspected_node_(NULL), active_tickmark_frame_(NULL), active_tickmark_(kNoTickmark), @@ -314,9 +300,11 @@ WebFrameImpl::~WebFrameImpl() { // WebFrame ------------------------------------------------------------------- void WebFrameImpl::InitMainFrame(WebViewImpl* webview_impl) { - webview_impl_ = webview_impl; // owning ref + webview_impl_ = webview_impl; - frame_ = Frame::create(webview_impl_->page(), 0, &frame_loader_client_); + RefPtr<Frame> frame = + Frame::create(webview_impl_->page(), 0, &frame_loader_client_); + frame_ = frame.get(); // Add reference on behalf of FrameLoader. See comments in // WebFrameLoaderClient::frameLoaderDestroyed for more info. @@ -713,7 +701,7 @@ void WebFrameImpl::BindToWindowObject(const std::wstring& name, String key = webkit_glue::StdWStringToString(name); #if USE(V8) - frame_->script()->BindToWindowObject(frame_.get(), key, object); + frame_->script()->BindToWindowObject(frame_, key, object); #endif #if USE(JSC) @@ -748,7 +736,7 @@ void WebFrameImpl::GetContentAsPlainText(int max_chars, if (!frame_) return; - FrameContentAsPlainText(max_chars, frame_.get(), text); + FrameContentAsPlainText(max_chars, frame_, text); } void WebFrameImpl::InvalidateArea(AreaToInvalidate area) { @@ -1436,9 +1424,9 @@ void WebFrameImpl::CreateFrameView() { if (is_main_frame) { IntSize initial_size( webview_impl_->size().width(), webview_impl_->size().height()); - view = new FrameView(frame_.get(), initial_size); + view = new FrameView(frame_, initial_size); } else { - view = new FrameView(frame_.get()); + view = new FrameView(frame_); } frame_->setView(view); @@ -1537,16 +1525,9 @@ bool WebFrameImpl::IsLoading() { } void WebFrameImpl::Closing() { - // let go of our references, this breaks reference cycles and will - // usually eventually lead to us being destroyed. - if (frameview()) - frameview()->clear(); - if (frame_) { - StopLoading(); - frame_ = NULL; - } alt_error_page_fetcher_.reset(); webview_impl_ = NULL; + frame_ = NULL; } void WebFrameImpl::DidReceiveData(DocumentLoader* loader, @@ -1639,12 +1620,8 @@ bool WebFrameImpl::Visible() { frame()->view()->visibleHeight() > 0; } -void WebFrameImpl::CreateChildFrame(const FrameLoadRequest& r, - HTMLFrameOwnerElement* owner_element, - bool allows_scrolling, - int margin_height, - int margin_width, - Frame*& result) { +PassRefPtr<Frame> WebFrameImpl::CreateChildFrame( + const FrameLoadRequest& request, HTMLFrameOwnerElement* owner_element) { // TODO(darin): share code with initWithName() scoped_refptr<WebFrameImpl> webframe = new WebFrameImpl(); @@ -1654,23 +1631,14 @@ void WebFrameImpl::CreateChildFrame(const FrameLoadRequest& r, // of this file for more info. webframe->AddRef(); - webframe->allows_scrolling_ = allows_scrolling; - webframe->margin_width_ = margin_width; - webframe->margin_height_ = margin_height; - - webframe->frame_ = - Frame::create(frame_->page(), owner_element, &webframe->frame_loader_client_); - webframe->frame_->tree()->setName(r.frameName()); - - webframe->webview_impl_ = webview_impl_; // owning ref + RefPtr<Frame> child_frame = Frame::create( + frame_->page(), owner_element, &webframe->frame_loader_client_); + webframe->frame_ = child_frame.get(); + webframe->webview_impl_ = webview_impl_; - // We wait until loader()->load() returns before deref-ing the Frame. - // Otherwise the danger is that the onload handler can cause - // the Frame to be dealloc-ed, and subsequently trash memory. - // (b:1055700) - WTF::RefPtr<Frame> protector(webframe->frame_.get()); + child_frame->tree()->setName(request.frameName()); - frame_->tree()->appendChild(webframe->frame_); + frame_->tree()->appendChild(child_frame); // Frame::init() can trigger onload event in the parent frame, // which may detach this frame and trigger a null-pointer access @@ -1681,56 +1649,58 @@ void WebFrameImpl::CreateChildFrame(const FrameLoadRequest& r, // it is necessary to check the value after calling init() and // return without loading URL. // (b:791612) - webframe->frame_->init(); // create an empty document - if (!webframe->frame_.get()) - return; + child_frame->init(); // create an empty document + if (!child_frame->tree()->parent()) + return NULL; // The following code was pulled from WebFrame.mm:_loadURL, with minor // modifications. The purpose is to ensure we load the right HistoryItem for // this child frame. - HistoryItem* parentItem = frame_->loader()->currentHistoryItem(); - FrameLoadType loadType = frame_->loader()->loadType(); - FrameLoadType childLoadType = WebCore::FrameLoadTypeRedirectWithLockedHistory; - KURL new_url = r.resourceRequest().url(); + HistoryItem* parent_item = frame_->loader()->currentHistoryItem(); + FrameLoadType load_type = frame_->loader()->loadType(); + FrameLoadType child_load_type = WebCore::FrameLoadTypeRedirectWithLockedHistory; + KURL new_url = request.resourceRequest().url(); // 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() != 0 && - (isBackForwardLoadType(loadType) || - loadType == WebCore::FrameLoadTypeReloadAllowingStaleData)) { - HistoryItem* childItem = parentItem->childItemWithName(r.frameName()); - if (childItem) { + if (parent_item && parent_item->children().size() != 0 && + (isBackForwardLoadType(load_type) || + load_type == WebCore::FrameLoadTypeReloadAllowingStaleData)) { + HistoryItem* child_item = parent_item->childItemWithName(request.frameName()); + if (child_item) { // 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. - new_url = KURL(KURL(""), - childItem->originalURLString()); + new_url = child_item->originalURL(); // These behaviors implied by these loadTypes should apply to the child // frames - childLoadType = loadType; + child_load_type = load_type; - if (isBackForwardLoadType(loadType)) { + if (isBackForwardLoadType(load_type)) { // For back/forward, remember this item so we can traverse any child // items as child frames load. - webframe->frame_->loader()->setProvisionalHistoryItem(childItem); + child_frame->loader()->setProvisionalHistoryItem(child_item); } 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 - webframe->frame_->loader()->setCurrentHistoryItem(childItem); + child_frame->loader()->setCurrentHistoryItem(child_item); } } } - - webframe->frame_->loader()->loadURLIntoChildFrame(new_url, - r.resourceRequest().httpReferrer(), - webframe->frame_.get()); + + child_frame->loader()->loadURL( + new_url, request.resourceRequest().httpReferrer(), request.frameName(), + child_load_type, 0, 0); // A synchronous navigation (about:blank) would have already processed // onload, so it is possible for the frame to have already been destroyed by // script in the page. - result = webframe->frame_.get(); + if (!child_frame->tree()->parent()) + return NULL; + + return child_frame.release(); } bool WebFrameImpl::ExecuteCoreCommandByName(const std::string& name, @@ -1785,7 +1755,6 @@ gfx::Size WebFrameImpl::ScrollOffset() const { } void WebFrameImpl::SetAllowsScrolling(bool flag) { - allows_scrolling_ = flag; frame_->view()->setCanHaveScrollbars(flag); } diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 57b6d39..14756f9 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -177,10 +177,9 @@ class WebFrameImpl : public WebFrame { // child frame failed to load. void SetPrinting(bool printing, float page_width_min, float page_width_max); - void CreateChildFrame(const WebCore::FrameLoadRequest&, - WebCore::HTMLFrameOwnerElement* owner_element, - bool allows_scrolling, int margin_width, - int margin_height, WebCore::Frame*& new_frame); + PassRefPtr<WebCore::Frame> CreateChildFrame( + const WebCore::FrameLoadRequest&, + WebCore::HTMLFrameOwnerElement* owner_element); // WebFrameImpl void Layout(); @@ -201,7 +200,7 @@ class WebFrameImpl : public WebFrame { } WebCore::Frame* frame() const { - return frame_.get(); + return frame_; } static WebFrameImpl* FromFrame(WebCore::Frame* frame); @@ -304,16 +303,12 @@ class WebFrameImpl : public WebFrame { // asynchronously in order to scope string matches during a find operation. ScopedRunnableMethodFactory<WebFrameImpl> scope_matches_factory_; - // Holding a reference back to the WebViewImpl is necessary to ensure that - // its HWND is not destroyed before all of the WebCore::Widgets, which refer - // to the WebViewImpl's HWND as their containingWindow. However, this ref - // creates a cycle between the WebViewImpl and the top-most WebFrameImpl. We - // break this cycle in our Closing method. - scoped_refptr<WebViewImpl> webview_impl_; + // This is a weak pointer to our containing WebViewImpl. + WebViewImpl* webview_impl_; - // The WebCore frame associated with this frame. MAY BE NULL if the frame - // has been detached from the DOM. - WTF::RefPtr<WebCore::Frame> frame_; + // This is a weak pointer to our corresponding WebCore frame. A reference to + // ourselves is held while frame_ is valid. See our Closing method. + WebCore::Frame* frame_; // This holds the request passed to LoadRequest, for access by the // WebFrameLoaderClient. Unfortunately we have no other way to pass this @@ -328,11 +323,6 @@ class WebFrameImpl : public WebFrame { // a pointer back to the appropriate plugin. WebPluginDelegate* plugin_delegate_; - // Frame construction parameters - bool allows_scrolling_; - int margin_width_; - int margin_height_; - // Handling requests from TextInputController on this frame. scoped_ptr<WebTextInputImpl> webtextinput_impl_; diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 6c50037..f7ab5cc 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -85,13 +85,12 @@ WebFrameLoaderClient::~WebFrameLoaderClient() { } void WebFrameLoaderClient::frameLoaderDestroyed() { - // When the WebFrame was created, it had an extra ref() given to it on behalf - // of the FrameWin, which accesses it via the FrameWinClient interface. - // Since the WebFrame owns us, this extra ref also serves to keep us alive - // until the FrameLoader is done with us. The FrameLoader calls this method - // when it's going away. Therefore, we balance out that extra ref. - // - // May delete 'this' + // When the WebFrame was created, it had an extra reference given to it on + // behalf of the Frame. Since the WebFrame owns us, this extra ref also + // serves to keep us alive until the FrameLoader is done with us. The + // FrameLoader calls this method when it's going away. Therefore, we balance + // out that extra reference, which may cause 'this' to be deleted. + webframe_->Closing(); webframe_->Release(); } @@ -146,16 +145,11 @@ void WebFrameLoaderClient::setCopiesOnScroll() { } void WebFrameLoaderClient::detachedFromParent2() { - // FIXME -} -void WebFrameLoaderClient::detachedFromParent3() { - // FIXME + // Nothing to do here. } -void WebFrameLoaderClient::detachedFromParent4() { - // Called during the last part of frame detaching, to indicate that we should - // destroy various objects (including the FrameWin). - webframe_->Closing(); +void WebFrameLoaderClient::detachedFromParent3() { + // Nothing to do here. } // This function is responsible for associating the |identifier| with a given @@ -1328,12 +1322,7 @@ PassRefPtr<Frame> WebFrameLoaderClient::createFrame( int margin_width, int margin_height) { FrameLoadRequest frame_request(ResourceRequest(url, referrer), name); - - Frame* new_frame = NULL; - if (webframe_) - webframe_->CreateChildFrame(frame_request, owner_element, allows_scrolling, - margin_width, margin_height, new_frame); - return new_frame; + return webframe_->CreateChildFrame(frame_request, owner_element); } // Utility function to convert a vector to an array of char*'s. diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h index 6010ba8..b14450d 100644 --- a/webkit/glue/webframeloaderclient_impl.h +++ b/webkit/glue/webframeloaderclient_impl.h @@ -55,7 +55,6 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient { virtual void detachedFromParent2(); virtual void detachedFromParent3(); - virtual void detachedFromParent4(); virtual void assignIdentifierToInitialRequest(unsigned long identifier, WebCore::DocumentLoader*, const WebCore::ResourceRequest&); diff --git a/webkit/glue/webplugin_impl.cc b/webkit/glue/webplugin_impl.cc index 6d3fef8..80936f9 100644 --- a/webkit/glue/webplugin_impl.cc +++ b/webkit/glue/webplugin_impl.cc @@ -808,9 +808,9 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) { if (event->shiftKey()) np_event.wParam |= MK_SHIFT; - if ((event->type() == WebCore::EventNames::mousemoveEvent) || - (event->type() == WebCore::EventNames::mouseoutEvent) || - (event->type() == WebCore::EventNames::mouseoverEvent)) { + if ((event->type() == WebCore::eventNames().mousemoveEvent) || + (event->type() == WebCore::eventNames().mouseoutEvent) || + (event->type() == WebCore::eventNames().mouseoverEvent)) { np_event.event = WM_MOUSEMOVE; if (event->buttonDown()) { switch (event->button()) { @@ -825,7 +825,7 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) { break; } } - } else if (event->type() == WebCore::EventNames::mousedownEvent) { + } else if (event->type() == WebCore::eventNames().mousedownEvent) { // Ensure that the frame containing the plugin has focus. WebCore::Frame* containing_frame = webframe_->frame(); if (WebCore::Page* current_page = containing_frame->page()) { @@ -851,7 +851,7 @@ void WebPluginImpl::handleMouseEvent(WebCore::MouseEvent* event) { np_event.wParam |= MK_RBUTTON; break; } - } else if (event->type() == WebCore::EventNames::mouseupEvent) { + } else if (event->type() == WebCore::eventNames().mouseupEvent) { switch (event->button()) { case WebCore::LeftButton: np_event.event = WM_LBUTTONUP; @@ -889,10 +889,10 @@ void WebPluginImpl::handleKeyboardEvent(WebCore::KeyboardEvent* event) { NPEvent np_event; np_event.wParam = event->keyCode(); - if (event->type() == WebCore::EventNames::keydownEvent) { + if (event->type() == WebCore::eventNames().keydownEvent) { np_event.event = WM_KEYDOWN; np_event.lParam = 0; - } else if (event->type() == WebCore::EventNames::keyupEvent) { + } else if (event->type() == WebCore::eventNames().keyupEvent) { np_event.event = WM_KEYUP; np_event.lParam = 0x8000; } else { diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index bf46c9d..9ee599e 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -251,7 +251,13 @@ WebView* WebView::Create(WebViewDelegate* delegate, WebViewImpl* instance = new WebViewImpl(); instance->AddRef(); instance->SetPreferences(prefs); - instance->main_frame_->InitMainFrame(instance); + + // Here, we construct a new WebFrameImpl with a reference count of 0. That + // is bumped up to 1 by InitMainFrame. The reference count is decremented + // when the corresponding WebCore::Frame object is destroyed. + WebFrameImpl* main_frame = new WebFrameImpl(); + main_frame->InitMainFrame(instance); + // Set the delegate after initializing the main frame, to avoid trying to // respond to notifications before we're fully initialized. instance->delegate_ = delegate; @@ -263,9 +269,7 @@ WebView* WebView::Create(WebViewDelegate* delegate, } WebViewImpl::WebViewImpl() - : delegate_(NULL), - pending_history_item_(NULL), - observed_new_navigation_(false), + : observed_new_navigation_(false), #ifndef NDEBUG new_navigation_loader_(NULL), #endif @@ -295,17 +299,9 @@ WebViewImpl::WebViewImpl() // The group name identifies a namespace of pages. I'm not sure how it's // intended to be used, but keeping all pages in the same group works for us. page_->setGroupName("default"); - - // This is created with a refcount of 1, and we assign it to a RefPtr, - // giving a refcount of 2. The ref is done on behalf of - // FrameWin/FrameLoaderWin which references the WebFrame via the - // FrameWinClient/FrameLoaderClient interfaces. See the comment at the - // top of webframe_impl.cc - main_frame_ = new WebFrameImpl(); } WebViewImpl::~WebViewImpl() { - DCHECK(main_frame_ == NULL); DCHECK(page_ == NULL); ReleaseFocusReferences(); for (std::set<ImageResourceFetcher*>::iterator i = image_fetchers_.begin(); @@ -329,7 +325,7 @@ void WebViewImpl::SetTabKeyCyclesThroughElements(bool value) { } void WebViewImpl::MouseMove(const WebMouseEvent& event) { - if (!main_frame_->frameview()) + if (!main_frame() || !main_frame()->frameview()) return; last_mouse_position_.SetPoint(event.x, event.y); @@ -337,47 +333,50 @@ void WebViewImpl::MouseMove(const WebMouseEvent& event) { // We call mouseMoved here instead of handleMouseMovedEvent because we need // our ChromeClientImpl to receive changes to the mouse position and // tooltip text, and mouseMoved handles all of that. - main_frame_->frameview()->frame()->eventHandler()->mouseMoved( - MakePlatformMouseEvent(main_frame_->frameview(), event)); + main_frame()->frame()->eventHandler()->mouseMoved( + MakePlatformMouseEvent(main_frame()->frameview(), event)); } void WebViewImpl::MouseLeave(const WebMouseEvent& event) { // This event gets sent as the main frame is closing. In that case, just // ignore it. - if (!main_frame_ || !main_frame_->frameview()) + if (!main_frame() || !main_frame()->frameview()) return; delegate_->UpdateTargetURL(this, GURL()); - main_frame_->frameview()->frame()->eventHandler()->handleMouseMoveEvent( - MakePlatformMouseEvent(main_frame_->frameview(), event)); + main_frame()->frame()->eventHandler()->handleMouseMoveEvent( + MakePlatformMouseEvent(main_frame()->frameview(), event)); } void WebViewImpl::MouseDown(const WebMouseEvent& event) { - if (!main_frame_->frameview()) + if (!main_frame() || !main_frame()->frameview()) return; last_mouse_down_point_ = gfx::Point(event.x, event.y); - main_frame_->frame()->eventHandler()->handleMousePressEvent( - MakePlatformMouseEvent(main_frame_->frameview(), event)); + main_frame()->frame()->eventHandler()->handleMousePressEvent( + MakePlatformMouseEvent(main_frame()->frameview(), event)); } void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { + if (!main_frame() || !main_frame()->frameview()) + return; + page_->contextMenuController()->clearContextMenu(); - MakePlatformMouseEvent pme(main_frame_->frameview(), event); + MakePlatformMouseEvent pme(main_frame()->frameview(), event); // Find the right target frame. See issue 1186900. IntPoint doc_point( - main_frame_->frame()->view()->windowToContents(pme.pos())); + page_->mainFrame()->view()->windowToContents(pme.pos())); HitTestResult result = - main_frame_->frame()->eventHandler()->hitTestResultAtPoint(doc_point, - false); + page_->mainFrame()->eventHandler()->hitTestResultAtPoint( + doc_point, false); Frame* target_frame; if (result.innerNonSharedNode()) - target_frame = result.innerNonSharedNode()->document()->frame(); + target_frame = result.innerNonSharedNode()->document()->frame(); else - target_frame = page_->focusController()->focusedOrMainFrame(); + target_frame = page_->focusController()->focusedOrMainFrame(); #if defined(OS_WIN) target_frame->view()->setCursor(pointerCursor()); @@ -391,12 +390,12 @@ void WebViewImpl::MouseContextMenu(const WebMouseEvent& event) { } void WebViewImpl::MouseUp(const WebMouseEvent& event) { - if (!main_frame_->frameview()) + if (!main_frame() || !main_frame()->frameview()) return; MouseCaptureLost(); - main_frame_->frameview()->frame()->eventHandler()->handleMouseReleaseEvent( - MakePlatformMouseEvent(main_frame_->frameview(), event)); + main_frame()->frame()->eventHandler()->handleMouseReleaseEvent( + MakePlatformMouseEvent(main_frame()->frameview(), event)); // Dispatch the contextmenu event regardless of if the click was swallowed. if (event.button == WebMouseEvent::BUTTON_RIGHT) @@ -404,8 +403,8 @@ void WebViewImpl::MouseUp(const WebMouseEvent& event) { } void WebViewImpl::MouseWheel(const WebMouseWheelEvent& event) { - MakePlatformWheelEvent platform_event(main_frame_->frameview(), event); - main_frame_->frame()->eventHandler()->handleWheelEvent(platform_event); + MakePlatformWheelEvent platform_event(main_frame()->frameview(), event); + main_frame()->frame()->eventHandler()->handleWheelEvent(platform_event); } bool WebViewImpl::KeyEvent(const WebKeyboardEvent& event) { @@ -718,11 +717,7 @@ bool WebViewImpl::ScrollViewWithKeyboard(int key_code) { } Frame* WebViewImpl::GetFocusedWebCoreFrame() { - if (!main_frame_ || !main_frame_->frame()) - return NULL; - - return - main_frame_->frame()->page()->focusController()->focusedOrMainFrame(); + return page_.get() ? page_->focusController()->focusedOrMainFrame() : NULL; } // static @@ -748,14 +743,13 @@ void WebViewImpl::Close() { // initiator of the close. delegate_ = NULL; - // Initiate shutdown for the entire frameset. - if (main_frame_) { - // This will cause a lot of notifications to be sent. - main_frame_->frame()->loader()->frameDetached(); - main_frame_ = NULL; + if (page_.get()) { + // Initiate shutdown for the entire frameset. This will cause a lot of + // notifications to be sent. + if (page_->mainFrame()) + page_->mainFrame()->loader()->frameDetached(); + page_.reset(); } - - page_.reset(); } WebViewDelegate* WebViewImpl::GetDelegate() { @@ -763,7 +757,7 @@ WebViewDelegate* WebViewImpl::GetDelegate() { } WebFrame* WebViewImpl::GetMainFrame() { - return main_frame_.get(); + return main_frame(); } WebFrame* WebViewImpl::GetFocusedFrame() { @@ -786,7 +780,7 @@ void WebViewImpl::SetFocusedFrame(WebFrame* frame) { WebFrame* WebViewImpl::GetFrameWithName(const std::wstring& name) { String name_str = webkit_glue::StdWStringToString(name); - Frame* frame = main_frame_->frame()->tree()->find(name_str); + Frame* frame = page_->mainFrame()->tree()->find(name_str); return frame ? WebFrameImpl::FromFrame(frame) : NULL; } @@ -809,9 +803,9 @@ void WebViewImpl::Resize(const gfx::Size& new_size) { return; size_ = new_size; - if (main_frame_->frameview()) { - main_frame_->frameview()->resize(size_.width(), size_.height()); - main_frame_->frame()->sendResizeEvent(); + if (main_frame()->frameview()) { + main_frame()->frameview()->resize(size_.width(), size_.height()); + main_frame()->frame()->sendResizeEvent(); } if (delegate_) { @@ -821,27 +815,29 @@ void WebViewImpl::Resize(const gfx::Size& new_size) { } void WebViewImpl::Layout() { - if (main_frame_) { + WebFrameImpl* webframe = main_frame(); + if (webframe) { // In order for our child HWNDs (NativeWindowWidgets) to update properly, // they need to be told that we are updating the screen. The problem is // that the native widgets need to recalculate their clip region and not // overlap any of our non-native widgets. To force the resizing, call // setFrameRect(). This will be a quick operation for most frames, but // the NativeWindowWidgets will update a proper clipping region. - FrameView* frameview = main_frame_->frameview(); - if (frameview) - frameview->setFrameRect(frameview->frameRect()); + FrameView* view = webframe->frameview(); + if (view) + view->setFrameRect(view->frameRect()); // setFrameRect may have the side-effect of causing existing page // layout to be invalidated, so layout needs to be called last. - main_frame_->Layout(); + webframe->Layout(); } } void WebViewImpl::Paint(gfx::PlatformCanvas* canvas, const gfx::Rect& rect) { - if (main_frame_) - main_frame_->Paint(canvas, rect); + WebFrameImpl* webframe = main_frame(); + if (webframe) + webframe->Paint(canvas, rect); } // TODO(eseidel): g_current_input_event should be removed once @@ -912,7 +908,7 @@ void WebViewImpl::MouseCaptureLost() { // TODO(darin): these navigation methods should be killed void WebViewImpl::StopLoading() { - main_frame_->StopLoading(); + main_frame()->StopLoading(); } void WebViewImpl::SetBackForwardListSize(int size) { @@ -933,15 +929,14 @@ void WebViewImpl::SetFocus(bool enable) { // frame as the focused frame if it is not already focused. Otherwise, if // there is already a focused frame, then this does nothing. GetFocusedFrame(); - if (main_frame_ && main_frame_->frame()) { - Frame* frame = main_frame_->frame(); + if (page_.get() && page_->mainFrame()) { + Frame* frame = page_->mainFrame(); if (!frame->selection()->isFocusedAndActive()) { // No one has focus yet, try to restore focus. RestoreFocus(); - frame->page()->focusController()->setActive(true); + page_->focusController()->setActive(true); } - Frame* focused_frame = - frame->page()->focusController()->focusedOrMainFrame(); + Frame* focused_frame = page_->focusController()->focusedOrMainFrame(); frame->selection()->setFocused(frame == focused_frame); } ime_accept_events_ = true; @@ -950,14 +945,15 @@ void WebViewImpl::SetFocus(bool enable) { // updated below. ReleaseFocusReferences(); - if (!main_frame_) + // Clear focus on the currently focused frame if any. + if (!page_.get()) return; - Frame* frame = main_frame_->frame(); + Frame* frame = page_->mainFrame(); if (!frame) return; - RefPtr<Frame> focused = frame->page()->focusController()->focusedFrame(); + RefPtr<Frame> focused = page_->focusController()->focusedFrame(); if (focused.get()) { // Update the focus refs, this way we can give focus back appropriately. // It's entirely possible to have a focused document, but not a focused @@ -974,7 +970,8 @@ void WebViewImpl::SetFocus(bool enable) { // document->setFocusedNode(NULL); } } - frame->page()->focusController()->setFocusedFrame(0); + page_->focusController()->setFocusedFrame(0); + // Finish an ongoing composition to delete the composition node. Editor* editor = focused->editor(); if (editor && editor->hasComposition()) @@ -1205,7 +1202,7 @@ void WebViewImpl::ReleaseFocusReferences() { } bool WebViewImpl::DownloadImage(int id, const GURL& image_url, int image_size) { - if (!main_frame_ || !main_frame_->frame()) + if (!page_.get()) return false; image_fetchers_.insert( new ImageResourceFetcher(this, id, image_url, image_size)); @@ -1287,23 +1284,23 @@ const WebPreferences& WebViewImpl::GetPreferences() { // Set the encoding of the current main frame to the one selected by // a user in the encoding menu. void WebViewImpl::SetPageEncoding(const std::wstring& encoding_name) { - if (!main_frame_) + if (!page_.get()) return; if (!encoding_name.empty()) { // only change override encoding, don't change default encoding // TODO(brettw) use std::string for encoding names. String new_encoding_name(webkit_glue::StdWStringToString(encoding_name)); - main_frame_->frame()->loader()->reloadAllowingStaleData(new_encoding_name); + page_->mainFrame()->loader()->reloadAllowingStaleData(new_encoding_name); } } // Return the canonical encoding name of current main webframe in webview. std::wstring WebViewImpl::GetMainFrameEncodingName() { - if (!main_frame_) - return std::wstring(L""); + if (!page_.get()) + return std::wstring(); - String encoding_name = main_frame_->frame()->loader()->encoding(); + String encoding_name = page_->mainFrame()->loader()->encoding(); return webkit_glue::StringToStdWString(encoding_name); } @@ -1341,11 +1338,12 @@ void WebViewImpl::ResetZoom() { } void WebViewImpl::CopyImageAt(int x, int y) { + if (!page_.get()) + return; + IntPoint point = IntPoint(x, y); - Frame* frame = main_frame_->frame(); - if (!frame) - return; + Frame* frame = page_->mainFrame(); HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(point, false); @@ -1365,14 +1363,16 @@ void WebViewImpl::CopyImageAt(int x, int y) { } void WebViewImpl::InspectElement(int x, int y) { + if (!page_.get()) + return; + if (x == -1 || y == -1) { page_->inspectorController()->inspect(NULL); } else { IntPoint point = IntPoint(x, y); HitTestResult result(point); - if (Frame* frame = main_frame_->frame()) - result = frame->eventHandler()->hitTestResultAtPoint(point, false); + result = page_->mainFrame()->eventHandler()->hitTestResultAtPoint(point, false); if (!result.innerNonSharedNode()) return; @@ -1391,8 +1391,7 @@ void WebViewImpl::DragSourceEndedAt( IntPoint(screen_x, screen_y), NoButton, MouseEventMoved, 0, false, false, false, false, 0); - main_frame_->frame()->eventHandler()->dragSourceEndedAt(pme, - DragOperationCopy); + page_->mainFrame()->eventHandler()->dragSourceEndedAt(pme, DragOperationCopy); } void WebViewImpl::DragSourceMovedTo( @@ -1401,7 +1400,7 @@ void WebViewImpl::DragSourceMovedTo( IntPoint(screen_x, screen_y), LeftButton, MouseEventMoved, 0, false, false, false, false, 0); - main_frame_->frame()->eventHandler()->dragSourceMovedTo(pme); + page_->mainFrame()->eventHandler()->dragSourceMovedTo(pme); } void WebViewImpl::DragSourceSystemDragEnded() { @@ -1449,15 +1448,10 @@ void WebViewImpl::DragTargetDrop( } SearchableFormData* WebViewImpl::CreateSearchableFormDataForFocusedNode() { - if (!main_frame_) - return NULL; - - Frame* frame = main_frame_->frame(); - if (!frame) + if (!page_.get()) return NULL; - if (RefPtr<Frame> focused = - frame->page()->focusController()->focusedFrame()) { + if (RefPtr<Frame> focused = page_->focusController()->focusedFrame()) { RefPtr<Document> document = focused->document(); if (document.get()) { RefPtr<Node> focused_node = document->focusedNode(); @@ -1475,17 +1469,12 @@ void WebViewImpl::AutofillSuggestionsForNode( int64 node_id, const std::vector<std::wstring>& suggestions, int default_suggestion_index) { - if (!main_frame_ || suggestions.empty()) + if (!page_.get() || suggestions.empty()) return; DCHECK(default_suggestion_index < static_cast<int>(suggestions.size())); - Frame* frame = main_frame_->frame(); - if (!frame) - return; - - if (RefPtr<Frame> focused = - frame->page()->focusController()->focusedFrame()) { + if (RefPtr<Frame> focused = page_->focusController()->focusedFrame()) { RefPtr<Document> document = focused->document(); if (!document.get()) return; @@ -1519,7 +1508,8 @@ void WebViewImpl::AutofillSuggestionsForNode( autocomplete_popup_ = WebCore::PopupContainer::create(autocomplete_popup_client_.get(), false); - autocomplete_popup_->show(focused_node->getRect(), frame->view(), 0); + autocomplete_popup_->show(focused_node->getRect(), + page_->mainFrame()->view(), 0); } } } @@ -1530,7 +1520,7 @@ void WebViewImpl::DidCommitLoad(bool* is_new_navigation) { #ifndef NDEBUG DCHECK(!observed_new_navigation_ || - main_frame_->frame()->loader()->documentLoader() == new_navigation_loader_); + page_->mainFrame()->loader()->documentLoader() == new_navigation_loader_); new_navigation_loader_ = NULL; #endif observed_new_navigation_ = false; @@ -1620,7 +1610,7 @@ void WebViewImpl::didAddHistoryItem(WebCore::HistoryItem* item) { // (ie, not a reload or back/forward). observed_new_navigation_ = true; #ifndef NDEBUG - new_navigation_loader_ = main_frame_->frame()->loader()->documentLoader(); + new_navigation_loader_ = page_->mainFrame()->loader()->documentLoader(); #endif delegate_->DidAddHistoryItem(); } @@ -1630,7 +1620,7 @@ void WebViewImpl::willGoToHistoryItem(WebCore::HistoryItem* item) { if (item == pending_history_item_->GetHistoryItem()) { // Let the main frame know this HistoryItem is loading, so it can cache // any ExtraData when the DataSource is created. - main_frame_->set_currently_loading_history_item(pending_history_item_); + main_frame()->set_currently_loading_history_item(pending_history_item_); pending_history_item_ = 0; } } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index e5b5e8e..f53f211 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -19,6 +19,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #include "BackForwardList.h" +#include "Page.h" MSVC_POP_WARNING(); namespace WebCore { @@ -118,20 +119,22 @@ class WebViewImpl : public WebView, public WebCore::BackForwardListClient { static WebViewImpl* FromPage(WebCore::Page* page); - WebFrameImpl* main_frame() { - return main_frame_; - } - WebViewDelegate* delegate() { return delegate_.get(); } - // Returns the page object associated with this view. This may be NULL when - // the page is shutting down, but will be valid all other times. + // Returns the page object associated with this view. This may be NULL when + // the page is shutting down, but will be valid at all other times. WebCore::Page* page() const { return page_.get(); } + // Returns the main frame associated with this view. This may be NULL when + // the page is shutting down, but will be valid at all other times. + WebFrameImpl* main_frame() { + return page_.get() ? WebFrameImpl::FromFrame(page_->mainFrame()) : NULL; + } + WebHistoryItemImpl* pending_history_item() const { return pending_history_item_; } @@ -224,7 +227,6 @@ class WebViewImpl : public WebView, public WebCore::BackForwardListClient { scoped_refptr<WebViewDelegate> delegate_; gfx::Size size_; - scoped_refptr<WebFrameImpl> main_frame_; gfx::Point last_mouse_position_; // Reference to the Frame that last had focus. This is set once when // we lose focus, and used when focus is gained to reinstall focus to |