mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 13:42:27 +01:00
Properly kludge last commit.
This commit is contained in:
@@ -272,8 +272,7 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
/* FIXME: This doesn't belong here. */
|
/* FIXME: This doesn't belong here. */
|
||||||
let mainWindowID = config.mainWindowID || "main-window";
|
let mainWindowID = config.mainWindowID || "main-window";
|
||||||
let fontSize = document.defaultView.getComputedStyle(document.getElementById(mainWindowID), null)
|
let fontSize = util.computedStyle(document.getElementById(mainWindowID))["font-size"];
|
||||||
.getPropertyValue("font-size");
|
|
||||||
|
|
||||||
styles.registerSheet("chrome://liberator/skin/liberator.css");
|
styles.registerSheet("chrome://liberator/skin/liberator.css");
|
||||||
let error = styles.addSheet("font-size", "chrome://liberator/content/buffer.xhtml",
|
let error = styles.addSheet("font-size", "chrome://liberator/content/buffer.xhtml",
|
||||||
@@ -578,9 +577,8 @@ function Buffer() //{{{
|
|||||||
|
|
||||||
for (match in matches)
|
for (match in matches)
|
||||||
{
|
{
|
||||||
let computedStyle = window.content.getComputedStyle(match, null);
|
let computedStyle = util.computedStyle(match);
|
||||||
|
if (computedStyle.visibility != "hidden" && computedStyle.display != "none")
|
||||||
if (computedStyle.getPropertyValue("visibility") != "hidden" && computedStyle.getPropertyValue("display") != "none")
|
|
||||||
elements.push(match);
|
elements.push(match);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1278,7 +1276,7 @@ function Buffer() //{{{
|
|||||||
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303
|
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303
|
||||||
getCurrentWord: function ()
|
getCurrentWord: function ()
|
||||||
{
|
{
|
||||||
var selection = window.content.getSelection();
|
let selection = window.content.getSelection();
|
||||||
if (selection.isCollapsed)
|
if (selection.isCollapsed)
|
||||||
{
|
{
|
||||||
let selController = this.selectionController;
|
let selController = this.selectionController;
|
||||||
@@ -1288,7 +1286,11 @@ function Buffer() //{{{
|
|||||||
selController.wordMove(true, true);
|
selController.wordMove(true, true);
|
||||||
selController.setCaretEnabled(caretmode);
|
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
|
// more advanced than a simple elem.focus() as it also works for iframes
|
||||||
|
|||||||
@@ -137,6 +137,14 @@ const util = { //{{{
|
|||||||
return str.length <= length ? str : str.substr(0, length - 3) + "...";
|
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)
|
copyToClipboard: function (str, verbose)
|
||||||
{
|
{
|
||||||
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
var clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
|
||||||
|
|||||||
Reference in New Issue
Block a user