blob: d8bb8efb88d41f2b116df5ea268f6abfecc68de5 [file] [log] [blame]
Andrew Geissler635e0e42020-08-21 15:58:33 -05001From cb929f59b527fe890376e47613dfe1434a320bc0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 11 Aug 2020 15:44:48 -0700
4Subject: [PATCH] [clang 11] fix build errors due to -WWc++11-narrowing
5
6https://bugs.webkit.org/show_bug.cgi?id=211193
7
8Reviewed by Adrian Perez de Castro.
9
10Fixes the following errors,
11
12Source/WebCore/html/MediaElementSession.cpp:1059:9: error: type 'WebCore::RenderMedia *' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing]
13m_element.renderer(),
14^~~~~~~~~~~~~~~~~~~~
15
16Source/WebCore/style/StyleResolver.cpp:106:55: error: type 'const char [4]' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing]
17m_mediaQueryEvaluator = MediaQueryEvaluator { "all" };
18 ^~~~~
19Source/WebCore/style/StyleResolver.cpp:106:55: note: insert an explicit cast to silence this issue
20m_mediaQueryEvaluator = MediaQueryEvaluator { "all" };
21 ^~~~~
22 static_cast<bool>( )
23
24* html/HTMLMediaElement.h:
25(WebCore::HTMLMediaElement::hasRenderer const):
26MediaElementSession was implicitly casting a pointer to a bool,
27which is not allowed with modern Clang checks. Add a helper method
28to encapsulate the now required static_cast<bool>.
29* html/MediaElementSession.cpp: Use the new helper method to see
30if the HTMLMediaElement has an associated renderer.
31(WebCore::MediaElementSession::updateMediaUsageIfChanged):
32* style/StyleResolver.cpp: This was calling MediaQueryEvaluator {
33"all" }; and seemingly expecting to cast a const char[] to a bool,
34or maybe String? It's confusing because of the MediaQueryEvaluator
35API. If it was implicitly converting to bool then that could be
36unintentional. Such casts are not allowed either now. The
37MediaQueryEvaluator's default constructor says it returns true for
38"all", which appears to be the original intent of this call, so I
39replaced it with that.
40(WebCore::Style::Resolver::Resolver):
41
42git-svn-id: http://svn.webkit.org/repository/webkit/trunk@260951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
43
44Upstream-Status: Backport [https://github.com/WebKit/webkit/commit/c3cf651016e4cdcb4350598d4a586821071f91bf.patch]
45
46Signed-off-by: Khem Raj <raj.khem@gmail.com>
47---
48 Source/WebCore/style/StyleResolver.cpp | 2 +-
49 1 file changed, 1 insertion(+), 1 deletion(-)
50
51diff --git a/Source/WebCore/style/StyleResolver.cpp b/Source/WebCore/style/StyleResolver.cpp
52index 8bf371a0..34580ddb 100644
53--- a/Source/WebCore/style/StyleResolver.cpp
54+++ b/Source/WebCore/style/StyleResolver.cpp
55@@ -107,7 +107,7 @@ Resolver::Resolver(Document& document)
56 if (view)
57 m_mediaQueryEvaluator = MediaQueryEvaluator { view->mediaType() };
58 else
59- m_mediaQueryEvaluator = MediaQueryEvaluator { "all" };
60+ m_mediaQueryEvaluator = MediaQueryEvaluator { };
61
62 if (root) {
63 m_rootDefaultStyle = styleForElement(*root, m_document.renderStyle(), nullptr, RuleMatchingBehavior::MatchOnlyUserAgentRules).renderStyle;
64--
652.28.0
66