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

Side by Side Diff: test/com/dom_distiller/client/SimpleContentHandler.java

Issue 296113004: Start using computed style instead of default tag actions. (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: Added tests Created 6 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.dom_distiller.client; 5 package com.dom_distiller.client;
6 6
7 import com.dom_distiller.client.sax.Attributes; 7 import com.dom_distiller.client.sax.Attributes;
8 import com.dom_distiller.client.sax.ContentHandler; 8 import com.dom_distiller.client.sax.ContentHandler;
9 import com.google.gwt.dom.client.Element;
9 10
10 /** 11 /**
11 * This is a simple SAX content handler that converts sax events to an xml docum ent. It only handles 12 * This is a simple SAX content handler that converts sax events to an xml docum ent. It only handles
12 * a small subset of those events. 13 * a small subset of those events.
13 */ 14 */
14 class SimpleContentHandler implements ContentHandler { 15 class SimpleContentHandler implements ContentHandler {
15 16
16 SimpleContentHandler() { 17 SimpleContentHandler() {
17 documentStringBuilder = new StringBuilder(); 18 documentStringBuilder = new StringBuilder();
18 } 19 }
19 20
20 String getDocumentString() { 21 String getDocumentString() {
21 return documentStringBuilder.toString(); 22 return documentStringBuilder.toString();
22 } 23 }
23 24
24 @Override 25 @Override
25 public void endDocument() {} 26 public void endDocument() {}
26 27
27 @Override 28 @Override
28 public void ignorableWhitespace(char[] ch, int start, int length) {} 29 public void ignorableWhitespace(char[] ch, int start, int length) {}
29 30
30 @Override 31 @Override
31 public void startDocument() {} 32 public void startDocument() {}
32 33
33 @Override 34 @Override
34 public void startElement(String uri, String localName, String qName, Attribu tes atts) { 35 public void startElement(
36 String uri, String localName, String qName, Element element, Attribu tes atts) {
35 documentStringBuilder.append("<" + localName); 37 documentStringBuilder.append("<" + localName);
36 for (int i = 0; i < atts.getLength(); i++) { 38 for (int i = 0; i < atts.getLength(); i++) {
37 documentStringBuilder.append(" "); 39 documentStringBuilder.append(" ");
38 documentStringBuilder.append(atts.getLocalName(i)); 40 documentStringBuilder.append(atts.getLocalName(i));
39 documentStringBuilder.append("=\""); 41 documentStringBuilder.append("=\"");
40 documentStringBuilder.append(atts.getValue(i)); 42 documentStringBuilder.append(atts.getValue(i));
41 documentStringBuilder.append("\""); 43 documentStringBuilder.append("\"");
42 44
43 } 45 }
44 documentStringBuilder.append(">"); 46 documentStringBuilder.append(">");
45 } 47 }
46 48
47 @Override 49 @Override
48 public void endElement(String uri, String localName, String qName) { 50 public void endElement(String uri, String localName, String qName, Element e lement) {
49 documentStringBuilder.append("</" + localName + ">"); 51 documentStringBuilder.append("</" + localName + ">");
50 } 52 }
51 53
52 @Override 54 @Override
53 public void characters(char[] ch, int start, int length) { 55 public void characters(char[] ch, int start, int length) {
54 documentStringBuilder.append(ch, start, length); 56 documentStringBuilder.append(ch, start, length);
55 } 57 }
56 58
57 private StringBuilder documentStringBuilder; 59 private StringBuilder documentStringBuilder;
58 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698