Diff
Modified: tags/Safari-606.1.9.4/Source/WebCore/ChangeLog (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/ChangeLog 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/ChangeLog 2018-03-19 21:27:18 UTC (rev 229717)
@@ -1,3 +1,86 @@
+2018-03-19 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r229654. rdar://problem/38382934
+
+ 2018-03-15 Megan Gardner <megan_gard...@apple.com>
+
+ Create MediaQueryParserContext to provide additional context for the evaluation of media queries
+ https://bugs.webkit.org/show_bug.cgi?id=183677
+
+ Reviewed by Tim Horton.
+
+ We need additional context for parsing media queries to make sure they are parsed correctly and valid.
+
+ Not currently testable, will add tests in a later patch.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/MediaList.cpp:
+ (WebCore::MediaQuerySet::create):
+ (WebCore::MediaQuerySet::set):
+ (WebCore::MediaQuerySet::add):
+ (WebCore::MediaQuerySet::remove):
+ * css/MediaList.h:
+ * css/MediaQueryEvaluator.cpp:
+ (WebCore::MediaQueryEvaluator::mediaAttributeMatches):
+ * css/MediaQueryExpression.cpp:
+ (WebCore::featureWithValidIdent):
+ (WebCore::featureWithValidDensity):
+ (WebCore::featureWithValidPositiveLength):
+ (WebCore::featureWithPositiveInteger):
+ (WebCore::featureWithPositiveNumber):
+ (WebCore::featureWithZeroOrOne):
+ (WebCore::isFeatureValidWithoutValue):
+ (WebCore::MediaQueryExpression::MediaQueryExpression):
+ * css/MediaQueryExpression.h:
+ * css/MediaQueryMatcher.cpp:
+ (WebCore::MediaQueryMatcher::matchMedia):
+ * css/MediaQueryParserContext.cpp: Added.
+ (WebCore::MediaQueryParserContext::MediaQueryParserContext):
+ * css/MediaQueryParserContext.h: Added.
+ (WebCore::MediaQueryParserContext::MediaQueryParserContext):
+ * css/StyleMedia.cpp:
+ (WebCore::StyleMedia::matchMedium const):
+ * css/StyleRuleImport.cpp:
+ (WebCore::StyleRuleImport::StyleRuleImport):
+ (WebCore::StyleRuleImport::setCSSStyleSheet):
+ * css/parser/CSSParser.cpp:
+ (WebCore::CSSParserContext::CSSParserContext):
+ (WebCore::operator==):
+ * css/parser/CSSParserImpl.cpp:
+ (WebCore::CSSParserImpl::consumeImportRule):
+ (WebCore::CSSParserImpl::consumeMediaRule):
+ * css/parser/MediaQueryParser.cpp:
+ (WebCore::MediaQueryParser::parseMediaQuerySet):
+ (WebCore::MediaQueryParser::parseMediaCondition):
+ (WebCore::MediaQueryParser::MediaQueryParser):
+ (WebCore::MediaQueryData::addExpression):
+ * css/parser/MediaQueryParser.h:
+ (WebCore::MediaQueryData::setMediaQueryParserContext):
+ * css/parser/SizesAttributeParser.cpp:
+ (WebCore::SizesAttributeParser::parse):
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createCSSStyleSheet):
+ * dom/InlineStyleSheetOwner.cpp:
+ (WebCore::InlineStyleSheetOwner::createSheet):
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::setCSSStyleSheet):
+ * html/HTMLImageElement.cpp:
+ (WebCore::HTMLImageElement::bestFitSourceFromPictureElement):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::process):
+ (WebCore::HTMLLinkElement::initializeStyleSheet):
+ (WebCore::HTMLLinkElement::setCSSStyleSheet):
+ * html/HTMLLinkElement.h:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::selectNextSourceChild):
+ * html/HTMLSourceElement.cpp:
+ (WebCore::HTMLSourceElement::parsedMediaAttribute const):
+ * html/HTMLSourceElement.h:
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::parseAttribute):
+ * html/parser/HTMLPreloadScanner.cpp:
+ (WebCore::TokenPreloadScanner::StartTagScanner::processAttribute):
+
2018-03-16 Jason Marcell <jmarc...@apple.com>
Cherry-pick r229597. rdar://problem/38431469
Modified: tags/Safari-606.1.9.4/Source/WebCore/Sources.txt (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/Sources.txt 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/Sources.txt 2018-03-19 21:27:18 UTC (rev 229717)
@@ -630,6 +630,7 @@
css/MediaQueryExpression.cpp
css/MediaQueryList.cpp
css/MediaQueryMatcher.cpp
+css/MediaQueryParserContext.cpp
css/PageRuleCollector.cpp
css/PropertySetCSSStyleDeclaration.cpp
css/RGBColor.cpp
Modified: tags/Safari-606.1.9.4/Source/WebCore/WebCore.xcodeproj/project.pbxproj (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-03-19 21:27:18 UTC (rev 229717)
@@ -1171,6 +1171,7 @@
443918001A91B2F8006E04F2 /* QuickLookSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 443917FE1A91B2F8006E04F2 /* QuickLookSoftLink.h */; };
445775E520472F73008DCE5D /* LocalDefaultSystemAppearance.h in Headers */ = {isa = PBXBuildFile; fileRef = 445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */; };
445775EA2047303C008DCE5D /* LocalDefaultSystemAppearance.mm in Sources */ = {isa = PBXBuildFile; fileRef = 445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */; };
+ 4471710E205AF945000A116E /* MediaQueryParserContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 4471710C205AF945000A116E /* MediaQueryParserContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
447958041643B49A001E0A7F /* ParsedContentType.h in Headers */ = {isa = PBXBuildFile; fileRef = 447958031643B47B001E0A7F /* ParsedContentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
448A29BF0A46D9CB0030759F /* JSHTMLOptionsCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 448A29BD0A46D9CB0030759F /* JSHTMLOptionsCollection.h */; settings = {ATTRIBUTES = (Private, ); }; };
448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */ = {isa = PBXBuildFile; fileRef = 448B1B780F3A2F9B0047A9E2 /* TextSizeAdjustment.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7372,6 +7373,8 @@
444D4E210F708B2E003158E0 /* WebCoreURLResponseIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreURLResponseIOS.mm; sourceTree = "<group>"; };
445775E420472F73008DCE5D /* LocalDefaultSystemAppearance.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalDefaultSystemAppearance.h; sourceTree = "<group>"; };
445775E92047303B008DCE5D /* LocalDefaultSystemAppearance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalDefaultSystemAppearance.mm; sourceTree = "<group>"; };
+ 4471710B205AF945000A116E /* MediaQueryParserContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaQueryParserContext.cpp; sourceTree = "<group>"; };
+ 4471710C205AF945000A116E /* MediaQueryParserContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaQueryParserContext.h; sourceTree = "<group>"; };
4476531A133170990006B789 /* SSLKeyGeneratorIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SSLKeyGeneratorIOS.cpp; sourceTree = "<group>"; };
447958021643B47B001E0A7F /* ParsedContentType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ParsedContentType.cpp; sourceTree = "<group>"; };
447958031643B47B001E0A7F /* ParsedContentType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsedContentType.h; sourceTree = "<group>"; };
@@ -25347,6 +25350,8 @@
D3A94A35122DABAC00A37BBC /* MediaQueryListListener.idl */,
D3AA10F1123A98AA0092152B /* MediaQueryMatcher.cpp */,
D3AA10F2123A98AA0092152B /* MediaQueryMatcher.h */,
+ 4471710B205AF945000A116E /* MediaQueryParserContext.cpp */,
+ 4471710C205AF945000A116E /* MediaQueryParserContext.h */,
FBDB619C16D6034600BB3394 /* PageRuleCollector.cpp */,
FBDB61A016D6037E00BB3394 /* PageRuleCollector.h */,
A80E6CD10A1989CA007FB8C5 /* Pair.h */,
@@ -28986,6 +28991,7 @@
D3A94A3B122DABAC00A37BBC /* MediaQueryListListener.h in Headers */,
D3AA10F4123A98AA0092152B /* MediaQueryMatcher.h in Headers */,
9493B6C11D74B4120088E780 /* MediaQueryParser.h in Headers */,
+ 4471710E205AF945000A116E /* MediaQueryParserContext.h in Headers */,
C90843D01B18E47D00B68564 /* MediaRemoteControls.h in Headers */,
CD8ACA8F1D23971900ECC59E /* MediaRemoteSoftLink.h in Headers */,
CEEFCD7A19DB31F7003876D7 /* MediaResourceLoader.h in Headers */,
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -61,12 +61,12 @@
* throw SyntaxError exception.
*/
-Ref<MediaQuerySet> MediaQuerySet::create(const String& mediaString)
+Ref<MediaQuerySet> MediaQuerySet::create(const String& mediaString, MediaQueryParserContext context)
{
if (mediaString.isEmpty())
return MediaQuerySet::create();
- return MediaQueryParser::parseMediaQuerySet(mediaString).releaseNonNull();
+ return MediaQueryParser::parseMediaQuerySet(mediaString, context).releaseNonNull();
}
MediaQuerySet::MediaQuerySet() = default;
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.h (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.h 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaList.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -21,6 +21,7 @@
#pragma once
#include "ExceptionOr.h"
+#include "MediaQueryParserContext.h"
#include <memory>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
@@ -43,9 +44,8 @@
{
return adoptRef(*new MediaQuerySet);
}
+ static WEBCORE_EXPORT Ref<MediaQuerySet> create(const String& mediaString, MediaQueryParserContext = MediaQueryParserContext());
- static WEBCORE_EXPORT Ref<MediaQuerySet> create(const String& mediaString);
-
WEBCORE_EXPORT ~MediaQuerySet();
bool set(const String&);
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryEvaluator.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryEvaluator.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryEvaluator.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -39,6 +39,7 @@
#include "MediaFeatureNames.h"
#include "MediaList.h"
#include "MediaQuery.h"
+#include "MediaQueryParserContext.h"
#include "NodeRenderStyle.h"
#include "Page.h"
#include "PlatformScreen.h"
@@ -813,8 +814,8 @@
bool MediaQueryEvaluator::mediaAttributeMatches(Document& document, const String& attributeValue)
{
ASSERT(document.renderView());
- auto mediaQueries = MediaQuerySet::create(attributeValue);
+ auto mediaQueries = MediaQuerySet::create(attributeValue, MediaQueryParserContext(document));
return MediaQueryEvaluator { "screen", document, &document.renderView()->style() }.evaluate(mediaQueries.get());
}
-} // namespace
+} // WebCore
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -32,12 +32,13 @@
#include "CSSPrimitiveValue.h"
#include "CSSPropertyParserHelpers.h"
#include "MediaFeatureNames.h"
+#include "MediaQueryParserContext.h"
#include <wtf/text/TextStream.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
-static inline bool featureWithValidIdent(const AtomicString& mediaFeature, const CSSPrimitiveValue& value)
+static inline bool featureWithValidIdent(const AtomicString& mediaFeature, const CSSPrimitiveValue& value, const MediaQueryParserContext& context)
{
if (value.primitiveType() != CSSPrimitiveValue::UnitType::CSS_IDENT)
return false;
@@ -53,7 +54,7 @@
|| mediaFeature == MediaFeatureNames::displayMode
#endif
|| mediaFeature == MediaFeatureNames::prefersReducedMotion
- || mediaFeature == MediaFeatureNames::defaultAppearance;
+ || (mediaFeature == MediaFeatureNames::defaultAppearance && context.useSystemAppearance);
}
static inline bool featureWithValidDensity(const String& mediaFeature, const CSSPrimitiveValue& value)
@@ -137,7 +138,7 @@
|| mediaFeature == MediaFeatureNames::maxDeviceAspectRatio;
}
-static inline bool isFeatureValidWithoutValue(const AtomicString& mediaFeature)
+static inline bool isFeatureValidWithoutValue(const AtomicString& mediaFeature, const MediaQueryParserContext& context)
{
// Media features that are prefixed by min/max cannot be used without a value.
return mediaFeature == MediaFeatureNames::anyHover
@@ -161,7 +162,7 @@
|| mediaFeature == MediaFeatureNames::invertedColors
|| mediaFeature == MediaFeatureNames::pointer
|| mediaFeature == MediaFeatureNames::prefersReducedMotion
- || mediaFeature == MediaFeatureNames::defaultAppearance
+ || (mediaFeature == MediaFeatureNames::defaultAppearance && context.useSystemAppearance)
|| mediaFeature == MediaFeatureNames::devicePixelRatio
|| mediaFeature == MediaFeatureNames::resolution
#if ENABLE(APPLICATION_MANIFEST)
@@ -192,13 +193,13 @@
return nullptr;
}
-MediaQueryExpression::MediaQueryExpression(const String& feature, CSSParserTokenRange& range)
+MediaQueryExpression::MediaQueryExpression(const String& feature, CSSParserTokenRange& range, MediaQueryParserContext& context)
: m_mediaFeature(feature.convertToASCIILowercase())
, m_isValid(false)
{
RefPtr<CSSPrimitiveValue> firstValue = consumeFirstValue(m_mediaFeature, range);
if (!firstValue) {
- if (isFeatureValidWithoutValue(m_mediaFeature)) {
+ if (isFeatureValidWithoutValue(m_mediaFeature, context)) {
// Valid, creates a MediaQueryExp with an 'invalid' MediaQueryExpValue
m_isValid = true;
}
@@ -222,7 +223,7 @@
}
if (featureWithPositiveInteger(m_mediaFeature, *firstValue) || featureWithPositiveNumber(m_mediaFeature, *firstValue)
|| featureWithZeroOrOne(m_mediaFeature, *firstValue) || featureWithValidDensity(m_mediaFeature, *firstValue)
- || featureWithValidPositiveLength(m_mediaFeature, *firstValue) || featureWithValidIdent(m_mediaFeature, *firstValue)) {
+ || featureWithValidPositiveLength(m_mediaFeature, *firstValue) || featureWithValidIdent(m_mediaFeature, *firstValue, context)) {
m_value = firstValue;
m_isValid = true;
return;
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.h (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.h 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryExpression.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -36,11 +36,13 @@
}
namespace WebCore {
+
+struct MediaQueryParserContext;
class MediaQueryExpression {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit MediaQueryExpression(const String& mediaFeature, CSSParserTokenRange&);
+ explicit MediaQueryExpression(const String& mediaFeature, CSSParserTokenRange&, MediaQueryParserContext&);
const AtomicString& mediaFeature() const;
CSSValue* value() const;
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryMatcher.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryMatcher.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryMatcher.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -28,6 +28,7 @@
#include "MediaQueryEvaluator.h"
#include "MediaQueryList.h"
#include "MediaQueryListListener.h"
+#include "MediaQueryParserContext.h"
#include "NodeRenderStyle.h"
#include "RenderElement.h"
#include "StyleResolver.h"
@@ -82,7 +83,7 @@
if (!m_document)
return nullptr;
- auto media = MediaQuerySet::create(query);
+ auto media = MediaQuerySet::create(query, MediaQueryParserContext(*m_document));
reportMediaQueryWarningIfNeeded(m_document, media.ptr());
bool result = evaluate(media.get());
return MediaQueryList::create(*this, WTFMove(media), result);
Copied: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.cpp (from rev 229716, tags/Safari-606.1.9.4/Source/WebCore/css/StyleMedia.cpp) (0 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.cpp (rev 0)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MediaQueryParserContext.h"
+
+#include "CSSParserMode.h"
+#include "Document.h"
+#include "Page.h"
+
+namespace WebCore {
+
+MediaQueryParserContext::MediaQueryParserContext(const CSSParserContext& context)
+{
+ useSystemAppearance = context.useSystemAppearance;
+}
+
+MediaQueryParserContext::MediaQueryParserContext(const Document& document)
+{
+ useSystemAppearance = document.page() ? document.page()->useSystemAppearance() : false;
+}
+
+} // namespace WebCore
Copied: tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.h (from rev 229716, tags/Safari-606.1.9.4/Source/WebCore/css/StyleMedia.cpp) (0 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.h (rev 0)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/MediaQueryParserContext.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebCore {
+
+class Document;
+struct CSSParserContext;
+
+struct MediaQueryParserContext {
+public:
+ MediaQueryParserContext() { }
+ MediaQueryParserContext(const CSSParserContext&);
+ WEBCORE_EXPORT MediaQueryParserContext(const Document&);
+
+ bool useSystemAppearance { false };
+};
+
+} // namespace WebCore
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/StyleMedia.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/StyleMedia.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/StyleMedia.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -31,6 +31,7 @@
#include "FrameView.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
+#include "MediaQueryParser.h"
#include "NodeRenderStyle.h"
#include "RenderElement.h"
#include "StyleResolver.h"
@@ -65,7 +66,7 @@
auto rootStyle = document->styleScope().resolver().styleForElement(*documentElement, document->renderStyle(), nullptr, MatchOnlyUserAgentRules).renderStyle;
- auto media = MediaQuerySet::create(query);
+ auto media = MediaQuerySet::create(query, MediaQueryParserContext(*document));
return MediaQueryEvaluator { type(), *document, rootStyle.get() }.evaluate(media.get());
}
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/StyleRuleImport.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/StyleRuleImport.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/StyleRuleImport.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -29,6 +29,7 @@
#include "CachedResourceRequestInitiators.h"
#include "Document.h"
#include "MediaList.h"
+#include "MediaQueryParser.h"
#include "SecurityOrigin.h"
#include "StyleSheetContents.h"
#include <wtf/StdLibExtras.h>
@@ -50,7 +51,7 @@
, m_loading(false)
{
if (!m_mediaQueries)
- m_mediaQueries = MediaQuerySet::create(String());
+ m_mediaQueries = MediaQuerySet::create(String(), MediaQueryParserContext());
}
StyleRuleImport::~StyleRuleImport()
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParser.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParser.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParser.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -40,6 +40,7 @@
#include "CSSVariableReferenceValue.h"
#include "Document.h"
#include "Element.h"
+#include "Page.h"
#include "RenderTheme.h"
#include "RuntimeEnabledFeatures.h"
#include "Settings.h"
@@ -90,6 +91,7 @@
conicGradientsEnabled = document.settings().conicGradientsEnabled();
deferredCSSParserEnabled = document.settings().deferredCSSParserEnabled();
allowNewLinesClamp = document.settings().appleMailLinesClampEnabled();
+ useSystemAppearance = document.page() ? document.page()->useSystemAppearance() : false;
#if PLATFORM(IOS)
// FIXME: Force the site specific quirk below to work on iOS. Investigating other site specific quirks
@@ -112,7 +114,8 @@
&& a.constantPropertiesEnabled == b.constantPropertiesEnabled
&& a.conicGradientsEnabled == b.conicGradientsEnabled
&& a.deferredCSSParserEnabled == b.deferredCSSParserEnabled
- && a.hasDocumentSecurityOrigin == b.hasDocumentSecurityOrigin;
+ && a.hasDocumentSecurityOrigin == b.hasDocumentSecurityOrigin
+ && a.useSystemAppearance == b.useSystemAppearance;
}
CSSParser::CSSParser(const CSSParserContext& context)
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParserImpl.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParserImpl.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/parser/CSSParserImpl.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -48,6 +48,7 @@
#include "Element.h"
#include "MediaList.h"
#include "MediaQueryParser.h"
+#include "MediaQueryParserContext.h"
#include "StyleProperties.h"
#include "StyleRuleImport.h"
#include "StyleSheetContents.h"
@@ -517,8 +518,8 @@
m_observerWrapper->observer().startRuleBody(endOffset);
m_observerWrapper->observer().endRuleBody(endOffset);
}
-
- return StyleRuleImport::create(uri, MediaQueryParser::parseMediaQuerySet(prelude).releaseNonNull());
+
+ return StyleRuleImport::create(uri, MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull());
}
RefPtr<StyleRuleNamespace> CSSParserImpl::consumeNamespaceRule(CSSParserTokenRange prelude)
@@ -537,7 +538,7 @@
RefPtr<StyleRuleMedia> CSSParserImpl::consumeMediaRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
{
if (m_deferredParser)
- return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude).releaseNonNull(), std::make_unique<DeferredStyleGroupRuleList>(block, *m_deferredParser));
+ return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull(), std::make_unique<DeferredStyleGroupRuleList>(block, *m_deferredParser));
Vector<RefPtr<StyleRuleBase>> rules;
@@ -554,7 +555,7 @@
if (m_observerWrapper)
m_observerWrapper->observer().endRuleBody(m_observerWrapper->endOffset(block));
- return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude).releaseNonNull(), rules);
+ return StyleRuleMedia::create(MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull(), rules);
}
RefPtr<StyleRuleSupports> CSSParserImpl::consumeSupportsRule(CSSParserTokenRange prelude, CSSParserTokenRange block)
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -32,23 +32,24 @@
#include "CSSTokenizer.h"
#include "MediaList.h"
+#include "MediaQueryParserContext.h"
#include <wtf/Vector.h>
namespace WebCore {
-RefPtr<MediaQuerySet> MediaQueryParser::parseMediaQuerySet(const String& queryString)
+RefPtr<MediaQuerySet> MediaQueryParser::parseMediaQuerySet(const String& queryString, MediaQueryParserContext context)
{
- return parseMediaQuerySet(CSSTokenizer(queryString).tokenRange());
+ return parseMediaQuerySet(CSSTokenizer(queryString).tokenRange(), context);
}
-RefPtr<MediaQuerySet> MediaQueryParser::parseMediaQuerySet(CSSParserTokenRange range)
+RefPtr<MediaQuerySet> MediaQueryParser::parseMediaQuerySet(CSSParserTokenRange range, MediaQueryParserContext context)
{
- return MediaQueryParser(MediaQuerySetParser).parseInternal(range);
+ return MediaQueryParser(MediaQuerySetParser, context).parseInternal(range);
}
-RefPtr<MediaQuerySet> MediaQueryParser::parseMediaCondition(CSSParserTokenRange range)
+RefPtr<MediaQuerySet> MediaQueryParser::parseMediaCondition(CSSParserTokenRange range, MediaQueryParserContext context)
{
- return MediaQueryParser(MediaConditionParser).parseInternal(range);
+ return MediaQueryParser(MediaConditionParser, context).parseInternal(range);
}
const MediaQueryParser::State MediaQueryParser::ReadRestrictor = &MediaQueryParser::readRestrictor;
@@ -64,9 +65,11 @@
const MediaQueryParser::State MediaQueryParser::SkipUntilBlockEnd = &MediaQueryParser::skipUntilBlockEnd;
const MediaQueryParser::State MediaQueryParser::Done = &MediaQueryParser::done;
-MediaQueryParser::MediaQueryParser(ParserType parserType)
+MediaQueryParser::MediaQueryParser(ParserType parserType, MediaQueryParserContext context)
: m_parserType(parserType)
+ , m_mediaQueryData(context)
, m_querySet(MediaQuerySet::create())
+
{
if (parserType == MediaQuerySetParser)
m_state = &MediaQueryParser::readRestrictor;
@@ -271,10 +274,11 @@
return m_querySet;
}
-MediaQueryData::MediaQueryData()
+MediaQueryData::MediaQueryData(MediaQueryParserContext context)
: m_restrictor(MediaQuery::None)
, m_mediaType("all")
, m_mediaTypeSet(false)
+ , m_context(context)
{
}
@@ -289,7 +293,7 @@
void MediaQueryData::addExpression(CSSParserTokenRange& range)
{
- MediaQueryExpression _expression_ = MediaQueryExpression(m_mediaFeature, range);
+ MediaQueryExpression _expression_ = MediaQueryExpression(m_mediaFeature, range, m_context);
m_expressions.append(WTFMove(_expression_));
}
@@ -309,4 +313,4 @@
m_mediaTypeSet = true;
}
-} // namespace WebCsore
+} // namespace WebCore
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.h (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.h 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/parser/MediaQueryParser.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -34,16 +34,18 @@
#include "MediaQuery.h"
#include "MediaQueryBlockWatcher.h"
#include "MediaQueryExpression.h"
+#include "MediaQueryParserContext.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
class MediaQuerySet;
+struct CSSParserContext;
class MediaQueryData {
WTF_MAKE_NONCOPYABLE(MediaQueryData);
public:
- MediaQueryData();
+ MediaQueryData(MediaQueryParserContext context);
void clear();
void addExpression(CSSParserTokenRange&);
bool lastExpressionValid();
@@ -63,6 +65,8 @@
inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor = restrictor; }
inline void setMediaFeature(const String& str) { m_mediaFeature = str; }
+
+ inline void setMediaQueryParserContext(MediaQueryParserContext context) { m_context = context; }
private:
MediaQuery::Restrictor m_restrictor;
@@ -70,14 +74,15 @@
Vector<MediaQueryExpression> m_expressions;
String m_mediaFeature;
bool m_mediaTypeSet;
+ MediaQueryParserContext m_context;
};
class MediaQueryParser {
WTF_MAKE_NONCOPYABLE(MediaQueryParser);
public:
- static RefPtr<MediaQuerySet> parseMediaQuerySet(const String&);
- static RefPtr<MediaQuerySet> parseMediaQuerySet(CSSParserTokenRange);
- static RefPtr<MediaQuerySet> parseMediaCondition(CSSParserTokenRange);
+ static RefPtr<MediaQuerySet> parseMediaQuerySet(const String&, MediaQueryParserContext);
+ static RefPtr<MediaQuerySet> parseMediaQuerySet(CSSParserTokenRange, MediaQueryParserContext);
+ static RefPtr<MediaQuerySet> parseMediaCondition(CSSParserTokenRange, MediaQueryParserContext);
private:
enum ParserType {
@@ -85,7 +90,7 @@
MediaConditionParser,
};
- MediaQueryParser(ParserType);
+ MediaQueryParser(ParserType, MediaQueryParserContext);
virtual ~MediaQueryParser();
RefPtr<MediaQuerySet> parseInternal(CSSParserTokenRange);
Modified: tags/Safari-606.1.9.4/Source/WebCore/css/parser/SizesAttributeParser.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/css/parser/SizesAttributeParser.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/css/parser/SizesAttributeParser.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -37,6 +37,7 @@
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "MediaQueryParser.h"
+#include "MediaQueryParserContext.h"
#include "RenderView.h"
#include "SizesCalcParser.h"
#include "StyleScope.h"
@@ -136,7 +137,7 @@
float length;
if (!calculateLengthInPixels(range.makeSubRange(lengthTokenStart, lengthTokenEnd), length))
continue;
- RefPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMediaCondition(range.makeSubRange(mediaConditionStart, lengthTokenStart));
+ RefPtr<MediaQuerySet> mediaCondition = MediaQueryParser::parseMediaCondition(range.makeSubRange(mediaConditionStart, lengthTokenStart), MediaQueryParserContext(m_document));
if (!mediaCondition || !mediaConditionMatches(*mediaCondition))
continue;
m_length = length;
Modified: tags/Safari-606.1.9.4/Source/WebCore/dom/InlineStyleSheetOwner.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -26,6 +26,7 @@
#include "Logging.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
+#include "MediaQueryParser.h"
#include "ScriptableDocumentParser.h"
#include "ShadowRoot.h"
#include "StyleScope.h"
@@ -171,7 +172,7 @@
if (!contentSecurityPolicy.allowInlineStyle(document.url(), m_startTextPosition.m_line, text, hasKnownNonce))
return;
- RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(m_media);
+ RefPtr<MediaQuerySet> mediaQueries = MediaQuerySet::create(m_media, MediaQueryParserContext(document));
MediaQueryEvaluator screenEval(ASCIILiteral("screen"), true);
MediaQueryEvaluator printEval(ASCIILiteral("print"), true);
Modified: tags/Safari-606.1.9.4/Source/WebCore/dom/ProcessingInstruction.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/dom/ProcessingInstruction.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/dom/ProcessingInstruction.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -31,6 +31,7 @@
#include "Frame.h"
#include "FrameLoader.h"
#include "MediaList.h"
+#include "MediaQueryParser.h"
#include "StyleScope.h"
#include "StyleSheetContents.h"
#include "XMLDocumentParser.h"
@@ -218,7 +219,7 @@
auto cssSheet = CSSStyleSheet::create(StyleSheetContents::create(href, parserContext), *this);
cssSheet.get().setDisabled(m_alternate);
cssSheet.get().setTitle(m_title);
- cssSheet.get().setMediaQueries(MediaQuerySet::create(m_media));
+ cssSheet.get().setMediaQueries(MediaQuerySet::create(m_media, MediaQueryParserContext(document())));
m_sheet = WTFMove(cssSheet);
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLImageElement.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLImageElement.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLImageElement.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -169,7 +169,7 @@
auto documentElement = makeRefPtr(document().documentElement());
MediaQueryEvaluator evaluator { document().printing() ? "print" : "screen", document(), documentElement ? documentElement->computedStyle() : nullptr };
- auto* queries = source.parsedMediaAttribute();
+ auto* queries = source.parsedMediaAttribute(document());
LOG(MediaQueries, "HTMLImageElement %p bestFitSourceFromPictureElement evaluating media queries", this);
auto evaluation = !queries || evaluator.evaluate(*queries, picture->viewportDependentResults());
if (picture->hasViewportDependentResults())
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -47,6 +47,7 @@
#include "Logging.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
+#include "MediaQueryParser.h"
#include "MouseEvent.h"
#include "RenderStyle.h"
#include "RuntimeEnabledFeatures.h"
@@ -287,7 +288,7 @@
std::optional<RenderStyle> documentStyle;
if (document().hasLivingRenderTree())
documentStyle = Style::resolveForDocument(document());
- auto media = MediaQuerySet::create(m_media);
+ auto media = MediaQuerySet::create(m_media, MediaQueryParserContext(document()));
LOG(MediaQueries, "HTMLLinkElement::process evaluating queries");
mediaQueryMatches = MediaQueryEvaluator { document().frame()->view()->mediaType(), document(), documentStyle ? &*documentStyle : nullptr }.evaluate(media.get());
}
@@ -385,7 +386,7 @@
HTMLElement::finishParsingChildren();
}
-void HTMLLinkElement::initializeStyleSheet(Ref<StyleSheetContents>&& styleSheet, const CachedCSSStyleSheet& cachedStyleSheet)
+void HTMLLinkElement::initializeStyleSheet(Ref<StyleSheetContents>&& styleSheet, const CachedCSSStyleSheet& cachedStyleSheet, MediaQueryParserContext context)
{
// FIXME: originClean should be turned to false except if fetch mode is CORS.
std::optional<bool> originClean;
@@ -393,7 +394,7 @@
originClean = cachedStyleSheet.isCORSSameOrigin();
m_sheet = CSSStyleSheet::create(WTFMove(styleSheet), *this, originClean);
- m_sheet->setMediaQueries(MediaQuerySet::create(m_media));
+ m_sheet->setMediaQueries(MediaQuerySet::create(m_media, context));
m_sheet->setTitle(title());
}
@@ -425,7 +426,7 @@
if (auto restoredSheet = const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext, cachePolicy, frame->loader())) {
ASSERT(restoredSheet->isCacheable());
ASSERT(!restoredSheet->isLoading());
- initializeStyleSheet(restoredSheet.releaseNonNull(), *cachedStyleSheet);
+ initializeStyleSheet(restoredSheet.releaseNonNull(), *cachedStyleSheet, MediaQueryParserContext(document()));
m_loading = false;
sheetLoaded();
@@ -434,7 +435,7 @@
}
auto styleSheet = StyleSheetContents::create(href, parserContext);
- initializeStyleSheet(styleSheet.copyRef(), *cachedStyleSheet);
+ initializeStyleSheet(styleSheet.copyRef(), *cachedStyleSheet, MediaQueryParserContext(document()));
styleSheet.get().parseAuthorStyleSheet(cachedStyleSheet, &document().securityOrigin());
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.h (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.h 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLLinkElement.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -37,6 +37,7 @@
class DOMTokenList;
class HTMLLinkElement;
class URL;
+struct MediaQueryParserContext;
template<typename T> class EventSender;
typedef EventSender<HTMLLinkElement> LinkEventSender;
@@ -89,7 +90,7 @@
void didFinishInsertingNode() final;
void removedFromAncestor(RemovalType, ContainerNode&) final;
- void initializeStyleSheet(Ref<StyleSheetContents>&&, const CachedCSSStyleSheet&);
+ void initializeStyleSheet(Ref<StyleSheetContents>&&, const CachedCSSStyleSheet&, MediaQueryParserContext);
// from CachedResourceClient
void setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet*) final;
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLMediaElement.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLMediaElement.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLMediaElement.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -4517,7 +4517,7 @@
if (mediaURL.isEmpty())
goto CheckAgain;
- if (auto* media = source->parsedMediaAttribute()) {
+ if (auto* media = source->parsedMediaAttribute(document())) {
if (shouldLog)
INFO_LOG(LOGIDENTIFIER, "'media' is ", source->attributeWithoutSynchronization(mediaAttr));
auto* renderer = this->renderer();
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -33,6 +33,7 @@
#include "HTMLPictureElement.h"
#include "Logging.h"
#include "MediaList.h"
+#include "MediaQueryParser.h"
#if ENABLE(VIDEO)
#include "HTMLMediaElement.h"
@@ -162,13 +163,13 @@
}
}
-const MediaQuerySet* HTMLSourceElement::parsedMediaAttribute() const
+const MediaQuerySet* HTMLSourceElement::parsedMediaAttribute(Document& document) const
{
if (!m_cachedParsedMediaAttribute) {
RefPtr<const MediaQuerySet> parsedAttribute;
auto& value = attributeWithoutSynchronization(mediaAttr);
if (!value.isNull())
- parsedAttribute = MediaQuerySet::create(value);
+ parsedAttribute = MediaQuerySet::create(value, MediaQueryParserContext(document));
m_cachedParsedMediaAttribute = WTFMove(parsedAttribute);
}
return m_cachedParsedMediaAttribute.value().get();
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.h (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.h 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLSourceElement.h 2018-03-19 21:27:18 UTC (rev 229717)
@@ -40,7 +40,7 @@
void scheduleErrorEvent();
void cancelPendingErrorEvent();
- const MediaQuerySet* parsedMediaAttribute() const;
+ const MediaQuerySet* parsedMediaAttribute(Document&) const;
private:
HTMLSourceElement(const QualifiedName&, Document&);
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/HTMLStyleElement.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/HTMLStyleElement.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/HTMLStyleElement.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -31,6 +31,7 @@
#include "EventSender.h"
#include "HTMLNames.h"
#include "MediaList.h"
+#include "MediaQueryParser.h"
#include "RuntimeEnabledFeatures.h"
#include "ScriptableDocumentParser.h"
#include "ShadowRoot.h"
@@ -79,7 +80,7 @@
else if (name == mediaAttr) {
m_styleSheetOwner.setMedia(value);
if (sheet()) {
- sheet()->setMediaQueries(MediaQuerySet::create(value));
+ sheet()->setMediaQueries(MediaQuerySet::create(value, MediaQueryParserContext(document())));
if (auto* scope = m_styleSheetOwner.styleScope())
scope->didChangeStyleSheetContents();
} else
Modified: tags/Safari-606.1.9.4/Source/WebCore/html/parser/HTMLPreloadScanner.cpp (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebCore/html/parser/HTMLPreloadScanner.cpp 2018-03-19 21:27:18 UTC (rev 229717)
@@ -39,6 +39,7 @@
#include "MIMETypeRegistry.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
+#include "MediaQueryParser.h"
#include "RenderView.h"
#include "SizesAttributeParser.h"
#include <wtf/MainThread.h>
@@ -215,7 +216,7 @@
}
if (match(attributeName, mediaAttr) && m_mediaAttribute.isNull()) {
m_mediaAttribute = attributeValue;
- auto mediaSet = MediaQuerySet::create(attributeValue);
+ auto mediaSet = MediaQuerySet::create(attributeValue, MediaQueryParserContext(document));
auto documentElement = makeRefPtr(document.documentElement());
LOG(MediaQueries, "HTMLPreloadScanner %p processAttribute evaluating media queries", this);
m_mediaMatched = MediaQueryEvaluator { document.printing() ? "print" : "screen", document, documentElement ? documentElement->computedStyle() : nullptr }.evaluate(mediaSet.get());
Modified: tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/ChangeLog (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/ChangeLog 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/ChangeLog 2018-03-19 21:27:18 UTC (rev 229717)
@@ -1,3 +1,19 @@
+2018-03-19 Jason Marcell <jmarc...@apple.com>
+
+ Cherry-pick r229654. rdar://problem/38382934
+
+ 2018-03-15 Megan Gardner <megan_gard...@apple.com>
+
+ Create MediaQueryParserContext to provide additional context for the evaluation of media queries
+ https://bugs.webkit.org/show_bug.cgi?id=183677
+
+ Reviewed by Tim Horton.
+
+ We need additional context for parsing media queries to make sure they are parsed correctly and valid.
+
+ * DOM/DOM.mm:
+ (-[DOMHTMLLinkElement _mediaQueryMatches]):
+
2018-03-12 Javier Fernandez <jfernan...@igalia.com>
Remove GridLayout runtime flag
Modified: tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/DOM/DOM.mm (229716 => 229717)
--- tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/DOM/DOM.mm 2018-03-19 21:27:09 UTC (rev 229716)
+++ tags/Safari-606.1.9.4/Source/WebKitLegacy/mac/DOM/DOM.mm 2018-03-19 21:27:18 UTC (rev 229717)
@@ -751,7 +751,7 @@
return true;
Document& document = link.document();
- auto mediaQuerySet = MediaQuerySet::create(media);
+ auto mediaQuerySet = MediaQuerySet::create(media, MediaQueryParserContext(document));
return MediaQueryEvaluator { "screen", document, document.renderView() ? &document.renderView()->style() : nullptr }.evaluate(mediaQuerySet.get());
}