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

Unified Diff: dart/site/try/src/html_to_text.dart

Issue 225893002: Refactor code to prepare for line-based tokenization. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | dart/site/try/src/interaction_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/site/try/src/html_to_text.dart
diff --git a/dart/site/try/src/html_to_text.dart b/dart/site/try/src/html_to_text.dart
index 623838af6d62709d800f3bbe738ee39a32e70eea..f90ded6104c41d4aa137d3832a55173f7a01a0df 100644
--- a/dart/site/try/src/html_to_text.dart
+++ b/dart/site/try/src/html_to_text.dart
@@ -7,7 +7,15 @@ library trydart.htmlToText;
import 'dart:math' show
max;
-import 'dart:html';
+import 'dart:html' show
+ Element,
+ Node,
+ NodeFilter,
+ Text,
+ TreeWalker;
+
+import 'selection.dart' show
+ TrySelection;
/// Returns true if [node] is a block element, that is, not inline.
bool isBlockElement(Node node) {
@@ -37,7 +45,7 @@ void skip(Node node, TreeWalker walker) {
/// Writes the text of [root] to [buffer]. Keeps track of [selection] and
/// returns the new anchorOffset from beginning of [buffer] or -1 if the
/// selection isn't in [root].
-int htmlToText(Node root, StringBuffer buffer, Selection selection) {
+int htmlToText(Node root, StringBuffer buffer, TrySelection selection) {
int selectionOffset = -1;
TreeWalker walker = new TreeWalker(root, NodeFilter.SHOW_ALL);
@@ -45,7 +53,7 @@ int htmlToText(Node root, StringBuffer buffer, Selection selection) {
switch (node.nodeType) {
case Node.CDATA_SECTION_NODE:
case Node.TEXT_NODE:
- if (selection.isCollapsed && selection.anchorNode == node) {
+ if (selection.anchorNode == node) {
selectionOffset = selection.anchorOffset + buffer.length;
}
Text text = node;
« no previous file with comments | « no previous file | dart/site/try/src/interaction_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698