Make Selection#{base,extent}{Node,Offset} as aliases of {anchor,focus}{Node,Offset} [chromium/src : master]

3 views
Skip to first unread message

Yoshifumi Inoue (Gerrit)

unread,
Mar 17, 2018, 8:14:34 AM3/17/18
to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

PTAL

View Change

    To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
    Gerrit-Change-Number: 965663
    Gerrit-PatchSet: 2
    Gerrit-Owner: Yoshifumi Inoue <yo...@chromium.org>
    Gerrit-Reviewer: Xiaocheng Hu <xiaoc...@chromium.org>
    Gerrit-Reviewer: Yoichi Osato <yoi...@chromium.org>
    Gerrit-Reviewer: Yoshifumi Inoue <yo...@chromium.org>
    Gerrit-CC: Commit Bot <commi...@chromium.org>
    Gerrit-Comment-Date: Sat, 17 Mar 2018 12:14:21 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    Gerrit-MessageType: comment

    Yoichi Osato (Gerrit)

    unread,
    Mar 18, 2018, 9:11:49 PM3/18/18
    to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

    Patch set 2:Code-Review +1

    View Change

      To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: chromium/src
      Gerrit-Branch: master
      Gerrit-Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
      Gerrit-Change-Number: 965663
      Gerrit-PatchSet: 2
      Gerrit-Owner: Yoshifumi Inoue <yo...@chromium.org>
      Gerrit-Reviewer: Xiaocheng Hu <xiaoc...@chromium.org>
      Gerrit-Reviewer: Yoichi Osato <yoi...@chromium.org>
      Gerrit-Reviewer: Yoshifumi Inoue <yo...@chromium.org>
      Gerrit-CC: Commit Bot <commi...@chromium.org>
      Gerrit-Comment-Date: Mon, 19 Mar 2018 01:11:45 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      Gerrit-MessageType: comment

      Xiaocheng Hu (Gerrit)

      unread,
      Mar 18, 2018, 10:37:42 PM3/18/18
      to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

      Patch set 2:Code-Review +1

      View Change

        To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
        Gerrit-Change-Number: 965663
        Gerrit-PatchSet: 2
        Gerrit-Owner: Yoshifumi Inoue <yo...@chromium.org>
        Gerrit-Reviewer: Xiaocheng Hu <xiaoc...@chromium.org>
        Gerrit-Reviewer: Yoichi Osato <yoi...@chromium.org>
        Gerrit-Reviewer: Yoshifumi Inoue <yo...@chromium.org>
        Gerrit-CC: Commit Bot <commi...@chromium.org>
        Gerrit-Comment-Date: Mon, 19 Mar 2018 02:37:39 +0000

        Yoshifumi Inoue (Gerrit)

        unread,
        Mar 19, 2018, 12:22:21 AM3/19/18
        to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

        Patch set 2:Commit-Queue +2

        View Change

          To view, visit change 965663. To unsubscribe, or for help writing mail filters, visit settings.

          Gerrit-Project: chromium/src
          Gerrit-Branch: master
          Gerrit-Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
          Gerrit-Change-Number: 965663
          Gerrit-PatchSet: 2
          Gerrit-Owner: Yoshifumi Inoue <yo...@chromium.org>
          Gerrit-Reviewer: Xiaocheng Hu <xiaoc...@chromium.org>
          Gerrit-Reviewer: Yoichi Osato <yoi...@chromium.org>
          Gerrit-Reviewer: Yoshifumi Inoue <yo...@chromium.org>
          Gerrit-CC: Commit Bot <commi...@chromium.org>
          Gerrit-Comment-Date: Mon, 19 Mar 2018 04:22:17 +0000

          Commit Bot (Gerrit)

          unread,
          Mar 19, 2018, 2:51:44 AM3/19/18
          to blink-...@chromium.org, Xiaocheng Hu, chromium...@chromium.org

          Commit Bot merged this change.

          View Change

          Approvals: Yoichi Osato: Looks good to me Xiaocheng Hu: Looks good to me Yoshifumi Inoue: Commit
          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.

          Gerrit-Project: chromium/src
          Gerrit-Branch: master
          Gerrit-Change-Id: I34fcdb4e80d5cef49bc1e0bdaea3cdec5c8b3758
          Gerrit-Change-Number: 965663
          Gerrit-PatchSet: 3
          Gerrit-Owner: Yoshifumi Inoue <yo...@chromium.org>
          Gerrit-Reviewer: Commit Bot <commi...@chromium.org>
          Gerrit-Reviewer: Xiaocheng Hu <xiaoc...@chromium.org>
          Gerrit-Reviewer: Yoichi Osato <yoi...@chromium.org>
          Gerrit-Reviewer: Yoshifumi Inoue <yo...@chromium.org>
          Gerrit-MessageType: merged
          Reply all
          Reply to author
          Forward
          0 new messages