mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-09 04:25:38 +00:00
Bug 1587433: part 7.2) Adapt callers of RangeBoundaryBase::Offset()
. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D54459 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
e25dbd58f9
commit
0752331fc7
@ -40,7 +40,8 @@ class RangeUtils final {
|
||||
// If aNode isn't in the child nodes of its parent node, we hit this case.
|
||||
// This may occur when we're called by a mutation observer while aNode is
|
||||
// removed from the parent node.
|
||||
if (NS_WARN_IF(afterNode.Offset() == 0)) {
|
||||
if (NS_WARN_IF(
|
||||
!afterNode.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets))) {
|
||||
return RawRangeBoundary();
|
||||
}
|
||||
return afterNode;
|
||||
|
@ -2123,7 +2123,9 @@ void Selection::Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
|
||||
aPoint.Container()->IsContent()) {
|
||||
int32_t frameOffset;
|
||||
nsTextFrame* f = do_QueryFrame(nsCaret::GetFrameAndOffset(
|
||||
this, aPoint.Container(), aPoint.Offset(), &frameOffset));
|
||||
this, aPoint.Container(),
|
||||
*aPoint.Offset(RawRangeBoundary::OffsetFilter::kValidOffsets),
|
||||
&frameOffset));
|
||||
if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
|
||||
// RawRangeBounary::Offset() causes computing offset if it's not been
|
||||
// done yet. However, it's called only when the container is a text
|
||||
@ -2131,7 +2133,9 @@ void Selection::Collapse(const RawRangeBoundary& aPoint, ErrorResult& aRv) {
|
||||
// any children. So, this doesn't cause computing offset with expensive
|
||||
// method, nsINode::ComputeIndexOf().
|
||||
if ((aPoint.Container()->AsContent() == f->GetContent() &&
|
||||
f->GetContentEnd() == static_cast<int32_t>(aPoint.Offset())) ||
|
||||
f->GetContentEnd() ==
|
||||
static_cast<int32_t>(*aPoint.Offset(
|
||||
RawRangeBoundary::OffsetFilter::kValidOffsets))) ||
|
||||
(aPoint.Container() == f->GetContent()->GetParentNode() &&
|
||||
f->GetContent() == aPoint.GetPreviousSiblingOfChildAtOffset())) {
|
||||
frameSelection->SetHint(CARET_ASSOCIATE_AFTER);
|
||||
|
@ -231,7 +231,9 @@ class Selection final : public nsSupportsWeakReference,
|
||||
}
|
||||
uint32_t AnchorOffset() const {
|
||||
const RangeBoundary& anchor = AnchorRef();
|
||||
return anchor.IsSet() ? anchor.Offset() : 0;
|
||||
const Maybe<uint32_t> offset =
|
||||
anchor.Offset(RangeBoundary::OffsetFilter::kValidOffsets);
|
||||
return offset ? *offset : 0;
|
||||
}
|
||||
nsINode* GetFocusNode() const {
|
||||
const RangeBoundary& focus = FocusRef();
|
||||
@ -239,7 +241,9 @@ class Selection final : public nsSupportsWeakReference,
|
||||
}
|
||||
uint32_t FocusOffset() const {
|
||||
const RangeBoundary& focus = FocusRef();
|
||||
return focus.IsSet() ? focus.Offset() : 0;
|
||||
const Maybe<uint32_t> offset =
|
||||
focus.Offset(RangeBoundary::OffsetFilter::kValidOffsets);
|
||||
return offset ? *offset : 0;
|
||||
}
|
||||
|
||||
nsIContent* GetChildAtAnchorOffset() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user