diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-18 10:52:00 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-08-18 10:52:00 -0700 |
commit | 14b66f1be3bd17e6c607bad649e68330489869a7 (patch) | |
tree | 866f09cc007625741f38b4e62209e329b63323f5 | |
parent | 7793e23e0420919c2970edc4a2ace1aabc3ed385 (diff) | |
parent | 29efdb685ae2c3da761273415d2f7df07852e463 (diff) | |
download | external_webkit-14b66f1be3bd17e6c607bad649e68330489869a7.zip external_webkit-14b66f1be3bd17e6c607bad649e68330489869a7.tar.gz external_webkit-14b66f1be3bd17e6c607bad649e68330489869a7.tar.bz2 |
Merge change 21466 into eclair
* changes:
Need to notify Java side when viewport tag is parsed.
-rw-r--r-- | WebCore/html/HTMLBodyElement.cpp | 10 | ||||
-rw-r--r-- | WebCore/html/HTMLDocument.cpp | 4 | ||||
-rw-r--r-- | WebCore/html/HTMLMetaElement.cpp | 20 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 5 |
5 files changed, 47 insertions, 4 deletions
diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp index 9852858..119a06a 100644 --- a/WebCore/html/HTMLBodyElement.cpp +++ b/WebCore/html/HTMLBodyElement.cpp @@ -41,6 +41,7 @@ #ifdef ANDROID_META_SUPPORT #include "Settings.h" +#include "WebViewCore.h" #endif namespace WebCore { @@ -181,9 +182,16 @@ void HTMLBodyElement::insertedIntoDocument() Settings * settings = document()->settings(); String host = document()->baseURI().host().lower(); if (settings->viewportWidth() == -1 && (host.startsWith("m.") || host.startsWith("mobile.") - || host.contains(".m.") || host.contains(".mobile."))) + || host.contains(".m.") || host.contains(".mobile."))) { // fit mobile sites directly in the screen settings->setMetadataSettings("width", "device-width"); + // update the meta data if it is the top document + if (!ownerElement) { + FrameView* view = document()->view(); + if (view) + android::WebViewCore::getWebViewCore(view)->updateViewport(); + } + } #endif // FIXME: This call to scheduleRelayout should not be needed here. diff --git a/WebCore/html/HTMLDocument.cpp b/WebCore/html/HTMLDocument.cpp index 01f151c..778c5ae 100644 --- a/WebCore/html/HTMLDocument.cpp +++ b/WebCore/html/HTMLDocument.cpp @@ -78,6 +78,7 @@ #ifdef ANDROID_META_SUPPORT #include "FrameTree.h" #include "Settings.h" +#include "WebViewCore.h" #endif namespace WebCore { @@ -399,6 +400,9 @@ void HTMLDocument::determineParseMode() strstr(pubIDStr.data(), "-//wapforum//dtd xhtml mobile 1.") == pubIDStr.data()) { // fit mobile sites directly in the screen frame()->settings()->setMetadataSettings("width", "device-width"); + FrameView* frameView = view(); + if (frameView) + android::WebViewCore::getWebViewCore(frameView)->updateViewport(); } #endif // Look up the entry in our gperf-generated table. diff --git a/WebCore/html/HTMLMetaElement.cpp b/WebCore/html/HTMLMetaElement.cpp index 5d3e925..83e38fe 100644 --- a/WebCore/html/HTMLMetaElement.cpp +++ b/WebCore/html/HTMLMetaElement.cpp @@ -29,6 +29,7 @@ #ifdef ANDROID_META_SUPPORT #include "Settings.h" +#include "WebViewCore.h" #endif namespace WebCore { @@ -70,12 +71,25 @@ void HTMLMetaElement::process() #ifdef ANDROID_META_SUPPORT if (!inDocument() || m_content.isNull()) return; - if (equalIgnoringCase(name(), "viewport") || equalIgnoringCase(name(), "format-detection")) + bool updateViewport = false; + if (equalIgnoringCase(name(), "viewport")) { document()->processMetadataSettings(m_content); - else if (equalIgnoringCase(name(), "HandheldFriendly") && equalIgnoringCase(m_content, "true") - && document()->settings()->viewportWidth() == -1) + updateViewport = true; + } else if (equalIgnoringCase(name(), "format-detection")) + document()->processMetadataSettings(m_content); + else if (equalIgnoringCase(name(), "HandheldFriendly") + && equalIgnoringCase(m_content, "true") + && document()->settings()->viewportWidth() == -1) { // fit mobile sites directly in the screen document()->settings()->setMetadataSettings("width", "device-width"); + updateViewport = true; + } + // update the meta data if it is the top document + if (updateViewport && !document()->ownerElement()) { + FrameView* view = document()->view(); + if (view) + android::WebViewCore::getWebViewCore(view)->updateViewport(); + } #endif // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while // it's not in the tree shouldn't have any effect on the document) diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index aa96b18..88a00b1 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -168,6 +168,7 @@ struct WebViewCore::JavaGlue { jmethodID m_jsUnload; jmethodID m_jsInterrupt; jmethodID m_didFirstLayout; + jmethodID m_updateViewport; jmethodID m_sendNotifyProgressFinished; jmethodID m_sendViewInvalidate; jmethodID m_updateTextfield; @@ -242,6 +243,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_jsUnload = GetJMethod(env, clazz, "jsUnload", "(Ljava/lang/String;Ljava/lang/String;)Z"); m_javaGlue->m_jsInterrupt = GetJMethod(env, clazz, "jsInterrupt", "()Z"); m_javaGlue->m_didFirstLayout = GetJMethod(env, clazz, "didFirstLayout", "(Z)V"); + m_javaGlue->m_updateViewport = GetJMethod(env, clazz, "updateViewport", "()V"); m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V"); m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V"); m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); @@ -839,6 +841,16 @@ void WebViewCore::didFirstLayout() m_history.setDidFirstLayout(true); } +void WebViewCore::updateViewport() +{ + DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); + LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); + + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_updateViewport); + checkException(env); +} + void WebViewCore::restoreScale(int scale) { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 1408cb7..97018f0 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -152,6 +152,11 @@ namespace android { void didFirstLayout(); /** + * Notify the view to update the viewport. + */ + void updateViewport(); + + /** * Notify the view to restore the screen width, which in turn restores * the scale. */ |