Changeset 176313 in webkit
- Timestamp:
- Nov 19, 2014, 12:57:13 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/selectors/lang-extended-filtering-expected.txt (added)
-
LayoutTests/fast/selectors/lang-extended-filtering.html (added)
-
LayoutTests/fast/selectors/lang-multiple-expected.txt (added)
-
LayoutTests/fast/selectors/lang-multiple.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/SelectorChecker.cpp (modified) (1 diff)
-
Source/WebCore/css/SelectorCheckerTestFunctions.h (modified) (2 diffs)
-
Source/WebCore/cssjit/SelectorCompiler.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r176311 r176313 1 2014-11-19 Dhi Aurrahman <diorahman@rockybars.com> 2 3 Add selector checker for :lang pseudo class in Selectors level 4 4 https://bugs.webkit.org/show_bug.cgi?id=138281 5 6 Reviewed by Benjamin Poulain. 7 8 Add layout tests for :lang selector checker with multiple arguments and 9 related behaviors on extended filtering. 10 11 * fast/selectors/lang-extended-filtering-expected.txt: Added. 12 * fast/selectors/lang-extended-filtering.html: Added. 13 * fast/selectors/lang-multiple-expected.txt: Added. 14 * fast/selectors/lang-multiple.html: Added. 15 1 16 2014-11-18 Philippe Normand <pnormand@igalia.com> 2 17 -
trunk/Source/WebCore/ChangeLog
r176311 r176313 1 2014-11-19 Dhi Aurrahman <diorahman@rockybars.com> 2 3 Add selector checker for :lang pseudo class in Selectors level 4 4 https://bugs.webkit.org/show_bug.cgi?id=138281 5 6 Reviewed by Benjamin Poulain. 7 8 Add selector checker for :lang pseudo class in Selectors level 4. 9 10 The language tags matching is specified in [1,2]. 11 12 [1] http://www.ietf.org/rfc/rfc4647.txt 13 [2] http://dev.w3.org/csswg/selectors4/#the-lang-pseudo 14 15 Tests: fast/selectors/lang-extended-filtering.html 16 fast/selectors/lang-multiple.html 17 18 * css/SelectorChecker.cpp: 19 (WebCore::SelectorChecker::checkOne): 20 * css/SelectorCheckerTestFunctions.h: 21 (WebCore::containslanguageSubtagMatchingRange): 22 (WebCore::matchesLangPseudoClass): 23 (WebCore::matchesLangPseudoClassDeprecated): 24 * cssjit/SelectorCompiler.cpp: 25 (WebCore::SelectorCompiler::addPseudoClassType): 26 1 27 2014-11-18 Philippe Normand <pnormand@igalia.com> 2 28 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r176307 r176313 968 968 #if ENABLE(CSS_SELECTORS_LEVEL4) 969 969 ASSERT(selector->argumentList() && !selector->argumentList()->isEmpty()); 970 const AtomicString& argument = selector->argumentList()->first();970 return matchesLangPseudoClass(element, *selector->argumentList()); 971 971 #else 972 const AtomicString& argument = selector->argument(); 973 #endif 972 const AtomicString& argument = selector->argument(); 974 973 if (argument.isNull()) 975 974 return false; 976 return matchesLangPseudoClass(element, argument.impl()); 975 return matchesLangPseudoClassDeprecated(element, argument.impl()); 976 #endif 977 977 } 978 978 #if ENABLE(FULLSCREEN_API) -
trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h
r176174 r176313 1 1 /* 2 2 * Copyright (C) 2014 Apple Inc. All rights reserved. 3 * Copyright (C) 2014 Dhi Aurrahman <diorahman@rockybars.com> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 119 120 return !element->document().page()->focusController().isActive(); 120 121 } 122 123 #if ENABLE(CSS_SELECTORS_LEVEL4) 124 inline bool containslanguageSubtagMatchingRange(const Vector<String>& languageSubtags, const String& range, size_t& position) 125 { 126 for (size_t languageSubtagIndex = position; languageSubtagIndex < languageSubtags.size(); ++languageSubtagIndex) { 127 const String& currentLanguageSubtag = languageSubtags[languageSubtagIndex]; 128 if (currentLanguageSubtag.length() == 1) 129 return false; 130 if (equalIgnoringCase(range, currentLanguageSubtag)) { 131 position = languageSubtagIndex + 1; 132 return true; 133 } 134 } 135 return false; 136 } 137 138 inline bool matchesLangPseudoClass(const Element* element, const Vector<AtomicString>& ranges) 139 { 140 ASSERT(element); 141 142 AtomicString language; 143 #if ENABLE(VIDEO_TRACK) 144 if (is<WebVTTElement>(*element)) 145 language = downcast<WebVTTElement>(*element).language(); 146 else 147 #endif 148 language = element->computeInheritedLanguage(); 149 150 if (language.isNull()) 151 return false; 152 153 // Implement basic and extended filterings of given language tags 154 // as specified in www.ietf.org/rfc/rfc4647.txt. 155 Vector<String> rangeSubtags; 156 Vector<String> languageSubtags; 157 158 language.string().split('-', true, languageSubtags); 159 160 for (const AtomicString& range : ranges) { 161 if (equalIgnoringCase(language, range) && !language.contains('-')) 162 return true; 163 164 range.string().split('-', true, rangeSubtags); 165 166 if (rangeSubtags.size() > languageSubtags.size()) 167 continue; 168 169 if (!equalIgnoringCase(rangeSubtags.first(), languageSubtags.first())) 170 continue; 171 172 size_t lastMatchedLanguageSubtagIndex = 1; 173 bool matchedRange = true; 174 for (size_t rangeSubtagIndex = 1; rangeSubtagIndex < rangeSubtags.size(); ++rangeSubtagIndex) { 175 if (!containslanguageSubtagMatchingRange(languageSubtags, rangeSubtags[rangeSubtagIndex], lastMatchedLanguageSubtagIndex)) { 176 matchedRange = false; 177 break; 178 } 179 } 180 if (matchedRange) 181 return true; 182 } 183 return false; 184 } 185 #endif 121 186 122 inline bool matchesLangPseudoClass (const Element* element, AtomicStringImpl* filter)187 inline bool matchesLangPseudoClassDeprecated(const Element* element, AtomicStringImpl* filter) 123 188 { 124 189 AtomicString value; -
trunk/Source/WebCore/cssjit/SelectorCompiler.cpp
r176307 r176313 735 735 { 736 736 #if ENABLE(CSS_SELECTORS_LEVEL4) 737 ASSERT(selector.argumentList() && !selector.argumentList()->isEmpty()); 738 const AtomicString& argument = selector.argumentList()->first(); 737 return FunctionType::CannotCompile; 739 738 #else 740 739 const AtomicString& argument = selector.argument(); 741 #endif 740 742 741 if (argument.isEmpty()) 743 742 return FunctionType::CannotMatchAnything; … … 755 754 } 756 755 return FunctionType::SimpleSelectorChecker; 756 #endif 757 757 } 758 758 … … 3147 3147 Assembler::RegisterID elementAddress = elementAddressRegister; 3148 3148 FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls); 3149 functionCall.setFunctionAddress(matchesLangPseudoClass );3149 functionCall.setFunctionAddress(matchesLangPseudoClassDeprecated); 3150 3150 functionCall.setTwoArguments(elementAddress, langFilterRegister); 3151 3151 failureCases.append(functionCall.callAndBranchOnBooleanReturnValue(Assembler::Zero));
Note:
See TracChangeset
for help on using the changeset viewer.