summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorAndy Huang <ath@google.com>2012-10-23 16:56:27 -0700
committerAndy Huang <ath@google.com>2012-10-23 17:10:44 -0700
commitf500db85dd13394dd6bdcfa38824b2ca6ada77e8 (patch)
treeccefbacf230579fa282592123e2d61f4fdb0c56b /assets
parent3c7f94d02ff557c955c5d191cef45361a10be5c9 (diff)
downloadandroid_packages_apps_UnifiedEmail-f500db85dd13394dd6bdcfa38824b2ca6ada77e8.tar.gz
android_packages_apps_UnifiedEmail-f500db85dd13394dd6bdcfa38824b2ca6ada77e8.tar.bz2
android_packages_apps_UnifiedEmail-f500db85dd13394dd6bdcfa38824b2ca6ada77e8.zip
process super-collapsed content
Content within a super-collapsed block that was lazy-loaded wasn't being processed for images and quoted text like initially expanded content. Most images were caught by the regexp anyway, but we need this step for completeness, and so quoted text isn't out of control. Patch up other cases of content replacement to hide images as well. Bug: 7392191 Change-Id: Ib784ce52c9c477635a125f261a2b9717b20887d2
Diffstat (limited to 'assets')
-rw-r--r--assets/script.js37
1 files changed, 23 insertions, 14 deletions
diff --git a/assets/script.js b/assets/script.js
index eafeba336..7ea607df3 100644
--- a/assets/script.js
+++ b/assets/script.js
@@ -174,18 +174,21 @@ function normalizeElementWidths(elements) {
}
}
-function hideUnsafeImages() {
- var i, bodyCount;
+function hideAllUnsafeImages() {
+ hideUnsafeImages(document.getElementsByClassName("mail-message-content"));
+}
+
+function hideUnsafeImages(msgContentDivs) {
+ var i, msgContentCount;
var j, imgCount;
- var body, image;
+ var msgContentDiv, image;
var images;
var showImages;
- var bodies = document.getElementsByClassName("mail-message-content");
- for (i = 0, bodyCount = bodies.length; i < bodyCount; i++) {
- body = bodies[i];
- showImages = body.classList.contains("mail-show-images");
+ for (i = 0, msgContentCount = msgContentDivs.length; i < msgContentCount; i++) {
+ msgContentDiv = msgContentDivs[i];
+ showImages = msgContentDiv.classList.contains("mail-show-images");
- images = body.getElementsByTagName("img");
+ images = msgContentDiv.getElementsByTagName("img");
for (j = 0, imgCount = images.length; j < imgCount; j++) {
image = images[j];
rewriteRelativeImageSrc(image);
@@ -394,7 +397,7 @@ function setMessageBodyVisible(messageDomId, isVisible, spacerHeight) {
}
function replaceSuperCollapsedBlock(startIndex) {
- var parent, block, header;
+ var parent, block, msg;
block = document.querySelector(".mail-super-collapsed-block[index='" + startIndex + "']");
if (!block) {
@@ -404,10 +407,14 @@ function replaceSuperCollapsedBlock(startIndex) {
parent = block.parentNode;
block.innerHTML = window.mail.getTempMessageBodies();
- header = block.firstChild;
- while (header) {
- parent.insertBefore(header, block);
- header = block.firstChild;
+ // process the new block contents in one go before we pluck them out of the common ancestor
+ processQuotedText(block, false /* showElided */);
+ hideUnsafeImages(block.getElementsByClassName("mail-message-content"));
+
+ msg = block.firstChild;
+ while (msg) {
+ parent.insertBefore(msg, block);
+ msg = block.firstChild;
}
parent.removeChild(block);
measurePositions();
@@ -423,6 +430,7 @@ function replaceMessageBodies(messageIds) {
msgContentDiv = document.querySelector("#" + id + " > .mail-message-content");
msgContentDiv.innerHTML = window.mail.getMessageBody(id);
processQuotedText(msgContentDiv, true /* showElided */);
+ hideUnsafeImages([msgContentDiv]);
}
}
@@ -433,6 +441,7 @@ function appendMessageHtml() {
msg = msg.children[0]; // toss the outer div, it was just to render innerHTML into
document.body.appendChild(msg);
processQuotedText(msg, true /* showElided */);
+ hideUnsafeImages(msg.getElementsByClassName("mail-message-content"));
}
// END Java->JavaScript handlers
@@ -442,7 +451,7 @@ function appendMessageHtml() {
setupContentReady();
collapseAllQuotedText();
-hideUnsafeImages();
+hideAllUnsafeImages();
normalizeAllMessageWidths();
//setWideViewport();
restoreScrollPosition();