Add back three deprecated DOM APIs removed from Chrome 34 (issue 243333003)

0 views
Skip to first unread message

ese...@chromium.org

unread,
Apr 18, 2014, 3:17:19 PM4/18/14
to ese...@chromium.org, blink-...@chromium.org, arv+...@chromium.org, sigb...@opera.com, eae+bli...@chromium.org, oj...@chromium.org, dglazko...@chromium.org, adamk...@chromium.org, rob....@samsung.com, watchdog-bli...@google.com, ch.d...@samsung.com, domi...@chromium.org, aba...@chromium.org, esp...@chromium.org
Reviewers: ,

Description:
Add back three deprecated DOM APIs removed from Chrome 34

I added back the APIs and marked them as deprecated.
I carefully checked to make sure they're using the
same UseCounter ids as they were before.
I did not add back the removed tests as it did not seem
worth the hassle of dealing with the conflicts and
rebaselines necessary due to the new deprecation messages.

These API removes are believed to have broken an unknown
number of Chrome users in enterprise environments.
Users in these settings are likely biased away from
having "anonymous chrome usage data" reporting enabled
meaning that their usage may not be reflected in the
data displayed at chromestatus.com. All we have currently
is annecdotal data such as comments on mailing lists or
in bugs reporting "100s of customers" from SAP
as affected (crbug.com/364028).

These APIs were removed from Blink as "low hanging fruit".
Each of these sees fewer than 1 view of every 1 million
anonymously reported chrome views (well below our historical
removal thresholds) and removing them is a step towards the
larger removal of Attr nodes from the DOM (as has been
proposed for the DOM 4 specification).

However the reward for the 99.99% of users who do not use
these features is quite small. The risk to this unknown
number of Blink "enterprise" users is likely too large
to be worth the small code complexity reward at this time.

Adding these back for now, with deprecation messages.
We'll likely remove these again from Blink in the future
as usage of these fatures continues to decline and hopefully
our measurement of enterprise usage improves.

BUG=341830,341296,353104,364028

Please review this at https://codereview.chromium.org/243333003/

SVN Base: svn://svn.chromium.org/blink/trunk

Affected files (+44, -2 lines):
M LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
M LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
M LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
M LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
M LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
M LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
M Source/core/dom/Attr.idl
M Source/core/dom/Document.h
M Source/core/dom/Document.cpp
M Source/core/dom/Document.idl
M Source/core/dom/Element.h
M Source/core/dom/Element.cpp
M Source/core/dom/Element.idl
M Source/core/frame/UseCounter.h
M Source/core/frame/UseCounter.cpp


Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
index
94b400d16815ef13d7998c71dfd02e26a4b440fd..3007d945bd31c35e42f263660b9fb5c01b26607d
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode01-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode01
Status Success
Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
index
3ec65e4bce3e0dcf6b10705519e38e7e9a4a6f4d..12c099281739f88962b70753dfedd5b30486e5b3
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode02-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode02
Status Success
Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
index
dc7b2e8df39aae4f5d6a85645c3faf78d26fefca..e0e9ca83e7e72217b227d9c23f48f787eb82ad35
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode03-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode03
Status Success
Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
index
869a7162e4e296bec8c9c85b87a641e24129bd87..7b4a2abfb26fe508d0fdaaadbab8ee918e747156
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode04-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode04
Status Success
Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
index
0d496514039d0ac52dc33b2d99bcc5b764361962..e5feb4b2e8eac16d60eae232fee2229ec4f3c0a2
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode05-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode05
Status Success
Index: LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
diff --git
a/LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
b/LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
index
212ed3ab96c07a74dfd5617530198c6860c0e56f..c606084279626b4af62b55b172d177256ddaaf0f
100644
--- a/LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
+++ b/LayoutTests/dom/xhtml/level3/core/documentadoptnode21-expected.txt
@@ -1,2 +1,3 @@
+CONSOLE WARNING: 'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).
Test http://www.w3.org/2001/DOM-Test-Suite/level3/core/documentadoptnode21
Status Success
Index: Source/core/dom/Attr.idl
diff --git a/Source/core/dom/Attr.idl b/Source/core/dom/Attr.idl
index
e497d13449f38ba2510f778ba29ad58baf4f1394..3e44a7316dd4b5abd8a8a199a544ceca1141c2f3
100644
--- a/Source/core/dom/Attr.idl
+++ b/Source/core/dom/Attr.idl
@@ -28,6 +28,10 @@ interface Attr : Node {

[ImplementedAs=valueForBindings, TreatReturnedNullStringAs=Null,
TreatNullAs=NullString, CustomElementCallbacks] attribute DOMString value;

+ // DOM Level 2
+
+ [DeprecateAs=AttributeOwnerElement] readonly attribute Element
ownerElement;
+
// DOM 4

[TreatReturnedNullStringAs=Null, PerWorldBindings] readonly attribute
DOMString prefix;
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index
8c770732ac76657342f57532da35367f200f9e9a..43e7d00eda7ca34bfb28f3657c8b644e2c9260bd
100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -4427,11 +4427,21 @@ WeakPtr<Document> Document::contextDocument()

PassRefPtr<Attr> Document::createAttribute(const AtomicString& name,
ExceptionState& exceptionState)
{
+ return createAttributeNS(nullAtom, name, exceptionState, true);
+}
+
+PassRefPtr<Attr> Document::createAttributeNS(const AtomicString&
namespaceURI, const AtomicString& qualifiedName, ExceptionState&
exceptionState, bool shouldIgnoreNamespaceChecks)
+{
AtomicString prefix, localName;
- if (!parseQualifiedName(name, prefix, localName, exceptionState))
+ if (!parseQualifiedName(qualifiedName, prefix, localName,
exceptionState))
return nullptr;

- QualifiedName qName(prefix, localName, nullAtom);
+ QualifiedName qName(prefix, localName, namespaceURI);
+
+ if (!shouldIgnoreNamespaceChecks
&& !hasValidNamespaceForAttributes(qName)) {
+ exceptionState.throwDOMException(NamespaceError, "The namespace
URI provided ('" + namespaceURI + "') is not valid for the qualified name
provided ('" + qualifiedName + "').");
+ return nullptr;
+ }

return Attr::create(*this, qName, emptyAtom);
}
Index: Source/core/dom/Document.h
diff --git a/Source/core/dom/Document.h b/Source/core/dom/Document.h
index
76c8226625351c652b7e1aece5b45a94f44d6a08..b92891fbb332c1748f86f07bdfe1edf4cdd135ea
100644
--- a/Source/core/dom/Document.h
+++ b/Source/core/dom/Document.h
@@ -322,6 +322,7 @@ public:
PassRefPtr<CDATASection> createCDATASection(const String& data,
ExceptionState&);
PassRefPtr<ProcessingInstruction> createProcessingInstruction(const
String& target, const String& data, ExceptionState&);
PassRefPtr<Attr> createAttribute(const AtomicString& name,
ExceptionState&);
+ PassRefPtr<Attr> createAttributeNS(const AtomicString& namespaceURI,
const AtomicString& qualifiedName, ExceptionState&, bool
shouldIgnoreNamespaceChecks = false);
PassRefPtr<Node> importNode(Node* importedNode, ExceptionState& ec) {
return importNode(importedNode, true, ec); }
PassRefPtr<Node> importNode(Node* importedNode, bool deep,
ExceptionState&);
PassRefPtr<Element> createElementNS(const AtomicString& namespaceURI,
const AtomicString& qualifiedName, ExceptionState&);
Index: Source/core/dom/Document.idl
diff --git a/Source/core/dom/Document.idl b/Source/core/dom/Document.idl
index
c628c5dc3c46cde82163aa930bd6901c3f21c7a3..f63709a85188fc540ae09ac3a3e7ed6b5ee5b0da
100644
--- a/Source/core/dom/Document.idl
+++ b/Source/core/dom/Document.idl
@@ -44,6 +44,8 @@ typedef (CanvasRenderingContext2D or
WebGLRenderingContext) RenderingContext;

[CustomElementCallbacks, PerWorldBindings,
ActivityLogging=ForIsolatedWorlds, RaisesException] Node importNode(Node
node, optional boolean deep);
[CustomElementCallbacks, PerWorldBindings,
ActivityLogging=ForIsolatedWorlds, RaisesException] Element
createElementNS([TreatNullAs=NullString] DOMString namespaceURI, DOMString
qualifiedName);
+ [RaisesException, DeprecateAs=DocumentCreateAttributeNS] Attr
createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional
DOMString namespaceURI,
+
[TreatNullAs=NullString,Default=Undefined]
optional DOMString
qualifiedName); // Removed from DOM4.
HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString]
DOMString namespaceURI, DOMString localName);
[PerWorldBindings] Element getElementById(DOMString elementId);

Index: Source/core/dom/Element.cpp
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp
index
9484c4fc9cc592cc5427a96fd3229f83eb74574f..95fdfd339f472af7fde79d2f29f2459e2a719154
100644
--- a/Source/core/dom/Element.cpp
+++ b/Source/core/dom/Element.cpp
@@ -1890,6 +1890,11 @@ PassRefPtr<Attr> Element::setAttributeNode(Attr*
attrNode, ExceptionState& excep
return oldAttrNode.release();
}

+PassRefPtr<Attr> Element::setAttributeNodeNS(Attr* attr, ExceptionState&
exceptionState)
+{
+ return setAttributeNode(attr, exceptionState);
+}
+
PassRefPtr<Attr> Element::removeAttributeNode(Attr* attr, ExceptionState&
exceptionState)
{
if (!attr) {
Index: Source/core/dom/Element.h
diff --git a/Source/core/dom/Element.h b/Source/core/dom/Element.h
index
97c6b6d70f149e7a9e1227353632eb31b5edd8ee..35321ae41795dcf4958822a763874c9da4123479
100644
--- a/Source/core/dom/Element.h
+++ b/Source/core/dom/Element.h
@@ -223,6 +223,7 @@ public:
PassRefPtr<Attr> getAttributeNode(const AtomicString& name);
PassRefPtr<Attr> getAttributeNodeNS(const AtomicString& namespaceURI,
const AtomicString& localName);
PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionState&);
+ PassRefPtr<Attr> setAttributeNodeNS(Attr*, ExceptionState&);
PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionState&);

PassRefPtr<Attr> attrIfExists(const QualifiedName&);
Index: Source/core/dom/Element.idl
diff --git a/Source/core/dom/Element.idl b/Source/core/dom/Element.idl
index
3025fd20b6f1aad92fb74d5328c4cc330f8cd132..2f6709a5ac8b9f5fa397606860f91eb263082f5f
100644
--- a/Source/core/dom/Element.idl
+++ b/Source/core/dom/Element.idl
@@ -45,6 +45,7 @@
HTMLCollection getElementsByTagNameNS([TreatNullAs=NullString]
DOMString namespaceURI, DOMString localName);
[MeasureAs=ElementGetAttributeNodeNS] Attr
getAttributeNodeNS([TreatNullAs=NullString,Default=Undefined] optional
DOMString namespaceURI,

[Default=Undefined] optional DOMString localName); // Removed from DOM4.
+ [RaisesException, CustomElementCallbacks,
DeprecateAs=ElementSetAttributeNodeNS] Attr
setAttributeNodeNS([Default=Undefined, StrictTypeChecking] optional Attr
newAttr); // Removed from DOM4.
boolean hasAttribute(DOMString name);
boolean hasAttributeNS([TreatNullAs=NullString] DOMString
namespaceURI, DOMString localName);

Index: Source/core/frame/UseCounter.cpp
diff --git a/Source/core/frame/UseCounter.cpp
b/Source/core/frame/UseCounter.cpp
index
decf0a1c79281adf204f0eacade3e89615397dd2..e385f639b1ea5dab4423d24c7a540d0982412d45
100644
--- a/Source/core/frame/UseCounter.cpp
+++ b/Source/core/frame/UseCounter.cpp
@@ -710,6 +710,15 @@ String UseCounter::deprecationMessage(Feature feature)
case HTMLHtmlElementManifest:
return "'HTMLHtmlElement.manifest' is deprecated. The manifest
attribute only has an effect during the early stages of document load.";

+ case DocumentCreateAttributeNS:
+ return "'Document.createAttributeNS' is deprecated and has been
removed from DOM4 (w3.org/tr/dom).";
+
+ case AttributeOwnerElement:
+ return "'Attr.ownerElement' is deprecated and has been removed
from DOM4 (w3.org/tr/dom).";
+
+ case ElementSetAttributeNodeNS:
+ return "'Element.setAttributeNodeNS' is deprecated and has been
removed from DOM4 (w3.org/tr/dom).";
+
// Features that aren't deprecated don't have a deprecation message.
default:
return String();
Index: Source/core/frame/UseCounter.h
diff --git a/Source/core/frame/UseCounter.h b/Source/core/frame/UseCounter.h
index
f5465047c2a5b3407a83dc06c3a7d479f0703666..6db617c08293ea903c331ea011392a87d36d3919
100644
--- a/Source/core/frame/UseCounter.h
+++ b/Source/core/frame/UseCounter.h
@@ -149,6 +149,7 @@ public:
ElementRemoveAttributeNode = 109, // Removed from DOM4.
ElementGetAttributeNodeNS = 110, // Removed from DOM4.
DocumentCreateAttribute = 111, // Removed from DOM4.
+ DocumentCreateAttributeNS = 112, // Removed from DOM4.
DocumentCreateCDATASection = 113, // Removed from DOM4.
DocumentInputEncoding = 114, // Removed from DOM4.
DocumentXMLEncoding = 115, // Removed from DOM4.
@@ -189,6 +190,7 @@ public:
HTMLObjectElementLegacyCall = 153,
GetMatchedCSSRules = 155,
SVGFontInCSS = 156,
+ AttributeOwnerElement = 160, // Removed in DOM4.
AttributeSpecified = 162, // Removed in DOM4.
PrefixedAudioDecodedByteCount = 164,
PrefixedVideoDecodedByteCount = 165,
@@ -234,6 +236,7 @@ public:
HTMLElementInnerText = 213,
HTMLElementOuterText = 214,
ReplaceDocumentViaJavaScriptURL = 215,
+ ElementSetAttributeNodeNS = 216, // Removed from DOM4.
ElementPrefixedMatchesSelector = 217,
CSSStyleSheetRules = 219,
CSSStyleSheetAddRule = 220,


aba...@chromium.org

unread,
Apr 18, 2014, 3:19:57 PM4/18/14
to ese...@chromium.org, blink-...@chromium.org, arv+...@chromium.org, sigb...@opera.com, eae+bli...@chromium.org, oj...@chromium.org, dglazko...@chromium.org, adamk...@chromium.org, rob....@samsung.com, watchdog-bli...@google.com, ch.d...@samsung.com, domi...@chromium.org, esp...@chromium.org
LGTM


https://codereview.chromium.org/243333003/diff/1/Source/core/frame/UseCounter.cpp
File Source/core/frame/UseCounter.cpp (right):

https://codereview.chromium.org/243333003/diff/1/Source/core/frame/UseCounter.cpp#newcode714
Source/core/frame/UseCounter.cpp:714: return
"'Document.createAttributeNS' is deprecated and has been removed from
DOM4 (w3.org/tr/dom).";
Can we give full URLs that clickable? http://www.w3.org/TR/dom/

https://codereview.chromium.org/243333003/

commi...@chromium.org

unread,
Apr 18, 2014, 3:26:25 PM4/18/14
to ese...@chromium.org, aba...@chromium.org, blink-...@chromium.org, arv+...@chromium.org, sigb...@opera.com, eae+bli...@chromium.org, oj...@chromium.org, dglazko...@chromium.org, adamk...@chromium.org, rob....@samsung.com, watchdog-bli...@google.com, ch.d...@samsung.com, domi...@chromium.org, aba...@chromium.org, esp...@chromium.org

commi...@chromium.org

unread,
Apr 18, 2014, 4:34:28 PM4/18/14
to ese...@chromium.org, aba...@chromium.org, blink-...@chromium.org, arv+...@chromium.org, sigb...@opera.com, eae+bli...@chromium.org, oj...@chromium.org, dglazko...@chromium.org, adamk...@chromium.org, rob....@samsung.com, watchdog-bli...@google.com, ch.d...@samsung.com, domi...@chromium.org, aba...@chromium.org, esp...@chromium.org
Change committed as 171971

https://codereview.chromium.org/243333003/
Reply all
Reply to author
Forward
0 new messages