[clang 11] fix build errors due to -WWc++11-narrowing
commit82639dc9ba4d88a26db1561efbfbbc9eb90c897a
authorcturner@igalia.com <cturner@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2020 15:12:36 +0000 (30 15:12 +0000)
committerKonstantin Tokarev <annulen@yandex.ru>
Mon, 21 Sep 2020 19:34:23 +0000 (21 22:34 +0300)
tree5910480da2525fda791d08255cfd30d0a8609e4c
parentb25af67465a406b396e8e42090eaeebaf3737e67
[clang 11] fix build errors due to -WWc++11-narrowing
https://bugs.webkit.org/show_bug.cgi?id=211193

Reviewed by Adrian Perez de Castro.

Fixes the following errors,

Source/WebCore/html/MediaElementSession.cpp:1059:9: error: type 'WebCore::RenderMedia *' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing]
m_element.renderer(),
^~~~~~~~~~~~~~~~~~~~

Source/WebCore/style/StyleResolver.cpp:106:55: error: type 'const char [4]' cannot be narrowed to 'bool' in initializer list [-Wc++11-narrowing]
m_mediaQueryEvaluator = MediaQueryEvaluator { "all" };
                                              ^~~~~
Source/WebCore/style/StyleResolver.cpp:106:55: note: insert an explicit cast to silence this issue
m_mediaQueryEvaluator = MediaQueryEvaluator { "all" };
                                              ^~~~~
                                              static_cast<bool>( )

* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::hasRenderer const):
MediaElementSession was implicitly casting a pointer to a bool,
which is not allowed with modern Clang checks. Add a helper method
to encapsulate the now required static_cast<bool>.
* html/MediaElementSession.cpp: Use the new helper method to see
if the HTMLMediaElement has an associated renderer.
(WebCore::MediaElementSession::updateMediaUsageIfChanged):
* style/StyleResolver.cpp: This was calling MediaQueryEvaluator {
"all" }; and seemingly expecting to cast a const char[] to a bool,
or maybe String? It's confusing because of the MediaQueryEvaluator
API. If it was implicitly converting to bool then that could be
unintentional. Such casts are not allowed either now. The
MediaQueryEvaluator's default constructor says it returns true for
"all", which appears to be the original intent of this call, so I
replaced it with that.
(WebCore::Style::Resolver::Resolver):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@260951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/html/HTMLMediaElement.h