| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 function removeSubsequentNodes(fromNode, toNode) | 196 function removeSubsequentNodes(fromNode, toNode) |
| 197 { | 197 { |
| 198 for (var node = fromNode; node && node !== toNode; ) { | 198 for (var node = fromNode; node && node !== toNode; ) { |
| 199 var nodeToRemove = node; | 199 var nodeToRemove = node; |
| 200 node = node.nextSibling; | 200 node = node.nextSibling; |
| 201 nodeToRemove.remove(); | 201 nodeToRemove.remove(); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 /** | 205 /** |
| 206 * @constructor | |
| 207 * @param {!Size} minimum | |
| 208 * @param {?Size=} preferred | |
| 209 */ | |
| 210 function Constraints(minimum, preferred) | |
| 211 { | |
| 212 /** | |
| 213 * @type {!Size} | |
| 214 */ | |
| 215 this.minimum = minimum; | |
| 216 | |
| 217 /** | |
| 218 * @type {!Size} | |
| 219 */ | |
| 220 this.preferred = preferred || minimum; | |
| 221 | |
| 222 if (this.minimum.width > this.preferred.width || this.minimum.height > this.
preferred.height) | |
| 223 throw new Error("Minimum size is greater than preferred."); | |
| 224 } | |
| 225 | |
| 226 /** | |
| 227 * @param {?Constraints} constraints | |
| 228 * @return {boolean} | |
| 229 */ | |
| 230 Constraints.prototype.isEqual = function(constraints) | |
| 231 { | |
| 232 return !!constraints && this.minimum.isEqual(constraints.minimum) && this.pr
eferred.isEqual(constraints.preferred); | |
| 233 } | |
| 234 | |
| 235 /** | |
| 236 * @param {!Constraints|number} value | |
| 237 * @return {!Constraints} | |
| 238 */ | |
| 239 Constraints.prototype.widthToMax = function(value) | |
| 240 { | |
| 241 if (typeof value === "number") | |
| 242 return new Constraints(this.minimum.widthToMax(value), this.preferred.wi
dthToMax(value)); | |
| 243 return new Constraints(this.minimum.widthToMax(value.minimum), this.preferre
d.widthToMax(value.preferred)); | |
| 244 } | |
| 245 | |
| 246 /** | |
| 247 * @param {!Constraints|number} value | |
| 248 * @return {!Constraints} | |
| 249 */ | |
| 250 Constraints.prototype.addWidth = function(value) | |
| 251 { | |
| 252 if (typeof value === "number") | |
| 253 return new Constraints(this.minimum.addWidth(value), this.preferred.addW
idth(value)); | |
| 254 return new Constraints(this.minimum.addWidth(value.minimum), this.preferred.
addWidth(value.preferred)); | |
| 255 } | |
| 256 | |
| 257 /** | |
| 258 * @param {!Constraints|number} value | |
| 259 * @return {!Constraints} | |
| 260 */ | |
| 261 Constraints.prototype.heightToMax = function(value) | |
| 262 { | |
| 263 if (typeof value === "number") | |
| 264 return new Constraints(this.minimum.heightToMax(value), this.preferred.h
eightToMax(value)); | |
| 265 return new Constraints(this.minimum.heightToMax(value.minimum), this.preferr
ed.heightToMax(value.preferred)); | |
| 266 } | |
| 267 | |
| 268 /** | |
| 269 * @param {!Constraints|number} value | |
| 270 * @return {!Constraints} | |
| 271 */ | |
| 272 Constraints.prototype.addHeight = function(value) | |
| 273 { | |
| 274 if (typeof value === "number") | |
| 275 return new Constraints(this.minimum.addHeight(value), this.preferred.add
Height(value)); | |
| 276 return new Constraints(this.minimum.addHeight(value.minimum), this.preferred
.addHeight(value.preferred)); | |
| 277 } | |
| 278 | |
| 279 /** | |
| 280 * @param {!Event} event | 206 * @param {!Event} event |
| 281 * @return {boolean} | 207 * @return {boolean} |
| 282 */ | 208 */ |
| 283 Element.prototype.containsEventPoint = function(event) | 209 Element.prototype.containsEventPoint = function(event) |
| 284 { | 210 { |
| 285 var box = this.getBoundingClientRect(); | 211 var box = this.getBoundingClientRect(); |
| 286 return box.left < event.x && event.x < box.right && | 212 return box.left < event.x && event.x < box.right && |
| 287 box.top < event.y && event.y < box.bottom; | 213 box.top < event.y && event.y < box.bottom; |
| 288 } | 214 } |
| 289 | 215 |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 */ | 770 */ |
| 845 function isEnterKey(event) { | 771 function isEnterKey(event) { |
| 846 // Check if in IME. | 772 // Check if in IME. |
| 847 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; | 773 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; |
| 848 } | 774 } |
| 849 | 775 |
| 850 function consumeEvent(e) | 776 function consumeEvent(e) |
| 851 { | 777 { |
| 852 e.consume(); | 778 e.consume(); |
| 853 } | 779 } |
| OLD | NEW |