diff options
| author | Stephen Blott | 2015-06-25 05:28:01 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-06-25 05:28:01 +0100 |
| commit | cb42acfc59c10df4c0fd56f068c83c7509d5a237 (patch) | |
| tree | f5caba89ec0472f42631d653ce21c55a242ecd03 /lib/dom_utils.coffee | |
| parent | c404f6799bb748754f91b1d515108706a024dce1 (diff) | |
| parent | e5faeff7d48a206a080a56a6541963d2d3c86da7 (diff) | |
| download | vimium-cb42acfc59c10df4c0fd56f068c83c7509d5a237.tar.bz2 | |
Merge branch 'hud-iframe-input-with-store-all-settings'
Diffstat (limited to 'lib/dom_utils.coffee')
| -rw-r--r-- | lib/dom_utils.coffee | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 7c47179c..9658df2b 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -326,6 +326,18 @@ DomUtils = document.body.removeChild div coordinates + getSelectionFocusElement: -> + sel = window.getSelection() + if not sel.focusNode? + null + else if sel.focusNode == sel.anchorNode and sel.focusOffset == sel.anchorOffset + # The selection either *is* an element, or is inside an opaque element (eg. <input>). + sel.focusNode.childNodes[sel.focusOffset] + else if sel.focusNode.nodeType != sel.focusNode.ELEMENT_NODE + sel.focusNode.parentElement + else + sel.focusNode + # Get the text content of an element (and its descendents), but omit the text content of previously-visited # nodes. See #1514. # NOTE(smblott). This is currently O(N^2) (when called on N elements). An alternative would be to mark |
