| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/css/cssom/CSSOMKeywords.h" | 5 #include "core/css/cssom/CSSOMKeywords.h" |
| 6 | 6 |
| 7 #include "core/css/cssom/KeywordValue.h" | 7 #include "core/css/cssom/CSSKeywordValue.h" |
| 8 #include "wtf/HashMap.h" | 8 #include "wtf/HashMap.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 using KeywordTable = HashMap<CSSPropertyID, Vector<CSSValueID>>; | 14 using KeywordTable = HashMap<CSSPropertyID, Vector<CSSValueID>>; |
| 15 | 15 |
| 16 KeywordTable createKeywordTable() | 16 KeywordTable createKeywordTable() |
| 17 { | 17 { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 KeywordTable& keywordTable() | 32 KeywordTable& keywordTable() |
| 33 { | 33 { |
| 34 DEFINE_STATIC_LOCAL(KeywordTable, keywordTable, (createKeywordTable())); | 34 DEFINE_STATIC_LOCAL(KeywordTable, keywordTable, (createKeywordTable())); |
| 35 return keywordTable; | 35 return keywordTable; |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 bool CSSOMKeywords::validKeywordForProperty(CSSPropertyID id, const KeywordValue
& keyword) | 40 bool CSSOMKeywords::validKeywordForProperty(CSSPropertyID id, const CSSKeywordVa
lue& keyword) |
| 41 { | 41 { |
| 42 CSSValueID valueID = keyword.keywordValueID(); | 42 CSSValueID valueID = keyword.keywordValueID(); |
| 43 if (valueID == CSSValueInvalid) { | 43 if (valueID == CSSValueInvalid) { |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 if (valueID == CSSValueInherit || valueID == CSSValueInitial || valueID == C
SSValueUnset) { | 47 if (valueID == CSSValueInherit || valueID == CSSValueInitial || valueID == C
SSValueUnset) { |
| 48 // These are css-wide keywords that are valid for all properties. | 48 // These are css-wide keywords that are valid for all properties. |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 const KeywordTable::iterator tableIterator = keywordTable().find(id); | 52 const KeywordTable::iterator tableIterator = keywordTable().find(id); |
| 53 if (tableIterator == keywordTable().end()) { | 53 if (tableIterator == keywordTable().end()) { |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| 56 | 56 |
| 57 return tableIterator->value.contains(valueID); | 57 return tableIterator->value.contains(valueID); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |