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

Side by Side Diff: client/html/src/ElementWrappingImplementation.dart

Issue 8548019: Add a script for determining which DOM methods correspond to which HTML methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: More code review changes Created 9 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality. 5 // TODO(jacobr): use Lists.dart to remove some of the duplicated functionality.
6 class _ChildrenElementList implements ElementList { 6 class _ChildrenElementList implements ElementList {
7 // Raw Element. 7 // Raw Element.
8 final _element; 8 final _element;
9 final _childElements; 9 final _childElements;
10 10
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool containsValue(String value) { 285 bool containsValue(String value) {
286 final attributes = _element.attributes; 286 final attributes = _element.attributes;
287 for (int i = 0, len = attributes.length; i < len; i++) { 287 for (int i = 0, len = attributes.length; i < len; i++) {
288 if(value == attributes.item(i).value) { 288 if(value == attributes.item(i).value) {
289 return true; 289 return true;
290 } 290 }
291 } 291 }
292 return false; 292 return false;
293 } 293 }
294 294
295 /** @domName Element.hasAttribute */
295 bool containsKey(String key) { 296 bool containsKey(String key) {
296 return _element.hasAttribute(key); 297 return _element.hasAttribute(key);
297 } 298 }
298 299
300 /** @domName Element.getAttribute */
299 String operator [](String key) { 301 String operator [](String key) {
300 return _element.getAttribute(key); 302 return _element.getAttribute(key);
301 } 303 }
302 304
305 /** @domName Element.setAttribute */
303 void operator []=(String key, String value) { 306 void operator []=(String key, String value) {
304 _element.setAttribute(key, value); 307 _element.setAttribute(key, value);
305 } 308 }
306 309
307 String putIfAbsent(String key, String ifAbsent()) { 310 String putIfAbsent(String key, String ifAbsent()) {
308 if (!containsKey(key)) { 311 if (!containsKey(key)) {
309 this[key] = ifAbsent(); 312 this[key] = ifAbsent();
310 } 313 }
311 } 314 }
312 315
316 /** @domName Element.removeAttribute */
313 String remove(String key) { 317 String remove(String key) {
314 _element.removeAttribute(key); 318 _element.removeAttribute(key);
315 } 319 }
316 320
317 void clear() { 321 void clear() {
318 final attributes = _element.attributes; 322 final attributes = _element.attributes;
319 for (int i = attributes.length - 1; i >= 0; i--) { 323 for (int i = attributes.length - 1; i >= 0; i--) {
320 _element.removeAttribute(attributes.item(i).name); 324 _element.removeAttribute(attributes.item(i).name);
321 } 325 }
322 } 326 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 435 }
432 436
433 String toString() => "($left, $top, $width, $height)"; 437 String toString() => "($left, $top, $width, $height)";
434 } 438 }
435 439
436 // TODO(jacobr): we cannot currently be lazy about calculating the client 440 // TODO(jacobr): we cannot currently be lazy about calculating the client
437 // rects as we must perform all measurement queries at a safe point to avoid 441 // rects as we must perform all measurement queries at a safe point to avoid
438 // triggering unneeded layouts. 442 // triggering unneeded layouts.
439 /** 443 /**
440 * All your element measurement needs in one place 444 * All your element measurement needs in one place
445 * @domName none
441 */ 446 */
442 class ElementRectWrappingImplementation implements ElementRect { 447 class ElementRectWrappingImplementation implements ElementRect {
443 final ClientRect client; 448 final ClientRect client;
444 final ClientRect offset; 449 final ClientRect offset;
445 final ClientRect scroll; 450 final ClientRect scroll;
446 451
447 // TODO(jacobr): should we move these outside of ElementRect to avoid the 452 // TODO(jacobr): should we move these outside of ElementRect to avoid the
448 // overhead of computing them every time even though they are rarely used. 453 // overhead of computing them every time even though they are rarely used.
449 // This should be type dom.ClientRect but that fails on dartium. b/5522629 454 // This should be type dom.ClientRect but that fails on dartium. b/5522629
450 final _boundingClientRect; 455 final _boundingClientRect;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 } 669 }
665 670
666 bool contains(Node element) { 671 bool contains(Node element) {
667 return _ptr.contains(LevelDom.unwrap(element)); 672 return _ptr.contains(LevelDom.unwrap(element));
668 } 673 }
669 674
670 void focus() { 675 void focus() {
671 _ptr.focus(); 676 _ptr.focus();
672 } 677 }
673 678
679 /** @domName HTMLElement.insertAdjacentElement */
674 Element insertAdjacentElement([String where = null, Element element = null]) { 680 Element insertAdjacentElement([String where = null, Element element = null]) {
675 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra p(element))); 681 return LevelDom.wrapElement(_ptr.insertAdjacentElement(where, LevelDom.unwra p(element)));
676 } 682 }
677 683
684 /** @domName HTMLElement.insertAdjacentHTML */
678 void insertAdjacentHTML([String position_OR_where = null, String text = null]) { 685 void insertAdjacentHTML([String position_OR_where = null, String text = null]) {
679 _ptr.insertAdjacentHTML(position_OR_where, text); 686 _ptr.insertAdjacentHTML(position_OR_where, text);
680 } 687 }
681 688
689 /** @domName HTMLElement.insertAdjacentText */
682 void insertAdjacentText([String where = null, String text = null]) { 690 void insertAdjacentText([String where = null, String text = null]) {
683 _ptr.insertAdjacentText(where, text); 691 _ptr.insertAdjacentText(where, text);
684 } 692 }
685 693
686 Element query(String selectors) { 694 Element query(String selectors) {
687 // TODO(jacobr): scope fix. 695 // TODO(jacobr): scope fix.
688 return LevelDom.wrapElement(_ptr.querySelector(selectors)); 696 return LevelDom.wrapElement(_ptr.querySelector(selectors));
689 } 697 }
690 698
691 ElementList queryAll(String selectors) { 699 ElementList queryAll(String selectors) {
(...skipping 14 matching lines...) Expand all
706 } 714 }
707 715
708 bool matchesSelector([String selectors = null]) { 716 bool matchesSelector([String selectors = null]) {
709 return _ptr.webkitMatchesSelector(selectors); 717 return _ptr.webkitMatchesSelector(selectors);
710 } 718 }
711 719
712 void set scrollLeft(int value) { _ptr.scrollLeft = value; } 720 void set scrollLeft(int value) { _ptr.scrollLeft = value; }
713 721
714 void set scrollTop(int value) { _ptr.scrollTop = value; } 722 void set scrollTop(int value) { _ptr.scrollTop = value; }
715 723
724 /** @domName getClientRects */
Jacob 2011/11/21 23:12:11 Should be Element.getClientRects?
nweiz 2011/11/22 01:11:09 "Element" is the default class, so it can be omitt
716 Future<ElementRect> get rect() { 725 Future<ElementRect> get rect() {
717 return _createMeasurementFuture( 726 return _createMeasurementFuture(
718 () => new ElementRectWrappingImplementation(_ptr), 727 () => new ElementRectWrappingImplementation(_ptr),
719 new Completer<ElementRect>()); 728 new Completer<ElementRect>());
720 } 729 }
721 730
722 Future<CSSStyleDeclaration> get computedStyle() { 731 Future<CSSStyleDeclaration> get computedStyle() {
723 // TODO(jacobr): last param should be null, see b/5045788 732 // TODO(jacobr): last param should be null, see b/5045788
724 return getComputedStyle(''); 733 return getComputedStyle('');
725 } 734 }
726 735
736 /** @domName DOMWindow.getComputedStyle */
727 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) { 737 Future<CSSStyleDeclaration> getComputedStyle(String pseudoElement) {
728 return _createMeasurementFuture(() => 738 return _createMeasurementFuture(() =>
729 LevelDom.wrapCSSStyleDeclaration( 739 LevelDom.wrapCSSStyleDeclaration(
730 dom.window.getComputedStyle(_ptr, pseudoElement)), 740 dom.window.getComputedStyle(_ptr, pseudoElement)),
731 new Completer<CSSStyleDeclaration>()); 741 new Completer<CSSStyleDeclaration>());
732 } 742 }
733 743
734 ElementEvents get on() { 744 ElementEvents get on() {
735 if (_on === null) { 745 if (_on === null) {
736 _on = new ElementEventsImplementation._wrap(_ptr); 746 _on = new ElementEventsImplementation._wrap(_ptr);
737 } 747 }
738 return _on; 748 return _on;
739 } 749 }
740 } 750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698