summaryrefslogtreecommitdiffstats
path: root/dom/base/Selection.h
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/Selection.h')
-rw-r--r--dom/base/Selection.h51
1 files changed, 49 insertions, 2 deletions
diff --git a/dom/base/Selection.h b/dom/base/Selection.h
index 9f031ab3cf..08563993ac 100644
--- a/dom/base/Selection.h
+++ b/dom/base/Selection.h
@@ -64,6 +64,9 @@ namespace dom {
class Selection final : public nsSupportsWeakReference,
public nsWrapperCache,
public SupportsWeakPtr {
+ using AllowRangeCrossShadowBoundary =
+ mozilla::dom::AllowRangeCrossShadowBoundary;
+
protected:
virtual ~Selection();
@@ -205,6 +208,10 @@ class Selection final : public nsSupportsWeakReference,
nsRange* aRange, Maybe<size_t>* aOutIndex,
DispatchSelectstartEvent aDispatchSelectstartEvent);
+ already_AddRefed<StaticRange> GetComposedRange(
+ const AbstractRange* aRange,
+ const Sequence<OwningNonNull<ShadowRoot>>& aShadowRoots) const;
+
public:
nsresult RemoveCollapsedRanges();
void Clear(nsPresContext* aPresContext);
@@ -246,6 +253,8 @@ class Selection final : public nsSupportsWeakReference,
// anchor and which end is focus.
const nsRange* GetAnchorFocusRange() const { return mAnchorFocusRange; }
+ void GetDirection(nsAString& aDirection) const;
+
nsDirection GetDirection() const { return mDirection; }
void SetDirection(nsDirection aDir) { mDirection = aDir; }
@@ -321,6 +330,30 @@ class Selection final : public nsSupportsWeakReference,
return offset ? *offset : 0;
}
+ nsINode* GetMayCrossShadowBoundaryAnchorNode() const {
+ const RangeBoundary& anchor = AnchorRef(AllowRangeCrossShadowBoundary::Yes);
+ return anchor.IsSet() ? anchor.Container() : nullptr;
+ }
+
+ uint32_t MayCrossShadowBoundaryAnchorOffset() const {
+ const RangeBoundary& anchor = AnchorRef(AllowRangeCrossShadowBoundary::Yes);
+ const Maybe<uint32_t> offset =
+ anchor.Offset(RangeBoundary::OffsetFilter::kValidOffsets);
+ return offset ? *offset : 0;
+ }
+
+ nsINode* GetMayCrossShadowBoundaryFocusNode() const {
+ const RangeBoundary& focus = FocusRef(AllowRangeCrossShadowBoundary::Yes);
+ return focus.IsSet() ? focus.Container() : nullptr;
+ }
+
+ uint32_t MayCrossShadowBoundaryFocusOffset() const {
+ const RangeBoundary& focus = FocusRef(AllowRangeCrossShadowBoundary::Yes);
+ const Maybe<uint32_t> offset =
+ focus.Offset(RangeBoundary::OffsetFilter::kValidOffsets);
+ return offset ? *offset : 0;
+ }
+
nsIContent* GetChildAtAnchorOffset() {
const RangeBoundary& anchor = AnchorRef();
return anchor.IsSet() ? anchor.GetChildAtOffset() : nullptr;
@@ -330,8 +363,12 @@ class Selection final : public nsSupportsWeakReference,
return focus.IsSet() ? focus.GetChildAtOffset() : nullptr;
}
- const RangeBoundary& AnchorRef() const;
- const RangeBoundary& FocusRef() const;
+ const RangeBoundary& AnchorRef(
+ AllowRangeCrossShadowBoundary aAllowCrossShadowBoundary =
+ AllowRangeCrossShadowBoundary::No) const;
+ const RangeBoundary& FocusRef(
+ AllowRangeCrossShadowBoundary aAllowCrossShadowBoundary =
+ AllowRangeCrossShadowBoundary::No) const;
/*
* IsCollapsed -- is the whole selection just one point, or unset?
@@ -385,6 +422,10 @@ class Selection final : public nsSupportsWeakReference,
MOZ_CAN_RUN_SCRIPT void RemoveAllRanges(mozilla::ErrorResult& aRv);
+ void GetComposedRanges(
+ const Sequence<OwningNonNull<ShadowRoot>>& aShadowRoots,
+ nsTArray<RefPtr<StaticRange>>& aComposedRanges);
+
/**
* Whether Stringify should flush layout or not.
*/
@@ -810,6 +851,12 @@ class Selection final : public nsSupportsWeakReference,
PostContentIterator& aPostOrderIter, nsIContent* aContent,
bool aSelected) const;
+ /**
+ * https://dom.spec.whatwg.org/#concept-shadow-including-descendant
+ */
+ void SelectFramesOfShadowIncludingDescendantsOfContent(nsIContent* aContent,
+ bool aSelected) const;
+
nsresult SelectFrames(nsPresContext* aPresContext, AbstractRange& aRange,
bool aSelect) const;