summaryrefslogtreecommitdiff
path: root/layout/generic
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 07:29:57 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 07:29:57 -0400
commit03adc6b4ee1819ab107f1c74e55e0be8b636014f (patch)
treeced1fbdc9767f6d87428f30331bf6305938a291e /layout/generic
parentc415dc0c18dad23c184e42d7e7e7efbd0ce409ce (diff)
downloadaura-central-03adc6b4ee1819ab107f1c74e55e0be8b636014f.tar.gz
Bug 1422197 - Add fast path to get DocGroup in binding code for [CEReactions]
Tag mcp-graveyard/UXP%1375
Diffstat (limited to 'layout/generic')
-rw-r--r--layout/generic/Selection.h4
-rw-r--r--layout/generic/nsSelection.cpp12
2 files changed, 16 insertions, 0 deletions
diff --git a/layout/generic/Selection.h b/layout/generic/Selection.h
index 5414d15c1..cc696a7c7 100644
--- a/layout/generic/Selection.h
+++ b/layout/generic/Selection.h
@@ -31,6 +31,9 @@ class nsHTMLCopyEncoder;
namespace mozilla {
class ErrorResult;
struct AutoPrepareFocusRange;
+namespace dom {
+class DocGroup;
+} // namespace dom
} // namespace mozilla
struct RangeData
@@ -73,6 +76,7 @@ public:
nsresult EndBatchChangesInternal(int16_t aReason = nsISelectionListener::NO_REASON);
nsIDocument* GetParentObject() const;
+ DocGroup* GetDocGroup() const;
// utility methods for scrolling the selection into view
nsPresContext* GetPresContext() const;
diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp
index 994ec4852..919ab0815 100644
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -3521,6 +3521,18 @@ Selection::GetParentObject() const
return nullptr;
}
+DocGroup*
+Selection::GetDocGroup() const
+{
+ nsIPresShell* shell = GetPresShell();
+ if (!shell) {
+ return nullptr;
+ }
+
+ nsIDocument* doc = shell->GetDocument();
+ return doc ? doc->GetDocGroup() : nullptr;
+}
+
NS_IMPL_CYCLE_COLLECTION_CLASS(Selection)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Selection)