summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShimeng (Simon) Wang <swang@google.com>2011-07-01 11:02:59 -0700
committerShimeng (Simon) Wang <swang@google.com>2011-07-01 11:14:47 -0700
commit8db9f9e9e78973e25adf06722ce8f9126e92c60b (patch)
treeb6d6349c5385749c7e37c07dcfb879ccf9506cfd
parentc19571f3ec3bec025fa05e8d81ffd1998324e844 (diff)
downloadexternal_webkit-8db9f9e9e78973e25adf06722ce8f9126e92c60b.zip
external_webkit-8db9f9e9e78973e25adf06722ce8f9126e92c60b.tar.gz
external_webkit-8db9f9e9e78973e25adf06722ce8f9126e92c60b.tar.bz2
Update viewport using webkit's way.
The Android's customized way of parsing viewport meta tags is kept intact; while the viewport update notification mechanism is changed to use webkit's way. This gives much better notification of viewport switching. issue: 4975315 Change-Id: I7896b67d684efec015245ee804a9243e72ff0b50
-rw-r--r--Source/WebCore/dom/Document.cpp16
-rw-r--r--Source/WebCore/dom/Document.h8
-rw-r--r--Source/WebCore/html/HTMLBodyElement.cpp8
-rw-r--r--Source/WebCore/html/HTMLMetaElement.cpp22
-rw-r--r--Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp16
-rw-r--r--Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h2
6 files changed, 26 insertions, 46 deletions
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 60d3af1..1ae3bae 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -695,10 +695,7 @@ void Document::setDocType(PassRefPtr<DocumentType> docType)
if (m_docType && !ownerElement()
&& m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", false)) {
// fit mobile sites directly in the screen
- if (Frame *f = frame())
- f->settings()->setMetadataSettings("width", "device-width");
- if (FrameView* frameView = view())
- PlatformBridge::updateViewport(frameView);
+ processViewport("width=device-width");
}
#endif
}
@@ -2614,14 +2611,6 @@ Node* Document::nodeWithAbsIndex(int absIndex)
return n;
}
-#ifdef ANDROID_META_SUPPORT
-void Document::processMetadataSettings(const String& content)
-{
- ASSERT(!content.isNull());
- processArguments(content, 0, 0);
-}
-#endif
-
void Document::processHttpEquiv(const String& equiv, const String& content)
{
ASSERT(!equiv.isNull() && !content.isNull());
@@ -2729,9 +2718,8 @@ void Document::processArguments(const String& features, void* data, ArgumentsCal
#ifdef ANDROID_META_SUPPORT
if (frame())
frame()->settings()->setMetadataSettings(keyString, valueString);
-#else
- callback(keyString, valueString, this, data);
#endif
+ callback(keyString, valueString, this, data);
}
}
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 5ab6d77..ca304c1 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -793,14 +793,6 @@ public:
void processHttpEquiv(const String& equiv, const String& content);
void processViewport(const String& features);
-#ifdef ANDROID_META_SUPPORT
- /**
- * Handles viewport like <meta name = "viewport" content = "width = device-width">
- * or format-detection like <meta name = "format-detection" content = "telephone=no">
- */
- void processMetadataSettings(const String& content);
-#endif
-
// Returns the owning element in the parent document.
// Returns 0 if this is the top level document.
HTMLFrameOwnerElement* ownerElement() const;
diff --git a/Source/WebCore/html/HTMLBodyElement.cpp b/Source/WebCore/html/HTMLBodyElement.cpp
index 9cf8730..0c93c95 100644
--- a/Source/WebCore/html/HTMLBodyElement.cpp
+++ b/Source/WebCore/html/HTMLBodyElement.cpp
@@ -206,13 +206,7 @@ void HTMLBodyElement::insertedIntoDocument()
if (settings->viewportWidth() == -1 && (host.startsWith("m.") || host.startsWith("mobile.")
|| host.startsWith("wap.") || host.contains(".m.") || host.contains(".mobile." || host.contains(".wap.")))) {
// 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)
- PlatformBridge::updateViewport(view);
- }
+ document()->processViewport("width=device-width");
}
}
#endif
diff --git a/Source/WebCore/html/HTMLMetaElement.cpp b/Source/WebCore/html/HTMLMetaElement.cpp
index d8d9fb3..493d4ac 100644
--- a/Source/WebCore/html/HTMLMetaElement.cpp
+++ b/Source/WebCore/html/HTMLMetaElement.cpp
@@ -75,30 +75,18 @@ void HTMLMetaElement::process()
{
if (!inDocument() || m_content.isNull())
return;
+ if (equalIgnoringCase(name(), "viewport"))
+ document()->processViewport(m_content);
#ifdef ANDROID_META_SUPPORT
// TODO: Evaluate whether to take upstreamed meta support
- bool updateViewport = false;
- if (equalIgnoringCase(name(), "viewport")) {
- document()->processMetadataSettings(m_content);
- updateViewport = true;
- } else if (equalIgnoringCase(name(), "format-detection"))
- document()->processMetadataSettings(m_content);
+ else if (equalIgnoringCase(name(), "format-detection"))
+ document()->processViewport(m_content);
else if (((equalIgnoringCase(name(), "HandheldFriendly") && equalIgnoringCase(m_content, "true")) || equalIgnoringCase(name(), "MobileOptimized"))
&& document()->settings()
&& document()->settings()->viewportWidth() == -1) {
// fit mobile sites directly in the screen
- document()->settings()->setMetadataSettings("width", "device-width");
- updateViewport = true;
+ document()->processViewport("width=device-width");
}
- // update the meta data if it is the top document
- if (updateViewport && !document()->ownerElement()) {
- FrameView* view = document()->view();
- if (view)
- PlatformBridge::updateViewport(view);
- }
-#else
- if (equalIgnoringCase(name(), "viewport"))
- document()->processViewport(m_content);
#endif
#if ENABLE(ANDROID_INSTALLABLE_WEB_APPS)
diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
index 1fd8ee9..7ff5b19 100644
--- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
+++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp
@@ -347,6 +347,22 @@ void ChromeClientAndroid::scrollbarsModeDidChange() const
notImplemented();
}
+void ChromeClientAndroid::dispatchViewportDataDidChange(const ViewportArguments& input) const {
+#ifdef ANDROID_META_SUPPORT
+ const ViewportArguments emptyArgument;
+ if (input == emptyArgument) {
+ // Empty Argument is for a page with no viewport meta tag; so reset everything.
+ m_webFrame->page()->settings()->resetMetadataSettings();
+ }
+ Document* doc = m_webFrame->page()->mainFrame()->document();
+ if (!doc->ownerElement()) {
+ FrameView* view = doc->view();
+ if (view)
+ PlatformBridge::updateViewport(view);
+ }
+#endif
+}
+
void ChromeClientAndroid::mouseDidMoveOverElement(const HitTestResult&, unsigned int) {}
void ChromeClientAndroid::setToolTip(const String&, TextDirection) {}
void ChromeClientAndroid::print(Frame*) {}
diff --git a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
index acb7792..36576e6 100644
--- a/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
+++ b/Source/WebKit/android/WebCoreSupport/ChromeClientAndroid.h
@@ -124,6 +124,8 @@ namespace android {
virtual void scrollRectIntoView(const IntRect&, const ScrollView*) const;
// End methods used by HostWindow.
+ virtual void dispatchViewportDataDidChange(const ViewportArguments&) const;
+
virtual void scrollbarsModeDidChange() const;
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned int);