OLD | NEW |
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 org.chromium.distiller.webdocument; | 5 package org.chromium.distiller.webdocument; |
6 | 6 |
7 import org.chromium.distiller.DomUtil; | 7 import org.chromium.distiller.DomUtil; |
8 import org.chromium.distiller.labels.DefaultLabels; | 8 import org.chromium.distiller.labels.DefaultLabels; |
9 | 9 |
10 import com.google.gwt.core.client.JavaScriptObject; | 10 import com.google.gwt.core.client.JavaScriptObject; |
11 import com.google.gwt.core.client.JsArrayString; | 11 import com.google.gwt.core.client.JsArrayString; |
12 import com.google.gwt.dom.client.Element; | 12 import com.google.gwt.dom.client.Element; |
13 import com.google.gwt.dom.client.Style; | 13 import com.google.gwt.dom.client.Style; |
14 import com.google.gwt.regexp.shared.RegExp; | 14 import com.google.gwt.regexp.shared.RegExp; |
15 | 15 |
16 public class ElementAction { | 16 public class ElementAction { |
17 public boolean changesTagLevel = false; | 17 public boolean changesTagLevel = false; |
18 public boolean flush = false; | 18 public boolean flush = false; |
19 public boolean isAnchor = false; | 19 public boolean isAnchor = false; |
| 20 public boolean isList = false; |
20 public JsArrayString labels = JavaScriptObject.createArray().<JsArrayString>
cast(); | 21 public JsArrayString labels = JavaScriptObject.createArray().<JsArrayString>
cast(); |
21 | 22 |
22 private static final RegExp REG_COMMENT = RegExp.compile("\\bcomments?\\b"); | 23 private static final RegExp REG_COMMENT = RegExp.compile("\\bcomments?\\b"); |
23 private static final int MAX_CLASS_COUNT = 5; | 24 private static final int MAX_CLASS_COUNT = 5; |
24 | 25 |
25 public static ElementAction getForElement(Element element) { | 26 public static ElementAction getForElement(Element element) { |
26 Style style = DomUtil.getComputedStyle(element); | 27 Style style = DomUtil.getComputedStyle(element); |
27 ElementAction action = new ElementAction(); | 28 ElementAction action = new ElementAction(); |
28 switch (style.getDisplay()) { | 29 switch (style.getDisplay()) { |
29 case "inline": | 30 case "inline": |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 action.labels.push(DefaultLabels.HEADING); | 85 action.labels.push(DefaultLabels.HEADING); |
85 break; | 86 break; |
86 case "A": | 87 case "A": |
87 // TODO(cjhopman): Anchors probably shouldn't unconditionall
y change the tag | 88 // TODO(cjhopman): Anchors probably shouldn't unconditionall
y change the tag |
88 // level. | 89 // level. |
89 action.changesTagLevel = true; | 90 action.changesTagLevel = true; |
90 if (element.hasAttribute("href")) { | 91 if (element.hasAttribute("href")) { |
91 action.isAnchor = true; | 92 action.isAnchor = true; |
92 } | 93 } |
93 break; | 94 break; |
| 95 case "OL": |
| 96 case "UL": |
| 97 action.isList = true; |
| 98 break; |
94 } | 99 } |
95 } | 100 } |
96 return action; | 101 return action; |
97 } | 102 } |
98 | 103 |
99 private ElementAction() {} | 104 private ElementAction() {} |
100 } | 105 } |
OLD | NEW |