Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 1 | From cb929f59b527fe890376e47613dfe1434a320bc0 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Tue, 11 Aug 2020 15:44:48 -0700 |
| 4 | Subject: [PATCH] [clang 11] fix build errors due to -WWc++11-narrowing |
| 5 | |
| 6 | https://bugs.webkit.org/show_bug.cgi?id=211193 |
| 7 | |
| 8 | Reviewed by Adrian Perez de Castro. |
| 9 | |
| 10 | Fixes the following errors, |
| 11 | |
| 12 | Source/WebCore/html/MediaElementSession.cpp:1059:9: error: type 'WebCore::RenderMedia *' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing] |
| 13 | m_element.renderer(), |
| 14 | ^~~~~~~~~~~~~~~~~~~~ |
| 15 | |
| 16 | Source/WebCore/style/StyleResolver.cpp:106:55: error: type 'const char [4]' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing] |
| 17 | m_mediaQueryEvaluator = MediaQueryEvaluator { "all" }; |
| 18 | ^~~~~ |
| 19 | Source/WebCore/style/StyleResolver.cpp:106:55: note: insert an explicit cast to silence this issue |
| 20 | m_mediaQueryEvaluator = MediaQueryEvaluator { "all" }; |
| 21 | ^~~~~ |
| 22 | static_cast<bool>( ) |
| 23 | |
| 24 | * html/HTMLMediaElement.h: |
| 25 | (WebCore::HTMLMediaElement::hasRenderer const): |
| 26 | MediaElementSession was implicitly casting a pointer to a bool, |
| 27 | which is not allowed with modern Clang checks. Add a helper method |
| 28 | to encapsulate the now required static_cast<bool>. |
| 29 | * html/MediaElementSession.cpp: Use the new helper method to see |
| 30 | if 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, |
| 34 | or maybe String? It's confusing because of the MediaQueryEvaluator |
| 35 | API. If it was implicitly converting to bool then that could be |
| 36 | unintentional. Such casts are not allowed either now. The |
| 37 | MediaQueryEvaluator's default constructor says it returns true for |
| 38 | "all", which appears to be the original intent of this call, so I |
| 39 | replaced it with that. |
| 40 | (WebCore::Style::Resolver::Resolver): |
| 41 | |
| 42 | git-svn-id: http://svn.webkit.org/repository/webkit/trunk@260951 268f45cc-cd09-0410-ab3c-d52691b4dbfc |
| 43 | |
| 44 | Upstream-Status: Backport [https://github.com/WebKit/webkit/commit/c3cf651016e4cdcb4350598d4a586821071f91bf.patch] |
| 45 | |
| 46 | Signed-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 | |
| 51 | diff --git a/Source/WebCore/style/StyleResolver.cpp b/Source/WebCore/style/StyleResolver.cpp |
| 52 | index 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 | -- |
| 65 | 2.28.0 |
| 66 | |