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

Side by Side Diff: java/org/chromium/distiller/DomUtil.java

Issue 1754213004: Retain image sizes (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Moving preserved attributes to the whitelist. Created 4 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 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 org.chromium.distiller; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.core.client.JsArray; 7 import com.google.gwt.core.client.JsArray;
8 import com.google.gwt.core.client.JsArrayString; 8 import com.google.gwt.core.client.JsArrayString;
9 import com.google.gwt.dom.client.AnchorElement; 9 import com.google.gwt.dom.client.AnchorElement;
10 import com.google.gwt.dom.client.Document; 10 import com.google.gwt.dom.client.Document;
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * @param ie The image element to strip in-place. 314 * @param ie The image element to strip in-place.
315 */ 315 */
316 public static void stripImageElement(ImageElement imgElement) { 316 public static void stripImageElement(ImageElement imgElement) {
317 JsArray<Node> attrs = getAttributes(imgElement); 317 JsArray<Node> attrs = getAttributes(imgElement);
318 for (int i = 0; i < attrs.length(); ) { 318 for (int i = 0; i < attrs.length(); ) {
319 String name = attrs.get(i).getNodeName(); 319 String name = attrs.get(i).getNodeName();
320 if (!"src".equals(name) && 320 if (!"src".equals(name) &&
321 !"alt".equals(name) && 321 !"alt".equals(name) &&
322 !"srcset".equals(name) && 322 !"srcset".equals(name) &&
323 !"dir".equals(name) && 323 !"dir".equals(name) &&
324 !"width".equals(name) &&
325 !"height".equals(name) &&
324 !"title".equals(name)) { 326 !"title".equals(name)) {
325 imgElement.removeAttribute(name); 327 imgElement.removeAttribute(name);
326 } else { 328 } else {
327 i++; 329 i++;
328 } 330 }
329 } 331 }
330 } 332 }
331 333
332 /** 334 /**
333 * Makes all "img", "source", "track", and "video" tags have an absolute "sr c" attribute. 335 * Makes all "img", "source", "track", and "video" tags have an absolute "sr c" attribute.
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 }-*/; 457 }-*/;
456 458
457 public static native Document createHTMLDocument(Document doc) /*-{ 459 public static native Document createHTMLDocument(Document doc) /*-{
458 return doc.implementation.createHTMLDocument(); 460 return doc.implementation.createHTMLDocument();
459 }-*/; 461 }-*/;
460 462
461 public static native Element getFirstElementChild(Document document) /*-{ 463 public static native Element getFirstElementChild(Document document) /*-{
462 return document.firstElementChild; 464 return document.firstElementChild;
463 }-*/; 465 }-*/;
464 } 466 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698