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

Unified Diff: third_party/WebKit/Source/core/dom/TreeScope.cpp

Issue 2264943002: Add UseCounters for name attribute matching of <map> and <input type=radio> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/TreeScope.cpp
diff --git a/third_party/WebKit/Source/core/dom/TreeScope.cpp b/third_party/WebKit/Source/core/dom/TreeScope.cpp
index 60654ec0831cc875f3bc30f279428cf72c2ab7be..63a4640bc9c3456fc78c83d46c4271e4ed0b41f6 100644
--- a/third_party/WebKit/Source/core/dom/TreeScope.cpp
+++ b/third_party/WebKit/Source/core/dom/TreeScope.cpp
@@ -196,9 +196,24 @@ HTMLMapElement* TreeScope::getImageMap(const String& url) const
return nullptr;
size_t hashPos = url.find('#');
String name = hashPos == kNotFound ? url : url.substring(hashPos + 1);
- if (rootNode().document().isHTMLDocument())
- return toHTMLMapElement(m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()), this));
- return toHTMLMapElement(m_imageMapsByName->getElementByMapName(AtomicString(name), this));
+ HTMLMapElement* map = toHTMLMapElement(rootNode().document().isHTMLDocument()
+ ? m_imageMapsByName->getElementByLowercasedMapName(AtomicString(name.lower()), this)
+ : m_imageMapsByName->getElementByMapName(AtomicString(name), this));
+ if (!map || !rootNode().document().isHTMLDocument())
+ return map;
+ const AtomicString& nameValue = map->fastGetAttribute(nameAttr);
+ if (nameValue.isNull())
+ return map;
+ String strippedName = nameValue;
+ if (strippedName.startsWith('#'))
+ strippedName = strippedName.substring(1);
+ if (strippedName == name)
+ UseCounter::count(rootNode().document(), UseCounter::MapNameMatchingStrict);
+ else if (equalIgnoringASCIICase(strippedName, name))
+ UseCounter::count(rootNode().document(), UseCounter::MapNameMatchingASCIICaseless);
+ else
+ UseCounter::count(rootNode().document(), UseCounter::MapNameMatchingUnicodeLower);
+ return map;
}
static bool pointWithScrollAndZoomIfPossible(const Document& document, IntPoint& point)
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698