From 4604c0d13ca11ad633e6b3f7adb64c6ee886705d Mon Sep 17 00:00:00 2001 From: Grace Kloba Date: Mon, 17 Aug 2009 16:00:17 -0700 Subject: Fix #2058833. For mobile sites, add "width=device-width" if viewport width is not defined as our default viewport width is 800px now. --- WebCore/html/HTMLBodyElement.cpp | 13 +++++++++++++ WebCore/html/HTMLMetaElement.cpp | 8 ++++++++ 2 files changed, 21 insertions(+) (limited to 'WebCore') diff --git a/WebCore/html/HTMLBodyElement.cpp b/WebCore/html/HTMLBodyElement.cpp index 9828dab..9852858 100644 --- a/WebCore/html/HTMLBodyElement.cpp +++ b/WebCore/html/HTMLBodyElement.cpp @@ -39,6 +39,10 @@ #include "MappedAttribute.h" #include "ScriptEventListener.h" +#ifdef ANDROID_META_SUPPORT +#include "Settings.h" +#endif + namespace WebCore { using namespace HTMLNames; @@ -173,6 +177,15 @@ void HTMLBodyElement::insertedIntoDocument() setAttribute(marginheightAttr, String::number(marginHeight)); } +#ifdef ANDROID_META_SUPPORT + 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."))) + // fit mobile sites directly in the screen + settings->setMetadataSettings("width", "device-width"); +#endif + // FIXME: This call to scheduleRelayout should not be needed here. // But without it we hang during WebKit tests; need to fix that and remove this. if (FrameView* view = document()->view()) diff --git a/WebCore/html/HTMLMetaElement.cpp b/WebCore/html/HTMLMetaElement.cpp index 48284e3..5d3e925 100644 --- a/WebCore/html/HTMLMetaElement.cpp +++ b/WebCore/html/HTMLMetaElement.cpp @@ -27,6 +27,10 @@ #include "HTMLNames.h" #include "MappedAttribute.h" +#ifdef ANDROID_META_SUPPORT +#include "Settings.h" +#endif + namespace WebCore { using namespace HTMLNames; @@ -68,6 +72,10 @@ void HTMLMetaElement::process() return; if (equalIgnoringCase(name(), "viewport") || 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"); #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) -- cgit v1.1