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

Delta Between Two Patch Sets: safari/ext/content.js

Issue 5641434644348928: Fixed element collapsing in Safari (Closed)
Left Patch Set: Created Jan. 15, 2014, 7:34 p.m.
Right Patch Set: Addressed comments Created Jan. 16, 2014, 1:20 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
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (objectInfo.isFunction) 272 if (objectInfo.isFunction)
273 obj.prototype = this.getProperty(objectId, "prototype"); 273 obj.prototype = this.getProperty(objectId, "prototype");
274 274
275 return obj; 275 return obj;
276 } 276 }
277 }; 277 };
278 278
279 279
280 /* Web request blocking */ 280 /* Web request blocking */
281 281
282 var errorEvent = document.createEvent("Event");
283 errorEvent.initEvent("error");
284
285 document.addEventListener("beforeload", function(event) 282 document.addEventListener("beforeload", function(event)
286 { 283 {
287 var type; 284 var type;
288 285
289 switch(event.target.localName) 286 switch(event.target.localName)
290 { 287 {
291 case "frame": 288 case "frame":
292 case "iframe": 289 case "iframe":
293 type = "sub_rame"; 290 type = "sub_rame";
294 break; 291 break;
(...skipping 25 matching lines...) Expand all
320 documentUrl: document.location.href, 317 documentUrl: document.location.href,
321 isTopLevel: window == window.top 318 isTopLevel: window == window.top
322 } 319 }
323 })) 320 }))
324 { 321 {
325 event.preventDefault(); 322 event.preventDefault();
326 323
327 // Safari doesn't dispatch an "error" event when preventing an element 324 // Safari doesn't dispatch an "error" event when preventing an element
328 // from loading by cancelling the "beforeload" event. So we have to 325 // from loading by cancelling the "beforeload" event. So we have to
329 // dispatch it manually. Otherwise element collapsing wouldn't work. 326 // dispatch it manually. Otherwise element collapsing wouldn't work.
330 event.target.dispatchEvent(errorEvent); 327 var evt = document.createEvent("Event");
Wladimir Palant 2014/01/16 09:21:24 a) Does Safari really allow dispatching the same e
Sebastian Noack 2014/01/16 13:20:56 Apparently it does. But if that is non-standard, I
328 evt.initEvent(type == "sub_frame" ? "load" : "error");
329 event.target.dispatchEvent(evt);
331 } 330 }
332 }, true); 331 }, true);
333 332
334 333
335 /* API */ 334 /* API */
336 335
337 ext.backgroundPage = { 336 ext.backgroundPage = {
338 sendMessage: function(message, responseCallback) { 337 sendMessage: function(message, responseCallback) {
339 _sendMessage( 338 _sendMessage(
340 message, responseCallback, 339 message, responseCallback,
341 safari.self.tab, safari.self, 340 safari.self.tab, safari.self,
342 { 341 {
343 documentUrl: document.location.href, 342 documentUrl: document.location.href,
344 isTopLevel: window == window.top 343 isTopLevel: window == window.top
345 } 344 }
346 ); 345 );
347 }, 346 },
348 getWindow: function() 347 getWindow: function()
349 { 348 {
350 return proxy.getObject(0); 349 return proxy.getObject(0);
351 } 350 }
352 }; 351 };
353 352
354 ext.onMessage = new ContentMessageEventTarget(); 353 ext.onMessage = new ContentMessageEventTarget();
355 })(); 354 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld