Cleaning up some DOM APIs which were marked as deprecated because they were moved or renamed.

There were basically two issues:
- localName and namespaceUri moved from Node down to Element.
- The transitionEnd event was polyfilled based on the deprecated webkitTransitionEnd event, so it was switched to the standard transtionEnd.

The Attr change was needed because the node map was using localName on Attr (inherited from Node), when it should have been using name. Attr is not actually exposed anywhere, so made it private.

BUG=
R=efortuna@google.com

Review URL: https://codereview.chromium.org//15814008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@23423 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
blois@google.com
2013-05-30 16:31:09 +00:00
parent 37b90d3bcb
commit 881e456c21
10 changed files with 176 additions and 60 deletions
+51 -21
View File
@@ -426,15 +426,6 @@ class AreaElement extends Element native "HTMLAreaElement" {
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('Attr')
class Attr extends Node native "Attr" {
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('HTMLAudioElement')
class AudioElement extends MediaElement native "HTMLAudioElement" {
@@ -7660,6 +7651,16 @@ abstract class Element extends Node implements ElementTraversal native "Element"
_xtag = value;
}
@DomName('Element.localName')
@DocsEditable
String get localName => $dom_localName;
@DomName('Element.namespaceUri')
@DocsEditable
String get namespaceUri => $dom_namespaceUri;
String toString() => localName;
/**
* Scrolls this element into view.
*
@@ -7714,7 +7715,7 @@ abstract class Element extends Node implements ElementTraversal native "Element"
}
}
@DomName('Element.webkitTransitionEndEvent')
@DomName('Element.transitionEndEvent')
static const EventStreamProvider<TransitionEvent> transitionEndEvent =
const _CustomEventStreamProvider<TransitionEvent>(
Element._determineTransitionEventType);
@@ -8872,13 +8873,12 @@ abstract class Element extends Node implements ElementTraversal native "Element"
@Experimental
Stream<TouchEvent> get onTouchStart => touchStartEvent.forTarget(this);
@DomName('Element.onwebkitTransitionEnd')
@DomName('Element.ontransitionend')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE, '10')
@SupportedBrowser(SupportedBrowser.SAFARI)
@deprecated
Stream<TransitionEvent> get onTransitionEnd => transitionEndEvent.forTarget(this);
@DomName('Element.onwebkitfullscreenchange')
@@ -15847,8 +15847,7 @@ class Node extends EventTarget native "Node" {
/**
* Print out a String representation of this Node.
*/
String toString() => localName == null ?
(nodeValue == null ? super.toString() : nodeValue) : localName;
String toString() => nodeValue == null ? super.toString() : nodeValue;
/**
* Binds the attribute [name] to the [path] of the [model].
@@ -15943,11 +15942,12 @@ class Node extends EventTarget native "Node" {
@DocsEditable
final Node $dom_lastChild;
@JSName('localName')
@DomName('Node.localName')
@DocsEditable
// http://dom.spec.whatwg.org/#dom-node-localname
@deprecated // deprecated
final String localName;
final String $dom_localName;
@JSName('namespaceURI')
@DomName('Node.namespaceURI')
@@ -23238,6 +23238,10 @@ class Window extends EventTarget implements WindowBase native "Window,DOMWindow"
@Experimental
Stream<TouchEvent> get onTouchStart => Element.touchStartEvent.forTarget(this);
@DomName('Window.ontransitionend')
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
@DomName('Window.onunload')
@DocsEditable
Stream<Event> get onUnload => unloadEvent.forTarget(this);
@@ -23257,11 +23261,6 @@ class Window extends EventTarget implements WindowBase native "Window,DOMWindow"
@Experimental // untriaged
Stream<AnimationEvent> get onAnimationStart => animationStartEvent.forTarget(this);
@DomName('Window.onwebkitTransitionEnd')
@DocsEditable
@deprecated
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
@DomName('DOMWindow.beforeunloadEvent')
@DocsEditable
@@ -23635,6 +23634,37 @@ class XsltProcessor native "XSLTProcessor" {
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('Attr')
class _Attr extends Node native "Attr" {
@DomName('Attr.isId')
@DocsEditable
final bool isId;
@DomName('Attr.name')
@DocsEditable
final String name;
@DomName('Attr.ownerElement')
@DocsEditable
@deprecated // deprecated
final Element ownerElement;
@DomName('Attr.specified')
@DocsEditable
@deprecated // deprecated
final bool specified;
@DomName('Attr.value')
@DocsEditable
String value;
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('CSSPrimitiveValue')
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
@@ -24875,7 +24905,7 @@ abstract class _AttributeMap implements Map<String, String> {
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
keys.add(attributes[i].localName);
keys.add(attributes[i].name);
}
}
return keys;
+59 -30
View File
@@ -540,19 +540,6 @@ class AreaElement extends _Element_Merged {
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('Attr')
class Attr extends Node {
Attr.internal() : super.internal();
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('HTMLAudioElement')
class AudioElement extends MediaElement {
@@ -8133,6 +8120,16 @@ abstract class Element extends Node implements ElementTraversal {
_xtag = value;
}
@DomName('Element.localName')
@DocsEditable
String get localName => $dom_localName;
@DomName('Element.namespaceUri')
@DocsEditable
String get namespaceUri => $dom_namespaceUri;
String toString() => localName;
/**
* Scrolls this element into view.
*
@@ -8612,13 +8609,9 @@ abstract class Element extends Node implements ElementTraversal {
@Experimental
static const EventStreamProvider<TouchEvent> touchStartEvent = const EventStreamProvider<TouchEvent>('touchstart');
@DomName('Element.webkitTransitionEndEvent')
@DomName('Element.transitionendEvent')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.SAFARI)
@Experimental
@deprecated
static const EventStreamProvider<TransitionEvent> transitionEndEvent = const EventStreamProvider<TransitionEvent>('webkitTransitionEnd');
static const EventStreamProvider<TransitionEvent> transitionEndEvent = const EventStreamProvider<TransitionEvent>('transitionend');
@DomName('Element.webkitfullscreenchangeEvent')
@DocsEditable
@@ -9183,13 +9176,12 @@ abstract class Element extends Node implements ElementTraversal {
@Experimental
Stream<TouchEvent> get onTouchStart => touchStartEvent.forTarget(this);
@DomName('Element.onwebkitTransitionEnd')
@DomName('Element.ontransitionend')
@DocsEditable
@SupportedBrowser(SupportedBrowser.CHROME)
@SupportedBrowser(SupportedBrowser.FIREFOX)
@SupportedBrowser(SupportedBrowser.IE, '10')
@SupportedBrowser(SupportedBrowser.SAFARI)
@deprecated
Stream<TransitionEvent> get onTransitionEnd => transitionEndEvent.forTarget(this);
@DomName('Element.onwebkitfullscreenchange')
@@ -16900,8 +16892,7 @@ class Node extends EventTarget {
/**
* Print out a String representation of this Node.
*/
String toString() => localName == null ?
(nodeValue == null ? super.toString() : nodeValue) : localName;
String toString() => nodeValue == null ? super.toString() : nodeValue;
/**
* Binds the attribute [name] to the [path] of the [model].
@@ -16996,7 +16987,7 @@ class Node extends EventTarget {
@DocsEditable
// http://dom.spec.whatwg.org/#dom-node-localname
@deprecated // deprecated
String get localName native "Node_localName_Getter";
String get $dom_localName native "Node_localName_Getter";
@DomName('Node.namespaceURI')
@DocsEditable
@@ -24737,6 +24728,10 @@ class Window extends EventTarget implements WindowBase {
@Experimental
Stream<TouchEvent> get onTouchStart => Element.touchStartEvent.forTarget(this);
@DomName('Window.ontransitionend')
@DocsEditable
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
@DomName('Window.onunload')
@DocsEditable
Stream<Event> get onUnload => unloadEvent.forTarget(this);
@@ -24756,11 +24751,6 @@ class Window extends EventTarget implements WindowBase {
@Experimental // untriaged
Stream<AnimationEvent> get onAnimationStart => animationStartEvent.forTarget(this);
@DomName('Window.onwebkitTransitionEnd')
@DocsEditable
@deprecated
Stream<TransitionEvent> get onTransitionEnd => Element.transitionEndEvent.forTarget(this);
@DomName('DOMWindow.beforeunloadEvent')
@DocsEditable
@@ -25170,6 +25160,45 @@ class XsltProcessor extends NativeFieldWrapperClass1 {
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('Attr')
class _Attr extends Node {
_Attr.internal() : super.internal();
@DomName('Attr.isId')
@DocsEditable
bool get isId native "Attr_isId_Getter";
@DomName('Attr.name')
@DocsEditable
String get name native "Attr_name_Getter";
@DomName('Attr.ownerElement')
@DocsEditable
@deprecated // deprecated
Element get ownerElement native "Attr_ownerElement_Getter";
@DomName('Attr.specified')
@DocsEditable
@deprecated // deprecated
bool get specified native "Attr_specified_Getter";
@DomName('Attr.value')
@DocsEditable
String get value native "Attr_value_Getter";
@DomName('Attr.value')
@DocsEditable
void set value(String value) native "Attr_value_Setter";
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('CSSPrimitiveValue')
// http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface
@@ -26749,7 +26778,7 @@ abstract class _AttributeMap implements Map<String, String> {
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
keys.add(attributes[i].localName);
keys.add(attributes[i].name);
}
}
return keys;
+47
View File
@@ -0,0 +1,47 @@
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library SVGTest;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:svg';
main() {
useHtmlConfiguration();
test('svg parsed attributes', () {
var content = """
<svg version="1.1"
xmlns:xlink="http://www.w3.org/1999/xlink">
<image xlink:href="foo.jpg"/>
</svg>""";
var svg = new SvgElement.svg(content);
var img = svg.children[0];
expect(img is ImageElement, isTrue);
var attrs = img.attributes;
expect(attrs.length, 0);
var xlinkAttrs =
img.getNamespacedAttributes('http://www.w3.org/1999/xlink');
expect(xlinkAttrs.length, 1);
expect(xlinkAttrs['href'], 'foo.jpg');
// validate that the namespaced attr was set by waiting for the image
// to fail to load.
return img.onError.first;
});
test('svg explicit attributes', () {
var img = new ImageElement();
var xlinkAttrs =
img.getNamespacedAttributes('http://www.w3.org/1999/xlink');
xlinkAttrs['href'] = 'foo.jpg';
// validate that the namespaced attr was set by waiting for the image
// to fail to load.
return img.onError.first;
});
}
+1
View File
@@ -2354,6 +2354,7 @@
"comment": "http://www.w3.org/TR/touch-events/, http://www.chromestatus.com/features",
"support_level": "experimental"
},
"ontransitionend": {},
"onwebkitTransitionEnd": {
"support_level": "deprecated"
},
+1 -1
View File
@@ -279,7 +279,7 @@ _annotations = monitored.Dict('dartmetadata._annotations', {
'DOMWindow.webkitNotifications': _webkit_experimental_annotations,
'DOMWindow.webkitRequestFileSystem': _file_system_annotations,
'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations,
'Element.onwebkitTransitionEnd': _all_but_ie9_annotations,
'Element.ontransitionend': _all_but_ie9_annotations,
# Placeholder to add experimental flag, implementation for this is
# pending in a separate CL.
'Element.webkitMatchesSelector': ['@Experimental()'],
+2 -3
View File
@@ -15,7 +15,7 @@ _logger = logging.getLogger('dartgenerator')
# onEventName methods in the IDL but some events aren't listed so we need
# to manually add them here so that they are easy for users to find.
_html_manual_events = monitored.Dict('htmleventgenerator._html_manual_events', {
'Element': ['touchleave', 'touchenter', 'webkitTransitionEnd'],
'Element': ['touchleave', 'touchenter', 'transitionend'],
'Window': ['DOMContentLoaded']
})
@@ -28,7 +28,6 @@ _on_attribute_to_event_name_mapping = monitored.Dict(
'webkitanimationiteration': 'webkitAnimationIteration',
'webkitanimationstart': 'webkitAnimationStart',
'webkitspeechchange': 'webkitSpeechChange',
'webkittransitionend': 'webkitTransitionEnd',
})
_html_event_types = monitored.Dict('htmleventgenerator._html_event_types', {
@@ -108,7 +107,7 @@ _html_event_types = monitored.Dict('htmleventgenerator._html_event_types', {
'*.webkitAnimationEnd': ('animationEnd', 'AnimationEvent'),
'*.webkitAnimationIteration': ('animationIteration', 'AnimationEvent'),
'*.webkitAnimationStart': ('animationStart', 'AnimationEvent'),
'*.webkitTransitionEnd': ('transitionEnd', 'TransitionEvent'),
'*.transitionend': ('transitionEnd', 'TransitionEvent'),
'*.webkitfullscreenchange': ('fullscreenChange', 'Event'),
'*.webkitfullscreenerror': ('fullscreenError', 'Event'),
'AbstractWorker.error': ('error', 'ErrorEvent'),
+2 -1
View File
@@ -23,6 +23,7 @@ typed_array_renames = {
html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames',
dict({
'Attr': '_Attr',
'CDATASection': 'CDataSection',
'Clipboard': 'DataTransfer',
'Database': 'SqlDatabase', # Avoid conflict with Index DB's Database.
@@ -270,6 +271,7 @@ _private_html_members = monitored.Set('htmlrenamer._private_html_members', [
'Node.childNodes',
'Node.firstChild',
'Node.lastChild',
'Node.localName',
'Node.namespaceURI',
'Node.removeChild',
'Node.replaceChild',
@@ -363,7 +365,6 @@ for member in convert_to_future_members:
# to be suppressed but not the setter, etc.
# TODO(jacobr): cleanup and augment this list.
_removed_html_members = monitored.Set('htmlrenamer._removed_html_members', [
'Attr.*',
'AudioBufferSourceNode.looping', # TODO(vsm): Use deprecated IDL annotation
'CSSStyleDeclaration.getPropertyCSSValue',
'CanvasRenderingContext2D.clearShadow',
+1 -1
View File
@@ -44,7 +44,7 @@ abstract class _AttributeMap implements Map<String, String> {
var keys = new List<String>();
for (int i = 0, len = attributes.length; i < len; i++) {
if (_matches(attributes[i])) {
keys.add(attributes[i].localName);
keys.add(attributes[i].name);
}
}
return keys;
@@ -468,6 +468,16 @@ $endif
_xtag = value;
}
@DomName('Element.localName')
@DocsEditable
String get localName => $dom_localName;
@DomName('Element.namespaceUri')
@DocsEditable
String get namespaceUri => $dom_namespaceUri;
String toString() => localName;
/**
* Scrolls this element into view.
*
@@ -525,7 +535,7 @@ $if DART2JS
}
}
@DomName('Element.webkitTransitionEndEvent')
@DomName('Element.transitionEndEvent')
static const EventStreamProvider<TransitionEvent> transitionEndEvent =
const _CustomEventStreamProvider<TransitionEvent>(
Element._determineTransitionEventType);
@@ -249,8 +249,7 @@ $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
/**
* Print out a String representation of this Node.
*/
String toString() => localName == null ?
(nodeValue == null ? super.toString() : nodeValue) : localName;
String toString() => nodeValue == null ? super.toString() : nodeValue;
/**
* Binds the attribute [name] to the [path] of the [model].