Patch set 2:Code-Review +1
Patch set 2:Code-Review +1
To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.
Patch set 2:Commit-Queue +2
Commit Bot merged this change.
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/965663
Reviewed-by: Yoichi Osato <yoi...@chromium.org>
Reviewed-by: Xiaocheng Hu <xiaoc...@chromium.org>
Commit-Queue: Yoshifumi Inoue <yo...@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543982}
---
M third_party/WebKit/Source/core/editing/DOMSelection.cpp
1 file changed, 4 insertions(+), 24 deletions(-)
diff --git a/third_party/WebKit/Source/core/editing/DOMSelection.cpp b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
index a4483ef..6ba35d8 100644
--- a/third_party/WebKit/Source/core/editing/DOMSelection.cpp
+++ b/third_party/WebKit/Source/core/editing/DOMSelection.cpp
@@ -129,14 +129,6 @@
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 @@
}
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 {
To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.