| OLD | NEW |
| 1 /* | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 * Copyright (C) 2012 Apple Inc. All rights reserved. | 3 // found in the LICENSE file. |
| 4 * | |
| 5 * Redistribution and use in source and binary forms, with or without | |
| 6 * modification, are permitted provided that the following conditions | |
| 7 * are met: | |
| 8 * | |
| 9 * 1. Redistributions of source code must retain the above | |
| 10 * copyright notice, this list of conditions and the following | |
| 11 * disclaimer. | |
| 12 * 2. Redistributions in binary form must reproduce the above | |
| 13 * copyright notice, this list of conditions and the following | |
| 14 * disclaimer in the documentation and/or other materials | |
| 15 * provided with the distribution. | |
| 16 * | |
| 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY | |
| 18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE | |
| 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | |
| 22 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | |
| 26 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | |
| 27 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 28 * SUCH DAMAGE. | |
| 29 */ | |
| 30 | 4 |
| 31 #ifndef CSSParserMode_h | 5 #ifndef CSSParserContext_h |
| 32 #define CSSParserMode_h | 6 #define CSSParserContext_h |
| 33 | 7 |
| 34 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/css/parser/CSSParserMode.h" |
| 35 #include "core/fetch/ResourceLoaderOptions.h" | 10 #include "core/fetch/ResourceLoaderOptions.h" |
| 36 #include "platform/weborigin/KURL.h" | 11 #include "platform/weborigin/KURL.h" |
| 37 #include "platform/weborigin/Referrer.h" | 12 #include "platform/weborigin/Referrer.h" |
| 38 | 13 |
| 39 namespace blink { | 14 namespace blink { |
| 40 | 15 |
| 41 class Document; | 16 class Document; |
| 42 | |
| 43 // Must not grow beyond 3 bits, due to packing in StylePropertySet. | |
| 44 enum CSSParserMode { | |
| 45 HTMLStandardMode, | |
| 46 HTMLQuirksMode, | |
| 47 // HTML attributes are parsed in quirks mode but also allows internal | |
| 48 // properties and values. | |
| 49 HTMLAttributeMode, | |
| 50 // SVG attributes are parsed in quirks mode but rules differ slightly. | |
| 51 SVGAttributeMode, | |
| 52 // @viewport/@font-face rules are specially tagged in StylePropertySet so | |
| 53 // CSSOM modifications don't treat them as style rules. | |
| 54 CSSViewportRuleMode, | |
| 55 CSSFontFaceRuleMode, | |
| 56 // User agent stylesheets are parsed in standards mode but also allows | |
| 57 // internal properties and values. | |
| 58 UASheetMode | |
| 59 }; | |
| 60 | |
| 61 inline bool isQuirksModeBehavior(CSSParserMode mode) { | |
| 62 return mode == HTMLQuirksMode; // || mode == HTMLAttributeMode; | |
| 63 } | |
| 64 | |
| 65 inline bool isUASheetBehavior(CSSParserMode mode) { | |
| 66 return mode == UASheetMode; | |
| 67 } | |
| 68 | |
| 69 inline bool isUnitLessLengthParsingEnabledForMode(CSSParserMode mode) { | |
| 70 return mode == HTMLAttributeMode || mode == SVGAttributeMode; | |
| 71 } | |
| 72 | |
| 73 inline bool isCSSViewportParsingEnabledForMode(CSSParserMode mode) { | |
| 74 return mode == CSSViewportRuleMode; | |
| 75 } | |
| 76 | |
| 77 inline bool isUseCounterEnabledForMode(CSSParserMode mode) { | |
| 78 // We don't count the UA style sheet in our statistics. | |
| 79 return mode != UASheetMode; | |
| 80 } | |
| 81 | |
| 82 class UseCounter; | 17 class UseCounter; |
| 83 | 18 |
| 84 class CORE_EXPORT CSSParserContext { | 19 class CORE_EXPORT CSSParserContext { |
| 85 USING_FAST_MALLOC(CSSParserContext); | 20 USING_FAST_MALLOC(CSSParserContext); |
| 86 | 21 |
| 87 public: | 22 public: |
| 88 // https://drafts.csswg.org/selectors/#profiles | 23 // https://drafts.csswg.org/selectors/#profiles |
| 89 enum SelectorProfile { DynamicProfile, StaticProfile }; | 24 enum SelectorProfile { DynamicProfile, StaticProfile }; |
| 90 | 25 |
| 91 CSSParserContext(CSSParserMode, | 26 CSSParserContext(CSSParserMode, |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; | 90 ContentSecurityPolicyDisposition m_shouldCheckContentSecurityPolicy; |
| 156 | 91 |
| 157 UseCounter* m_useCounter; | 92 UseCounter* m_useCounter; |
| 158 }; | 93 }; |
| 159 | 94 |
| 160 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); | 95 CORE_EXPORT const CSSParserContext& strictCSSParserContext(); |
| 161 | 96 |
| 162 } // namespace blink | 97 } // namespace blink |
| 163 | 98 |
| 164 #endif // CSSParserMode_h | 99 #endif // CSSParserMode_h |
| OLD | NEW |