Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: Source/core/dom/Document.cpp

Issue 23742003: Use css-device-adapt constraining for legacy viewport tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed review issues. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 25 matching lines...) Expand all
36 #include "XMLNSNames.h" 36 #include "XMLNSNames.h"
37 #include "XMLNames.h" 37 #include "XMLNames.h"
38 #include "bindings/v8/CustomElementConstructorBuilder.h" 38 #include "bindings/v8/CustomElementConstructorBuilder.h"
39 #include "bindings/v8/Dictionary.h" 39 #include "bindings/v8/Dictionary.h"
40 #include "bindings/v8/ExceptionMessages.h" 40 #include "bindings/v8/ExceptionMessages.h"
41 #include "bindings/v8/ExceptionState.h" 41 #include "bindings/v8/ExceptionState.h"
42 #include "bindings/v8/ExceptionStatePlaceholder.h" 42 #include "bindings/v8/ExceptionStatePlaceholder.h"
43 #include "bindings/v8/ScriptController.h" 43 #include "bindings/v8/ScriptController.h"
44 #include "core/accessibility/AXObjectCache.h" 44 #include "core/accessibility/AXObjectCache.h"
45 #include "core/animation/DocumentTimeline.h" 45 #include "core/animation/DocumentTimeline.h"
46 #include "core/css/CSSDefaultStyleSheets.h"
46 #include "core/css/CSSStyleDeclaration.h" 47 #include "core/css/CSSStyleDeclaration.h"
47 #include "core/css/CSSStyleSheet.h" 48 #include "core/css/CSSStyleSheet.h"
48 #include "core/css/FontLoader.h" 49 #include "core/css/FontLoader.h"
49 #include "core/css/MediaQueryMatcher.h" 50 #include "core/css/MediaQueryMatcher.h"
50 #include "core/css/StylePropertySet.h" 51 #include "core/css/StylePropertySet.h"
51 #include "core/css/StyleSheetContents.h" 52 #include "core/css/StyleSheetContents.h"
52 #include "core/css/StyleSheetList.h" 53 #include "core/css/StyleSheetList.h"
53 #include "core/css/resolver/StyleResolver.h" 54 #include "core/css/resolver/StyleResolver.h"
54 #include "core/dom/Attr.h" 55 #include "core/dom/Attr.h"
55 #include "core/dom/BeforeUnloadEvent.h" 56 #include "core/dom/BeforeUnloadEvent.h"
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 , m_xmlStandalone(StandaloneUnspecified) 422 , m_xmlStandalone(StandaloneUnspecified)
422 , m_hasXMLDeclaration(0) 423 , m_hasXMLDeclaration(0)
423 , m_designMode(inherit) 424 , m_designMode(inherit)
424 , m_hasAnnotatedRegions(false) 425 , m_hasAnnotatedRegions(false)
425 , m_annotatedRegionsDirty(false) 426 , m_annotatedRegionsDirty(false)
426 , m_useSecureKeyboardEntryWhenActive(false) 427 , m_useSecureKeyboardEntryWhenActive(false)
427 , m_documentClasses(documentClasses) 428 , m_documentClasses(documentClasses)
428 , m_isViewSource(false) 429 , m_isViewSource(false)
429 , m_sawElementsInKnownNamespaces(false) 430 , m_sawElementsInKnownNamespaces(false)
430 , m_isSrcdocDocument(false) 431 , m_isSrcdocDocument(false)
432 , m_isMobileDocument(false)
431 , m_renderer(0) 433 , m_renderer(0)
432 , m_eventQueue(DocumentEventQueue::create(this)) 434 , m_eventQueue(DocumentEventQueue::create(this))
433 , m_weakFactory(this) 435 , m_weakFactory(this)
434 , m_idAttributeName(idAttr) 436 , m_idAttributeName(idAttr)
435 , m_hasFullscreenElementStack(false) 437 , m_hasFullscreenElementStack(false)
436 , m_loadEventDelayCount(0) 438 , m_loadEventDelayCount(0)
437 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 439 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
438 , m_referrerPolicy(ReferrerPolicyDefault) 440 , m_referrerPolicy(ReferrerPolicyDefault)
439 , m_directionSetOnDocumentElement(false) 441 , m_directionSetOnDocumentElement(false)
440 , m_writingModeSetOnDocumentElement(false) 442 , m_writingModeSetOnDocumentElement(false)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 } 663 }
662 664
663 void Document::setDoctype(PassRefPtr<DocumentType> docType) 665 void Document::setDoctype(PassRefPtr<DocumentType> docType)
664 { 666 {
665 // This should never be called more than once. 667 // This should never be called more than once.
666 ASSERT(!m_docType || !docType); 668 ASSERT(!m_docType || !docType);
667 m_docType = docType; 669 m_docType = docType;
668 if (m_docType) { 670 if (m_docType) {
669 this->adoptIfNeeded(m_docType.get()); 671 this->adoptIfNeeded(m_docType.get());
670 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", /* caseSensitive */ false)) 672 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", /* caseSensitive */ false))
671 processViewport("width=device-width, height=device-height", Viewport Arguments::XHTMLMobileProfile); 673 m_isMobileDocument = true;
672 } 674 }
673 // Doctype affects the interpretation of the stylesheets. 675 // Doctype affects the interpretation of the stylesheets.
674 clearStyleResolver(); 676 clearStyleResolver();
675 } 677 }
676 678
677 DOMImplementation* Document::implementation() 679 DOMImplementation* Document::implementation()
678 { 680 {
679 if (!m_implementation) 681 if (!m_implementation)
680 m_implementation = DOMImplementation::create(this); 682 m_implementation = DOMImplementation::create(this);
681 return m_implementation.get(); 683 return m_implementation.get();
(...skipping 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2916 callback(keyString, valueString, this, data); 2918 callback(keyString, valueString, this, data);
2917 } 2919 }
2918 if (error) 2920 if (error)
2919 reportViewportWarning(this, InvalidKeyValuePairSeparatorError, String(), String()); 2921 reportViewportWarning(this, InvalidKeyValuePairSeparatorError, String(), String());
2920 } 2922 }
2921 2923
2922 void Document::processViewport(const String& features, ViewportArguments::Type o rigin) 2924 void Document::processViewport(const String& features, ViewportArguments::Type o rigin)
2923 { 2925 {
2924 ASSERT(!features.isNull()); 2926 ASSERT(!features.isNull());
2925 2927
2926 if (origin < m_viewportArguments.type) 2928 // We are adding viewport properties from a legacy meta tag.
2929 // The different meta tags have different priorities based on the type regar dless
2930 // of which order they appear in the DOM. The priority is given by the
2931 // ViewportArguments::Type enum. If we process viewport properties with a lo wer
2932 // priority than an already processed meta tag, just ignore it.
2933 if (origin < m_legacyViewportArguments.type)
2927 return; 2934 return;
2928 2935
2929 m_viewportArguments = ViewportArguments(origin); 2936 // Overwrite viewport arguments from previously encountered meta tags.
2930 processArguments(features, (void*)&m_viewportArguments, &setViewportFeature) ; 2937 m_legacyViewportArguments = ViewportArguments(origin);
2931 2938
2932 updateViewportArguments(); 2939 processArguments(features, (void*)&m_legacyViewportArguments, &setViewportFe ature);
2940
2941 if (m_legacyViewportArguments.minZoom == ViewportArguments::ValueAuto)
2942 m_legacyViewportArguments.minZoom = 0.25;
2943
2944 if (m_legacyViewportArguments.maxZoom == ViewportArguments::ValueAuto) {
2945 m_legacyViewportArguments.maxZoom = 5;
2946 if (m_legacyViewportArguments.minZoom > 5)
2947 m_legacyViewportArguments.minZoom = 5;
2948 }
2949
2950 if (m_legacyViewportArguments.maxWidth == ViewportArguments::ValueAuto) {
2951
2952 if (m_legacyViewportArguments.zoom == ViewportArguments::ValueAuto) {
2953 m_legacyViewportArguments.minWidth = ViewportArguments::ValueExtendT oZoom;
2954 m_legacyViewportArguments.maxWidth = page()->settings().layoutFallba ckWidth();
2955 } else if (m_legacyViewportArguments.maxHeight == ViewportArguments::Val ueAuto) {
2956 m_legacyViewportArguments.minWidth = m_legacyViewportArguments.maxWi dth = ViewportArguments::ValueExtendToZoom;
2957 }
2958 }
2959
2960 if (m_viewportArguments.type != ViewportArguments::AuthorStyleSheet)
2961 useLegacyViewportArguments();
2933 } 2962 }
2934 2963
2935 void Document::updateViewportArguments() 2964 void Document::updateViewportArguments()
2936 { 2965 {
2937 if (page() && page()->mainFrame() == frame()) { 2966 if (page() && page()->mainFrame() == frame()) {
2938 #ifndef NDEBUG 2967 #ifndef NDEBUG
2939 m_didDispatchViewportPropertiesChanged = true; 2968 m_didDispatchViewportPropertiesChanged = true;
2940 #endif 2969 #endif
2941 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments ); 2970 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments );
2942 } 2971 }
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
5294 { 5323 {
5295 return DocumentLifecycleNotifier::create(this); 5324 return DocumentLifecycleNotifier::create(this);
5296 } 5325 }
5297 5326
5298 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5327 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5299 { 5328 {
5300 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5329 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5301 } 5330 }
5302 5331
5303 } // namespace WebCore 5332 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698