diff options
author | Moonchild <mcwerewolf@gmail.com> | 2018-04-23 11:45:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-23 11:45:04 +0200 |
commit | 3b55277bc59d6bea5f61c164f9687ae242b88550 (patch) | |
tree | 1e0a3ca438adc705be3618808e71bb6aa5f1e330 /layout | |
parent | d220a5e6aaa7410b8c62fd3f7f37e8fb853e5797 (diff) | |
parent | 0a9acadccafe04aa5bc3335523bb55fe52ca8e50 (diff) | |
download | UXP-3b55277bc59d6bea5f61c164f9687ae242b88550.tar UXP-3b55277bc59d6bea5f61c164f9687ae242b88550.tar.gz UXP-3b55277bc59d6bea5f61c164f9687ae242b88550.tar.lz UXP-3b55277bc59d6bea5f61c164f9687ae242b88550.tar.xz UXP-3b55277bc59d6bea5f61c164f9687ae242b88550.zip |
Merge pull request #237 from janekptacijarabaci/js_dom_getSelection_document_1
moebius#121: DOM - Selection API - getSelection() should exist on XMLDocument / Selection.type
Diffstat (limited to 'layout')
-rw-r--r-- | layout/generic/Selection.h | 3 | ||||
-rw-r--r-- | layout/generic/nsSelection.cpp | 12 |
2 files changed, 15 insertions, 0 deletions
diff --git a/layout/generic/Selection.h b/layout/generic/Selection.h index 6f94303ca..3d5e334fc 100644 --- a/layout/generic/Selection.h +++ b/layout/generic/Selection.h @@ -179,6 +179,9 @@ public: { return mRanges.Length(); } + + void GetType(nsAString& aOutType) const; + nsRange* GetRangeAt(uint32_t aIndex, mozilla::ErrorResult& aRv); void AddRange(nsRange& aRange, mozilla::ErrorResult& aRv); void RemoveRange(nsRange& aRange, mozilla::ErrorResult& aRv); diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index e0d65632e..a2227c39c 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -5349,6 +5349,18 @@ Selection::GetRangeCount(int32_t* aRangeCount) return NS_OK; } +void +Selection::GetType(nsAString& aOutType) const +{ + if (!RangeCount()) { + aOutType.AssignLiteral("None"); + } else if (IsCollapsed()) { + aOutType.AssignLiteral("Caret"); + } else { + aOutType.AssignLiteral("Range"); + } +} + NS_IMETHODIMP Selection::GetRangeAt(int32_t aIndex, nsIDOMRange** aReturn) { |