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

Side by Side Diff: tools/dom/src/CssRectangle.dart

Issue 1310363006: Patched in Dartium JsInterop (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/src/Html5NodeValidator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of html; 5 part of html;
6 6
7 /** 7 /**
8 * A rectangle representing all the content of the element in the 8 * A rectangle representing all the content of the element in the
9 * [box model](http://www.w3.org/TR/CSS2/box.html). 9 * [box model](http://www.w3.org/TR/CSS2/box.html).
10 */ 10 */
11 class _ContentCssRect extends CssRect { 11 class _ContentCssRect extends CssRect {
12 12
13 _ContentCssRect(element) : super(element); 13 _ContentCssRect(element) : super(element);
14 14
15 num get height => _element.offsetHeight + 15 num get height => _element.offsetHeight +
16 _addOrSubtractToBoxModel(_HEIGHT, _CONTENT); 16 _addOrSubtractToBoxModel(_HEIGHT, _CONTENT);
17 17
18 num get width => _element.offsetWidth + 18 num get width => _element.offsetWidth +
19 _addOrSubtractToBoxModel(_WIDTH, _CONTENT); 19 _addOrSubtractToBoxModel(_WIDTH, _CONTENT);
20 20
21 /** 21 /**
22 * Set the height to `newHeight`. 22 * Set the height to `newHeight`.
23 * 23 *
24 * newHeight can be either a [num] representing the height in pixels or a 24 * newHeight can be either a [num] representing the height in pixels or a
25 * [Dimension] object. Values of newHeight that are less than zero are 25 * [Dimension] object. Values of newHeight that are less than zero are
26 * converted to effectively setting the height to 0. This is equivalent to the 26 * converted to effectively setting the height to 0. This is equivalent to the
27 * `height` function in jQuery and the calculated `height` CSS value, 27 * `height` function in jQuery and the calculated `height` CSS value,
28 * converted to a num in pixels. 28 * converted to a num in pixels.
29 */ 29 */
30 void set height(newHeight) { 30 set height(newHeight) {
31 if (newHeight is Dimension) { 31 if (newHeight is Dimension) {
32 if (newHeight.value < 0) newHeight = new Dimension.px(0); 32 if (newHeight.value < 0) newHeight = new Dimension.px(0);
33 _element.style.height = newHeight.toString(); 33 _element.style.height = newHeight.toString();
34 } else { 34 } else {
35 if (newHeight < 0) newHeight = 0; 35 if (newHeight < 0) newHeight = 0;
36 _element.style.height = '${newHeight}px'; 36 _element.style.height = '${newHeight}px';
37 } 37 }
38 } 38 }
39 39
40 /** 40 /**
41 * Set the current computed width in pixels of this element. 41 * Set the current computed width in pixels of this element.
42 * 42 *
43 * newWidth can be either a [num] representing the width in pixels or a 43 * newWidth can be either a [num] representing the width in pixels or a
44 * [Dimension] object. This is equivalent to the `width` function in jQuery 44 * [Dimension] object. This is equivalent to the `width` function in jQuery
45 * and the calculated 45 * and the calculated
46 * `width` CSS value, converted to a dimensionless num in pixels. 46 * `width` CSS value, converted to a dimensionless num in pixels.
47 */ 47 */
48 void set width(newWidth) { 48 set width(newWidth) {
49 if (newWidth is Dimension) { 49 if (newWidth is Dimension) {
50 if (newWidth.value < 0) newWidth = new Dimension.px(0); 50 if (newWidth.value < 0) newWidth = new Dimension.px(0);
51 _element.style.width = newWidth.toString(); 51 _element.style.width = newWidth.toString();
52 } else { 52 } else {
53 if (newWidth < 0) newWidth = 0; 53 if (newWidth < 0) newWidth = 0;
54 _element.style.width = '${newWidth}px'; 54 _element.style.width = '${newWidth}px';
55 } 55 }
56 } 56 }
57 57
58 num get left => _element.getBoundingClientRect().left - 58 num get left => _element.getBoundingClientRect().left -
(...skipping 14 matching lines...) Expand all
73 } 73 }
74 74
75 /** 75 /**
76 * Set the height to `newHeight`. 76 * Set the height to `newHeight`.
77 * 77 *
78 * Values of newHeight that are less than zero are converted to effectively 78 * Values of newHeight that are less than zero are converted to effectively
79 * setting the height to 0. This is equivalent to the `height` 79 * setting the height to 0. This is equivalent to the `height`
80 * function in jQuery and the calculated `height` CSS value, converted to a 80 * function in jQuery and the calculated `height` CSS value, converted to a
81 * num in pixels. 81 * num in pixels.
82 */ 82 */
83 void set height(newHeight) { 83 set height(newHeight) {
84 _elementList.forEach((e) => e.contentEdge.height = newHeight); 84 _elementList.forEach((e) => e.contentEdge.height = newHeight);
85 } 85 }
86 86
87 /** 87 /**
88 * Set the current computed width in pixels of this element. 88 * Set the current computed width in pixels of this element.
89 * 89 *
90 * This is equivalent to the `width` function in jQuery and the calculated 90 * This is equivalent to the `width` function in jQuery and the calculated
91 * `width` CSS value, converted to a dimensionless num in pixels. 91 * `width` CSS value, converted to a dimensionless num in pixels.
92 */ 92 */
93 void set width(newWidth) { 93 set width(newWidth) {
94 _elementList.forEach((e) => e.contentEdge.width = newWidth); 94 _elementList.forEach((e) => e.contentEdge.width = newWidth);
95 } 95 }
96 } 96 }
97 97
98 /** 98 /**
99 * A rectangle representing the dimensions of the space occupied by the 99 * A rectangle representing the dimensions of the space occupied by the
100 * element's content + padding in the 100 * element's content + padding in the
101 * [box model](http://www.w3.org/TR/CSS2/box.html). 101 * [box model](http://www.w3.org/TR/CSS2/box.html).
102 */ 102 */
103 class _PaddingCssRect extends CssRect { 103 class _PaddingCssRect extends CssRect {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 * Set the height to `newHeight`. 190 * Set the height to `newHeight`.
191 * 191 *
192 * newHeight can be either a [num] representing the height in pixels or a 192 * newHeight can be either a [num] representing the height in pixels or a
193 * [Dimension] object. Values of newHeight that are less than zero are 193 * [Dimension] object. Values of newHeight that are less than zero are
194 * converted to effectively setting the height to 0. This is equivalent to the 194 * converted to effectively setting the height to 0. This is equivalent to the
195 * `height` function in jQuery and the calculated `height` CSS value, 195 * `height` function in jQuery and the calculated `height` CSS value,
196 * converted to a num in pixels. 196 * converted to a num in pixels.
197 * 197 *
198 * Note that only the content height can actually be set via this method. 198 * Note that only the content height can actually be set via this method.
199 */ 199 */
200 void set height(newHeight) { 200 set height(newHeight) {
201 throw new UnsupportedError("Can only set height for content rect."); 201 throw new UnsupportedError("Can only set height for content rect.");
202 } 202 }
203 203
204 /** 204 /**
205 * Set the current computed width in pixels of this element. 205 * Set the current computed width in pixels of this element.
206 * 206 *
207 * newWidth can be either a [num] representing the width in pixels or a 207 * newWidth can be either a [num] representing the width in pixels or a
208 * [Dimension] object. This is equivalent to the `width` function in jQuery 208 * [Dimension] object. This is equivalent to the `width` function in jQuery
209 * and the calculated 209 * and the calculated
210 * `width` CSS value, converted to a dimensionless num in pixels. 210 * `width` CSS value, converted to a dimensionless num in pixels.
211 * 211 *
212 * Note that only the content width can be set via this method. 212 * Note that only the content width can be set via this method.
213 */ 213 */
214 void set width(newWidth) { 214 set width(newWidth) {
215 throw new UnsupportedError("Can only set width for content rect."); 215 throw new UnsupportedError("Can only set width for content rect.");
216 } 216 }
217 217
218 /** 218 /**
219 * Return a value that is used to modify the initial height or width 219 * Return a value that is used to modify the initial height or width
220 * measurement of an element. Depending on the value (ideally an enum) passed 220 * measurement of an element. Depending on the value (ideally an enum) passed
221 * to augmentingMeasurement, we may need to add or subtract margin, padding, 221 * to augmentingMeasurement, we may need to add or subtract margin, padding,
222 * or border values, depending on the measurement we're trying to obtain. 222 * or border values, depending on the measurement we're trying to obtain.
223 */ 223 */
224 num _addOrSubtractToBoxModel(List<String> dimensions, 224 num _addOrSubtractToBoxModel(List<String> dimensions,
(...skipping 28 matching lines...) Expand all
253 } 253 }
254 return val; 254 return val;
255 } 255 }
256 } 256 }
257 257
258 final _HEIGHT = ['top', 'bottom']; 258 final _HEIGHT = ['top', 'bottom'];
259 final _WIDTH = ['right', 'left']; 259 final _WIDTH = ['right', 'left'];
260 final _CONTENT = 'content'; 260 final _CONTENT = 'content';
261 final _PADDING = 'padding'; 261 final _PADDING = 'padding';
262 final _MARGIN = 'margin'; 262 final _MARGIN = 'margin';
OLDNEW
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/src/Html5NodeValidator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698