diff options
author | Derek Sollenberger <djsollen@google.com> | 2009-08-25 09:47:47 -0400 |
---|---|---|
committer | Derek Sollenberger <djsollen@google.com> | 2009-08-25 09:47:47 -0400 |
commit | 59d6f2367e5fd0e25609fed4b5bb77b0c740d677 (patch) | |
tree | a5822b98ec49a5da3b68a737978681cdc19cdc12 | |
parent | 85052a16d3835375d73411fe3a8573df94d3b61b (diff) | |
download | external_webkit-59d6f2367e5fd0e25609fed4b5bb77b0c740d677.zip external_webkit-59d6f2367e5fd0e25609fed4b5bb77b0c740d677.tar.gz external_webkit-59d6f2367e5fd0e25609fed4b5bb77b0c740d677.tar.bz2 |
modifying how onLoad events are sent to plugins to properly handle IFrames.
Change-Id: I634ae9c2e18e03c95dff435679f547d37c6f430e
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 25 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 36 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 3 |
3 files changed, 47 insertions, 17 deletions
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 103dc4b..c9e712e 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -295,7 +295,7 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro } AssetManager* am = globalAssetManager(); - + // Check to see if the error code was not generated internally WebFrame::RAW_RES_ID id = WebFrame::NODOMAIN; if ((error.errorCode() == ErrorFile || @@ -335,7 +335,7 @@ void FrameLoaderClientAndroid::dispatchDidFailProvisionalLoad(const ResourceErro // Replace all occurances of %s with the failing url. String s = UTF8Encoding().decode((const char*)a->getBuffer(false), a->getLength()); s = s.replace("%s", String(url.data(), url.size())); - + // Replace all occurances of %e with the error text s = s.replace("%e", error.localizedDescription()); @@ -563,10 +563,13 @@ void FrameLoaderClientAndroid::postProgressEstimateChangedNotification() { // This is just a notification that the progress has finished. Don't call // setProgress(1) because postProgressEstimateChangedNotification will do so. void FrameLoaderClientAndroid::postProgressFinishedNotification() { + WebViewCore* core = WebViewCore::getWebViewCore(m_frame->view()); if (!m_frame->tree()->parent()) { // only need to notify Java for the top frame - WebViewCore::getWebViewCore(m_frame->view())->notifyProgressFinished(); + core->notifyProgressFinished(); } + // notify plugins that the frame has loaded + core->notifyPluginsOnFrameLoad(m_frame); } void FrameLoaderClientAndroid::setMainFrameDocumentReady(bool) { @@ -666,7 +669,7 @@ bool FrameLoaderClientAndroid::shouldFallBack(const ResourceError&) { bool FrameLoaderClientAndroid::canHandleRequest(const ResourceRequest& request) const { ASSERT(m_frame); // Don't allow hijacking of intrapage navigation - if (WebCore::equalIgnoringFragmentIdentifier(request.url(), m_frame->loader()->url())) + if (WebCore::equalIgnoringFragmentIdentifier(request.url(), m_frame->loader()->url())) return true; // Don't allow hijacking of iframe urls that are http or https @@ -865,7 +868,7 @@ WTF::PassRefPtr<WebCore::Frame> FrameLoaderClientAndroid::createFrame(const KURL newFrame->tree()->setName(name); // Create a new FrameView and WebFrameView for the child frame to draw into. RefPtr<FrameView> frameView = FrameView::create(newFrame); - WebFrameView* webFrameView = new WebFrameView(frameView.get(), + WebFrameView* webFrameView = new WebFrameView(frameView.get(), WebViewCore::getWebViewCore(parent->view())); // frameView Retains webFrameView, so call Release for webFrameView Release(webFrameView); @@ -878,7 +881,7 @@ WTF::PassRefPtr<WebCore::Frame> FrameLoaderClientAndroid::createFrame(const KURL // The creation of the frame may have run arbitrary JavaScript that removed it from the page already. if (!pFrame->page()) return 0; - + parent->loader()->loadURLIntoChildFrame(url, referrer, pFrame.get()); // onLoad may cuase the frame to be removed from the document. Allow the RefPtr to delete the child frame. @@ -1037,7 +1040,7 @@ String FrameLoaderClientAndroid::overrideMediaType() const { // This function is used to re-attach Javascript<->native code classes. void FrameLoaderClientAndroid::windowObjectCleared() { ASSERT(m_frame); - LOGV("::WebCore:: windowObjectCleared called on frame %p for %s\n", + LOGV("::WebCore:: windowObjectCleared called on frame %p for %s\n", m_frame, m_frame->loader()->url().string().ascii().data()); m_webFrame->windowObjectCleared(m_frame); } @@ -1052,11 +1055,11 @@ ResourceError FrameLoaderClientAndroid::blockedError(ResourceRequest const& requ // functions new to Nov-07 tip of tree merge: void FrameLoaderClientAndroid::didPerformFirstNavigation() const { - // This seems to be just a notification that the UI can listen to, to - // know if the user has performed first navigation action. - // It is called from + // This seems to be just a notification that the UI can listen to, to + // know if the user has performed first navigation action. + // It is called from // void FrameLoader::addBackForwardItemClippedAtTarget(bool doClip) - // "Navigation" here means a transition from one page to another that + // "Navigation" here means a transition from one page to another that // ends up in the back/forward list. } diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 670b64a..2f9a4fc 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -899,12 +899,6 @@ void WebViewCore::notifyProgressFinished() m_check_domtree_version = true; updateFrameCache(); sendNotifyProgressFinished(); - - // trigger an event notifying the plugins that the page has loaded - ANPEvent event; - SkANP::InitEvent(&event, kLifecycle_ANPEventType); - event.data.lifecycle.action = kOnLoad_ANPLifecycleAction; - sendPluginEvent(event); } void WebViewCore::doMaxScroll(CacheBuilder::Direction dir) @@ -1226,6 +1220,36 @@ void WebViewCore::drawPlugins() } } +void WebViewCore::notifyPluginsOnFrameLoad(const Frame* frame) { + // if frame is the parent then notify all plugins + if (!frame->tree()->parent()) { + // trigger an event notifying the plugins that the page has loaded + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kOnLoad_ANPLifecycleAction; + sendPluginEvent(event); + } + // else if frame's parent has completed + else if (!frame->tree()->parent()->loader()->isLoading()) { + // send to all plugins who have this frame in their heirarchy + PluginWidgetAndroid** iter = m_plugins.begin(); + PluginWidgetAndroid** stop = m_plugins.end(); + for (; iter < stop; ++iter) { + Frame* currentFrame = (*iter)->pluginView()->parentFrame(); + while (currentFrame) { + if (frame == currentFrame) { + ANPEvent event; + SkANP::InitEvent(&event, kLifecycle_ANPEventType); + event.data.lifecycle.action = kOnLoad_ANPLifecycleAction; + (*iter)->sendEvent(event); + break; + } + currentFrame = currentFrame->tree()->parent(); + } + } + } +} + void WebViewCore::sendPluginVisibleScreen() { ANPRectI visibleRect; diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 97018f0..697ed59 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -341,6 +341,9 @@ namespace android { // send the current screen size/zoom to all of the plugins in our list void sendPluginVisibleScreen(); + // send onLoad event to plugins who are descendents of the given frame + void notifyPluginsOnFrameLoad(const Frame*); + // send this event to all of the plugins in our list void sendPluginEvent(const ANPEvent&); |