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

Unified Diff: client/html/src/XMLElementWrappingImplementation.dart

Issue 9845043: Rename client/{dom,html} to lib/{dom,html} . (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/html/src/XMLElement.dart ('k') | client/html/src/XMLHttpRequestProgressEvent.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/html/src/XMLElementWrappingImplementation.dart
===================================================================
--- client/html/src/XMLElementWrappingImplementation.dart (revision 5796)
+++ client/html/src/XMLElementWrappingImplementation.dart (working copy)
@@ -1,191 +0,0 @@
-// 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.
-
-class _XMLClassSet extends _CssClassSet {
- _XMLClassSet(element) : super(element);
-
- String _className() {
- final classStr = _element.getAttribute('class');
- return classStr == null ? '' : classStr;
- }
-
- void _write(Set s) => _element.setAttribute('class', _formatSet(s));
-}
-
-class XMLElementWrappingImplementation extends ElementWrappingImplementation
- implements XMLElement {
- XMLElementWrappingImplementation._wrap(ptr) : super._wrap(ptr);
-
- factory XMLElementWrappingImplementation.tag(String tag) =>
- LevelDom.wrapElement(dom.document.createElementNS(null, tag));
-
- factory XMLElementWrappingImplementation.xml(String xml) {
- XMLElement parentTag = new XMLElement.tag('xml');
- parentTag.innerHTML = xml;
- if (parentTag.nodes.length == 1) return parentTag.nodes.removeLast();
-
- throw new IllegalArgumentException('XML had ${parentTag.nodes.length} ' +
- 'top-level nodes but 1 expected');
- }
-
- Set<String> get classes() {
- if (_cssClassSet === null) {
- _cssClassSet = new _XMLClassSet(_ptr);
- }
- return _cssClassSet;
- }
-
- ElementList get elements() {
- if (_elements == null) {
- _elements = new FilteredElementList(this);
- }
- return _elements;
- }
-
- void set elements(Collection<Element> value) {
- final elements = this.elements;
- elements.clear();
- elements.addAll(value);
- }
-
- String get outerHTML() {
- final container = new Element.tag("div");
- // Safari requires that the clone be removed from its owner document before
- // being inserted into the HTML document.
- container.elements.add(this.clone(true).remove());
- return container.innerHTML;
- }
-
- String get innerHTML() {
- final container = new Element.tag("div");
- // Safari requires that the clone be removed from its owner document before
- // being inserted into the HTML document.
- container.nodes.addAll(this.clone(true).remove().nodes);
- return container.innerHTML;
- }
-
- void set innerHTML(String xml) {
- final xmlDoc = new XMLDocument.xml('<xml>$xml</xml>');
- // Safari requires that the root node be removed from the document before
- // being inserted into the HTML document.
- this.nodes = xmlDoc.remove().nodes;
- }
-
- Node _insertAdjacentNode(String where, Node node) {
- switch (where.toLowerCase()) {
- case "beforebegin":
- if (parent == null) return null;
- parent.insertBefore(node, this);
- return node;
- case "afterend":
- if (parent == null) return null;
- if (nextNode == null) {
- parent.nodes.add(node);
- } else {
- parent.insertBefore(node, nextNode);
- }
- return node;
- case "afterbegin":
- this.insertBefore(node, nodes.first);
- return node;
- case "beforeend":
- this.nodes.add(node);
- return node;
- default:
- throw new IllegalArgumentException("Invalid position ${where}");
- }
- }
-
- XMLElement insertAdjacentElement([String where = null,
- XMLElement element = null]) => this._insertAdjacentNode(where, element);
-
- void insertAdjacentText([String where = null, String text = null]) {
- this._insertAdjacentNode(where, new Text(text));
- }
-
- void insertAdjacentHTML(
- [String position_OR_where = null, String text = null]) {
- this._insertAdjacentNode(
- position_OR_where, new DocumentFragment.xml(text));
- }
-
- Future<ElementRect> get rect() {
- return _createMeasurementFuture(() => const EmptyElementRect(),
- new Completer<ElementRect>());
- }
-
- // For HTML elemens, the default value of "contentEditable" is "inherit", so
- // we'll use that here as well even though it doesn't really make sense.
- String get contentEditable() => _attr('contentEditable', 'inherit');
-
- void set contentEditable(String value) {
- attributes['contentEditable'] = value;
- }
-
- void blur() {}
- void focus() {}
- void scrollByLines([int lines = null]) {}
- void scrollByPages([int pages = null]) {}
- void scrollIntoView([bool centerIfNeeded = null]) {}
-
- // Parentless HTML elements return false regardless of the value of their
- // contentEditable attribute, so XML elements do the same since they're never
- // actually editable.
- bool get isContentEditable() => false;
-
- bool get draggable() => attributes['draggable'] == 'true';
-
- void set draggable(bool value) { attributes['draggable'] = value.toString(); }
-
- bool get spellcheck() => attributes['spellcheck'] == 'true';
-
- void set spellcheck(bool value) {
- attributes['spellcheck'] = value.toString();
- }
-
- bool get hidden() => attributes.containsKey('hidden');
-
- void set hidden(bool value) {
- if (value) {
- attributes['hidden'] = '';
- } else {
- attributes.remove('hidden');
- }
- }
-
- int get tabIndex() {
- try {
- return Math.parseInt(_attr('tabIndex'));
- } catch (BadNumberFormatException e) {
- return 0;
- }
- }
-
- void set tabIndex(int value) { attributes['tabIndex'] = value.toString(); }
-
- String get id() => _attr('id');
-
- void set id(String value) { attributes['id'] = value; }
-
- String get title() => _attr('title');
-
- void set title(String value) { attributes['title'] = value; }
-
- String get webkitdropzone() => _attr('webkitdropzone');
-
- void set webkitdropzone(String value) {
- attributes['webkitdropzone'] = value;
- }
-
- String get lang() => _attr('lang');
-
- void set lang(String value) { attributes['lang'] = value; }
-
- String get dir() => _attr('dir');
-
- void set dir(String value) { attributes['dir'] = value; }
-
- String _attr(String name, [String def = '']) =>
- attributes.containsKey(name) ? attributes[name] : def;
-}
« no previous file with comments | « client/html/src/XMLElement.dart ('k') | client/html/src/XMLHttpRequestProgressEvent.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698