Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index 655a8cc748bfa0a50d8e4865dad35acb5bfd7ed7..0e4498805358a3190f181523e3faf06f1c134405 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -43,6 +43,7 @@ |
| #include "bindings/v8/ScriptController.h" |
| #include "core/accessibility/AXObjectCache.h" |
| #include "core/animation/DocumentTimeline.h" |
| +#include "core/css/CSSDefaultStyleSheets.h" |
| #include "core/css/CSSStyleDeclaration.h" |
| #include "core/css/CSSStyleSheet.h" |
| #include "core/css/FontLoader.h" |
| @@ -428,6 +429,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
| , m_isViewSource(false) |
| , m_sawElementsInKnownNamespaces(false) |
| , m_isSrcdocDocument(false) |
| + , m_isMobileDocument(false) |
| , m_renderer(0) |
| , m_eventQueue(DocumentEventQueue::create(this)) |
| , m_weakFactory(this) |
| @@ -669,7 +671,7 @@ void Document::setDoctype(PassRefPtr<DocumentType> docType) |
| if (m_docType) { |
| this->adoptIfNeeded(m_docType.get()); |
| if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", /* caseSensitive */ false)) |
| - processViewport("width=device-width, height=device-height", ViewportArguments::XHTMLMobileProfile); |
| + m_isMobileDocument = true; |
|
kenneth.r.christiansen
2013/09/04 11:39:01
Hack using viewport meta, removed
|
| } |
| // Doctype affects the interpretation of the stylesheets. |
| clearStyleResolver(); |
| @@ -2924,13 +2926,44 @@ void Document::processViewport(const String& features, ViewportArguments::Type o |
| { |
| ASSERT(!features.isNull()); |
| - if (origin < m_viewportArguments.type) |
| + // We are adding viewport properties from a legacy meta tag. |
| + // The different meta tags have different priorities based on the type regardless |
| + // of which order they appear in the DOM. The priority is given by the |
| + // ViewportArguments::Type enum. If we process viewport properties with a lower |
| + // priority than an already processed meta tag, just ignore it. |
| + if (origin < m_legacyViewportArguments.type) |
| return; |
| - m_viewportArguments = ViewportArguments(origin); |
| - processArguments(features, (void*)&m_viewportArguments, &setViewportFeature); |
| + // Overwrite viewport arguments from previously encountered meta tags. |
| + m_legacyViewportArguments = ViewportArguments(origin); |
| - updateViewportArguments(); |
| + processArguments(features, (void*)&m_legacyViewportArguments, &setViewportFeature); |
| + |
| + if (m_legacyViewportArguments.minZoom == ViewportArguments::ValueAuto) |
| + m_legacyViewportArguments.minZoom = 0.25; |
| + |
| + if (m_legacyViewportArguments.maxZoom == ViewportArguments::ValueAuto) { |
| + m_legacyViewportArguments.maxZoom = 5; |
| + if (m_legacyViewportArguments.minZoom > 5) |
| + m_legacyViewportArguments.minZoom = 5; |
| + } |
| + |
| + if (m_legacyViewportArguments.maxWidth.isAuto()) { |
| + |
| + if (m_legacyViewportArguments.zoom == ViewportArguments::ValueAuto) { |
| + m_legacyViewportArguments.minWidth = Length(ExtendToZoom); |
| + m_legacyViewportArguments.maxWidth = Length(page()->settings().layoutFallbackWidth(), Fixed); |
| + } else if (m_legacyViewportArguments.maxHeight.isAuto()) { |
| + m_legacyViewportArguments.minWidth = m_legacyViewportArguments.maxWidth = Length(ExtendToZoom); |
| + } |
| + } |
| + |
| + // When no author style for @viewport is present, and a meta tag for defining the |
| + // viewport is present, apply the meta tag viewport arguments instead of the UA styles. |
| + if (m_viewportArguments.type != ViewportArguments::AuthorStyleSheet) { |
| + m_viewportArguments = m_legacyViewportArguments; |
| + updateViewportArguments(); |
| + } |
| } |
| void Document::updateViewportArguments() |