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

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: Review issue: one assignent per line/statement 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
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/ViewportArguments.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/CSSFontSelector.h" 47 #include "core/css/CSSFontSelector.h"
47 #include "core/css/CSSStyleDeclaration.h" 48 #include "core/css/CSSStyleDeclaration.h"
48 #include "core/css/CSSStyleSheet.h" 49 #include "core/css/CSSStyleSheet.h"
49 #include "core/css/FontLoader.h" 50 #include "core/css/FontLoader.h"
50 #include "core/css/MediaQueryMatcher.h" 51 #include "core/css/MediaQueryMatcher.h"
51 #include "core/css/StylePropertySet.h" 52 #include "core/css/StylePropertySet.h"
52 #include "core/css/StyleSheetContents.h" 53 #include "core/css/StyleSheetContents.h"
53 #include "core/css/StyleSheetList.h" 54 #include "core/css/StyleSheetList.h"
54 #include "core/css/resolver/FontBuilder.h" 55 #include "core/css/resolver/FontBuilder.h"
55 #include "core/css/resolver/StyleResolver.h" 56 #include "core/css/resolver/StyleResolver.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 , m_xmlStandalone(StandaloneUnspecified) 425 , m_xmlStandalone(StandaloneUnspecified)
425 , m_hasXMLDeclaration(0) 426 , m_hasXMLDeclaration(0)
426 , m_designMode(inherit) 427 , m_designMode(inherit)
427 , m_hasAnnotatedRegions(false) 428 , m_hasAnnotatedRegions(false)
428 , m_annotatedRegionsDirty(false) 429 , m_annotatedRegionsDirty(false)
429 , m_useSecureKeyboardEntryWhenActive(false) 430 , m_useSecureKeyboardEntryWhenActive(false)
430 , m_documentClasses(documentClasses) 431 , m_documentClasses(documentClasses)
431 , m_isViewSource(false) 432 , m_isViewSource(false)
432 , m_sawElementsInKnownNamespaces(false) 433 , m_sawElementsInKnownNamespaces(false)
433 , m_isSrcdocDocument(false) 434 , m_isSrcdocDocument(false)
435 , m_isMobileDocument(false)
434 , m_renderer(0) 436 , m_renderer(0)
435 , m_eventQueue(DocumentEventQueue::create(this)) 437 , m_eventQueue(DocumentEventQueue::create(this))
436 , m_weakFactory(this) 438 , m_weakFactory(this)
437 , m_idAttributeName(idAttr) 439 , m_idAttributeName(idAttr)
438 , m_hasFullscreenElementStack(false) 440 , m_hasFullscreenElementStack(false)
439 , m_loadEventDelayCount(0) 441 , m_loadEventDelayCount(0)
440 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) 442 , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired)
441 , m_referrerPolicy(ReferrerPolicyDefault) 443 , m_referrerPolicy(ReferrerPolicyDefault)
442 , m_directionSetOnDocumentElement(false) 444 , m_directionSetOnDocumentElement(false)
443 , m_writingModeSetOnDocumentElement(false) 445 , m_writingModeSetOnDocumentElement(false)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 666 }
665 667
666 void Document::setDoctype(PassRefPtr<DocumentType> docType) 668 void Document::setDoctype(PassRefPtr<DocumentType> docType)
667 { 669 {
668 // This should never be called more than once. 670 // This should never be called more than once.
669 ASSERT(!m_docType || !docType); 671 ASSERT(!m_docType || !docType);
670 m_docType = docType; 672 m_docType = docType;
671 if (m_docType) { 673 if (m_docType) {
672 this->adoptIfNeeded(m_docType.get()); 674 this->adoptIfNeeded(m_docType.get());
673 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", /* caseSensitive */ false)) 675 if (m_docType->publicId().startsWith("-//wapforum//dtd xhtml mobile 1.", /* caseSensitive */ false))
674 processViewport("width=device-width, height=device-height", Viewport Arguments::XHTMLMobileProfile); 676 m_isMobileDocument = true;
675 } 677 }
676 // Doctype affects the interpretation of the stylesheets. 678 // Doctype affects the interpretation of the stylesheets.
677 clearStyleResolver(); 679 clearStyleResolver();
678 } 680 }
679 681
680 DOMImplementation* Document::implementation() 682 DOMImplementation* Document::implementation()
681 { 683 {
682 if (!m_implementation) 684 if (!m_implementation)
683 m_implementation = DOMImplementation::create(this); 685 m_implementation = DOMImplementation::create(this);
684 return m_implementation.get(); 686 return m_implementation.get();
(...skipping 2305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2990 callback(keyString, valueString, this, data); 2992 callback(keyString, valueString, this, data);
2991 } 2993 }
2992 if (error) 2994 if (error)
2993 reportViewportWarning(this, InvalidKeyValuePairSeparatorError, String(), String()); 2995 reportViewportWarning(this, InvalidKeyValuePairSeparatorError, String(), String());
2994 } 2996 }
2995 2997
2996 void Document::processViewport(const String& features, ViewportArguments::Type o rigin) 2998 void Document::processViewport(const String& features, ViewportArguments::Type o rigin)
2997 { 2999 {
2998 ASSERT(!features.isNull()); 3000 ASSERT(!features.isNull());
2999 3001
3000 if (origin < m_viewportArguments.type) 3002 // We are adding viewport properties from a legacy meta tag.
3003 // The different meta tags have different priorities based on the type regar dless
3004 // of which order they appear in the DOM. The priority is given by the
3005 // ViewportArguments::Type enum. If we process viewport properties with a lo wer
3006 // priority than an already processed meta tag, just ignore it.
3007 if (origin < m_legacyViewportArguments.type)
3001 return; 3008 return;
3002 3009
3003 m_viewportArguments = ViewportArguments(origin); 3010 // Overwrite viewport arguments from previously encountered meta tags.
3004 processArguments(features, (void*)&m_viewportArguments, &setViewportFeature) ; 3011 m_legacyViewportArguments = ViewportArguments(origin);
3005 3012
3006 if (page() && page()->settings().viewportMetaZeroValuesQuirk() && m_viewport Arguments.type == ViewportArguments::ViewportMeta 3013 processArguments(features, (void*)&m_legacyViewportArguments, &setViewportFe ature);
3007 && m_viewportArguments.width == ViewportArguments::ValueDeviceWidth && ! static_cast<int>(m_viewportArguments.zoom))
3008 m_viewportArguments.zoom = 1.0;
3009 3014
3010 updateViewportArguments(); 3015 if (m_legacyViewportArguments.minZoom == ViewportArguments::ValueAuto)
3016 m_legacyViewportArguments.minZoom = 0.25;
3017
3018 if (m_legacyViewportArguments.maxZoom == ViewportArguments::ValueAuto) {
3019 m_legacyViewportArguments.maxZoom = 5;
3020 if (m_legacyViewportArguments.minZoom > 5)
3021 m_legacyViewportArguments.minZoom = 5;
3022 }
3023
3024 if (m_legacyViewportArguments.maxWidth.isAuto()) {
3025
3026 if (m_legacyViewportArguments.zoom == ViewportArguments::ValueAuto) {
3027 m_legacyViewportArguments.minWidth = Length(ExtendToZoom);
3028 m_legacyViewportArguments.maxWidth = Length(page()->settings().layou tFallbackWidth(), Fixed);
3029 } else if (m_legacyViewportArguments.maxHeight.isAuto()) {
3030 m_legacyViewportArguments.minWidth = m_legacyViewportArguments.maxWi dth = Length(ExtendToZoom);
3031 }
3032 }
3033
3034 if (page() && page()->settings().viewportMetaZeroValuesQuirk() && m_legacyVi ewportArguments.type == ViewportArguments::ViewportMeta
3035 && m_legacyViewportArguments.maxWidth.type() == ViewportPercentageWidth && !static_cast<int>(m_legacyViewportArguments.zoom))
3036 m_legacyViewportArguments.zoom = 1.0;
3037
3038 // When no author style for @viewport is present, and a meta tag for definin g the
3039 // viewport is present, apply the meta tag viewport arguments instead of the UA styles.
3040 if (m_viewportArguments.type != ViewportArguments::AuthorStyleSheet) {
3041 m_viewportArguments = m_legacyViewportArguments;
3042 updateViewportArguments();
3043 }
3011 } 3044 }
3012 3045
3013 void Document::updateViewportArguments() 3046 void Document::updateViewportArguments()
3014 { 3047 {
3015 if (page() && page()->mainFrame() == frame()) { 3048 if (page() && page()->mainFrame() == frame()) {
3016 #ifndef NDEBUG 3049 #ifndef NDEBUG
3017 m_didDispatchViewportPropertiesChanged = true; 3050 m_didDispatchViewportPropertiesChanged = true;
3018 #endif 3051 #endif
3019 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments ); 3052 page()->chrome().dispatchViewportPropertiesDidChange(m_viewportArguments );
3020 } 3053 }
(...skipping 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after
5372 { 5405 {
5373 return DocumentLifecycleNotifier::create(this); 5406 return DocumentLifecycleNotifier::create(this);
5374 } 5407 }
5375 5408
5376 DocumentLifecycleNotifier* Document::lifecycleNotifier() 5409 DocumentLifecycleNotifier* Document::lifecycleNotifier()
5377 { 5410 {
5378 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier()); 5411 return static_cast<DocumentLifecycleNotifier*>(ScriptExecutionContext::lifec ycleNotifier());
5379 } 5412 }
5380 5413
5381 } // namespace WebCore 5414 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/ViewportArguments.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698