OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 * Used when hideTimer is running, time when the tab should be hidden. | 107 * Used when hideTimer is running, time when the tab should be hidden. |
108 * @type Integer | 108 * @type Integer |
109 */ | 109 */ |
110 hideTargetTime: 0, | 110 hideTargetTime: 0, |
111 | 111 |
112 /** | 112 /** |
113 * Initializes object tabs (generates random classes and registers stylesheet)
. | 113 * Initializes object tabs (generates random classes and registers stylesheet)
. |
114 */ | 114 */ |
115 _initCSS: function() | 115 _initCSS: function() |
116 { | 116 { |
| 117 function processCSSData(request) |
| 118 { |
| 119 if (onShutdown.done) |
| 120 return; |
| 121 |
| 122 let data = request.responseText; |
| 123 |
| 124 let rnd = []; |
| 125 let offset = "a".charCodeAt(0); |
| 126 for (let i = 0; i < 60; i++) |
| 127 rnd.push(offset + Math.random() * 26); |
| 128 |
| 129 this.objTabClassVisibleTop = String.fromCharCode.apply(String, rnd.slice(0
, 20)); |
| 130 this.objTabClassVisibleBottom = String.fromCharCode.apply(String, rnd.slic
e(20, 40)); |
| 131 this.objTabClassHidden = String.fromCharCode.apply(String, rnd.slice(40, 6
0)); |
| 132 |
| 133 let {Utils} = require("utils"); |
| 134 let url = Utils.makeURI("data:text/css," + encodeURIComponent(data.replace
(/%%CLASSVISIBLETOP%%/g, this.objTabClassVisibleTop) |
| 135 .replace
(/%%CLASSVISIBLEBOTTOM%%/g, this.objTabClassVisibleBottom) |
| 136 .replace
(/%%CLASSHIDDEN%%/g, this.objTabClassHidden))); |
| 137 Utils.styleService.loadAndRegisterSheet(url, Ci.nsIStyleSheetService.USER_
SHEET); |
| 138 onShutdown.add(function() |
| 139 { |
| 140 Utils.styleService.unregisterSheet(url, Ci.nsIStyleSheetService.USER_SHE
ET); |
| 141 }); |
| 142 |
| 143 this.initializing = false; |
| 144 this.initialized = true; |
| 145 |
| 146 if (this.delayedShowParams) |
| 147 this._showTab.apply(this, this.delayedShowParams); |
| 148 } |
| 149 |
117 this.delayedShowParams = arguments; | 150 this.delayedShowParams = arguments; |
118 | 151 |
119 if (!this.initializing) | 152 if (!this.initializing) |
120 { | 153 { |
121 this.initializing = true; | 154 this.initializing = true; |
122 | 155 |
123 function processCSSData(request) | |
124 { | |
125 if (onShutdown.done) | |
126 return; | |
127 | |
128 let data = request.responseText; | |
129 | |
130 let rnd = []; | |
131 let offset = "a".charCodeAt(0); | |
132 for (let i = 0; i < 60; i++) | |
133 rnd.push(offset + Math.random() * 26); | |
134 | |
135 this.objTabClassVisibleTop = String.fromCharCode.apply(String, rnd.slice
(0, 20)); | |
136 this.objTabClassVisibleBottom = String.fromCharCode.apply(String, rnd.sl
ice(20, 40)); | |
137 this.objTabClassHidden = String.fromCharCode.apply(String, rnd.slice(40,
60)); | |
138 | |
139 let {Utils} = require("utils"); | |
140 let url = Utils.makeURI("data:text/css," + encodeURIComponent(data.repla
ce(/%%CLASSVISIBLETOP%%/g, this.objTabClassVisibleTop) | |
141 .repla
ce(/%%CLASSVISIBLEBOTTOM%%/g, this.objTabClassVisibleBottom) | |
142 .repla
ce(/%%CLASSHIDDEN%%/g, this.objTabClassHidden))); | |
143 Utils.styleService.loadAndRegisterSheet(url, Ci.nsIStyleSheetService.USE
R_SHEET); | |
144 onShutdown.add(function() | |
145 { | |
146 Utils.styleService.unregisterSheet(url, Ci.nsIStyleSheetService.USER_S
HEET); | |
147 }); | |
148 | |
149 this.initializing = false; | |
150 this.initialized = true; | |
151 | |
152 if (this.delayedShowParams) | |
153 this._showTab.apply(this, this.delayedShowParams); | |
154 } | |
155 | |
156 // Load CSS asynchronously | 156 // Load CSS asynchronously |
157 try { | 157 try { |
158 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstan
ce(Ci.nsIXMLHttpRequest); | 158 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstan
ce(Ci.nsIXMLHttpRequest); |
159 request.mozBackgroundRequest = true; | 159 request.mozBackgroundRequest = true; |
160 request.open("GET", "chrome://adblockplus/content/objtabs.css"); | 160 request.open("GET", "chrome://adblockplus/content/objtabs.css"); |
161 request.overrideMimeType("text/plain"); | 161 request.overrideMimeType("text/plain"); |
162 | 162 |
163 request.addEventListener("load", processCSSData.bind(this, request), fal
se); | 163 request.addEventListener("load", processCSSData.bind(this, request), fal
se); |
164 request.send(null); | 164 request.send(null); |
165 } | 165 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 { | 358 { |
359 // Restrict rectangle coordinates by the boundaries of a window's client are
a | 359 // Restrict rectangle coordinates by the boundaries of a window's client are
a |
360 function intersectRect(rect, wnd) | 360 function intersectRect(rect, wnd) |
361 { | 361 { |
362 // Cannot use wnd.innerWidth/Height because they won't account for scrollb
ars | 362 // Cannot use wnd.innerWidth/Height because they won't account for scrollb
ars |
363 let doc = wnd.document; | 363 let doc = wnd.document; |
364 let wndWidth = doc.documentElement.clientWidth; | 364 let wndWidth = doc.documentElement.clientWidth; |
365 let wndHeight = doc.documentElement.clientHeight; | 365 let wndHeight = doc.documentElement.clientHeight; |
366 if (doc.compatMode == "BackCompat") // clientHeight will be bogus in quirk
s mode | 366 if (doc.compatMode == "BackCompat") // clientHeight will be bogus in quirk
s mode |
367 wndHeight = Math.max(doc.documentElement.offsetHeight, doc.body.offsetHe
ight) - wnd.scrollMaxY - 1; | 367 wndHeight = Math.max(doc.documentElement.offsetHeight, doc.body.offsetHe
ight) - wnd.scrollMaxY - 1; |
368 | 368 |
369 rect.left = Math.max(rect.left, 0); | 369 rect.left = Math.max(rect.left, 0); |
370 rect.top = Math.max(rect.top, 0); | 370 rect.top = Math.max(rect.top, 0); |
371 rect.right = Math.min(rect.right, wndWidth); | 371 rect.right = Math.min(rect.right, wndWidth); |
372 rect.bottom = Math.min(rect.bottom, wndHeight); | 372 rect.bottom = Math.min(rect.bottom, wndHeight); |
373 } | 373 } |
374 | 374 |
375 let rect = element.getBoundingClientRect(); | 375 let rect = element.getBoundingClientRect(); |
376 let wnd = element.ownerDocument.defaultView; | 376 let wnd = element.ownerDocument.defaultView; |
377 | 377 |
378 let style = wnd.getComputedStyle(element, null); | 378 let style = wnd.getComputedStyle(element, null); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 event.stopPropagation(); | 483 event.stopPropagation(); |
484 | 484 |
485 objTabs.doBlock(); | 485 objTabs.doBlock(); |
486 } | 486 } |
487 else if (event.type == "mouseover") | 487 else if (event.type == "mouseover") |
488 objTabs.showTabFor(objTabs.currentElement); | 488 objTabs.showTabFor(objTabs.currentElement); |
489 else if (event.type == "mouseout") | 489 else if (event.type == "mouseout") |
490 objTabs.hideTabFor(objTabs.currentElement); | 490 objTabs.hideTabFor(objTabs.currentElement); |
491 } | 491 } |
492 exports.objectMouseEventHander = objectMouseEventHander; | 492 exports.objectMouseEventHander = objectMouseEventHander; |
OLD | NEW |