SVG Library cleanups and adding supported tag.

BUG=

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

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@17940 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
efortuna@google.com
2013-01-31 19:38:00 +00:00
parent f644dfc14e
commit cab5d4cc51
20 changed files with 2645 additions and 1726 deletions
+107 -107
View File
@@ -27430,24 +27430,6 @@ class XsltProcessor native "*XSLTProcessor" {
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('HTMLAppletElement')
class _AppletElement extends Element native "*HTMLAppletElement" {
}
// 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('HTMLBaseFontElement')
class _BaseFontElement extends Element native "*HTMLBaseFontElement" {
}
// 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('ClientRectList')
class _ClientRectList implements JavaScriptIndexingBehavior, List<ClientRect> native "*ClientRectList" {
@@ -28039,15 +28021,6 @@ class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexi
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('HTMLDirectoryElement')
class _DirectoryElement extends Element native "*HTMLDirectoryElement" {
}
// 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('EntryArray')
class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*EntryArray" {
@@ -28442,85 +28415,6 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('HTMLFontElement')
class _FontElement extends Element native "*HTMLFontElement" {
}
// 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('HTMLFrameElement')
class _FrameElement extends Element native "*HTMLFrameElement" {
}
// 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('HTMLFrameSetElement')
class _FrameSetElement extends Element native "*HTMLFrameSetElement" {
@DocsEditable
@DomName('EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent')
@deprecated
_FrameSetElementEvents get on =>
new _FrameSetElementEvents(this);
}
@DocsEditable
@deprecated
class _FrameSetElementEvents extends ElementEvents {
@DocsEditable
_FrameSetElementEvents(EventTarget _ptr) : super(_ptr);
@DocsEditable
EventListenerList get beforeUnload => this['beforeunload'];
@DocsEditable
EventListenerList get blur => this['blur'];
@DocsEditable
EventListenerList get error => this['error'];
@DocsEditable
EventListenerList get focus => this['focus'];
@DocsEditable
EventListenerList get hashChange => this['hashchange'];
@DocsEditable
EventListenerList get load => this['load'];
@DocsEditable
EventListenerList get message => this['message'];
@DocsEditable
EventListenerList get offline => this['offline'];
@DocsEditable
EventListenerList get online => this['online'];
@DocsEditable
EventListenerList get popState => this['popstate'];
@DocsEditable
EventListenerList get resize => this['resize'];
@DocsEditable
EventListenerList get storage => this['storage'];
@DocsEditable
EventListenerList get unload => this['unload'];
}
// 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('GamepadList')
class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "*GamepadList" {
@@ -28718,9 +28612,115 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
// BSD-style license that can be found in the LICENSE file.
@DocsEditable
@DomName('HTMLAppletElement')
class _HTMLAppletElement extends Element native "*HTMLAppletElement" {
}
// 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('HTMLBaseFontElement')
class _HTMLBaseFontElement extends Element native "*HTMLBaseFontElement" {
}
// 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('HTMLDirectoryElement')
class _HTMLDirectoryElement extends Element native "*HTMLDirectoryElement" {
}
// 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('HTMLFontElement')
class _HTMLFontElement extends Element native "*HTMLFontElement" {
}
// 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('HTMLFrameElement')
class _HTMLFrameElement extends Element native "*HTMLFrameElement" {
}
// 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('HTMLFrameSetElement')
class _HTMLFrameSetElement extends Element native "*HTMLFrameSetElement" {
@DocsEditable
@DomName('EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent')
@deprecated
_HTMLFrameSetElementEvents get on =>
new _HTMLFrameSetElementEvents(this);
}
@DocsEditable
@deprecated
class _HTMLFrameSetElementEvents extends ElementEvents {
@DocsEditable
_HTMLFrameSetElementEvents(EventTarget _ptr) : super(_ptr);
@DocsEditable
EventListenerList get beforeUnload => this['beforeunload'];
@DocsEditable
EventListenerList get blur => this['blur'];
@DocsEditable
EventListenerList get error => this['error'];
@DocsEditable
EventListenerList get focus => this['focus'];
@DocsEditable
EventListenerList get hashChange => this['hashchange'];
@DocsEditable
EventListenerList get load => this['load'];
@DocsEditable
EventListenerList get message => this['message'];
@DocsEditable
EventListenerList get offline => this['offline'];
@DocsEditable
EventListenerList get online => this['online'];
@DocsEditable
EventListenerList get popState => this['popstate'];
@DocsEditable
EventListenerList get resize => this['resize'];
@DocsEditable
EventListenerList get storage => this['storage'];
@DocsEditable
EventListenerList get unload => this['unload'];
}
// 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('HTMLMarqueeElement')
class _MarqueeElement extends Element native "*HTMLMarqueeElement" {
class _HTMLMarqueeElement extends Element native "*HTMLMarqueeElement" {
}
// 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
+133 -132
View File
@@ -10050,6 +10050,7 @@ abstract class Element extends Node implements ElementTraversal {
@DomName('Element.webkitMatchesSelector')
@DocsEditable
@Experimental()
bool matches(String selectors) native "Element_webkitMatchesSelector_Callback";
@DomName('Element.webkitRequestFullScreen')
@@ -29843,32 +29844,6 @@ class XsltProcessor extends NativeFieldWrapperClass1 {
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('HTMLAppletElement')
class _AppletElement extends _Element_Merged {
_AppletElement.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('HTMLBaseFontElement')
class _BaseFontElement extends _Element_Merged {
_BaseFontElement.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('ClientRectList')
class _ClientRectList extends NativeFieldWrapperClass1 implements List<ClientRect> {
@@ -30472,19 +30447,6 @@ class _CssValueList extends CssValue implements List<CssValue> {
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('HTMLDirectoryElement')
class _DirectoryElement extends _Element_Merged {
_DirectoryElement.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('HTMLElement')
class _Element_Merged extends Element {
@@ -31024,97 +30986,6 @@ class _EntryArraySync extends NativeFieldWrapperClass1 implements List<EntrySync
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('HTMLFontElement')
class _FontElement extends _Element_Merged {
_FontElement.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('HTMLFrameElement')
class _FrameElement extends _Element_Merged {
_FrameElement.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('HTMLFrameSetElement')
class _FrameSetElement extends _Element_Merged {
_FrameSetElement.internal() : super.internal();
@DocsEditable
@DomName('EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent')
@deprecated
_FrameSetElementEvents get on =>
new _FrameSetElementEvents(this);
}
@DocsEditable
@deprecated
class _FrameSetElementEvents extends ElementEvents {
@DocsEditable
_FrameSetElementEvents(EventTarget _ptr) : super(_ptr);
@DocsEditable
EventListenerList get beforeUnload => this['beforeunload'];
@DocsEditable
EventListenerList get blur => this['blur'];
@DocsEditable
EventListenerList get error => this['error'];
@DocsEditable
EventListenerList get focus => this['focus'];
@DocsEditable
EventListenerList get hashChange => this['hashchange'];
@DocsEditable
EventListenerList get load => this['load'];
@DocsEditable
EventListenerList get message => this['message'];
@DocsEditable
EventListenerList get offline => this['offline'];
@DocsEditable
EventListenerList get online => this['online'];
@DocsEditable
EventListenerList get popState => this['popstate'];
@DocsEditable
EventListenerList get resize => this['resize'];
@DocsEditable
EventListenerList get storage => this['storage'];
@DocsEditable
EventListenerList get unload => this['unload'];
}
// 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('GamepadList')
class _GamepadList extends NativeFieldWrapperClass1 implements List<Gamepad> {
@@ -31316,10 +31187,140 @@ class _GamepadList extends NativeFieldWrapperClass1 implements List<Gamepad> {
// WARNING: Do not edit - generated code.
@DocsEditable
@DomName('HTMLAppletElement')
class _HTMLAppletElement extends _Element_Merged {
_HTMLAppletElement.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('HTMLBaseFontElement')
class _HTMLBaseFontElement extends _Element_Merged {
_HTMLBaseFontElement.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('HTMLDirectoryElement')
class _HTMLDirectoryElement extends _Element_Merged {
_HTMLDirectoryElement.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('HTMLFontElement')
class _HTMLFontElement extends _Element_Merged {
_HTMLFontElement.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('HTMLFrameElement')
class _HTMLFrameElement extends _Element_Merged {
_HTMLFrameElement.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('HTMLFrameSetElement')
class _HTMLFrameSetElement extends _Element_Merged {
_HTMLFrameSetElement.internal() : super.internal();
@DocsEditable
@DomName('EventTarget.addEventListener, EventTarget.removeEventListener, EventTarget.dispatchEvent')
@deprecated
_HTMLFrameSetElementEvents get on =>
new _HTMLFrameSetElementEvents(this);
}
@DocsEditable
@deprecated
class _HTMLFrameSetElementEvents extends ElementEvents {
@DocsEditable
_HTMLFrameSetElementEvents(EventTarget _ptr) : super(_ptr);
@DocsEditable
EventListenerList get beforeUnload => this['beforeunload'];
@DocsEditable
EventListenerList get blur => this['blur'];
@DocsEditable
EventListenerList get error => this['error'];
@DocsEditable
EventListenerList get focus => this['focus'];
@DocsEditable
EventListenerList get hashChange => this['hashchange'];
@DocsEditable
EventListenerList get load => this['load'];
@DocsEditable
EventListenerList get message => this['message'];
@DocsEditable
EventListenerList get offline => this['offline'];
@DocsEditable
EventListenerList get online => this['online'];
@DocsEditable
EventListenerList get popState => this['popstate'];
@DocsEditable
EventListenerList get resize => this['resize'];
@DocsEditable
EventListenerList get storage => this['storage'];
@DocsEditable
EventListenerList get unload => this['unload'];
}
// 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('HTMLMarqueeElement')
class _MarqueeElement extends _Element_Merged {
_MarqueeElement.internal() : super.internal();
class _HTMLMarqueeElement extends _Element_Merged {
_HTMLMarqueeElement.internal() : super.internal();
}
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
@@ -930,5 +930,5 @@ class VersionChangeRequestEvents extends RequestEvents {
@DocsEditable
@DomName('IDBAny')
class _Any native "*IDBAny" {
class _IDBAny native "*IDBAny" {
}
@@ -1056,7 +1056,7 @@ class VersionChangeRequestEvents extends RequestEvents {
@DocsEditable
@DomName('IDBAny')
class _Any extends NativeFieldWrapperClass1 {
_Any.internal();
class _IDBAny extends NativeFieldWrapperClass1 {
_IDBAny.internal();
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+43 -14
View File
@@ -85,9 +85,14 @@ notifications_test/supported: Fail
serialized_script_value_test: Fail
shadow_dom_test/supported: Fail
speechrecognition_test/supported: Fail
storage_test: Fail, Pass
svgelement_test/additionalConstructors: Fail
svgelement2_test: Fail
storage_test: Fail, Pas
svgelement_test/supported_altGlyph: Fail
svgelement_test/supported_animate: Fail
svgelement_test/supported_animateTransform: Fail
svgelement_test/supported_animateMotion: Fail
svgelement_test/supported_foreignObject: Fail
svgelement_test/supported_set: Fail
svgelement2_test/supported: Fail
touchevent_test/supported: Fail
webgl_1_test/supported: Fail
websql_test/supported: Fail
@@ -156,9 +161,37 @@ postmessage_structured_test: Skip # BUG(5685): times out.
serialized_script_value_test: Fail
shadow_dom_test/supported: Fail
speechrecognition_test/supported: Fail
svg_3_test: Fail
svgelement_test/additionalConstructors: Fail
svgelement2_test: Fail
svg_test/supported_externalResourcesRequired: Fail
svgelement_test/supported_altGlyph: Fail
svgelement_test/supported_animate: Fail
svgelement_test/supported_animateTransform: Fail
svgelement_test/supported_animateMotion: Fail
svgelement_test/supported_feBlend: Fail
svgelement_test/supported_feColorMatrix: Fail
svgelement_test/supported_feComponentTransfer: Fail
svgelement_test/supported_feConvolveMatrix: Fail
svgelement_test/supported_feDiffuseLighting: Fail
svgelement_test/supported_feDisplacementMap: Fail
svgelement_test/supported_feDistantLight: Fail
svgelement_test/supported_feFlood: Fail
svgelement_test/supported_feFuncA: Fail
svgelement_test/supported_feFuncB: Fail
svgelement_test/supported_feFuncG: Fail
svgelement_test/supported_feFuncR: Fail
svgelement_test/supported_feGaussianBlur: Fail
svgelement_test/supported_feImage: Fail
svgelement_test/supported_feMerge: Fail
svgelement_test/supported_feMergeNode: Fail
svgelement_test/supported_feOffset: Fail
svgelement_test/supported_fePointLight: Fail
svgelement_test/supported_feSpecularLighting: Fail
svgelement_test/supported_feSpotLight: Fail
svgelement_test/supported_feTile: Fail
svgelement_test/supported_feTurbulence: Fail
svgelement_test/supported_filter: Fail
svgelement_test/supported_foreignObject: Fail
svgelement_test/supported_set: Fail
svgelement2_test/supported: Fail
touchevent_test/supported: Fail
url_test: Fail # IE9 does not support createObjectURL (it is supported in IE10)
websocket_test/supported: Fail
@@ -227,9 +260,8 @@ notifications_test/supported: Fail
performance_api_test/supported: Fail
serialized_script_value_test: Fail
speechrecognition_test/supported: Fail
svg_3_test: Fail
svgelement_test/additionalConstructors: Fail
svgelement2_test: Fail
svg_test/supported_externalResourcesRequired: Fail
svg_test/supported_langSpace: Fail
typed_arrays_arraybuffer_test: Fail
url_test: Fail
fileapi_test: Skip # Timeout.
@@ -268,10 +300,8 @@ media_stream_test/supported_MediaStreamTrackEvent: Fail
notifications_test/supported: Fail
shadow_dom_test/supported: Fail
speechrecognition_test/supported: Fail
# Interfaces not implemented: SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable
svg_3_test: Fail
svgelement_test/additionalConstructors: Fail
svgelement2_test: Fail
svg_test/supported_externalResourcesRequired: Fail
svg_test/supported_langSpace: Fail
touchevent_test/supported: Fail
transferables_test: Fail # Issue 3392.
webgl_1_test: Pass, Fail # Issue 8219
@@ -300,4 +330,3 @@ isolates_test: Skip # Timeout because leg does not support web workers.
[ $compiler == dart2js && $runtime == ff ]
inner_frame_test: Skip # Timeout
svg_3_test: Skip # Timeout
-46
View File
@@ -1,46 +0,0 @@
library SVG1Test;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
import 'dart:svg' as svg;
// Test that SVG is present in dart:html API
main() {
useHtmlConfiguration();
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
test('simpleRect', () {
var div = new Element.tag('div');
document.body.nodes.add(div);
div.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
var e = document.query('#svg1');
expect(e, isNotNull);
svg.RectElement r = document.query('#rect1');
expect(r.x.baseVal.value, 10);
expect(r.y.baseVal.value, 20);
expect(r.height.baseVal.value, 40);
expect(r.width.baseVal.value, 130);
expect(r.rx.baseVal.value, 5);
});
test('trailing newline', () {
// Ensures that we handle SVG with trailing newlines.
var logo = new svg.SvgElement.svg("""
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<path/>
</svg>
""");
expect(logo, isSvgElement);
});
}
-65
View File
@@ -1,65 +0,0 @@
library SVG2Test;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
import 'dart:svg' as svg;
// Test that SVG elements explicitly implement the IDL interfaces (is-checks
// only, see SVGTest3 for behavioural tests).
main() {
insertTestDiv() {
var element = new Element.tag('div');
element.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
document.body.nodes.add(element);
return element;
}
useHtmlConfiguration();
var isElement = predicate((x) => x is Element, 'is an Element');
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
var isSvgSvgElement =
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
var isNode = predicate((x) => x is Node, 'is a Node');
var isSvgTests = predicate((x) => x is svg.Tests, 'is a svg.Tests');
var isSvgLangSpace = predicate((x) => x is svg.LangSpace, 'is a svg.LangSpace');
var isSvgExternalResourcesRequired =
predicate((x) => x is svg.ExternalResourcesRequired,
'is a svg.ExternalResourcesRequired');
var isSvgTransformable =
predicate((x) => x is svg.Transformable, 'is a svg.Transformable');
var isSvgLocatable =
predicate((x) => x is svg.Locatable, 'is a svg.Locatable');
var isSvgNumber = predicate((x) => x is svg.Number, 'is a svg.Number');
var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
test('rect_isChecks', () {
var div = insertTestDiv();
var r = document.query('#rect1');
// Direct inheritance chain
expect(r, isSvgElement);
expect(r, isElement);
expect(r, isNode);
// Other implemented interfaces.
expect(r, isSvgTests);
expect(r, isSvgLangSpace);
expect(r, isSvgExternalResourcesRequired);
expect(r, isSvgTransformable);
expect(r, isSvgLocatable);
// Interfaces not implemented.
expect(r, isNot(isSvgNumber));
expect(r, isNot(isSvgRect));
expect(r, isNot(isSvgSvgElement));
div.remove();
});
}
-129
View File
@@ -1,129 +0,0 @@
library SVG3Test;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
import 'dart:svg' as svg;
// Test that SVG elements have the operations advertised through all the IDL
// interfaces. This is a 'duck typing' test, and does not explicitly use 'is'
// checks on the expected interfaces (that is in SVGTest2).
main() {
var isString = predicate((x) => x is String, 'is a String');
var isStringList = predicate((x) => x is List<String>, 'is a List<String>');
var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix');
var isSvgAnimatedBoolean =
predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean');
var isSvgAnimatedString =
predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString');
var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
var isSvgAnimatedTransformList =
predicate((x) => x is svg.AnimatedTransformList,
'is an svg.AnimatedTransformList');
var isCssStyleDeclaration =
predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration');
var isCssValue = predicate((x) => x is CssValue, 'is a CssValue');
insertTestDiv() {
var element = new Element.tag('div');
element.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
document.body.nodes.add(element);
return element;
}
useHtmlConfiguration();
/**
* Verifies that [e] supports the operations on the svg.Tests interface.
*/
checkSvgTests(e) {
// Just check that the operations seem to exist.
var rx = e.requiredExtensions;
expect(rx, isStringList);
var rf = e.requiredFeatures;
expect(rf, isStringList);
var sl = e.systemLanguage;
expect(sl, isStringList);
bool hasDoDo = e.hasExtension("DoDo");
expect(hasDoDo, isFalse);
}
/**
* Verifies that [e] supports the operations on the svg.LangSpace interface.
*/
checkSvgLangSpace(e) {
// Just check that the attribtes seem to exist.
var lang = e.xmllang;
e.xmllang = lang;
String space = e.xmlspace;
e.xmlspace = space;
expect(lang, isString);
expect(space, isString);
}
/**
* Verifies that [e] supports the operations on the
* svg.ExternalResourcesRequired interface.
*/
checkSvgExternalResourcesRequired(e) {
var b = e.externalResourcesRequired;
expect(b, isSvgAnimatedBoolean);
expect(b.baseVal, isFalse);
expect(b.animVal, isFalse);
}
/**
* Verifies that [e] supports the operations on the svg.Locatable interface.
*/
checkSvgLocatable(e) {
var v1 = e.farthestViewportElement;
var v2 = e.nearestViewportElement;
expect(v1, same(v2));
var bbox = e.getBBox();
expect(bbox, isSvgRect);
var ctm = e.getCtm();
expect(ctm, isSvgMatrix);
var sctm = e.getScreenCtm();
expect(sctm, isSvgMatrix);
var xf2e = e.getTransformToElement(e);
expect(xf2e, isSvgMatrix);
}
/**
* Verifies that [e] supports the operations on the svg.Transformable
* interface.
*/
checkSvgTransformable(e) {
var trans = e.transform;
expect(trans, isSvgAnimatedTransformList);
}
testRect(name, checker) {
test(name, () {
var div = insertTestDiv();
var r = document.query('#rect1');
checker(r);
div.remove();
});
}
testRect('rect_SvgTests', checkSvgTests);
testRect('rect_SvgLangSpace', checkSvgLangSpace);
testRect('rect_SvgExternalResourcesRequired',
checkSvgExternalResourcesRequired);
testRect('rect_SvgLocatable', checkSvgLocatable);
testRect('rect_SvgTransformable', checkSvgTransformable);
}
+247
View File
@@ -0,0 +1,247 @@
// 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_individual_config.dart';
import 'dart:html';
import 'dart:svg' as svg;
main() {
useHtmlIndividualConfiguration();
group('svgPresence', () {
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
test('simpleRect', () {
var div = new Element.tag('div');
document.body.nodes.add(div);
div.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
var e = document.query('#svg1');
expect(e, isNotNull);
svg.RectElement r = document.query('#rect1');
expect(r.x.baseVal.value, 10);
expect(r.y.baseVal.value, 20);
expect(r.height.baseVal.value, 40);
expect(r.width.baseVal.value, 130);
expect(r.rx.baseVal.value, 5);
});
test('trailing newline', () {
// Ensures that we handle SVG with trailing newlines.
var logo = new svg.SvgElement.svg("""
<svg xmlns='http://www.w3.org/2000/svg' version='1.1'>
<path/>
</svg>
""");
expect(logo, isSvgElement);
});
});
group('svgInterfaceMatch', () {
// Test that SVG elements explicitly implement the IDL interfaces (is-checks
// only, see SVGTest3 for behavioural tests).
insertTestDiv() {
var element = new Element.tag('div');
element.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
document.body.nodes.add(element);
return element;
}
var isElement = predicate((x) => x is Element, 'is an Element');
var isSvgElement = predicate((x) => x is svg.SvgElement, 'is a SvgElement');
var isSvgSvgElement =
predicate((x) => x is svg.SvgSvgElement, 'is a SvgSvgElement');
var isNode = predicate((x) => x is Node, 'is a Node');
var isSvgTests = predicate((x) => x is svg.Tests, 'is a svg.Tests');
var isSvgLangSpace = predicate((x) => x is svg.LangSpace, 'is a svg.LangSpace');
var isSvgExternalResourcesRequired =
predicate((x) => x is svg.ExternalResourcesRequired,
'is a svg.ExternalResourcesRequired');
var isSvgTransformable =
predicate((x) => x is svg.Transformable, 'is a svg.Transformable');
var isSvgLocatable =
predicate((x) => x is svg.Locatable, 'is a svg.Locatable');
var isSvgNumber = predicate((x) => x is svg.Number, 'is a svg.Number');
var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
test('rect_isChecks', () {
var div = insertTestDiv();
var r = document.query('#rect1');
// Direct inheritance chain
expect(r, isSvgElement);
expect(r, isElement);
expect(r, isNode);
// Other implemented interfaces.
expect(r, isSvgTests);
expect(r, isSvgLangSpace);
expect(r, isSvgExternalResourcesRequired);
expect(r, isSvgTransformable);
expect(r, isSvgLocatable);
// Interfaces not implemented.
expect(r, isNot(isSvgNumber));
expect(r, isNot(isSvgRect));
expect(r, isNot(isSvgSvgElement));
div.remove();
});
});
insertTestDiv() {
var element = new Element.tag('div');
element.innerHtml = r'''
<svg id='svg1' width='200' height='100'>
<rect id='rect1' x='10' y='20' width='130' height='40' rx='5'fill='blue'></rect>
</svg>
''';
document.body.nodes.add(element);
return element;
}
group('supported_externalResourcesRequired', () {
test('supported', () {
var div = insertTestDiv();
var r = document.query('#rect1');
expect(svg.ExternalResourcesRequired.supported(r), true);
div.remove();
});
});
group('supported_langSpace', () {
test('supported', () {
var div = insertTestDiv();
var r = document.query('#rect1');
expect(svg.LangSpace.supported(r), true);
div.remove();
});
});
group('svgBehavioral', () {
// Test that SVG elements have the operations advertised through all the IDL
// interfaces. This is a 'duck typing' test, and does not explicitly use
// 'is' checks on the expected interfaces (that is in the test group above).
var isString = predicate((x) => x is String, 'is a String');
var isStringList = predicate((x) => x is List<String>, 'is a List<String>');
var isSvgMatrix = predicate((x) => x is svg.Matrix, 'is a svg.Matrix');
var isSvgAnimatedBoolean =
predicate((x) => x is svg.AnimatedBoolean, 'is an svg.AnimatedBoolean');
var isSvgAnimatedString =
predicate((x) => x is svg.AnimatedString, 'is an svg.AnimatedString');
var isSvgRect = predicate((x) => x is svg.Rect, 'is a svg.Rect');
var isSvgAnimatedTransformList =
predicate((x) => x is svg.AnimatedTransformList,
'is an svg.AnimatedTransformList');
var isCssStyleDeclaration =
predicate((x) => x is CssStyleDeclaration, 'is a CssStyleDeclaration');
var isCssValue = predicate((x) => x is CssValue, 'is a CssValue');
/// Verifies that [e] supports the operations on the svg.Tests interface.
checkSvgTests(e) {
// Just check that the operations seem to exist.
var rx = e.requiredExtensions;
expect(rx, isStringList);
var rf = e.requiredFeatures;
expect(rf, isStringList);
var sl = e.systemLanguage;
expect(sl, isStringList);
bool hasDoDo = e.hasExtension("DoDo");
expect(hasDoDo, isFalse);
}
/// Verifies that [e] supports the operations on the svg.Locatable interface.
checkSvgLocatable(e) {
var v1 = e.farthestViewportElement;
var v2 = e.nearestViewportElement;
expect(v1, same(v2));
var bbox = e.getBBox();
expect(bbox, isSvgRect);
var ctm = e.getCtm();
expect(ctm, isSvgMatrix);
var sctm = e.getScreenCtm();
expect(sctm, isSvgMatrix);
var xf2e = e.getTransformToElement(e);
expect(xf2e, isSvgMatrix);
}
/**
* Verifies that [e] supports the operations on the svg.Transformable
* interface.
*/
checkSvgTransformable(e) {
var trans = e.transform;
expect(trans, isSvgAnimatedTransformList);
}
testRect(name, checker) {
test(name, () {
var div = insertTestDiv();
var r = document.query('#rect1');
checker(r);
div.remove();
});
}
/**
* Verifies that [e] supports the operations on the svg.LangSpace interface.
*/
checkSvgLangSpace(e) {
if (svg.LangSpace.supported(e)) {
// Just check that the attributes seem to exist.
var lang = e.xmllang;
e.xmllang = lang;
String space = e.xmlspace;
e.xmlspace = space;
expect(lang, isString);
expect(space, isString);
}
}
/**
* Verifies that [e] supports the operations on the
* svg.ExternalResourcesRequired interface.
*/
checkSvgExternalResourcesRequired(e) {
if (svg.ExternalResourcesRequired.supported(e)) {
var b = e.externalResourcesRequired;
expect(b, isSvgAnimatedBoolean);
expect(b.baseVal, isFalse);
expect(b.animVal, isFalse);
}
}
testRect('rect_SvgTests', checkSvgTests);
testRect('rect_SvgLangSpace', checkSvgLangSpace);
testRect('rect_SvgExternalResourcesRequired',
checkSvgExternalResourcesRequired);
testRect('rect_SvgLocatable', checkSvgLocatable);
testRect('rect_SvgTransformable', checkSvgTransformable);
});
}
+10 -6
View File
@@ -4,7 +4,7 @@
library SVGElement2Test;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import '../../pkg/unittest/lib/html_individual_config.dart';
import 'svgelement_test.dart' as originalTest;
class A {
@@ -13,9 +13,13 @@ class A {
}
main() {
// The svgelement_test requires the field "_this" to map to "_this". In this
// test-case we use another library's '_this' first (see issue 3039 and
// _ChildNodeListLazy.first).
expect(new A(499)._this, 499);
originalTest.main();
useHtmlIndividualConfiguration();
group('supported', () {
// The svgelement_test requires the field "_this" to map to "_this". In this
// test-case we use another library's '_this' first (see issue 3039 and
// _ChildNodeListLazy.first).
expect(new A(499)._this, 499);
originalTest.main();
});
}
+297 -107
View File
@@ -27,126 +27,316 @@ main() {
return out;
};
testConstructor(String tagName, Function isExpectedClass) {
testConstructor(String tagName, Function isExpectedClass,
[bool expectation = true]) {
test(tagName, () {
expect(isExpectedClass(new svg.SvgElement.tag(tagName)), isTrue);
expect(isExpectedClass(new svg.SvgElement.tag(tagName)), expectation);
expect(isExpectedClass(
new svg.SvgElement.svg('<$tagName></$tagName>')), isTrue);
new svg.SvgElement.svg('<$tagName></$tagName>')), expectation);
});
}
group('additionalConstructors', () {
group('svg', () {
test('valid', () {
final svgContent = """
test('valid', () {
final svgContent = """
<svg version="1.1">
<circle></circle>
<path></path>
</svg>""";
final el = new svg.SvgElement.svg(svgContent);
expect(el, isSvgSvgElement);
expect(el.innerHtml, "<circle></circle><path></path>");
expect(el.outerHtml, svgContent);
});
test('has no parent', () =>
expect(new svg.SvgElement.svg('<circle/>').parent, isNull)
);
test('empty', () {
expect(() => new svg.SvgElement.svg(""), throwsArgumentError);
});
test('too many elements', () {
expect(() => new svg.SvgElement.svg("<circle></circle><path></path>"),
throwsArgumentError);
});
final el = new svg.SvgElement.svg(svgContent);
expect(el, isSvgSvgElement);
expect(el.innerHtml, anyOf("<circle></circle><path></path>", '<circle '
'xmlns="http://www.w3.org/2000/svg" /><path '
'xmlns="http://www.w3.org/2000/svg" />'));
expect(el.outerHtml, anyOf(svgContent,
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">\n '
'<circle />\n <path />\n</svg>'));
});
test('has no parent', () =>
expect(new svg.SvgElement.svg('<circle/>').parent, isNull)
);
test('empty', () {
expect(() => new svg.SvgElement.svg(""), throwsArgumentError);
});
test('too many elements', () {
expect(() => new svg.SvgElement.svg("<circle></circle><path></path>"),
throwsArgumentError);
});
});
// Unfortunately, because the filtering mechanism in unitttest is a regex done
group('supported_altGlyph', () {
test('supported', () {
expect(svg.AltGlyphElement.supported, true);
});
});
group('supported_animate', () {
test('supported', () {
expect(svg.AnimateElement.supported, true);
});
});
group('supported_animateMotion', () {
test('supported', () {
expect(svg.AnimateMotionElement.supported, true);
});
});
group('supported_animateTransform', () {
test('supported', () {
expect(svg.AnimateTransformElement.supported, true);
});
});
group('supported_feBlend', () {
test('supported', () {
expect(svg.FEBlendElement.supported, true);
});
});
group('supported_feColorMatrix', () {
test('supported', () {
expect(svg.FEColorMatrixElement.supported, true);
});
});
group('supported_feComponentTransfer', () {
test('supported', () {
expect(svg.FEComponentTransferElement.supported, true);
});
});
group('supported_feConvolveMatrix', () {
test('supported', () {
expect(svg.FEConvolveMatrixElement.supported, true);
});
});
group('supported_feDiffuseLighting', () {
test('supported', () {
expect(svg.FEDiffuseLightingElement.supported, true);
});
});
group('supported_feDisplacementMap', () {
test('supported', () {
expect(svg.FEDisplacementMapElement.supported, true);
});
});
group('supported_feDistantLight', () {
test('supported', () {
expect(svg.FEDistantLightElement.supported, true);
});
});
group('supported_feFlood', () {
test('supported', () {
expect(svg.FEFloodElement.supported, true);
});
});
group('supported_feFuncA', () {
test('supported', () {
expect(svg.FEFuncAElement.supported, true);
});
});
group('supported_feFuncB', () {
test('supported', () {
expect(svg.FEFuncBElement.supported, true);
});
});
group('supported_feFuncG', () {
test('supported', () {
expect(svg.FEFuncGElement.supported, true);
});
});
group('supported_feFuncR', () {
test('supported', () {
expect(svg.FEFuncRElement.supported, true);
});
});
group('supported_feGaussianBlur', () {
test('supported', () {
expect(svg.FEGaussianBlurElement.supported, true);
});
});
group('supported_feImage', () {
test('supported', () {
expect(svg.FEImageElement.supported, true);
});
});
group('supported_feMerge', () {
test('supported', () {
expect(svg.FEMergeElement.supported, true);
});
});
group('supported_feMergeNode', () {
test('supported', () {
expect(svg.FEMergeNodeElement.supported, true);
});
});
group('supported_feOffset', () {
test('supported', () {
expect(svg.FEOffsetElement.supported, true);
});
});
group('supported_feComponentTransfer', () {
test('supported', () {
expect(svg.FEPointLightElement.supported, true);
});
});
group('supported_feSpecularLighting', () {
test('supported', () {
expect(svg.FESpecularLightingElement.supported, true);
});
});
group('supported_feComponentTransfer', () {
test('supported', () {
expect(svg.FESpotLightElement.supported, true);
});
});
group('supported_feTile', () {
test('supported', () {
expect(svg.FETileElement.supported, true);
});
});
group('supported_feTurbulence', () {
test('supported', () {
expect(svg.FETurbulenceElement.supported, true);
});
});
group('supported_filter', () {
test('supported', () {
expect(svg.FilterElement.supported, true);
});
});
group('supported_foreignObject', () {
test('supported', () {
expect(svg.ForeignObjectElement.supported, true);
});
});
group('supported_set', () {
test('supported', () {
expect(svg.SetElement.supported, true);
});
testConstructor('altGlyphDef', (e) => e is svg.AltGlyphDefElement);
testConstructor('altGlyph', (e) => e is svg.AltGlyphElement);
testConstructor('animateColor', (e) => e is svg.AnimateColorElement);
testConstructor('animate', (e) => e is svg.AnimateElement);
// WebKit doesn't recognize animateMotion
// testConstructor('animateMotion', (e) => e is svg.AnimateMotionElement);
testConstructor('animateTransform', (e) => e is svg.AnimateTransformElement);
testConstructor('cursor', (e) => e is svg.CursorElement);
testConstructor('feBlend', (e) => e is svg.FEBlendElement);
testConstructor('feColorMatrix', (e) => e is svg.FEColorMatrixElement);
testConstructor('feComponentTransfer',
(e) => e is svg.FEComponentTransferElement);
testConstructor('feConvolveMatrix', (e) => e is svg.FEConvolveMatrixElement);
testConstructor('feDiffuseLighting',
(e) => e is svg.FEDiffuseLightingElement);
testConstructor('feDisplacementMap',
(e) => e is svg.FEDisplacementMapElement);
testConstructor('feDistantLight', (e) => e is svg.FEDistantLightElement);
testConstructor('feDropShadow', (e) => e is svg.FEDropShadowElement);
testConstructor('feFlood', (e) => e is svg.FEFloodElement);
testConstructor('feFuncA', (e) => e is svg.FEFuncAElement);
testConstructor('feFuncB', (e) => e is svg.FEFuncBElement);
testConstructor('feFuncG', (e) => e is svg.FEFuncGElement);
testConstructor('feFuncR', (e) => e is svg.FEFuncRElement);
testConstructor('feGaussianBlur', (e) => e is svg.FEGaussianBlurElement);
testConstructor('feImage', (e) => e is svg.FEImageElement);
testConstructor('feMerge', (e) => e is svg.FEMergeElement);
testConstructor('feMergeNode', (e) => e is svg.FEMergeNodeElement);
testConstructor('feOffset', (e) => e is svg.FEOffsetElement);
testConstructor('fePointLight', (e) => e is svg.FEPointLightElement);
testConstructor('feSpecularLighting',
(e) => e is svg.FESpecularLightingElement);
testConstructor('feSpotLight', (e) => e is svg.FESpotLightElement);
testConstructor('feTile', (e) => e is svg.FETileElement);
testConstructor('feTurbulence', (e) => e is svg.FETurbulenceElement);
testConstructor('filter', (e) => e is svg.FilterElement);
testConstructor('font', (e) => e is svg.FontElement);
testConstructor('font-face', (e) => e is svg.FontFaceElement);
testConstructor('font-face-format', (e) => e is svg.FontFaceFormatElement);
testConstructor('font-face-name', (e) => e is svg.FontFaceNameElement);
testConstructor('font-face-src', (e) => e is svg.FontFaceSrcElement);
testConstructor('font-face-uri', (e) => e is svg.FontFaceUriElement);
testConstructor('foreignObject', (e) => e is svg.ForeignObjectElement);
testConstructor('glyph', (e) => e is svg.GlyphElement);
testConstructor('glyphRef', (e) => e is svg.GlyphRefElement);
testConstructor('metadata', (e) => e is svg.MetadataElement);
testConstructor('missing-glyph', (e) => e is svg.MissingGlyphElement);
testConstructor('set', (e) => e is svg.SetElement);
testConstructor('tref', (e) => e is svg.TRefElement);
testConstructor('vkern', (e) => e is svg.VKernElement);
});
group('constructors', () {
testConstructor('a', (e) => e is svg.AElement);
testConstructor('circle', (e) => e is svg.CircleElement);
testConstructor('clipPath', (e) => e is svg.ClipPathElement);
testConstructor('defs', (e) => e is svg.DefsElement);
testConstructor('desc', (e) => e is svg.DescElement);
testConstructor('ellipse', (e) => e is svg.EllipseElement);
testConstructor('g', (e) => e is svg.GElement);
// WebKit doesn't recognize hkern
// testConstructor('hkern', (e) => e is svg.HKernElement);
testConstructor('image', (e) => e is svg.ImageElement);
testConstructor('line', (e) => e is svg.LineElement);
testConstructor('linearGradient', (e) => e is svg.LinearGradientElement);
// WebKit doesn't recognize mpath
// testConstructor('mpath', (e) => e is svg.MPathElement);
testConstructor('marker', (e) => e is svg.MarkerElement);
testConstructor('mask', (e) => e is svg.MaskElement);
testConstructor('path', (e) => e is svg.PathElement);
testConstructor('pattern', (e) => e is svg.PatternElement);
testConstructor('polygon', (e) => e is svg.PolygonElement);
testConstructor('polyline', (e) => e is svg.PolylineElement);
testConstructor('radialGradient', (e) => e is svg.RadialGradientElement);
testConstructor('rect', (e) => e is svg.RectElement);
testConstructor('script', (e) => e is svg.ScriptElement);
testConstructor('stop', (e) => e is svg.StopElement);
testConstructor('style', (e) => e is svg.StyleElement);
testConstructor('switch', (e) => e is svg.SwitchElement);
testConstructor('symbol', (e) => e is svg.SymbolElement);
testConstructor('tspan', (e) => e is svg.TSpanElement);
testConstructor('text', (e) => e is svg.TextElement);
testConstructor('textPath', (e) => e is svg.TextPathElement);
testConstructor('title', (e) => e is svg.TitleElement);
testConstructor('use', (e) => e is svg.UseElement);
testConstructor('view', (e) => e is svg.ViewElement);
test('supported', () {
testConstructor('a', (e) => e is svg.AElement);
testConstructor('circle', (e) => e is svg.CircleElement);
testConstructor('clipPath', (e) => e is svg.ClipPathElement);
testConstructor('defs', (e) => e is svg.DefsElement);
testConstructor('desc', (e) => e is svg.DescElement);
testConstructor('ellipse', (e) => e is svg.EllipseElement);
testConstructor('g', (e) => e is svg.GElement);
testConstructor('image', (e) => e is svg.ImageElement);
testConstructor('line', (e) => e is svg.LineElement);
testConstructor('linearGradient', (e) => e is svg.LinearGradientElement);
testConstructor('marker', (e) => e is svg.MarkerElement);
testConstructor('mask', (e) => e is svg.MaskElement);
testConstructor('path', (e) => e is svg.PathElement);
testConstructor('pattern', (e) => e is svg.PatternElement);
testConstructor('polygon', (e) => e is svg.PolygonElement);
testConstructor('polyline', (e) => e is svg.PolylineElement);
testConstructor('radialGradient', (e) => e is svg.RadialGradientElement);
testConstructor('rect', (e) => e is svg.RectElement);
testConstructor('script', (e) => e is svg.ScriptElement);
testConstructor('stop', (e) => e is svg.StopElement);
testConstructor('style', (e) => e is svg.StyleElement);
testConstructor('switch', (e) => e is svg.SwitchElement);
testConstructor('symbol', (e) => e is svg.SymbolElement);
testConstructor('tspan', (e) => e is svg.TSpanElement);
testConstructor('text', (e) => e is svg.TextElement);
testConstructor('textPath', (e) => e is svg.TextPathElement);
testConstructor('title', (e) => e is svg.TitleElement);
testConstructor('use', (e) => e is svg.UseElement);
testConstructor('view', (e) => e is svg.ViewElement);
testConstructor('altGlyph', (e) => e is svg.AltGlyphElement,
svg.AltGlyphElement.supported);
testConstructor('animate', (e) => e is svg.AnimateElement,
svg.AnimateElement.supported);
testConstructor('animateMotion', (e) => e is svg.AnimateMotionElement,
svg.AnimateMotionElement.supported);
testConstructor('animateTransform', (e) => e is svg.AnimateTransformElement,
svg.AnimateTransformElement.supported);
testConstructor('feBlend', (e) => e is svg.FEBlendElement,
svg.FEBlendElement.supported);
testConstructor('feColorMatrix', (e) => e is svg.FEColorMatrixElement,
svg.FEColorMatrixElement.supported);
testConstructor('feComponentTransfer',
(e) => e is svg.FEComponentTransferElement,
svg.FEComponentTransferElement.supported);
testConstructor('feConvolveMatrix',
(e) => e is svg.FEConvolveMatrixElement,
svg.FEConvolveMatrixElement.supported);
testConstructor('feDiffuseLighting',
(e) => e is svg.FEDiffuseLightingElement,
svg.FEDiffuseLightingElement.supported);
testConstructor('feDisplacementMap',
(e) => e is svg.FEDisplacementMapElement,
svg.FEDisplacementMapElement.supported);
testConstructor('feDistantLight', (e) => e is svg.FEDistantLightElement,
svg.FEDistantLightElement.supported);
testConstructor('feFlood', (e) => e is svg.FEFloodElement,
svg.FEFloodElement.supported);
testConstructor('feFuncA', (e) => e is svg.FEFuncAElement,
svg.FEFuncAElement.supported);
testConstructor('feFuncB', (e) => e is svg.FEFuncBElement,
svg.FEFuncBElement.supported);
testConstructor('feFuncG', (e) => e is svg.FEFuncGElement,
svg.FEFuncGElement.supported);
testConstructor('feFuncR', (e) => e is svg.FEFuncRElement,
svg.FEFuncRElement.supported);
testConstructor('feGaussianBlur', (e) => e is svg.FEGaussianBlurElement,
svg.FEGaussianBlurElement.supported);
testConstructor('feImage', (e) => e is svg.FEImageElement,
svg.FEImageElement.supported);
testConstructor('feMerge', (e) => e is svg.FEMergeElement,
svg.FEMergeElement.supported);
testConstructor('feMergeNode', (e) => e is svg.FEMergeNodeElement,
svg.FEMergeNodeElement.supported);
testConstructor('feOffset', (e) => e is svg.FEOffsetElement,
svg.FEOffsetElement.supported);
testConstructor('fePointLight', (e) => e is svg.FEPointLightElement,
svg.FEPointLightElement.supported);
testConstructor('feSpecularLighting',
(e) => e is svg.FESpecularLightingElement,
svg.FESpecularLightingElement.supported);
testConstructor('feSpotLight', (e) => e is svg.FESpotLightElement,
svg.FESpotLightElement.supported);
testConstructor('feTile', (e) => e is svg.FETileElement,
svg.FETileElement.supported);
testConstructor('feTurbulence', (e) => e is svg.FETurbulenceElement,
svg.FETurbulenceElement.supported);
testConstructor('filter', (e) => e is svg.FilterElement,
svg.FilterElement.supported);
testConstructor('foreignObject', (e) => e is svg.ForeignObjectElement,
svg.ForeignObjectElement.supported);
testConstructor('metadata', (e) => e is svg.MetadataElement);
testConstructor('set', (e) => e is svg.SetElement,
svg.SetElement.supported);
});
});
group('outerHtml', () {
+44 -23
View File
@@ -26,10 +26,8 @@ _pure_interfaces = set([
'MediaQueryListListener',
'MutationCallback',
'NodeSelector',
'SVGExternalResourcesRequired',
'SVGFilterPrimitiveStandardAttributes',
'SVGFitToViewBox',
'SVGLangSpace',
'SVGLocatable',
'SVGTests',
'SVGTransformable',
@@ -654,12 +652,6 @@ dart2js_annotations = {
],
}
# Placeholder to add experimental flag, implementation for this is
# pending in a separate CL.
dart_annotations = {
'Element.webkitMatchesSelector': ['@Experimental'],
}
_indexed_db_annotations = [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX, '15')",
@@ -687,6 +679,12 @@ _webkit_experimental_annotations = [
_history_annotations = _all_but_ie9_annotations
_no_ie_annotations = [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX)",
"@SupportedBrowser(SupportedBrowser.SAFARI)",
]
_performance_annotations = [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX)",
@@ -698,6 +696,8 @@ _speech_recognition_annotations = [
"@Experimental",
]
_svg_annotations = _all_but_ie9_annotations;
_web_sql_annotations = [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.SAFARI)",
@@ -734,6 +734,9 @@ dart_annotations = {
'DOMWindow.webkitNotifications': _webkit_experimental_annotations,
'DOMWindow.webkitRequestFileSystem': _file_system_annotations,
'DOMWindow.webkitResolveLocalFileSystemURL': _file_system_annotations,
# Placeholder to add experimental flag, implementation for this is
# pending in a separate CL.
'Element.webkitMatchesSelector': ['@Experimental()'],
'Element.webkitCreateShadowRoot': [
"@SupportedBrowser(SupportedBrowser.CHROME, '25')",
"@Experimental",
@@ -759,21 +762,9 @@ dart_annotations = {
"@SupportedBrowser(SupportedBrowser.SAFARI)",
],
'HTMLKeygenElement': _webkit_experimental_annotations,
'HTMLMeterElement': [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX)",
"@SupportedBrowser(SupportedBrowser.SAFARI)",
],
'HTMLObjectElement': [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX)",
"@SupportedBrowser(SupportedBrowser.SAFARI)",
],
'HTMLOutputElement': [
"@SupportedBrowser(SupportedBrowser.CHROME)",
"@SupportedBrowser(SupportedBrowser.FIREFOX)",
"@SupportedBrowser(SupportedBrowser.SAFARI)",
],
'HTMLMeterElement': _no_ie_annotations,
'HTMLObjectElement': _no_ie_annotations,
'HTMLOutputElement': _no_ie_annotations,
'HTMLProgressElement': _all_but_ie9_annotations,
'HTMLShadowElement': [
"@SupportedBrowser(SupportedBrowser.CHROME, '25')",
@@ -804,6 +795,36 @@ dart_annotations = {
'SpeechRecognitionError': _speech_recognition_annotations,
'SpeechRecognitionEvent': _speech_recognition_annotations,
'SpeechRecognitionResult': _speech_recognition_annotations,
'SVGAltGlyphElement': _no_ie_annotations,
'SVGAnimateElement': _no_ie_annotations,
'SVGAnimateMotionElement': _no_ie_annotations,
'SVGAnimateTransformElement': _no_ie_annotations,
'SVGFEBlendElement': _svg_annotations,
'SVGFEColorMatrixElement': _svg_annotations,
'SVGFEComponentTransferElement': _svg_annotations,
'SVGFEConvolveMatrixElement': _svg_annotations,
'SVGFEDiffuseLightingElement': _svg_annotations,
'SVGFEDisplacementMapElement': _svg_annotations,
'SVGFEDistantLightElement': _svg_annotations,
'SVGFEFloodElement': _svg_annotations,
'SVGFEFuncAElement': _svg_annotations,
'SVGFEFuncBElement': _svg_annotations,
'SVGFEFuncGElement': _svg_annotations,
'SVGFEFuncRElement': _svg_annotations,
'SVGFEGaussianBlurElement': _svg_annotations,
'SVGFEImageElement': _svg_annotations,
'SVGFEMergeElement': _svg_annotations,
'SVGFEMergeNodeElement': _svg_annotations,
'SVGFEMorphology': _svg_annotations,
'SVGFEOffsetElement': _svg_annotations,
'SVGFEPointLightElement': _svg_annotations,
'SVGFESpecularLightingElement': _svg_annotations,
'SVGFESpotLightElement': _svg_annotations,
'SVGFETileElement': _svg_annotations,
'SVGFETurbulenceElement': _svg_annotations,
'SVGFilterElement': _svg_annotations,
'SVGForeignObjectElement': _no_ie_annotations,
'SVGSetElement': _no_ie_annotations,
'SQLTransaction': _web_sql_annotations,
'SQLTransactionSync': _web_sql_annotations,
'WebGLRenderingContext': _webgl_annotations,
+8 -3
View File
@@ -32,11 +32,16 @@ class HtmlDartGenerator(object):
def EmitSupportCheck(self):
if self.HasSupportCheck():
support_check = self.GetSupportCheck()
check = self.GetSupportCheck()
if type(check) != tuple:
signature = 'get supported'
else:
signature = check[0]
check = check[1]
self._members_emitter.Emit('\n'
' /// Checks if this type is supported on the current platform.\n'
' static bool get supported => $SUPPORT_CHECK;\n',
SUPPORT_CHECK=support_check)
' static bool $SIGNATURE => $SUPPORT_CHECK;\n',
SIGNATURE=signature, SUPPORT_CHECK=check)
def EmitEventGetter(self, events_class_name):
self._members_emitter.Emit(
+36 -8
View File
@@ -16,15 +16,7 @@ html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', {
'DOMFormData': 'FormData',
'DOMURL': 'Url',
'DOMWindow': 'Window',
'HTMLAppletElement' : '_AppletElement',
'HTMLBaseFontElement' : '_BaseFontElement',
'HTMLDirectoryElement' : '_DirectoryElement',
'HTMLDocument' : 'HtmlDocument',
'HTMLFontElement' : '_FontElement',
'HTMLFrameElement' : '_FrameElement',
'HTMLFrameSetElement' : '_FrameSetElement',
'HTMLMarqueeElement' : '_MarqueeElement',
'IDBAny': '_Any', # Suppressed, but needs to exist for Dartium.
'IDBFactory': 'IdbFactory', # Manual to avoid name conflicts.
'NavigatorUserMediaErrorCallback': '_NavigatorUserMediaErrorCallback',
'NavigatorUserMediaSuccessCallback': '_NavigatorUserMediaSuccessCallback',
@@ -46,6 +38,42 @@ html_interface_renames = monitored.Dict('htmlrenamer.html_interface_renames', {
'XMLHttpRequestUpload': 'HttpRequestUpload',
})
# Interfaces that are suppressed, but need to still exist for Dartium and to
# properly wrap DOM objects if/when encountered.
_removed_html_interfaces = [
'HTMLAppletElement',
'HTMLBaseFontElement',
'HTMLDirectoryElement',
'HTMLFontElement',
'HTMLFrameElement',
'HTMLFrameSetElement',
'HTMLMarqueeElement',
'IDBAny',
'SVGAltGlyphDefElement', # Webkit only.
'SVGAltGlyphItemElement', # Webkit only.
'SVGAnimateColorElement', # Deprecated. Use AnimateElement instead.
'SVGComponentTransferFunctionElement', # Currently not supported anywhere.
'SVGCursorElement', # Webkit only.
'SVGGradientElement', # Currently not supported anywhere.
'SVGFEDropShadowElement', # Webkit only for the following:
'SVGFontElement',
'SVGFontFaceElement',
'SVGFontFaceFormatElement',
'SVGFontFaceNameElement',
'SVGFontFaceSrcElement',
'SVGFontFaceUriElement',
'SVGGlyphElement',
'SVGGlyphRefElement',
'SVGHKernElement',
'SVGMissingGlyphElement',
'SVGMPathElement',
'SVGTRefElement',
'SVGVKernElement',
]
for interface in _removed_html_interfaces:
html_interface_renames[interface] = '_' + interface
# Members from the standard dom that should not be exposed publicly in dart:html
# but need to be exposed internally to implement dart:html on top of a standard
# browser.
+3
View File
@@ -29,6 +29,9 @@ class Dict(MonitoredCollection):
self._used_keys.add(key)
return self._map[key]
def __setitem__(self, key, value):
self._map[key] = value
def __contains__(self, key):
self._used_keys.add(key)
return key in self._map
+221 -137
View File
@@ -69,40 +69,6 @@ _js_custom_members = set([
'WorkerContext.indexedDB',
])
js_support_checks = {
'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')",
'Database': "JS('bool', '!!(window.openDatabase)')",
'DOMApplicationCache': "JS('bool', '!!(window.applicationCache)')",
'DOMFileSystem': "JS('bool', '!!(window.webkitRequestFileSystem)')",
'HashChangeEvent': "Event._isTypeSupported('HashChangeEvent')",
'HTMLContentElement': "Element.isTagSupported('content')",
'HTMLDataListElement': "Element.isTagSupported('datalist')",
'HTMLDetailsElement': "Element.isTagSupported('details')",
'HTMLEmbedElement': "Element.isTagSupported('embed')",
# IE creates keygen as Block elements
'HTMLKeygenElement': "Element.isTagSupported('keygen') "
"&& (new Element.tag('keygen') is KeygenElement)",
'HTMLMeterElement': "Element.isTagSupported('meter')",
'HTMLObjectElement': "Element.isTagSupported('object')",
'HTMLOutputElement': "Element.isTagSupported('output')",
'HTMLProgressElement': "Element.isTagSupported('progress')",
'HTMLShadowElement': "Element.isTagSupported('shadow')",
'HTMLTrackElement': "Element.isTagSupported('track')",
'MediaStreamEvent': "Event._isTypeSupported('MediaStreamEvent')",
'MediaStreamTrackEvent': "Event._isTypeSupported('MediaStreamTrackEvent')",
'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')",
'Performance': "JS('bool', '!!(window.performance)')",
'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || "
"window.webkitSpeechRecognition)')",
'XMLHttpRequestProgressEvent':
"Event._isTypeSupported('XMLHttpRequestProgressEvent')",
'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')",
'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')",
'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')",
'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')",
'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')",
}
# Classes that offer only static methods, and therefore we should suppress
# constructor creation.
_static_classes = set(['Url'])
@@ -140,122 +106,139 @@ class ElementConstructorInfo(object):
return info
_html_element_constructors = {
'AnchorElement' :
'HTMLAnchorElement' :
ElementConstructorInfo(tag='a', opt_params=[('DOMString', 'href')]),
'AreaElement': 'area',
'ButtonElement': 'button',
'BRElement': 'br',
'BaseElement': 'base',
'BodyElement': 'body',
'ButtonElement': 'button',
'CanvasElement':
'HTMLAreaElement': 'area',
'HTMLButtonElement': 'button',
'HTMLBRElement': 'br',
'HTMLBaseElement': 'base',
'HTMLBodyElement': 'body',
'HTMLButtonElement': 'button',
'HTMLCanvasElement':
ElementConstructorInfo(tag='canvas',
opt_params=[('int', 'width'), ('int', 'height')]),
'ContentElement': 'content',
'DataListElement': 'datalist',
'DListElement': 'dl',
'DetailsElement': 'details',
'DivElement': 'div',
'EmbedElement': 'embed',
'FieldSetElement': 'fieldset',
'FormElement': 'form',
'HRElement': 'hr',
'HeadElement': 'head',
'HeadingElement': [ElementConstructorInfo('h1'),
'HTMLContentElement': 'content',
'HTMLDataListElement': 'datalist',
'HTMLDListElement': 'dl',
'HTMLDetailsElement': 'details',
'HTMLDivElement': 'div',
'HTMLEmbedElement': 'embed',
'HTMLFieldSetElement': 'fieldset',
'HTMLFormElement': 'form',
'HTMLHRElement': 'hr',
'HTMLHeadElement': 'head',
'HTMLHeadingElement': [ElementConstructorInfo('h1'),
ElementConstructorInfo('h2'),
ElementConstructorInfo('h3'),
ElementConstructorInfo('h4'),
ElementConstructorInfo('h5'),
ElementConstructorInfo('h6')],
'HtmlElement': 'html',
'IFrameElement': 'iframe',
'ImageElement':
'HTMLHtmlElement': 'html',
'HTMLIFrameElement': 'iframe',
'HTMLImageElement':
ElementConstructorInfo(tag='img',
opt_params=[('DOMString', 'src'),
('int', 'width'), ('int', 'height')]),
'KeygenElement': 'keygen',
'LIElement': 'li',
'LabelElement': 'label',
'LegendElement': 'legend',
'LinkElement': 'link',
'MapElement': 'map',
'MenuElement': 'menu',
'MeterElement': 'meter',
'OListElement': 'ol',
'ObjectElement': 'object',
'OptGroupElement': 'optgroup',
'OutputElement': 'output',
'ParagraphElement': 'p',
'ParamElement': 'param',
'PreElement': 'pre',
'ProgressElement': 'progress',
'ScriptElement': 'script',
'SelectElement': 'select',
'SourceElement': 'source',
'SpanElement': 'span',
'StyleElement': 'style',
'TableCaptionElement': 'caption',
'TableCellElement': 'td',
'TableColElement': 'col',
'TableElement': 'table',
'TableRowElement': 'tr',
#'TableSectionElement' <thead> <tbody> <tfoot>
'TextAreaElement': 'textarea',
'TitleElement': 'title',
'TrackElement': 'track',
'UListElement': 'ul',
'VideoElement': 'video'
'HTMLKeygenElement': 'keygen',
'HTMLLIElement': 'li',
'HTMLLabelElement': 'label',
'HTMLLegendElement': 'legend',
'HTMLLinkElement': 'link',
'HTMLMapElement': 'map',
'HTMLMenuElement': 'menu',
'HTMLMeterElement': 'meter',
'HTMLOListElement': 'ol',
'HTMLObjectElement': 'object',
'HTMLOptGroupElement': 'optgroup',
'HTMLOutputElement': 'output',
'HTMLParagraphElement': 'p',
'HTMLParamElement': 'param',
'HTMLPreElement': 'pre',
'HTMLProgressElement': 'progress',
'HTMLScriptElement': 'script',
'HTMLSelectElement': 'select',
'HTMLSourceElement': 'source',
'HTMLSpanElement': 'span',
'HTMLStyleElement': 'style',
'HTMLTableCaptionElement': 'caption',
'HTMLTableCellElement': 'td',
'HTMLTableColElement': 'col',
'HTMLTableElement': 'table',
'HTMLTableRowElement': 'tr',
#'HTMLTableSectionElement' <thead> <tbody> <tfoot>
'HTMLTextAreaElement': 'textarea',
'HTMLTitleElement': 'title',
'HTMLTrackElement': 'track',
'HTMLUListElement': 'ul',
'HTMLVideoElement': 'video'
}
_svg_element_constructors = {
'AElement': 'a',
'AnimateColorElement': 'animateColor',
'AnimateElement': 'animate',
'AnimateMotionElement': 'animateMotion',
'AnimateTransformElement': 'animateTransform',
'AnimationElement': 'animation',
'CircleElement': 'circle',
'ClipPathElement': 'clipPath',
'CursorElement': 'cursor',
'DefsElement': 'defs',
'DescElement': 'desc',
'EllipseElement': 'ellipse',
'FilterElement': 'filter',
'FontElement': 'font',
'FontFaceElement': 'font-face',
'FontFaceFormatElement': 'font-face-format',
'FontFaceNameElement': 'font-face-name',
'FontFaceSrcElement': 'font-face-src',
'FontFaceUriElement': 'font-face-uri',
'ForeignObjectElement': 'foreignObject',
'GlyphElement': 'glyph',
'GElement': 'g',
'HKernElement': 'hkern',
'ImageElement': 'image',
'LinearGradientElement': 'linearGradient',
'LineElement': 'line',
'MarkerElement': 'marker',
'MaskElement': 'mask',
'MPathElement': 'mpath',
'PathElement': 'path',
'PatternElement': 'pattern',
'PolygonElement': 'polygon',
'PolylineElement': 'polyline',
'RadialGradientElement': 'radialGradient',
'RectElement': 'rect',
'ScriptElement': 'script',
'SetElement': 'set',
'StopElement': 'stop',
'StyleElement': 'style',
'SwitchElement': 'switch',
'SymbolElement': 'symbol',
'TextElement': 'text',
'TitleElement': 'title',
'TRefElement': 'tref',
'TSpanElement': 'tspan',
'UseElement': 'use',
'ViewElement': 'view',
'VKernElement': 'vkern',
'SVGAElement': 'a',
'SVGAltGlyphElement': 'altGlyph',
'SVGAnimateElement': 'animate',
'SVGAnimateMotionElement': 'animateMotion',
'SVGAnimateTransformElement': 'animateTransform',
'SVGAnimationElement': 'animation',
'SVGCircleElement': 'circle',
'SVGClipPathElement': 'clipPath',
'SVGCursorElement': 'cursor',
'SVGDefsElement': 'defs',
'SVGDescElement': 'desc',
'SVGEllipseElement': 'ellipse',
'SVGFEBlendElement': 'feBlend',
'SVGFEColorMatrixElement': 'feColorMatrix',
'SVGFEComponentTransferElement': 'feComponentTransfer',
'SVGFEConvolveMatrixElement': 'feConvolveMatrix',
'SVGFEDiffuseLightingElement': 'feDiffuseLighting',
'SVGFEDisplacementMapElement': 'feDisplacementMap',
'SVGFEDistantLightElement': 'feDistantLight',
'SVGFEFloodElement': 'feFlood',
'SVGFEFuncAElement': 'feFuncA',
'SVGFEFuncBElement': 'feFuncB',
'SVGFEFuncGElement': 'feFuncG',
'SVGFEFuncRElement': 'feFuncR',
'SVGFEGaussianBlurElement': 'feGaussianBlur',
'SVGFEImageElement': 'feImage',
'SVGFEMergeElement': 'feMerge',
'SVGFEMergeNodeElement': 'feMergeNode',
'SVGFEMorphology': 'feMorphology',
'SVGFEOffsetElement': 'feOffset',
'SVGFEPointLightElement': 'fePointLight',
'SVGFESpecularLightingElement': 'feSpecularLighting',
'SVGFESpotLightElement': 'feSpotLight',
'SVGFETileElement': 'feTile',
'SVGFETurbulenceElement': 'feTurbulence',
'SVGFilterElement': 'filter',
'SVGForeignObjectElement': 'foreignObject',
'SVGGlyphElement': 'glyph',
'SVGGElement': 'g',
'SVGHKernElement': 'hkern',
'SVGImageElement': 'image',
'SVGLinearGradientElement': 'linearGradient',
'SVGLineElement': 'line',
'SVGMarkerElement': 'marker',
'SVGMaskElement': 'mask',
'SVGMPathElement': 'mpath',
'SVGPathElement': 'path',
'SVGPatternElement': 'pattern',
'SVGPolygonElement': 'polygon',
'SVGPolylineElement': 'polyline',
'SVGRadialGradientElement': 'radialGradient',
'SVGRectElement': 'rect',
'SVGScriptElement': 'script',
'SVGSetElement': 'set',
'SVGStopElement': 'stop',
'SVGStyleElement': 'style',
'SVGSwitchElement': 'switch',
'SVGSymbolElement': 'symbol',
'SVGTextElement': 'text',
'SVGTitleElement': 'title',
'SVGTRefElement': 'tref',
'SVGTSpanElement': 'tspan',
'SVGUseElement': 'use',
'SVGViewElement': 'view',
'SVGVKernElement': 'vkern',
}
_element_constructors = {
@@ -300,6 +283,94 @@ def ElementConstructorInfos(typename, element_constructors,
return infos
# ------------------------------------------------------------------------------
def SvgSupportStr(tagName):
return 'Svg%s' % ElemSupportStr(tagName)
def ElemSupportStr(tagName):
return "Element.isTagSupported('%s')" % tagName
_js_support_checks_basic_element = [
'HTMLContentElement',
'HTMLDataListElement',
'HTMLDetailsElement',
'HTMLEmbedElement',
'HTMLMeterElement',
'HTMLObjectElement',
'HTMLOutputElement',
'HTMLProgressElement',
'HTMLTrackElement',
]
_js_support_checks_additional_element = [
# IE creates keygen as Block elements
'HTMLKeygenElement',
'SVGAltGlyphElement',
'SVGAnimateElement',
'SVGAnimateMotionElement',
'SVGAnimateTransformElement',
'SVGCursorElement',
'SVGFEBlendElement',
'SVGFEColorMatrixElement',
'SVGFEComponentTransferElement',
'SVGFEConvolveMatrixElement',
'SVGFEDiffuseLightingElement',
'SVGFEDisplacementMapElement',
'SVGFEDistantLightElement',
'SVGFEFloodElement',
'SVGFEFuncAElement',
'SVGFEFuncBElement',
'SVGFEFuncGElement',
'SVGFEFuncRElement',
'SVGFEGaussianBlurElement',
'SVGFEImageElement',
'SVGFEMergeElement',
'SVGFEMergeNodeElement',
'SVGFEMorphology',
'SVGFEOffsetElement',
'SVGFEPointLightElement',
'SVGFESpecularLightingElement',
'SVGFESpotLightElement',
'SVGFETileElement',
'SVGFETurbulenceElement',
'SVGFilterElement',
'SVGForeignObjectElement',
'SVGSetElement',
]
js_support_checks = dict({
'ArrayBuffer': "JS('bool', 'typeof window.ArrayBuffer != \"undefined\"')",
'Database': "JS('bool', '!!(window.openDatabase)')",
'DOMApplicationCache': "JS('bool', '!!(window.applicationCache)')",
'DOMFileSystem': "JS('bool', '!!(window.webkitRequestFileSystem)')",
'HashChangeEvent': "Event._isTypeSupported('HashChangeEvent')",
'HTMLShadowElement': ElemSupportStr('shadow'),
'MediaStreamEvent': "Event._isTypeSupported('MediaStreamEvent')",
'MediaStreamTrackEvent': "Event._isTypeSupported('MediaStreamTrackEvent')",
'NotificationCenter': "JS('bool', '!!(window.webkitNotifications)')",
'Performance': "JS('bool', '!!(window.performance)')",
'SpeechRecognition': "JS('bool', '!!(window.SpeechRecognition || "
"window.webkitSpeechRecognition)')",
'SVGExternalResourcesRequired': ('supported(SvgElement element)',
"JS('bool', '#.externalResourcesRequired !== undefined && "
"#.externalResourcesRequired.animVal !== undefined', "
"element, element)"),
'SVGLangSpace': ('supported(SvgElement element)',
"JS('bool', '#.xmlspace !== undefined && #.xmllang !== undefined', "
"element, element)"),
'XMLHttpRequestProgressEvent':
"Event._isTypeSupported('XMLHttpRequestProgressEvent')",
'WebGLRenderingContext': "JS('bool', '!!(window.WebGLRenderingContext)')",
'WebKitCSSMatrix': "JS('bool', '!!(window.WebKitCSSMatrix)')",
'WebKitPoint': "JS('bool', '!!(window.WebKitPoint)')",
'WebSocket': "JS('bool', 'typeof window.WebSocket != \"undefined\"')",
'XSLTProcessor': "JS('bool', '!!(window.XSLTProcessor)')",
}.items() +
dict((key,
SvgSupportStr(_svg_element_constructors[key]) if key.startswith('SVG')
else ElemSupportStr(_html_element_constructors[key])) for key in
_js_support_checks_basic_element +
_js_support_checks_additional_element).items())
# ------------------------------------------------------------------------------
class HtmlDartInterfaceGenerator(object):
"""Generates dart interface and implementation for the DOM IDL interface."""
@@ -359,7 +430,7 @@ class HtmlDartInterfaceGenerator(object):
factory_provider = interface_name
# HTML Elements and SVG Elements have convenience constructors.
infos = ElementConstructorInfos(interface_name,
infos = ElementConstructorInfos(self._interface.id,
_element_constructors[self._library_name], factory_provider_name=
_factory_ctr_strings[self._library_name]['provider_name'])
@@ -521,6 +592,19 @@ class Dart2JSBackend(HtmlDartGenerator):
return self._interface.doc_js_name in js_support_checks
def GetSupportCheck(self):
"""Return a tuple of the support check function signature and the support
test itself. If no parameters are supplied, we assume the default."""
if self._interface.doc_js_name in _js_support_checks_additional_element:
if self._interface.doc_js_name in _svg_element_constructors:
lib_prefix = 'Svg'
constructors = _svg_element_constructors
else:
lib_prefix = ''
constructors = _html_element_constructors
return (js_support_checks.get(self._interface.doc_js_name) +
" && (new %sElement.tag('%s') is %s)" % (lib_prefix,
constructors[self._interface.doc_js_name],
self._renamer.RenameInterface(self._interface)))
return js_support_checks.get(self._interface.doc_js_name)
def GenerateCustomFactory(self, constructor_info):
+5 -1
View File
@@ -235,7 +235,11 @@ class DartiumBackend(HtmlDartGenerator):
def GetSupportCheck(self):
# Assume that everything is supported on Dartium.
return 'true'
value = js_support_checks.get(self._interface.doc_js_name)
if type(value) == tuple:
return value
else:
return 'true'
def FinishInterface(self):
self._GenerateCPPHeader()
@@ -111,5 +111,14 @@ $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
throw new UnsupportedError("Cannot invoke click SVG.");
}
/**
* Checks to see if the SVG element type is supported by the current platform.
*
* The tag should be a valid SVG element tag name.
*/
static bool isTagSupported(String tag) {
var e = new $CLASSNAME.tag(tag);
return e is $CLASSNAME && !(e is UnknownElement);
}
$!MEMBERS
}