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

Side by Side Diff: safari/ext/content.js

Issue 5641434644348928: Fixed element collapsing in Safari (Closed)
Patch Set: Created Jan. 15, 2014, 7:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
282 document.addEventListener("beforeload", function(event) 285 document.addEventListener("beforeload", function(event)
283 { 286 {
284 var type; 287 var type;
285 288
286 switch(event.target.localName) 289 switch(event.target.localName)
287 { 290 {
288 case "frame": 291 case "frame":
289 case "iframe": 292 case "iframe":
290 type = "sub_rame"; 293 type = "sub_rame";
291 break; 294 break;
(...skipping 19 matching lines...) Expand all
311 314
312 if (!safari.self.tab.canLoad(event, { 315 if (!safari.self.tab.canLoad(event, {
313 type: "webRequest", 316 type: "webRequest",
314 payload: { 317 payload: {
315 url: event.url, 318 url: event.url,
316 type: type, 319 type: type,
317 documentUrl: document.location.href, 320 documentUrl: document.location.href,
318 isTopLevel: window == window.top 321 isTopLevel: window == window.top
319 } 322 }
320 })) 323 }))
324 {
321 event.preventDefault(); 325 event.preventDefault();
326
327 // Safari doesn't dispatch an "error" event when preventing an element
328 // from loading by cancelling the "beforeload" event. So we have to
329 // dispatch it manually. Otherwise element collapsing wouldn't work.
330 event.target.dispatchEvent(errorEvent);
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
331 }
322 }, true); 332 }, true);
323 333
324 334
325 /* API */ 335 /* API */
326 336
327 ext.backgroundPage = { 337 ext.backgroundPage = {
328 sendMessage: function(message, responseCallback) { 338 sendMessage: function(message, responseCallback) {
329 _sendMessage( 339 _sendMessage(
330 message, responseCallback, 340 message, responseCallback,
331 safari.self.tab, safari.self, 341 safari.self.tab, safari.self,
332 { 342 {
333 documentUrl: document.location.href, 343 documentUrl: document.location.href,
334 isTopLevel: window == window.top 344 isTopLevel: window == window.top
335 } 345 }
336 ); 346 );
337 }, 347 },
338 getWindow: function() 348 getWindow: function()
339 { 349 {
340 return proxy.getObject(0); 350 return proxy.getObject(0);
341 } 351 }
342 }; 352 };
343 353
344 ext.onMessage = new ContentMessageEventTarget(); 354 ext.onMessage = new ContentMessageEventTarget();
345 })(); 355 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld