1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 09:17:59 +01:00

Properly kludge last commit.

This commit is contained in:
Kris Maglione
2008-10-31 16:22:01 +00:00
parent f7141d55e1
commit d7c5e79cd7
2 changed files with 17 additions and 7 deletions

View File

@@ -272,8 +272,7 @@ function Buffer() //{{{
/* FIXME: This doesn't belong here. */
let mainWindowID = config.mainWindowID || "main-window";
let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null)
.getPropertyValue("font-size");
let fontSize = util.computedStyle(document.getElementById(mainWindowID))["font-size"];
styles.registerSheet("chrome://liberator/skin/liberator.css");
let error = styles.addSheet("font-size", "chrome://liberator/content/buffer.xhtml",
@@ -578,9 +577,8 @@ function Buffer() //{{{
for (match in matches)
{
let computedStyle = window.content.getComputedStyle(match, null);
if (computedStyle.getPropertyValue("visibility") != "hidden" && computedStyle.getPropertyValue("display") != "none")
let computedStyle = util.computedStyle(match);
if (computedStyle.visibility != "hidden" && computedStyle.display != "none")
elements.push(match);
}
@@ -1278,7 +1276,7 @@ function Buffer() //{{{
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303
getCurrentWord: function ()
{
var selection = window.content.getSelection();
let selection = window.content.getSelection();
if (selection.isCollapsed)
{
let selController = this.selectionController;
@@ -1288,7 +1286,11 @@ function Buffer() //{{{
selController.wordMove(true, true);
selController.setCaretEnabled(caretmode);
}
return String(selection.getRangeAt(0));
let range = selection.getRangeAt(0);
if (util.computedStyle(range.startContainer)["white-space"] == "pre"
&& util.computedStyle(range.endContainer)["white-space"] == "pre")
return String(range);
return String(selection);
},
// more advanced than a simple elem.focus() as it also works for iframes

View File

@@ -137,6 +137,14 @@ const util = { //{{{
return str.length <= length ? str : str.substr(0, length - 3) + "...";
},
computedStyle: function (node)
{
while (node instanceof Text && node.parentNode)
node = node.parentNode;
let style = node.ownerDocument.defaultView.getComputedStyle(node, null);
return util.Array.assocToObj(Array.map(style, function (k) [k, style.getPropertyValue(k)]));
},
copyToClipboard: function (str, verbose)
{
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]