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

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

Issue 2501893003: Deprecate case-insensitive matching for |usemap| attribute (Closed)
Patch Set: Created 4 years, 1 month 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
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 422de1a85924481fffd9b307750560cfd402d758..189c39f471c2d6b34d26e11b056d79112e3a7683 100644
--- a/third_party/WebKit/Source/core/dom/TreeScope.cpp
+++ b/third_party/WebKit/Source/core/dom/TreeScope.cpp
@@ -40,11 +40,14 @@
#include "core/dom/shadow/ShadowRoot.h"
#include "core/editing/DOMSelection.h"
#include "core/events/EventPath.h"
+#include "core/frame/Deprecation.h"
+#include "core/frame/FrameConsole.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLAnchorElement.h"
#include "core/html/HTMLFrameOwnerElement.h"
#include "core/html/HTMLMapElement.h"
+#include "core/inspector/ConsoleMessage.h"
#include "core/layout/HitTestResult.h"
#include "core/layout/api/LayoutViewItem.h"
#include "core/page/FocusController.h"
@@ -55,6 +58,21 @@ namespace blink {
using namespace HTMLNames;
+namespace {
+
+void addSingletonDeprecationMessageForImageMap(const LocalFrame* frame,
+ UseCounter::Feature feature,
+ const String& usemap,
+ const AtomicString& name) {
+ if (!frame)
+ return;
+ frame->console().addSingletonMessage(ConsoleMessage::create(
+ DeprecationMessageSource, WarningMessageLevel,
+ Deprecation::deprecationMessage(feature) + " Comparing usemap=" + usemap +
+ " and name=" + name));
+}
+}
+
TreeScope::TreeScope(ContainerNode& rootNode, Document& document)
: m_rootNode(&rootNode),
m_document(&document),
@@ -186,11 +204,11 @@ HTMLMapElement* TreeScope::getImageMap(const String& url) const {
size_t hashPos = url.find('#');
String name = hashPos == kNotFound ? url : url.substring(hashPos + 1);
HTMLMapElement* map = toHTMLMapElement(
- rootNode().document().isHTMLDocument()
+ document().isHTMLDocument()
? m_imageMapsByName->getElementByLowercasedMapName(
AtomicString(name.lower()), this)
: m_imageMapsByName->getElementByMapName(AtomicString(name), this));
- if (!map || !rootNode().document().isHTMLDocument())
+ if (!map || !document().isHTMLDocument())
return map;
const AtomicString& nameValue = map->fastGetAttribute(nameAttr);
if (nameValue.isNull())
@@ -198,14 +216,17 @@ HTMLMapElement* TreeScope::getImageMap(const String& url) const {
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);
+ if (strippedName == name) {
+ UseCounter::count(document(), UseCounter::MapNameMatchingStrict);
+ } else if (equalIgnoringASCIICase(strippedName, name)) {
+ addSingletonDeprecationMessageForImageMap(
+ document().frame(), UseCounter::MapNameMatchingASCIICaseless, url,
+ nameValue);
+ } else {
+ addSingletonDeprecationMessageForImageMap(
+ document().frame(), UseCounter::MapNameMatchingUnicodeLower, url,
+ nameValue);
+ }
return map;
}

Powered by Google App Engine
This is Rietveld 408576698