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

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

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version Created 8 years, 11 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
Index: client/html/src/CSSStyleDeclarationWrappingImplementation.dart
diff --git a/client/html/src/CSSStyleDeclarationWrappingImplementation.dart b/client/html/src/CSSStyleDeclarationWrappingImplementation.dart
index 9659ab65bbbd8e9928ce021f3c74d7ed10beae12..6cdf2461ecb219e9a95aa8ccdb41bbfaacf39d31 100644
--- a/client/html/src/CSSStyleDeclarationWrappingImplementation.dart
+++ b/client/html/src/CSSStyleDeclarationWrappingImplementation.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// 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.
@@ -12,8 +12,18 @@
class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implements CSSStyleDeclaration {
static String _cachedBrowserPrefix;
-
- CSSStyleDeclarationWrappingImplementation._wrap(ptr) : super._wrap(ptr) {}
+ /**
+ * The element this style declaration is associated with if any. This
+ * should only be set to a non-null value if modifying this object
+ * will change the associated element. Thus this should not be set for
+ * computed styles.
+ */
+ final ElementWrappingImplementation _element;
+
+ CSSStyleDeclarationWrappingImplementation._wrap(ptr)
+ : super._wrap(ptr), _element = null;
+ CSSStyleDeclarationWrappingImplementation._wrapWithElement(
+ ptr, this._element) : super._wrap(ptr);
factory CSSStyleDeclarationWrappingImplementation.css(String css) {
var style = new Element.tag('div').style;
@@ -32,14 +42,21 @@ class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implement
} else {
_cachedBrowserPrefix = '-webkit-';
}
- // TODO(jacobr): support IE 9.0 and Opera as well.
+ // TODO(jacobr): support IE and Opera as well.
}
return _cachedBrowserPrefix;
}
- String get cssText() { return _ptr.cssText; }
+ String get cssText() => _ptr.cssText;
+
+ bool get _inDocument() {
+ return _element !== null && _element._inDocument;
+ }
- void set cssText(String value) { _ptr.cssText = value; }
+ void set cssText(String value) {
+ assert(!_inMeasurementFrame || !_inDocument);
+ _ptr.cssText = value;
+ }
int get length() { return _ptr.length; }
@@ -70,16 +87,15 @@ class CSSStyleDeclarationWrappingImplementation extends DOMWrapperBase implement
}
String removeProperty(String propertyName) {
+ assert(!_inMeasurementFrame || !_inDocument);
return _ptr.removeProperty(propertyName);
}
void setProperty(String propertyName, var value, [String priority = '']) {
+ assert(!_inMeasurementFrame || !_inDocument);
_ptr.setProperty(propertyName, '$value', priority);
}
- String get typeName() { return "CSSStyleDeclaration"; }
-
-
/** Gets the value of "animation" */
String get animation() =>
getPropertyValue('${_browserPrefix}animation');

Powered by Google App Engine
This is Rietveld 408576698