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

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

Issue 1930363002: Avoid clobbering state in viewport tag initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 4 years, 7 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 3132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 } 3143 }
3144 3144
3145 if (httpRefreshType == HttpRefreshFromMetaTag && isSandboxed(SandboxAutomati cFeatures)) { 3145 if (httpRefreshType == HttpRefreshFromMetaTag && isSandboxed(SandboxAutomati cFeatures)) {
3146 String message = "Refused to execute the redirect specified via '<meta h ttp-equiv='refresh' content='...'>'. The document is sandboxed, and the 'allow-s cripts' keyword is not set."; 3146 String message = "Refused to execute the redirect specified via '<meta h ttp-equiv='refresh' content='...'>'. The document is sandboxed, and the 'allow-s cripts' keyword is not set.";
3147 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message)); 3147 addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMes sageLevel, message));
3148 return; 3148 return;
3149 } 3149 }
3150 m_frame->navigationScheduler().scheduleRedirect(delay, refreshURL); 3150 m_frame->navigationScheduler().scheduleRedirect(delay, refreshURL);
3151 } 3151 }
3152 3152
3153 bool Document::shouldMergeWithLegacyDescription(ViewportDescription::Type origin ) 3153 bool Document::shouldMergeWithLegacyDescription(ViewportDescription::Type origin ) const
3154 { 3154 {
3155 return settings() && settings()->viewportMetaMergeContentQuirk() && m_legacy ViewportDescription.isMetaViewportType() && m_legacyViewportDescription.type == origin; 3155 return settings() && settings()->viewportMetaMergeContentQuirk() && m_legacy ViewportDescription.isMetaViewportType() && m_legacyViewportDescription.type == origin;
3156 } 3156 }
3157 3157
3158 void Document::setViewportDescription(const ViewportDescription& viewportDescrip tion) 3158 void Document::setViewportDescription(const ViewportDescription& viewportDescrip tion)
3159 { 3159 {
3160 if (viewportDescription == m_viewportDescription) 3160 if (viewportDescription == m_viewportDescription)
dgozman 2016/05/09 17:36:19 This check looks strange now (and was before). Why
aelias_OOO_until_Jul13 2016/05/09 23:56:02 Agreed it's weird now. I'd like to preserve a saf
3161 return; 3161 return;
3162 3162
3163 if (settings() && !settings()->viewportMetaEnabled() && viewportDescription. isLegacyViewportType())
3164 return;
3165
3166 // The UA-defined min-width is used by the processing of legacy meta tags. 3163 // The UA-defined min-width is used by the processing of legacy meta tags.
3167 if (!viewportDescription.isSpecifiedByAuthor()) 3164 if (!viewportDescription.isSpecifiedByAuthor())
3168 m_viewportDefaultMinWidth = viewportDescription.minWidth; 3165 m_viewportDefaultMinWidth = viewportDescription.minWidth;
dgozman 2016/05/09 17:36:19 Should we do something similar to |m_viewportDefau
aelias_OOO_until_Jul13 2016/05/09 23:56:02 I don't think there's a risk of bugs with this one
3169 3166
3170 if (viewportDescription.isLegacyViewportType()) { 3167 if (viewportDescription.isLegacyViewportType()) {
3171 m_legacyViewportDescription = viewportDescription; 3168 m_legacyViewportDescription = viewportDescription;
3172 3169 } else {
3173 // When no author style for @viewport is present, and a meta tag for def ining
3174 // the viewport is, apply the meta tag viewport instead of the UA styles .
3175 if (m_viewportDescription.type == ViewportDescription::AuthorStyleSheet)
3176 return;
3177 m_viewportDescription = viewportDescription; 3170 m_viewportDescription = viewportDescription;
3178 } else {
3179 // If the legacy viewport tag has higher priority than the cascaded @vie wport
3180 // descriptors, use the values from the legacy tag.
3181 if (!shouldOverrideLegacyDescription(viewportDescription.type))
3182 m_viewportDescription = m_legacyViewportDescription;
3183 else
3184 m_viewportDescription = viewportDescription;
3185 } 3171 }
3186 3172
3187 updateViewportDescription(); 3173 updateViewportDescription();
3188 } 3174 }
3189 3175
3176 ViewportDescription Document::viewportDescription() const
3177 {
3178 ViewportDescription appliedViewportDescription = m_viewportDescription;
3179 bool viewportMetaEnabled = settings() && settings()->viewportMetaEnabled();
3180 if (m_legacyViewportDescription.type != ViewportDescription::UserAgentStyleS heet && viewportMetaEnabled)
3181 appliedViewportDescription = m_legacyViewportDescription;
3182 if (shouldOverrideLegacyDescription(m_viewportDescription.type))
3183 appliedViewportDescription = m_viewportDescription;
3184
3185 return appliedViewportDescription;
3186 }
3187
3190 void Document::updateViewportDescription() 3188 void Document::updateViewportDescription()
3191 { 3189 {
3192 if (frame() && frame()->isMainFrame()) { 3190 if (frame() && frame()->isMainFrame()) {
3193 frameHost()->chromeClient().dispatchViewportPropertiesDidChange(m_viewpo rtDescription); 3191 frameHost()->chromeClient().dispatchViewportPropertiesDidChange(viewport Description());
3194 } 3192 }
3195 } 3193 }
3196 3194
3197 void Document::processReferrerPolicy(const String& policy) 3195 void Document::processReferrerPolicy(const String& policy)
3198 { 3196 {
3199 ReferrerPolicy referrerPolicy; 3197 ReferrerPolicy referrerPolicy;
3200 if (!SecurityPolicy::referrerPolicyFromString(policy, &referrerPolicy)) { 3198 if (!SecurityPolicy::referrerPolicyFromString(policy, &referrerPolicy)) {
3201 addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMe ssageLevel, "Failed to set referrer policy: The value '" + policy + "' is not on e of 'always', 'default', 'never', 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-crossorigin', or 'unsafe-url'. This document's referrer p olicy has been left unchanged.")); 3199 addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMe ssageLevel, "Failed to set referrer policy: The value '" + policy + "' is not on e of 'always', 'default', 'never', 'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-crossorigin', or 'unsafe-url'. This document's referrer p olicy has been left unchanged."));
3202 return; 3200 return;
3203 } 3201 }
(...skipping 2824 matching lines...) Expand 10 before | Expand all | Expand 10 after
6028 #ifndef NDEBUG 6026 #ifndef NDEBUG
6029 using namespace blink; 6027 using namespace blink;
6030 void showLiveDocumentInstances() 6028 void showLiveDocumentInstances()
6031 { 6029 {
6032 Document::WeakDocumentSet& set = Document::liveDocumentSet(); 6030 Document::WeakDocumentSet& set = Document::liveDocumentSet();
6033 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6031 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6034 for (Document* document : set) 6032 for (Document* document : set)
6035 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data()); 6033 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get String().utf8().data());
6036 } 6034 }
6037 #endif 6035 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698