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

Unified Diff: Source/core/css/SelectorChecker.cpp

Issue 14980012: Recognize html whitespaces as separators for attribute selectors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/selectors/attr-list-01-expected.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index 058657134baf080f0f7e0bf21b042f4c9f975429..ae4c3d91a981a45504ce70690e52546e394b1747 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -46,6 +46,7 @@
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLProgressElement.h"
#include "core/html/HTMLStyleElement.h"
+#include "core/html/parser/HTMLParserIdioms.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/page/FocusController.h"
#include "core/page/Frame.h"
@@ -236,6 +237,14 @@ SelectorChecker::Match SelectorChecker::match(const SelectorCheckingContext& con
return SelectorFailsCompletely;
}
+static inline bool containsHTMLSpace(const AtomicString& string)
+{
+ for (unsigned i = 0; i < string.length(); i++)
+ if (isHTMLSpace(string[i]))
+ return true;
+ return false;
+}
+
static bool attributeValueMatches(const Attribute* attributeItem, CSSSelector::Match match, const AtomicString& selectorValue, bool caseSensitive)
{
const AtomicString& value = attributeItem->value();
@@ -249,8 +258,8 @@ static bool attributeValueMatches(const Attribute* attributeItem, CSSSelector::M
break;
case CSSSelector::List:
{
- // Ignore empty selectors or selectors containing spaces
- if (selectorValue.contains(' ') || selectorValue.isEmpty())
+ // Ignore empty selectors or selectors containing HTML spaces
+ if (containsHTMLSpace(selectorValue) || selectorValue.isEmpty())
return false;
unsigned startSearchAt = 0;
@@ -258,9 +267,9 @@ static bool attributeValueMatches(const Attribute* attributeItem, CSSSelector::M
size_t foundPos = value.find(selectorValue, startSearchAt, caseSensitive);
if (foundPos == notFound)
return false;
- if (!foundPos || value[foundPos - 1] == ' ') {
+ if (!foundPos || isHTMLSpace(value[foundPos - 1])) {
unsigned endStr = foundPos + selectorValue.length();
- if (endStr == value.length() || value[endStr] == ' ')
+ if (endStr == value.length() || isHTMLSpace(value[endStr]))
break; // We found a match.
}
« no previous file with comments | « LayoutTests/fast/selectors/attr-list-01-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698