OLD | NEW |
1 /* | 1 /* |
2 * This Source Code is subject to the terms of the Mozilla Public License | 2 * This Source Code is subject to the terms of the Mozilla Public License |
3 * version 2.0 (the "License"). You can obtain a copy of the License at | 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
4 * http://mozilla.org/MPL/2.0/. | 4 * http://mozilla.org/MPL/2.0/. |
5 */ | 5 */ |
6 | 6 |
7 let {Prefs} = require("prefs"); | 7 let {Prefs} = require("prefs"); |
8 | 8 |
9 // Make sure to stop selection when we are uninstalled | 9 // Make sure to stop selection when we are uninstalled |
10 onShutdown.add(function() Aardvark.quit()); | 10 onShutdown.add(function() Aardvark.quit()); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 addition += ", style: " + elem.style.cssText; | 327 addition += ", style: " + elem.style.cssText; |
328 | 328 |
329 return [tagName, addition]; | 329 return [tagName, addition]; |
330 }, | 330 }, |
331 | 331 |
332 selectElement: function(elem) | 332 selectElement: function(elem) |
333 { | 333 { |
334 this.selectedElem = elem; | 334 this.selectedElem = elem; |
335 this.prevSelectionUpdate = Date.now(); | 335 this.prevSelectionUpdate = Date.now(); |
336 | 336 |
337 let border = this.boxElem.getElementsByClassName("border")[0]; | 337 let border = this.boxElem.getElementsByClassName("ehh-border")[0]; |
338 let label = this.boxElem.getElementsByClassName("label")[0]; | 338 let label = this.boxElem.getElementsByClassName("ehh-label")[0]; |
339 let labelTag = this.boxElem.getElementsByClassName("labelTag")[0]; | 339 let labelTag = this.boxElem.getElementsByClassName("ehh-labelTag")[0]; |
340 let labelAddition = this.boxElem.getElementsByClassName("labelAddition")[0]; | 340 let labelAddition = this.boxElem.getElementsByClassName("ehh-labelAddition")
[0]; |
341 | 341 |
342 if (this.boxElem.parentNode) | 342 if (this.boxElem.parentNode) |
343 this.boxElem.parentNode.removeChild(this.boxElem); | 343 this.boxElem.parentNode.removeChild(this.boxElem); |
344 | 344 |
345 let doc = this.browser.contentDocument; | 345 let doc = this.browser.contentDocument; |
346 let [wndWidth, wndHeight] = this.getWindowSize(doc.defaultView); | 346 let [wndWidth, wndHeight] = this.getWindowSize(doc.defaultView); |
347 | 347 |
348 let pos = this.getElementPosition(elem); | 348 let pos = this.getElementPosition(elem); |
349 this.boxElem.style.left = Math.min(pos.left - 1, wndWidth - 2) + "px"; | 349 this.boxElem.style.left = Math.min(pos.left - 1, wndWidth - 2) + "px"; |
350 this.boxElem.style.top = Math.min(pos.top - 1, wndHeight - 2) + "px"; | 350 this.boxElem.style.top = Math.min(pos.top - 1, wndHeight - 2) + "px"; |
351 border.style.width = Math.max(pos.right - pos.left - 2, 0) + "px"; | 351 border.style.width = Math.max(pos.right - pos.left - 2, 0) + "px"; |
352 border.style.height = Math.max(pos.bottom - pos.top - 2, 0) + "px"; | 352 border.style.height = Math.max(pos.bottom - pos.top - 2, 0) + "px"; |
353 | 353 |
354 [labelTag.textContent, labelAddition.textContent] = this.getElementLabel(ele
m); | 354 [labelTag.textContent, labelAddition.textContent] = this.getElementLabel(ele
m); |
355 | 355 |
356 // If there is not enough space to show the label move it up a little | 356 // If there is not enough space to show the label move it up a little |
357 if (pos.bottom < wndHeight - 25) | 357 if (pos.bottom < wndHeight - 25) |
358 label.className = "label"; | 358 label.className = "ehh-label"; |
359 else | 359 else |
360 label.className = "label onTop"; | 360 label.className = "ehh-label onTop"; |
361 | 361 |
362 doc.documentElement.appendChild(this.boxElem); | 362 doc.documentElement.appendChild(this.boxElem); |
363 | 363 |
364 this.paintNode = doc.defaultView; | 364 this.paintNode = doc.defaultView; |
365 if (this.paintNode) | 365 if (this.paintNode) |
366 { | 366 { |
367 this.prevPos = pos; | 367 this.prevPos = pos; |
368 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false)
; | 368 this.paintNode.addEventListener("MozAfterPaint", this.onAfterPaint, false)
; |
369 } | 369 } |
370 }, | 370 }, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 // Show help box | 725 // Show help box |
726 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); | 726 helpBox.showPopup(this.browser, -1, -1, "tooltip", "topleft", "topleft"); |
727 return true; | 727 return true; |
728 } | 728 } |
729 } | 729 } |
730 | 730 |
731 // Makes sure event handlers like Aardvark.onKeyPress always have the correct | 731 // Makes sure event handlers like Aardvark.onKeyPress always have the correct |
732 // this pointer set. | 732 // this pointer set. |
733 for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageH
ide", "onMouseMove", "onAfterPaint", "quit"]) | 733 for each (let method in ["onMouseClick", "onMouseScroll", "onKeyPress", "onPageH
ide", "onMouseMove", "onAfterPaint", "quit"]) |
734 Aardvark[method] = Aardvark[method].bind(Aardvark); | 734 Aardvark[method] = Aardvark[method].bind(Aardvark); |
OLD | NEW |