Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: Source/core/css/MediaQueryEvaluator.cpp

Issue 178803006: Turn MQ classes into thread safe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased after MediaFeature generation landed Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * CSS Media Query Evaluator 2 * CSS Media Query Evaluator
3 * 3 *
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>.
5 * Copyright (C) 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. 6 * Copyright (C) 2013 Intel Corporation. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 typedef HashMap<StringImpl*, EvalFunc> FunctionMap; 63 typedef HashMap<StringImpl*, EvalFunc> FunctionMap;
64 static FunctionMap* gFunctionMap; 64 static FunctionMap* gFunctionMap;
65 65
66 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) 66 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult)
67 : m_frame(0) 67 : m_frame(0)
68 , m_style(nullptr) 68 , m_style(nullptr)
69 , m_expResult(mediaFeatureResult) 69 , m_expResult(mediaFeatureResult)
70 { 70 {
71 } 71 }
72 72
73 MediaQueryEvaluator::MediaQueryEvaluator(const AtomicString& acceptedMediaType, bool mediaFeatureResult) 73 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m ediaFeatureResult)
74 : m_mediaType(acceptedMediaType) 74 : m_mediaType(acceptedMediaType)
75 , m_frame(0) 75 , m_frame(0)
76 , m_style(nullptr) 76 , m_style(nullptr)
77 , m_expResult(mediaFeatureResult) 77 , m_expResult(mediaFeatureResult)
78 { 78 {
79 } 79 }
80 80
81 MediaQueryEvaluator::MediaQueryEvaluator(const char* acceptedMediaType, bool med iaFeatureResult) 81 MediaQueryEvaluator::MediaQueryEvaluator(const char* acceptedMediaType, bool med iaFeatureResult)
82 : m_mediaType(acceptedMediaType) 82 : m_mediaType(acceptedMediaType)
83 , m_frame(0) 83 , m_frame(0)
84 , m_style(nullptr) 84 , m_style(nullptr)
85 , m_expResult(mediaFeatureResult) 85 , m_expResult(mediaFeatureResult)
86 { 86 {
87 } 87 }
88 88
89 MediaQueryEvaluator::MediaQueryEvaluator(const AtomicString& acceptedMediaType, LocalFrame* frame, RenderStyle* style) 89 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, LocalF rame* frame, RenderStyle* style)
90 : m_mediaType(acceptedMediaType) 90 : m_mediaType(acceptedMediaType)
91 , m_frame(frame) 91 , m_frame(frame)
92 , m_style(style) 92 , m_style(style)
93 , m_expResult(false) // Doesn't matter when we have m_frame and m_style. 93 , m_expResult(false) // Doesn't matter when we have m_frame and m_style.
94 { 94 {
95 } 95 }
96 96
97 MediaQueryEvaluator::~MediaQueryEvaluator() 97 MediaQueryEvaluator::~MediaQueryEvaluator()
98 { 98 {
99 } 99 }
100 100
101 bool MediaQueryEvaluator::mediaTypeMatch(const AtomicString& mediaTypeToMatch) c onst 101 bool MediaQueryEvaluator::mediaTypeMatch(const String& mediaTypeToMatch) const
102 { 102 {
103 return mediaTypeToMatch.isEmpty() 103 return mediaTypeToMatch.isEmpty()
104 || equalIgnoringCase(mediaTypeToMatch, "all") 104 || equalIgnoringCase(mediaTypeToMatch, "all")
105 || equalIgnoringCase(mediaTypeToMatch, m_mediaType); 105 || equalIgnoringCase(mediaTypeToMatch, m_mediaType);
106 } 106 }
107 107
108 bool MediaQueryEvaluator::mediaTypeMatchSpecific(const char* mediaTypeToMatch) c onst 108 bool MediaQueryEvaluator::mediaTypeMatchSpecific(const char* mediaTypeToMatch) c onst
109 { 109 {
110 // Like mediaTypeMatch, but without the special cases for "" and "all". 110 // Like mediaTypeMatch, but without the special cases for "" and "all".
111 ASSERT(mediaTypeToMatch); 111 ASSERT(mediaTypeToMatch);
112 ASSERT(mediaTypeToMatch[0] != '\0'); 112 ASSERT(mediaTypeToMatch[0] != '\0');
113 ASSERT(!equalIgnoringCase(mediaTypeToMatch, AtomicString("all"))); 113 ASSERT(!equalIgnoringCase(mediaTypeToMatch, String("all")));
abarth-chromium 2014/03/06 08:03:57 Didn't you create a static string for all? We sho
114 return equalIgnoringCase(mediaTypeToMatch, m_mediaType); 114 return equalIgnoringCase(mediaTypeToMatch, m_mediaType);
115 } 115 }
116 116
117 static bool applyRestrictor(MediaQuery::Restrictor r, bool value) 117 static bool applyRestrictor(MediaQuery::Restrictor r, bool value)
118 { 118 {
119 return r == MediaQuery::Not ? !value : value; 119 return r == MediaQuery::Not ? !value : value;
120 } 120 }
121 121
122 bool MediaQueryEvaluator::eval(const MediaQuerySet* querySet, MediaQueryResultLi st* viewportDependentMediaQueryResults) const 122 bool MediaQueryEvaluator::eval(const MediaQuerySet* querySet, MediaQueryResultLi st* viewportDependentMediaQueryResults) const
123 { 123 {
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 // Call the media feature evaluation function. Assume no prefix and let 691 // Call the media feature evaluation function. Assume no prefix and let
692 // trampoline functions override the prefix if prefix is used. 692 // trampoline functions override the prefix if prefix is used.
693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); 693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl());
694 if (func) 694 if (func)
695 return func(expr->value(), m_style.get(), m_frame, NoPrefix); 695 return func(expr->value(), m_style.get(), m_frame, NoPrefix);
696 696
697 return false; 697 return false;
698 } 698 }
699 699
700 } // namespace 700 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698