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

Unified Diff: src/com/dom_distiller/client/ContentExtractor.java

Issue 322553005: Improve handling of <video>, <figure> and <br> (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/com/dom_distiller/client/FilteringDomVisitor.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/com/dom_distiller/client/ContentExtractor.java
diff --git a/src/com/dom_distiller/client/ContentExtractor.java b/src/com/dom_distiller/client/ContentExtractor.java
index 0598bc6f272138141076156ec87122a3f2b8511f..18e954c6c7ce47db6dfbc717b33a49bb1aae180f 100644
--- a/src/com/dom_distiller/client/ContentExtractor.java
+++ b/src/com/dom_distiller/client/ContentExtractor.java
@@ -7,7 +7,6 @@ package com.dom_distiller.client;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.ImageElement;
import com.google.gwt.dom.client.Node;
import com.google.gwt.dom.client.NodeList;
@@ -73,8 +72,8 @@ public class ContentExtractor implements Exportable {
}
// The base URL in the distilled page viewer is different from that in
- // the live page. This breaks all relative links (in anchors and
- // images), so make them absolute in the distilled content.
+ // the live page. This breaks all relative links (in anchors,
+ // images, etc.), so make them absolute in the distilled content.
makeAllLinksAbsolute(clonedSubtree);
// TODO(cjhopman): this discards the top element and just returns its children. This might
@@ -106,11 +105,13 @@ public class ContentExtractor implements Exportable {
AnchorElement link = AnchorElement.as(allLinks.getItem(i));
link.setHref(link.getHref());
}
+ makeAllSrcAttributesAbsolute(root);
+ }
- NodeList<Element> allImages = root.getElementsByTagName("IMG");
- for (int i = 0; i < allImages.getLength(); i++) {
- ImageElement image = ImageElement.as(allImages.getItem(i));
- image.setSrc(image.getSrc());
+ private static native void makeAllSrcAttributesAbsolute(Element root) /*-{
+ var elementsWithSrc = root.querySelectorAll('img,source,track,video');
+ for (var key in elementsWithSrc) {
+ elementsWithSrc[key].src = elementsWithSrc[key].src;
}
- }
+ }-*/;
}
« no previous file with comments | « no previous file | src/com/dom_distiller/client/FilteringDomVisitor.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698