Make CharacterIterator::GetPosition{Before,After}() not to crash with block content [chromium/src : master]

0 views
Skip to first unread message

Yoshifumi Inoue (Gerrit)

unread,
Apr 23, 2018, 6:19:55 AM4/23/18
to Xiaocheng Hu, blink-...@chromium.org

Yoshifumi Inoue would like Xiaocheng Hu and Yoichi Osato to review this change.

View Change

Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

This patch makes |CharacterIterator::GetPosition{Before,After}() not to crash
with block content, e.g. "a<div>b</div>c".

This is follow-up of the patch[1].

[1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
to work with BR

Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
---
M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
2 files changed, 75 insertions(+), 12 deletions(-)


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

Gerrit-Project: chromium/src
Gerrit-Branch: master
Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
Gerrit-Change-Number: 1023502
Gerrit-PatchSet: 3
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-MessageType: newchange

Yoshifumi Inoue (Gerrit)

unread,
Apr 23, 2018, 6:19:56 AM4/23/18
to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

PTAL

Patch set 3:-Code-Review

View Change

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

    Gerrit-Project: chromium/src
    Gerrit-Branch: master
    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
    Gerrit-Change-Number: 1023502
    Gerrit-PatchSet: 3
    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, 23 Apr 2018 10:19:52 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Xiaocheng Hu (Gerrit)

    unread,
    Apr 23, 2018, 2:47:34 PM4/23/18
    to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

    CTI::GetPositionBefore/After are becoming hackier and hackier...

    I think a better approach is move all complex logic into TI, by introducing "proper" position getters in TI (that don't use EditingPositionOf):

    • TI::GetPositionBeforeTextRun
    • TI::GetPositionAfterTextRun
    • TI::GetPositionBeforeCharacter(offset)
    • TI::GetPositionAfterCharacter(offset)

    And then CTI can simply wrap the last two

    View Change

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

      Gerrit-Project: chromium/src
      Gerrit-Branch: master
      Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
      Gerrit-Change-Number: 1023502
      Gerrit-PatchSet: 3
      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, 23 Apr 2018 18:47:32 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: No
      Gerrit-MessageType: comment

      Yoichi Osato (Gerrit)

      unread,
      Apr 23, 2018, 9:48:57 PM4/23/18
      to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

      Patch Set 3:

      CTI::GetPositionBefore/After are becoming hackier and hackier...

      I think a better approach is move all complex logic into TI, by introducing "proper" position getters in TI (that don't use EditingPositionOf):

      • TI::GetPositionBeforeTextRun
      • TI::GetPositionAfterTextRun
      • TI::GetPositionBeforeCharacter(offset)
      • TI::GetPositionAfterCharacter(offset)

      And then CTI can simply wrap the last two

      +1
      I also think TextIterator is already hacky and complex then it is better to
      refactor the class by splitting functionality,,,

      View Change

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

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
        Gerrit-Change-Number: 1023502
        Gerrit-PatchSet: 3
        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: Tue, 24 Apr 2018 01:48:52 +0000

        Yoshifumi Inoue (Gerrit)

        unread,
        Apr 24, 2018, 6:22:16 AM4/24/18
        to Xiaocheng Hu, blink-...@chromium.org, chromium...@chromium.org, Commit Bot

        Yoshifumi Inoue uploaded patch set #6 to this change.

        View Change

        Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

        This patch introduces |TextIterator::GetPosition{Before,After}()| as
        implementation of |CharacterIterator::GetPosition{Before,After}()| not to crash
        with block content.

        To implement before/after position, this patch introduces
        |position_anchor_node_| and |position_node_type_| in |TextIteratorTextState| to
        remember what |SpliceBuffer()| used for emitting characters.


        This is follow-up of the patch[1].

        [1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
        to work with BR

        Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
        ---
        M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
        M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator.h
        M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.h
        6 files changed, 281 insertions(+), 33 deletions(-)

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

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
        Gerrit-Change-Number: 1023502
        Gerrit-PatchSet: 6
        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-MessageType: newpatchset

        Yoshifumi Inoue (Gerrit)

        unread,
        Apr 24, 2018, 6:23:35 AM4/24/18
        to Xiaocheng Hu, blink-...@chromium.org, chromium...@chromium.org, Commit Bot

        Yoshifumi Inoue uploaded patch set #7 to this change.

        View Change

        Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

        This patch introduces |TextIterator::GetPosition{Before,After}()| as
        implementation of |CharacterIterator::GetPosition{Before,After}()| not to crash
        with block content.

        To implement before/after position, this patch introduces
        |position_anchor_node_| and |position_node_type_| in |TextIteratorTextState| to
        remember the purpose of emitted characters.


        This is follow-up of the patch[1].

        [1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
        to work with BR

        Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
        ---
        M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
        M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator.h
        M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.cc
        M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.h
        6 files changed, 281 insertions(+), 33 deletions(-)

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

        Gerrit-Project: chromium/src
        Gerrit-Branch: master
        Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
        Gerrit-Change-Number: 1023502
        Gerrit-PatchSet: 7
        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-MessageType: newpatchset

        Yoshifumi Inoue (Gerrit)

        unread,
        Apr 24, 2018, 11:25:29 AM4/24/18
        to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

        PTAL

        View Change

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

          Gerrit-Project: chromium/src
          Gerrit-Branch: master
          Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
          Gerrit-Change-Number: 1023502
          Gerrit-PatchSet: 9
          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: Tue, 24 Apr 2018 15:25:24 +0000

          Xiaocheng Hu (Gerrit)

          unread,
          Apr 24, 2018, 2:51:15 PM4/24/18
          to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

          There seem to be too many merge conflicts with the other refactoring patches.

          I'll wait until those patches are settled.

          View Change

          1 comment:

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

          Gerrit-Project: chromium/src
          Gerrit-Branch: master
          Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
          Gerrit-Change-Number: 1023502
          Gerrit-PatchSet: 9
          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: Tue, 24 Apr 2018 18:51:10 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Gerrit-MessageType: comment

          Yoshifumi Inoue (Gerrit)

          unread,
          Apr 24, 2018, 9:57:18 PM4/24/18
          to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

          PTAL

          The dependent patch is still in CQ due by android try bot flakiness...

          View Change

          1 comment:

            • Could you document these two functions? In particular, meaning of |run_offset|?

              Done

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

          Gerrit-Project: chromium/src
          Gerrit-Branch: master
          Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
          Gerrit-Change-Number: 1023502
          Gerrit-PatchSet: 12
          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: Wed, 25 Apr 2018 01:57:11 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Xiaocheng Hu <xiaoc...@chromium.org>
          Gerrit-MessageType: comment

          Yoichi Osato (Gerrit)

          unread,
          Apr 24, 2018, 10:02:21 PM4/24/18
          to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

          This patch looks rearchitecture/refactoring rather than fixing a crash bug.
          Could you split them to each other?

          View Change

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

            Gerrit-Project: chromium/src
            Gerrit-Branch: master
            Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
            Gerrit-Change-Number: 1023502
            Gerrit-PatchSet: 12
            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: Wed, 25 Apr 2018 02:02:07 +0000

            Yoshifumi Inoue (Gerrit)

            unread,
            Apr 24, 2018, 10:25:00 PM4/24/18
            to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

            PTAL

            No more dependent patches and merge conflicts!

            View Change

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

              Gerrit-Project: chromium/src
              Gerrit-Branch: master
              Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
              Gerrit-Change-Number: 1023502
              Gerrit-PatchSet: 13
              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: Wed, 25 Apr 2018 02:24:52 +0000

              Yoshifumi Inoue (Gerrit)

              unread,
              Apr 24, 2018, 10:52:54 PM4/24/18
              to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

              Patch Set 12:

              This patch looks rearchitecture/refactoring rather than fixing a crash bug.
              Could you split them to each other?

              No, the PS#1 fixed the crash bug.

              But, we decide to move implementation into TextIterator and I found PS#1 is not enough.
              This is reason why I change TextIteratorTextState.

              I don't see no good reason to split this patch more.

              Could you tell me your idea of splitting this patch?

              View Change

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

                Gerrit-Project: chromium/src
                Gerrit-Branch: master
                Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                Gerrit-Change-Number: 1023502
                Gerrit-PatchSet: 13
                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: Wed, 25 Apr 2018 02:52:51 +0000

                Yoichi Osato (Gerrit)

                unread,
                Apr 25, 2018, 12:58:56 AM4/25/18
                to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                Patch Set 13:

                Patch Set 12:

                This patch looks rearchitecture/refactoring rather than fixing a crash bug.
                Could you split them to each other?

                No, the PS#1 fixed the crash bug.

                But, we decide to move implementation into TextIterator and I found PS#1 is not enough.
                This is reason why I change TextIteratorTextState.

                I don't see no good reason to split this patch more.

                Could you tell me your idea of splitting this patch?

                1. Move each CIA::GetPositionBefore/After function body to TIA::GetBepositioBefore/After.
                This is pure refactoring.

                2. Fix the issue by modifying the TIA::GetBepositioBefore/After.

                View Change

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 13
                  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: Wed, 25 Apr 2018 04:58:50 +0000

                  Xiaocheng Hu (Gerrit)

                  unread,
                  Apr 25, 2018, 1:24:50 AM4/25/18
                  to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                  View Change

                  5 comments:

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 13
                  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: Wed, 25 Apr 2018 05:24:48 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Gerrit-MessageType: comment

                  Yoshifumi Inoue (Gerrit)

                  unread,
                  Apr 25, 2018, 2:26:14 AM4/25/18
                  to Xiaocheng Hu, blink-...@chromium.org, chromium...@chromium.org, Commit Bot

                  Yoshifumi Inoue uploaded patch set #14 to this change.

                  View Change

                  Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

                  This patch introduces |TextIterator::GetPosition{Before,After}()| as
                  implementation of |CharacterIterator::GetPosition{Before,After}()| not to crash
                  with block content.

                  To implement before/after position, this patch introduces
                  |position_anchor_node_| and |position_node_type_| in |TextIteratorTextState| to
                  remember the relative position of node of emitted characters since
                  |position_node_| and |position_offset_base_node_| are changed by
                  |FlushPositionOffsets()| via |{Start,End}OffsetInCurrentContainer()| in
                  |TextIterator|.

                  In current implementation, relative node position is encoded by start and end
                  offsets of |SpliceBuffer()|.


                  This is follow-up of the patch[1].

                  [1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
                  to work with BR

                  Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  ---
                  M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
                  M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
                  M third_party/blink/renderer/core/editing/iterators/text_iterator.cc
                  M third_party/blink/renderer/core/editing/iterators/text_iterator.h
                  M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.cc
                  M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.h
                  6 files changed, 314 insertions(+), 35 deletions(-)

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 14
                  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-MessageType: newpatchset

                  Yoshifumi Inoue (Gerrit)

                  unread,
                  Apr 25, 2018, 2:31:34 AM4/25/18
                  to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                  PTAL

                  Update to follow review comments.

                  View Change

                  5 comments:

                    • I haven't seen why we need to introduce |position_anchor_node_| and |position_anchor_kind_|. […]

                      Yes, I would like to get rid of |position_node_| and |position_offset_base_node|.

                      The reason I introduce |position_anchor_node_| is to keep it after calling
                      |FlushPositionOffsets()| which is called by |TextIterator::StartOffsetInCurrentContainer()| and |TextIterator::EndOffsetInCurrentContainer()|.

                      The reason of introducing |AnchorNodeKind| is avoid to decode start/end
                      offset pair in |SpliceBuffer()|. See TODO for |SpliceBuffer()|.

                      I would like to introduce |SpliceBufferBefore()|, |SpliceBufferAfter()| etc, to set |position_anchor_kind_| directly instead of checking start/end offsets.

                      I updated commit message about |position_anchor_node_| and |position_anchor_kind_|.

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 15
                  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: Wed, 25 Apr 2018 06:31:29 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No

                  Xiaocheng Hu (Gerrit)

                  unread,
                  Apr 25, 2018, 2:09:31 PM4/25/18
                  to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                  View Change

                  5 comments:

                    • Yes, I would like to get rid of |position_node_| and |position_offset_base_node|. […]

                      OK, that makes sense.

                      I think the refactoring to TextIteratorTextState is complex enough to deserve its own patch. Could you move them to another patch with more details of the motivation and plan of the refactoring?

                  • File third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.cc:

                    • Patch Set #13, Line 109: position_anchor_kind_ = AnchorNodeKind::kReplaced;

                      The only call site of this function is in HandleReplacedElement() as a preparation step for emitting alt text.

                      We probably want another anchor type |kAltText| for it.

                    • Patch Set #13, Line 141:

                        // TODO(editing-dev): We should introduce
                      // - SpliceBufferBefore(const Node&, UChar);
                      // - SpliceBufferAfter(const Node&, UChar);
                      // - SpliceBufferReplacer(const Node&, UChar);
                      // - SpliceBuffer(const Text&, UChar, start, end)
                      // instead of checking |start_offset| and |end_offset| for non-|Text| node.

                      Let's finish this part first in a refactoring patch.

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 15
                  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: Wed, 25 Apr 2018 18:09:29 +0000
                  Gerrit-HasComments: Yes
                  Gerrit-Has-Labels: No
                  Comment-In-Reply-To: Xiaocheng Hu <xiaoc...@chromium.org>
                  Comment-In-Reply-To: Yoshifumi Inoue <yo...@chromium.org>
                  Gerrit-MessageType: comment

                  Yoichi Osato (Gerrit)

                  unread,
                  Apr 25, 2018, 9:53:42 PM4/25/18
                  to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                  View Change

                  1 comment:

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 15
                  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: Thu, 26 Apr 2018 01:53:38 +0000

                  Yoshifumi Inoue (Gerrit)

                  unread,
                  Apr 27, 2018, 4:34:07 AM4/27/18
                  to Xiaocheng Hu, blink-...@chromium.org, chromium...@chromium.org, Commit Bot

                  Yoshifumi Inoue uploaded patch set #17 to this change.

                  View Change

                  Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

                  This patch introduces |TextIterator::GetPosition{Before,After}()| as
                  implementation of |CharacterIterator::GetPosition{Before,After}()| not to crash
                  with block content.


                  This is follow-up of the patch[1].

                  [1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
                  to work with BR

                  Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  ---
                  M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
                  M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
                  M third_party/blink/renderer/core/editing/iterators/text_iterator.cc
                  M third_party/blink/renderer/core/editing/iterators/text_iterator.h
                  M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.h
                  5 files changed, 220 insertions(+), 26 deletions(-)

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

                  Gerrit-Project: chromium/src
                  Gerrit-Branch: master
                  Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                  Gerrit-Change-Number: 1023502
                  Gerrit-PatchSet: 17
                  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-MessageType: newpatchset

                  Yoshifumi Inoue (Gerrit)

                  unread,
                  Apr 27, 2018, 4:35:24 AM4/27/18
                  to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                  PTAL

                  View Change

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 17
                    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: Fri, 27 Apr 2018 08:35:21 +0000

                    Xiaocheng Hu (Gerrit)

                    unread,
                    Apr 27, 2018, 3:29:41 PM4/27/18
                    to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                    View Change

                    7 comments:

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 17
                    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: Fri, 27 Apr 2018 19:29:39 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Gerrit-MessageType: comment

                    Yoshifumi Inoue (Gerrit)

                    unread,
                    May 7, 2018, 2:29:47 AM5/7/18
                    to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                    PTAL

                    View Change

                    7 comments:

                      • nit: node

                        Done

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 18
                    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, 07 May 2018 06:29:42 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No

                    Xiaocheng Hu (Gerrit)

                    unread,
                    May 7, 2018, 2:27:52 PM5/7/18
                    to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                    Since TextIteratorTextState already stores all information about the DOM position of the text run, we should move most of TI::GetPositionBefore/After (when not AtEnd()) to TITextState.

                    In this way, we also avoid manipulating text offsets in TI, which is error prone.

                    View Change

                    1 comment:

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 18
                    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, 07 May 2018 18:27:48 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Gerrit-MessageType: comment

                    Yoshifumi Inoue (Gerrit)

                    unread,
                    May 8, 2018, 6:08:37 AM5/8/18
                    to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                    PTAL

                    View Change

                    1 comment:

                      • This is incorrect if the current text run is set with an |EmitChar16Before()| call.

                        Discussed offline and get three options:
                        1. templatize TITextState, so that it can create position, and we can also merge UpdatePositionOffsets() calls from TI and SBTI to TITextState
                        2. Add a new anchor type for EmitChar16Before
                        3. Ignore

                        We take option 2 since option 1 increase code size due by template and
                        some callers may hit this (not sure now).

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 19
                    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: Tue, 08 May 2018 10:08:31 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No

                    Xiaocheng Hu (Gerrit)

                    unread,
                    May 8, 2018, 6:01:15 PM5/8/18
                    to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                    LGTM with some nits regarding comments and var names.

                    Patch set 19:Code-Review +1

                    View Change

                    5 comments:

                      •   PositionTemplate<Strategy> GetPositionBefore(int run_offset) const;

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 19
                    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: Tue, 08 May 2018 22:01:10 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: Yes
                    Gerrit-MessageType: comment

                    Xiaocheng Hu (Gerrit)

                    unread,
                    May 8, 2018, 6:04:55 PM5/8/18
                    to blink-...@chromium.org, Commit Bot, chromium...@chromium.org

                    View Change

                    1 comment:

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 19
                    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: Tue, 08 May 2018 22:04:53 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: No
                    Gerrit-MessageType: comment

                    Yoshifumi Inoue (Gerrit)

                    unread,
                    May 9, 2018, 12:28:45 AM5/9/18
                    to blink-...@chromium.org, Xiaocheng Hu, Commit Bot, chromium...@chromium.org

                    Thanks for reviewing!

                    Committing...

                    Patch set 20:Commit-Queue +2

                    View Change

                    6 comments:

                      • Patch Set #19, Line 247:

                         EXPECT_EQ(Position(text_b, 3), it.GetPositionBefore());
                        EXPECT_EQ(Position(text_b, 3), it.GetPositionAfter());

                      • nit: |char_offset| seems a better name.

                      • Done

                      • nit: |char_offset| seems a better name.

                      • Done

                      • Done

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

                    Gerrit-Project: chromium/src
                    Gerrit-Branch: master
                    Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                    Gerrit-Change-Number: 1023502
                    Gerrit-PatchSet: 20
                    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: Wed, 09 May 2018 04:28:41 +0000
                    Gerrit-HasComments: Yes
                    Gerrit-Has-Labels: Yes

                    Commit Bot (Gerrit)

                    unread,
                    May 9, 2018, 12:28:48 AM5/9/18
                    to blink-...@chromium.org, Xiaocheng Hu, chromium...@chromium.org

                    CQ is trying the patch.

                    Note: The patchset sent to CQ was uploaded after this CL was approved.
                    "2018-05-09T13:26:29" https://chromium-review.googlesource.com/c/1023502/20

                    Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/chromium-review.googlesource.com/1023502/20

                    Bot data: {"action": "start", "triggered_at": "2018-05-09T04:28:41.0Z", "cq_cfg_revision": "ffcb66b8cd25853c8032d1c584f85512bf031ffc", "revision": "219988ea3de5db41409a2aec3e31261ace94190c"}

                    View Change

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

                      Gerrit-Project: chromium/src
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                      Gerrit-Change-Number: 1023502
                      Gerrit-PatchSet: 20
                      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: Wed, 09 May 2018 04:28:47 +0000

                      Commit Bot (Gerrit)

                      unread,
                      May 9, 2018, 1:34:34 AM5/9/18
                      to blink-...@chromium.org, Xiaocheng Hu, chromium...@chromium.org

                      Commit Bot merged this change.

                      View Change

                      Approvals: Xiaocheng Hu: Looks good to me Yoshifumi Inoue: Commit
                      Make CharacterIterator::GetPosition{Before,After}() not to crash with block content

                      This patch introduces |TextIterator::GetPosition{Before,After}()| as
                      implementation of |CharacterIterator::GetPosition{Before,After}()| not to crash
                      with block content.

                      This is follow-up of the patch[1].

                      [1] http://crrev.com/c/1021430 Make CharacterIterator::GetPosition{After,Before}()
                      to work with BR

                      Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                      Reviewed-on: https://chromium-review.googlesource.com/1023502
                      Commit-Queue: Yoshifumi Inoue <yo...@chromium.org>
                      Reviewed-by: Xiaocheng Hu <xiaoc...@chromium.org>
                      Cr-Commit-Position: refs/heads/master@{#557103}

                      ---
                      M third_party/blink/renderer/core/editing/iterators/character_iterator.cc
                      M third_party/blink/renderer/core/editing/iterators/character_iterator_test.cc
                      M third_party/blink/renderer/core/editing/iterators/text_iterator.cc
                      M third_party/blink/renderer/core/editing/iterators/text_iterator.h
                      M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.cc
                      M third_party/blink/renderer/core/editing/iterators/text_iterator_text_state.h
                      6 files changed, 304 insertions(+), 28 deletions(-)


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

                      Gerrit-Project: chromium/src
                      Gerrit-Branch: master
                      Gerrit-Change-Id: I0e5aae4cef69d6c1d902cbeb86e8e3552968c280
                      Gerrit-Change-Number: 1023502
                      Gerrit-PatchSet: 21
                      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