Commit 1c0152d0 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make Selection#{base,extent}{Node,Offset} as aliases of {anchor,focus}{Node,Offset}

This patch makes |Selection#{base,extent}{Node,Offset}| as aliases of
|Selection#{anchor,focus}{Node,Offset}| instead of getting position from
|VisibleSelection| which we don't want to expose to JavaScript.

Note: Selection#{base,extent}{Node,Offset} are not standard API and there
are some discussion for standardizing them[1].

[1] https://github.com/w3c/selection-api/issues/34
Specify baseNode/baseOffset/extentNode/extentOffset?

Bug: 701501
Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
Reviewed-on: https://chromium-review.googlesource.com/965663Reviewed-by: default avatarYoichi Osato <yoichio@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543982}
parent 70dd80fe
......@@ -129,14 +129,6 @@ static Position FocusPosition(const VisibleSelection& selection) {
return focus.ParentAnchoredEquivalent();
}
static Position BasePosition(const VisibleSelection& selection) {
return selection.Base().ParentAnchoredEquivalent();
}
static Position ExtentPosition(const VisibleSelection& selection) {
return selection.Extent().ParentAnchoredEquivalent();
}
Node* DOMSelection::anchorNode() const {
if (Range* range = PrimaryRangeOrNull()) {
if (!GetFrame() || IsBaseFirstInSelection())
......@@ -174,31 +166,19 @@ unsigned DOMSelection::focusOffset() const {
}
Node* DOMSelection::baseNode() const {
if (!IsAvailable())
return nullptr;
return ShadowAdjustedNode(BasePosition(GetVisibleSelection()));
return anchorNode();
}
unsigned DOMSelection::baseOffset() const {
if (!IsAvailable())
return 0;
return ShadowAdjustedOffset(BasePosition(GetVisibleSelection()));
return anchorOffset();
}
Node* DOMSelection::extentNode() const {
if (!IsAvailable())
return nullptr;
return ShadowAdjustedNode(ExtentPosition(GetVisibleSelection()));
return focusNode();
}
unsigned DOMSelection::extentOffset() const {
if (!IsAvailable())
return 0;
return ShadowAdjustedOffset(ExtentPosition(GetVisibleSelection()));
return focusOffset();
}
bool DOMSelection::isCollapsed() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment