| 
    
      
  | 
  
 Chromium Code Reviews
        
  DescriptionFix TextIterator's behavior with first-letter
TextIterator's behavior with first-letter is broken:
1. If its starts in a text node with first-letter and the starting
offset is non-zero, wrong text is passed to its text state.
2. When the text state is handling the remaining text of first-letter,
it doesn't consider the length of first-letter, and hence, reports
wrong offsets of the current text.
To fix 2, this patch makes the text state remember the length of
first-letter, and use it to adjust the output of
start/endOffsetInCurrentContainer.
To fix 1, given that the current behavior is correct when we start in
a text node at offset 0 (even with first-letter), this patch performs
a reduction that:
- start iterating with offset 0 instead of the given start offset
- have extra calls of |advance()| during initialization so that we have
moved to the given start position when initialization ends
- adjust text run start and end offsets when emitting text of the starting
text node
This patch partially corrects the behavior in two layout tests:
- editing/selection/extend-by-word-002.html
- editing/text-iterator/first-letter-word-boundary.html
The tests are still failing for other reasons, see crbug.com/671104
This patch is not an ultimate fix of TextIterator's behavior with
first-letter, but more like a first-aid hack built upon the current design.
In the long term, we should rewrite TextIterator.
BUG=647080
Committed: https://crrev.com/5185769b9ba7e9239d68c7dc672a27dd19b1685f
Cr-Commit-Position: refs/heads/master@{#436255}
   
  Patch Set 1 #Patch Set 2 : Change relevant bug number #
      Total comments: 7
      
     
  
  Patch Set 3 : Thu Dec 1 19:08:08 JST 2016 #Patch Set 4 : Mon Dec 5 15:41:31 JST 2016 #
      Total comments: 8
      
     
  
  Patch Set 5 : Mon Dec 5 18:00:48 JST 2016 #Messages
    Total messages: 40 (27 generated)
     
  
  
 The CQ bit was checked by xiaochengh@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 The CQ bit was checked by xiaochengh@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 Description was changed from ========== Fix TextIterator's behavior with first-letter BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node BUG=647080 ========== 
 Description was changed from ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html BUG=647080 ========== 
 Description was changed from ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack. In the long term, we should rewrite TextIterator. BUG=647080 ========== 
 Description was changed from ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack. In the long term, we should rewrite TextIterator. BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack built upon the current design. In the long term, we should rewrite TextIterator. BUG=647080 ========== 
 xiaochengh@chromium.org changed reviewers: + yosin@chromium.org 
 PTAL. 
 C++ changes are fine. Could you improve layout tests? m(_ _)m https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/editing/selection/extend-by-word-002-expected.txt (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/editing/selection/extend-by-word-002-expected.txt:4: PASS selection.focusNode is $("test").querySelectorAll("li a")[3].firstChild Could you convert this test to assert_selection() for ease of expectation changes? https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/editing/selection/extend-by-word-002.html (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/editing/selection/extend-by-word-002.html:55: if (window.internals) Could you convert this test to assert_selection() for ease of expectation changes? https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... File third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Layo... third_party/WebKit/LayoutTests/editing/text-iterator/first-letter-word-boundary-expected.txt:4: white-space: normal; Could you convert this test to assert_selection() for ease of expectation changes? https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:227: if (m_node != m_startContainer) nit: return m_node == m_startContainer; as simplified if-statement. https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.h (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.h:141: bool prepareForFirstLetterInitialization(); Could you add a comment to explain what |bool| result is? 
 I think it's better to convert the two tests in separate patches after this one lands. As the two tests currently fail, it seems a little bit weird to convert them assert_selection together with FAIL expectations... https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:227: if (m_node != m_startContainer) On 2016/12/01 at 09:41:42, Yosi_UTC9 wrote: > nit: return m_node == m_startContainer; > as simplified if-statement. Done. https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.h (right): https://codereview.chromium.org/2541163003/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.h:141: bool prepareForFirstLetterInitialization(); On 2016/12/01 at 09:41:42, Yosi_UTC9 wrote: > Could you add a comment to explain what |bool| result is? Done. 
 The CQ bit was checked by xiaochengh@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Dry run: Try jobs failed on following builders: linux_chromium_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) 
 Description was changed from ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch also corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack built upon the current design. In the long term, we should rewrite TextIterator. BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch partially corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html The tests are still failing for other reasons, see crbug.com/671104 This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack built upon the current design. In the long term, we should rewrite TextIterator. BUG=647080 ========== 
 The CQ bit was checked by xiaochengh@chromium.org 
 CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 The CQ bit was unchecked by commit-bot@chromium.org 
 No L-G-T-M from a valid reviewer yet. CQ run can only be started by full committers or once the patch has received an L-G-T-M from a full committer. Even if an L-G-T-M may have been provided, it was from a non-committer, _not_ a full super star committer. See http://www.chromium.org/getting-involved/become-a-committer Note that this has nothing to do with OWNERS files. 
 The CQ bit was checked by xiaochengh@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 xiaochengh@chromium.org changed reviewers: + tkent@chromium.org 
 PTAL, as yosin@ is OOO... 
 yosin@ already said "fine". So I reviewed only cosmetic stuff of the code. https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp (right): https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1208: Node* textNode, Can we make it |const Node*| or |const Node&|? https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1209: LayoutText* layoutObject, Can we make it |const LayoutText*| or |const LayoutText&|? https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1229: Node* textNode, Can we make it |const Node*| or |const Node&|? https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1230: LayoutText* layoutObject, Can we make it |const LayoutText*| or |const LayoutText&|? 
 The CQ bit was unchecked by commit-bot@chromium.org 
 Dry run: This issue passed the CQ dry run. 
 The CQ bit was checked by xiaochengh@chromium.org to run a CQ dry run 
 Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp (right): https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1208: Node* textNode, On 2016/12/05 at 08:42:47, tkent wrote: > Can we make it |const Node*| or |const Node&|? Changed to |const Node&|. https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1209: LayoutText* layoutObject, On 2016/12/05 at 08:42:47, tkent wrote: > Can we make it |const LayoutText*| or |const LayoutText&|? Changed to |const LayoutText&|. https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1229: Node* textNode, On 2016/12/05 at 08:42:47, tkent wrote: > Can we make it |const Node*| or |const Node&|? Changed to |const Node&|. https://codereview.chromium.org/2541163003/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp:1230: LayoutText* layoutObject, On 2016/12/05 at 08:42:47, tkent wrote: > Can we make it |const LayoutText*| or |const LayoutText&|? Changed to |const LayoutText&|. 
 rs lgtm 
 The CQ bit was unchecked by xiaochengh@chromium.org 
 The CQ bit was checked by xiaochengh@chromium.org 
 Thanks for the review! 
 CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or... 
 CQ is committing da patch.
Bot data: {"patchset_id": 80001, "attempt_start_ts": 1480928867846710,
"parent_rev": "53ad122bb044f9b52a3c8bba1a611b20a15e0378", "commit_rev":
"251c42a9405ab87378d9c850fd5b95e9c1063531"}
          
 
            
              
                Message was sent while issue was closed.
              
            
             
          
        Committed patchset #5 (id:80001) 
 
            
              
                Message was sent while issue was closed.
              
            
             
          
        Description was changed from ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch partially corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html The tests are still failing for other reasons, see crbug.com/671104 This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack built upon the current design. In the long term, we should rewrite TextIterator. BUG=647080 ========== to ========== Fix TextIterator's behavior with first-letter TextIterator's behavior with first-letter is broken: 1. If its starts in a text node with first-letter and the starting offset is non-zero, wrong text is passed to its text state. 2. When the text state is handling the remaining text of first-letter, it doesn't consider the length of first-letter, and hence, reports wrong offsets of the current text. To fix 2, this patch makes the text state remember the length of first-letter, and use it to adjust the output of start/endOffsetInCurrentContainer. To fix 1, given that the current behavior is correct when we start in a text node at offset 0 (even with first-letter), this patch performs a reduction that: - start iterating with offset 0 instead of the given start offset - have extra calls of |advance()| during initialization so that we have moved to the given start position when initialization ends - adjust text run start and end offsets when emitting text of the starting text node This patch partially corrects the behavior in two layout tests: - editing/selection/extend-by-word-002.html - editing/text-iterator/first-letter-word-boundary.html The tests are still failing for other reasons, see crbug.com/671104 This patch is not an ultimate fix of TextIterator's behavior with first-letter, but more like a first-aid hack built upon the current design. In the long term, we should rewrite TextIterator. BUG=647080 Committed: https://crrev.com/5185769b9ba7e9239d68c7dc672a27dd19b1685f Cr-Commit-Position: refs/heads/master@{#436255} ========== 
 
            
              
                Message was sent while issue was closed.
              
            
             
          
        Patchset 5 (id:??) landed as https://crrev.com/5185769b9ba7e9239d68c7dc672a27dd19b1685f Cr-Commit-Position: refs/heads/master@{#436255}  | 
    
