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

Side by Side Diff: sdk/lib/html/src/shared_FactoryProviders.dart

Issue 11365019: Merging dart:html interfaces and implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixing merged classes in dartium not compiling under dartc. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _CustomEventFactoryProvider { 5 class _CustomEventFactoryProvider {
6 static CustomEvent createCustomEvent(String type, [bool canBubble = true, 6 static CustomEvent createCustomEvent(String type, [bool canBubble = true,
7 bool cancelable = true, Object detail = null]) { 7 bool cancelable = true, Object detail = null]) {
8 final _CustomEventImpl e = _document.$dom_createEvent("CustomEvent"); 8 final CustomEvent e = document.$dom_createEvent("CustomEvent");
9 e.$dom_initCustomEvent(type, canBubble, cancelable, detail); 9 e.$dom_initCustomEvent(type, canBubble, cancelable, detail);
10 return e; 10 return e;
11 } 11 }
12 } 12 }
13 13
14 class _EventFactoryProvider { 14 class _EventFactoryProvider {
15 static Event createEvent(String type, [bool canBubble = true, 15 static Event createEvent(String type, [bool canBubble = true,
16 bool cancelable = true]) { 16 bool cancelable = true]) {
17 final _EventImpl e = _document.$dom_createEvent("Event"); 17 final Event e = document.$dom_createEvent("Event");
18 e.$dom_initEvent(type, canBubble, cancelable); 18 e.$dom_initEvent(type, canBubble, cancelable);
19 return e; 19 return e;
20 } 20 }
21 } 21 }
22 22
23 class _MouseEventFactoryProvider { 23 class _MouseEventFactoryProvider {
24 static MouseEvent createMouseEvent(String type, Window view, int detail, 24 static MouseEvent createMouseEvent(String type, Window view, int detail,
25 int screenX, int screenY, int clientX, int clientY, int button, 25 int screenX, int screenY, int clientX, int clientY, int button,
26 [bool canBubble = true, bool cancelable = true, bool ctrlKey = false, 26 [bool canBubble = true, bool cancelable = true, bool ctrlKey = false,
27 bool altKey = false, bool shiftKey = false, bool metaKey = false, 27 bool altKey = false, bool shiftKey = false, bool metaKey = false,
28 EventTarget relatedTarget = null]) { 28 EventTarget relatedTarget = null]) {
29 final e = _document.$dom_createEvent("MouseEvent"); 29 final e = document.$dom_createEvent("MouseEvent");
30 e.$dom_initMouseEvent(type, canBubble, cancelable, view, detail, 30 e.$dom_initMouseEvent(type, canBubble, cancelable, view, detail,
31 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, 31 screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
32 button, relatedTarget); 32 button, relatedTarget);
33 return e; 33 return e;
34 } 34 }
35 } 35 }
36 36
37 class _CSSStyleDeclarationFactoryProvider { 37 class _CSSStyleDeclarationFactoryProvider {
38 static CSSStyleDeclaration createCSSStyleDeclaration_css(String css) { 38 static CSSStyleDeclaration createCSSStyleDeclaration_css(String css) {
39 final style = new Element.tag('div').style; 39 final style = new Element.tag('div').style;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Copy list first since we don't want liveness during iteration. 77 // Copy list first since we don't want liveness during iteration.
78 final List nodes = new List.from(e.nodes); 78 final List nodes = new List.from(e.nodes);
79 fragment.nodes.addAll(nodes); 79 fragment.nodes.addAll(nodes);
80 return fragment; 80 return fragment;
81 } 81 }
82 } 82 }
83 83
84 class _SVGElementFactoryProvider { 84 class _SVGElementFactoryProvider {
85 static SVGElement createSVGElement_tag(String tag) { 85 static SVGElement createSVGElement_tag(String tag) {
86 final Element temp = 86 final Element temp =
87 _document.$dom_createElementNS("http://www.w3.org/2000/svg", tag); 87 document.$dom_createElementNS("http://www.w3.org/2000/svg", tag);
88 return temp; 88 return temp;
89 } 89 }
90 90
91 static SVGElement createSVGElement_svg(String svg) { 91 static SVGElement createSVGElement_svg(String svg) {
92 Element parentTag; 92 Element parentTag;
93 final match = _START_TAG_REGEXP.firstMatch(svg); 93 final match = _START_TAG_REGEXP.firstMatch(svg);
94 if (match != null && match.group(1).toLowerCase() == 'svg') { 94 if (match != null && match.group(1).toLowerCase() == 'svg') {
95 parentTag = new Element.tag('div'); 95 parentTag = new Element.tag('div');
96 } else { 96 } else {
97 parentTag = new SVGSVGElement(); 97 parentTag = new SVGSVGElement();
98 } 98 }
99 99
100 parentTag.innerHTML = svg; 100 parentTag.innerHTML = svg;
101 if (parentTag.elements.length == 1) return parentTag.elements.removeLast(); 101 if (parentTag.elements.length == 1) return parentTag.elements.removeLast();
102 102
103 throw new ArgumentError( 103 throw new ArgumentError(
104 'SVG had ${parentTag.elements.length} ' 104 'SVG had ${parentTag.elements.length} '
105 'top-level elements but 1 expected'); 105 'top-level elements but 1 expected');
106 } 106 }
107 } 107 }
108 108
109 class _SVGSVGElementFactoryProvider { 109 class _SVGSVGElementFactoryProvider {
110 static SVGSVGElement createSVGSVGElement() { 110 static SVGSVGElement createSVGSVGElement() {
111 final el = new SVGElement.tag("svg"); 111 final el = new SVGElement.tag("svg");
112 // The SVG spec requires the version attribute to match the spec version 112 // The SVG spec requires the version attribute to match the spec version
113 el.attributes['version'] = "1.1"; 113 el.attributes['version'] = "1.1";
114 return el; 114 return el;
115 } 115 }
116 } 116 }
OLDNEW
« no previous file with comments | « sdk/lib/html/src/native_DOMImplementation.dart ('k') | sdk/lib/html/templates/dart2js_impl.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698