| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 class _ChildrenElementList extends ListBase<Element> { | 7 class _ChildrenElementList extends ListBase<Element> { |
| 8 // Raw Element. | 8 // Raw Element. |
| 9 final Element _element; | 9 final Element _element; |
| 10 final HtmlCollection _childElements; | 10 final HtmlCollection _childElements; |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 if (foundAsParent) return new Point(0, 0); | 1182 if (foundAsParent) return new Point(0, 0); |
| 1183 throw new ArgumentError("Specified element is not a transitive offset " | 1183 throw new ArgumentError("Specified element is not a transitive offset " |
| 1184 "parent of this element."); | 1184 "parent of this element."); |
| 1185 } | 1185 } |
| 1186 Element parentOffset = current.offsetParent; | 1186 Element parentOffset = current.offsetParent; |
| 1187 Point p = Element._offsetToHelper(parentOffset, parent); | 1187 Point p = Element._offsetToHelper(parentOffset, parent); |
| 1188 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); | 1188 return new Point(p.x + current.offsetLeft, p.y + current.offsetTop); |
| 1189 } | 1189 } |
| 1190 | 1190 |
| 1191 static HtmlDocument _parseDocument; | 1191 static HtmlDocument _parseDocument; |
| 1192 static Range _parseRange; |
| 1192 static NodeValidatorBuilder _defaultValidator; | 1193 static NodeValidatorBuilder _defaultValidator; |
| 1193 static _ValidatingTreeSanitizer _defaultSanitizer; | 1194 static _ValidatingTreeSanitizer _defaultSanitizer; |
| 1194 | 1195 |
| 1195 /** | 1196 /** |
| 1196 * Create a DocumentFragment from the HTML fragment and ensure that it follows | 1197 * Create a DocumentFragment from the HTML fragment and ensure that it follows |
| 1197 * the sanitization rules specified by the validator or treeSanitizer. | 1198 * the sanitization rules specified by the validator or treeSanitizer. |
| 1198 * | 1199 * |
| 1199 * If the default validation behavior is too restrictive then a new | 1200 * If the default validation behavior is too restrictive then a new |
| 1200 * NodeValidator should be created, either extending or wrapping a default | 1201 * NodeValidator should be created, either extending or wrapping a default |
| 1201 * validator and overriding the validation APIs. | 1202 * validator and overriding the validation APIs. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1227 _defaultSanitizer.validator = validator; | 1228 _defaultSanitizer.validator = validator; |
| 1228 } | 1229 } |
| 1229 treeSanitizer = _defaultSanitizer; | 1230 treeSanitizer = _defaultSanitizer; |
| 1230 } else if (validator != null) { | 1231 } else if (validator != null) { |
| 1231 throw new ArgumentError( | 1232 throw new ArgumentError( |
| 1232 'validator can only be passed if treeSanitizer is null'); | 1233 'validator can only be passed if treeSanitizer is null'); |
| 1233 } | 1234 } |
| 1234 | 1235 |
| 1235 if (_parseDocument == null) { | 1236 if (_parseDocument == null) { |
| 1236 _parseDocument = document.implementation.createHtmlDocument(''); | 1237 _parseDocument = document.implementation.createHtmlDocument(''); |
| 1238 _parseRange = _parseDocument.createRange(); |
| 1237 } | 1239 } |
| 1238 var contextElement; | 1240 var contextElement; |
| 1239 if (this is BodyElement) { | 1241 if (this is BodyElement) { |
| 1240 contextElement = _parseDocument.body; | 1242 contextElement = _parseDocument.body; |
| 1241 } else { | 1243 } else { |
| 1242 contextElement = _parseDocument.$dom_createElement(tagName); | 1244 contextElement = _parseDocument.$dom_createElement(tagName); |
| 1243 _parseDocument.body.append(contextElement); | 1245 _parseDocument.body.append(contextElement); |
| 1244 } | 1246 } |
| 1245 var fragment; | 1247 var fragment; |
| 1246 if (Range.supportsCreateContextualFragment) { | 1248 if (Range.supportsCreateContextualFragment) { |
| 1247 var range = _parseDocument.createRange(); | 1249 _parseRange.selectNodeContents(contextElement); |
| 1248 range.selectNodeContents(contextElement); | 1250 fragment = _parseRange.createContextualFragment(html); |
| 1249 fragment = range.createContextualFragment(html); | |
| 1250 } else { | 1251 } else { |
| 1251 contextElement._innerHtml = html; | 1252 contextElement._innerHtml = html; |
| 1252 | 1253 |
| 1253 fragment = _parseDocument.createDocumentFragment(); | 1254 fragment = _parseDocument.createDocumentFragment(); |
| 1254 while (contextElement.firstChild != null) { | 1255 while (contextElement.firstChild != null) { |
| 1255 fragment.append(contextElement.firstChild); | 1256 fragment.append(contextElement.firstChild); |
| 1256 } | 1257 } |
| 1257 } | 1258 } |
| 1258 if (contextElement != _parseDocument.body) { | 1259 if (contextElement != _parseDocument.body) { |
| 1259 contextElement.remove(); | 1260 contextElement.remove(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1339 const ScrollAlignment._internal(this._value); | 1340 const ScrollAlignment._internal(this._value); |
| 1340 toString() => 'ScrollAlignment.$_value'; | 1341 toString() => 'ScrollAlignment.$_value'; |
| 1341 | 1342 |
| 1342 /// Attempt to align the element to the top of the scrollable area. | 1343 /// Attempt to align the element to the top of the scrollable area. |
| 1343 static const TOP = const ScrollAlignment._internal('TOP'); | 1344 static const TOP = const ScrollAlignment._internal('TOP'); |
| 1344 /// Attempt to center the element in the scrollable area. | 1345 /// Attempt to center the element in the scrollable area. |
| 1345 static const CENTER = const ScrollAlignment._internal('CENTER'); | 1346 static const CENTER = const ScrollAlignment._internal('CENTER'); |
| 1346 /// Attempt to align the element to the bottom of the scrollable area. | 1347 /// Attempt to align the element to the bottom of the scrollable area. |
| 1347 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); | 1348 static const BOTTOM = const ScrollAlignment._internal('BOTTOM'); |
| 1348 } | 1349 } |
| OLD | NEW |