webengine/osswebengine/WebCore/css/MediaFeatureNames.cpp
changeset 10 a359256acfc6
parent 0 dd21522fd290
equal deleted inserted replaced
5:10e98eab6f85 10:a359256acfc6
    35 #define DEFINE_MEDIAFEATURE_GLOBAL(name, str) \
    35 #define DEFINE_MEDIAFEATURE_GLOBAL(name, str) \
    36     DEFINE_GLOBAL(AtomicString, name##MediaFeature, str)
    36     DEFINE_GLOBAL(AtomicString, name##MediaFeature, str)
    37 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(DEFINE_MEDIAFEATURE_GLOBAL)
    37 CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(DEFINE_MEDIAFEATURE_GLOBAL)
    38 #undef DEFINE_MEDIAFEATURE_GLOBAL
    38 #undef DEFINE_MEDIAFEATURE_GLOBAL
    39 
    39 
       
    40 static bool initialized;
       
    41 
    40 void init()
    42 void init()
    41 {
    43 {
    42     static bool initialized;
       
    43     if (!initialized) {
    44     if (!initialized) {
    44        // Use placement new to initialize the globals.
    45        // Use placement new to initialize the globals.
    45 
    46 
    46         AtomicString::init();
    47         AtomicString::init();
    47         #define INITIALIZE_GLOBAL(name, str) new ((void*)&name##MediaFeature) AtomicString(str);
    48         #define INITIALIZE_GLOBAL(name, str) new ((void*)&name##MediaFeature) AtomicString(str);
    49         #undef INITIALIZE_GLOBAL
    50         #undef INITIALIZE_GLOBAL
    50         initialized = true;
    51         initialized = true;
    51     }
    52     }
    52 }
    53 }
    53 
    54 
       
    55 void remove()
       
    56 {
       
    57     if( initialized ) {
       
    58         #define DESTROY_GLOBAL(name, str) delete ((AtomicString*)&name##MediaFeature)->impl();
       
    59         CSS_MEDIAQUERY_NAMES_FOR_EACH_MEDIAFEATURE(DESTROY_GLOBAL)
       
    60         #undef DESTROY_GLOBAL
       
    61         AtomicString::remove();
       
    62 
       
    63         initialized = false;
       
    64     }
       
    65 
       
    66 } //remove()
       
    67 
    54 } // namespace MediaFeatureNames
    68 } // namespace MediaFeatureNames
    55 } // namespace WebCore
    69 } // namespace WebCore