Title: [220090] trunk/Source/WebCore
Revision
220090
Author
[email protected]
Date
2017-07-31 23:42:51 -0700 (Mon, 31 Jul 2017)

Log Message

Use LazyNeverDestroyed instead of DEFINE_GLOBAL for MediaFeatureNames
https://bugs.webkit.org/show_bug.cgi?id=175008

Patch by Fujii Hironori <[email protected]> on 2017-07-31
Reviewed by Alex Christensen.

No new tests because no behavior change.

Stop using DEFINE_GLOBAL hack in favor of LazyNeverDestroyed.

* css/MediaFeatureNames.cpp:
(WebCore::MediaFeatureNames::init): Do not include
<wtf/StaticConstructors.h>. Use LazyNeverDestroyed instead of
DEFINE_GLOBAL. Call LazyNeverDestroyed::construct instead of
placement new.
* css/MediaFeatureNames.h: Use LazyNeverDestroyed.
* css/MediaQueryEvaluator.cpp:
(WebCore::MediaQueryEvaluator::evaluate const): Dereference with ->.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (220089 => 220090)


--- trunk/Source/WebCore/ChangeLog	2017-08-01 06:40:04 UTC (rev 220089)
+++ trunk/Source/WebCore/ChangeLog	2017-08-01 06:42:51 UTC (rev 220090)
@@ -1,5 +1,25 @@
 2017-07-31  Fujii Hironori  <[email protected]>
 
+        Use LazyNeverDestroyed instead of DEFINE_GLOBAL for MediaFeatureNames
+        https://bugs.webkit.org/show_bug.cgi?id=175008
+
+        Reviewed by Alex Christensen.
+
+        No new tests because no behavior change.
+
+        Stop using DEFINE_GLOBAL hack in favor of LazyNeverDestroyed.
+
+        * css/MediaFeatureNames.cpp:
+        (WebCore::MediaFeatureNames::init): Do not include
+        <wtf/StaticConstructors.h>. Use LazyNeverDestroyed instead of
+        DEFINE_GLOBAL. Call LazyNeverDestroyed::construct instead of
+        placement new.
+        * css/MediaFeatureNames.h: Use LazyNeverDestroyed.
+        * css/MediaQueryEvaluator.cpp:
+        (WebCore::MediaQueryEvaluator::evaluate const): Dereference with ->.
+
+2017-07-31  Fujii Hironori  <[email protected]>
+
         Use LazyNeverDestroyed instead of DEFINE_GLOBAL for QualifiedName
         https://bugs.webkit.org/show_bug.cgi?id=175010
 

Modified: trunk/Source/WebCore/css/MediaFeatureNames.cpp (220089 => 220090)


--- trunk/Source/WebCore/css/MediaFeatureNames.cpp	2017-08-01 06:40:04 UTC (rev 220089)
+++ trunk/Source/WebCore/css/MediaFeatureNames.cpp	2017-08-01 06:42:51 UTC (rev 220090)
@@ -19,18 +19,12 @@
  */
 
 #include "config.h"
-
-#ifdef SKIP_STATIC_CONSTRUCTORS_ON_GCC
-#define CSS_MEDIAQUERY_NAMES_HIDE_GLOBALS 1
-#endif
-
 #include "MediaFeatureNames.h"
-#include <wtf/StaticConstructors.h>
 
 namespace WebCore {
 namespace MediaFeatureNames {
 
-#define DEFINE_MEDIAFEATURE_GLOBAL(name, string) DEFINE_GLOBAL(AtomicString, name)
+#define DEFINE_MEDIAFEATURE_GLOBAL(name, string) LazyNeverDestroyed<const AtomicString> name;
 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(DEFINE_MEDIAFEATURE_GLOBAL)
 #undef DEFINE_MEDIAFEATURE_GLOBAL
 
@@ -38,9 +32,8 @@
 {
     static bool initialized;
     if (!initialized) {
-        // Use placement new to initialize the globals.
         AtomicString::init();
-#define INITIALIZE_GLOBAL(name, string) new (NotNull, (void*)&name) AtomicString(string, AtomicString::ConstructFromLiteral);
+#define INITIALIZE_GLOBAL(name, string) name.construct(string, AtomicString::ConstructFromLiteral);
         CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(INITIALIZE_GLOBAL)
 #undef INITIALIZE_GLOBAL
         initialized = true;

Modified: trunk/Source/WebCore/css/MediaFeatureNames.h (220089 => 220090)


--- trunk/Source/WebCore/css/MediaFeatureNames.h	2017-08-01 06:40:04 UTC (rev 220089)
+++ trunk/Source/WebCore/css/MediaFeatureNames.h	2017-08-01 06:42:51 UTC (rev 220090)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include <wtf/NeverDestroyed.h>
 #include <wtf/text/AtomicString.h>
 
 #if ENABLE(VIEW_MODE_CSS_MEDIA)
@@ -83,11 +84,9 @@
 namespace WebCore {
 namespace MediaFeatureNames {
 
-#ifndef CSS_MEDIAQUERY_NAMES_HIDE_GLOBALS
-#define CSS_MEDIAQUERY_NAMES_DECLARE(name, string) extern const AtomicString name;
+#define CSS_MEDIAQUERY_NAMES_DECLARE(name, string) extern LazyNeverDestroyed<const AtomicString> name;
     CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(CSS_MEDIAQUERY_NAMES_DECLARE)
 #undef CSS_MEDIAQUERY_NAMES_DECLARE
-#endif
 
     void init();
 

Modified: trunk/Source/WebCore/css/MediaQueryEvaluator.cpp (220089 => 220090)


--- trunk/Source/WebCore/css/MediaQueryEvaluator.cpp	2017-08-01 06:40:04 UTC (rev 220089)
+++ trunk/Source/WebCore/css/MediaQueryEvaluator.cpp	2017-08-01 06:42:51 UTC (rev 220090)
@@ -718,7 +718,7 @@
 
     static NeverDestroyed<MediaQueryFunctionMap> map = [] {
         MediaQueryFunctionMap map;
-#define ADD_TO_FUNCTIONMAP(name, str) add(map, MediaFeatureNames::name.impl(), name##Evaluate);
+#define ADD_TO_FUNCTIONMAP(name, str) add(map, MediaFeatureNames::name->impl(), name##Evaluate);
         CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(ADD_TO_FUNCTIONMAP);
 #undef ADD_TO_FUNCTIONMAP
         return map;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to