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

Side by Side Diff: site/try/src/html_to_text.dart

Issue 408783002: Enable Try Dart to run on IE11. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library trydart.htmlToText; 5 library trydart.htmlToText;
6 6
7 import 'dart:math' show 7 import 'dart:math' show
8 max; 8 max;
9 9
10 import 'dart:html' show 10 import 'dart:html' show
(...skipping 23 matching lines...) Expand all
34 34
35 return element.getComputedStyle().display != 'inline'; 35 return element.getComputedStyle().display != 'inline';
36 } 36 }
37 37
38 /// Writes the text of [root] to [buffer]. Keeps track of [selection] and 38 /// Writes the text of [root] to [buffer]. Keeps track of [selection] and
39 /// returns the new anchorOffset from beginning of [buffer] or -1 if the 39 /// returns the new anchorOffset from beginning of [buffer] or -1 if the
40 /// selection isn't in [root]. 40 /// selection isn't in [root].
41 int htmlToText(Node root, 41 int htmlToText(Node root,
42 StringBuffer buffer, 42 StringBuffer buffer,
43 TrySelection selection, 43 TrySelection selection,
44 {bool treatRootAsInline: false}) { 44 {bool treatRootAsInline: true}) {
aam-me 2014/07/21 01:38:28 Reason for this change is that diagnostic messages
ahe 2014/07/21 08:16:00 IIRC, this code is to support copy and paste from,
aam-me 2014/07/21 12:20:38 Interesting. I will look into this.
aam-me 2014/07/30 00:28:25 htmlToText is invoked from normalizeMutationRecord
ahe 2014/08/04 08:59:55 I noticed something troublesome in normalizeMutati
45 int selectionOffset = -1; 45 int selectionOffset = -1;
46 walkNodes(root, (Node node) { 46 walkNodes(root, (Node node) {
47 if (selection.anchorNode == node) { 47 if (selection.anchorNode == node) {
48 selectionOffset = selection.anchorOffset + buffer.length; 48 selectionOffset = selection.anchorOffset + buffer.length;
49 } 49 }
50 switch (node.nodeType) { 50 switch (node.nodeType) {
51 case Node.CDATA_SECTION_NODE: 51 case Node.CDATA_SECTION_NODE:
52 case Node.TEXT_NODE: 52 case Node.TEXT_NODE:
53 CharacterData text = node; 53 CharacterData text = node;
54 buffer.write(text.data.replaceAll('\xA0', ' ')); 54 buffer.write(text.data.replaceAll('\xA0', ' '));
(...skipping 12 matching lines...) Expand all
67 67
68 return WALKER_NEXT; 68 return WALKER_NEXT;
69 }); 69 });
70 70
71 if (!treatRootAsInline && isBlockElement(root)) { 71 if (!treatRootAsInline && isBlockElement(root)) {
72 buffer.write('\n'); 72 buffer.write('\n');
73 } 73 }
74 74
75 return selectionOffset; 75 return selectionOffset;
76 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698