Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/child/contentPolicy.js

Issue 29329742: Issue 3251 - Simplify messaging from child scripts to parent (Closed)
Left Patch Set: Created Nov. 4, 2015, 2:58 p.m.
Right Patch Set: Rebased Created Nov. 12, 2015, 12:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return; 246 return;
247 247
248 let wnd = Utils.getRequestWindow(newChannel); 248 let wnd = Utils.getRequestWindow(newChannel);
249 if (!wnd) 249 if (!wnd)
250 return; 250 return;
251 251
252 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT) 252 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT)
253 { 253 {
254 if (wnd.history.length <= 1 && wnd.opener) 254 if (wnd.history.length <= 1 && wnd.opener)
255 { 255 {
256 // Special treatment for pop-up windows. Note that we might not have 256 // Special treatment for pop-up windows - this will close the window
257 // rather than preventing the redirect. Note that we might not have
257 // seen the original channel yet because the redirect happened before 258 // seen the original channel yet because the redirect happened before
258 // the async code in observe() had a chance to run. 259 // the async code in observe() had a chance to run.
259 this.observe(wnd, "content-document-global-created", null, oldChannel. URI.spec); 260 this.observe(wnd, "content-document-global-created", null, oldChannel. URI.spec);
260 this.observe(wnd, "content-document-global-created", null, newChannel. URI.spec); 261 this.observe(wnd, "content-document-global-created", null, newChannel. URI.spec);
261 } 262 }
262 return; 263 return;
263 } 264 }
264 265
265 if (!shouldAllow(wnd, wnd.document, types.get(contentType), newChannel.URI .spec)) 266 if (!shouldAllow(wnd, wnd.document, types.get(contentType), newChannel.URI .spec))
266 result = Cr.NS_BINDING_ABORTED; 267 result = Cr.NS_BINDING_ABORTED;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 Utils.runAsync(postProcessNodes); 309 Utils.runAsync(postProcessNodes);
309 } 310 }
310 } 311 }
311 312
312 /** 313 /**
313 * Processes nodes scheduled for post-processing (typically hides them). 314 * Processes nodes scheduled for post-processing (typically hides them).
314 */ 315 */
315 function postProcessNodes() 316 function postProcessNodes()
316 { 317 {
317 if (!collapsedClass) 318 if (!collapsedClass)
318 { 319 collapsedClass = sendSyncMessage("AdblockPlus:GetCollapsedClass");
319 let response = sendSyncMessage("AdblockPlus:GetCollapsedClass");
320 if (response.length)
321 collapsedClass = response[0];
322
323 if (!collapsedClass)
324 {
325 Utils.runAsync(postProcessNodes);
326 return;
327 }
328 }
329 320
330 let nodes = scheduledNodes; 321 let nodes = scheduledNodes;
331 scheduledNodes = null; 322 scheduledNodes = null;
323
324 if (!collapsedClass)
325 return;
332 326
333 for (let node of nodes) 327 for (let node of nodes)
334 { 328 {
335 // adjust frameset's cols/rows for frames 329 // adjust frameset's cols/rows for frames
336 let parentNode = node.parentNode; 330 let parentNode = node.parentNode;
337 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement) 331 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement)
338 { 332 {
339 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0); 333 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0);
340 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0); 334 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0);
341 if ((hasCols || hasRows) && !(hasCols && hasRows)) 335 if ((hasCols || hasRows) && !(hasCols && hasRows))
342 { 336 {
343 let index = -1; 337 let index = -1;
344 for (let frame = node; frame; frame = frame.previousSibling) 338 for (let frame = node; frame; frame = frame.previousSibling)
345 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci. nsIDOMHTMLFrameSetElement) 339 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci. nsIDOMHTMLFrameSetElement)
346 index++; 340 index++;
347 341
348 let property = (hasCols ? "cols" : "rows"); 342 let property = (hasCols ? "cols" : "rows");
349 let weights = parentNode[property].split(","); 343 let weights = parentNode[property].split(",");
350 weights[index] = "0"; 344 weights[index] = "0";
351 parentNode[property] = weights.join(","); 345 parentNode[property] = weights.join(",");
352 } 346 }
353 } 347 }
354 else 348 else
355 node.classList.add(collapsedClass); 349 node.classList.add(collapsedClass);
356 } 350 }
357 } 351 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld