Commit 91fed012 authored by Masayuki Nakano's avatar Masayuki Nakano
Browse files

Bug 1723895 - Make `WhiteSpaceVisibilityKeeper::ReplaceText()` call...

Bug 1723895 - Make `WhiteSpaceVisibilityKeeper::ReplaceText()` call `GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace` with end of the replacing range instead of start of it r=m_kato

It tries to replace a following NBSP with an ASCII white-space if there is.
However, it calls the scan method with start of the replacing range.  Therefore,
the assertion in `GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace()`
detects this bug.

Note that this occurs only when updating composition string because it's
called with non-collapsed range only for doing it.  Otherwise, selected range
has already been deleted by `HTMLEditor::DeleteSelectionAsSubAction()`.

Unfortunately, I don't have how to make this bug appear.  It seems that the
path does nothing in the wild because it tries to replace a first character
of composition string from an NBSP to a normal white-space, but it'll be
replaced with new composition string anyway.  Therefore, this patch does not
have new tests.

Differential Revision: https://phabricator.services.mozilla.com/D122182
parent baac08fa
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
<div contenteditable id="editor"><p><br></p></div>
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.expectAssertions(2);  // Assertions in WSRunScanner::TextFragmentData::GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace()
SimpleTest.waitForFocus(function doTests() {
  for (let editorId of ["input", "textarea", "editor"]) {
    let editor = document.getElementById(editorId);
+1 −1
Original line number Diff line number Diff line
@@ -831,7 +831,7 @@ nsresult WhiteSpaceVisibilityKeeper::ReplaceText(
      EditorDOMPointInText atNBSPReplacedWithASCIIWhiteSpace =
          textFragmentDataAtEnd
              .GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace(
                  pointToInsert);
                  aRangeToBeReplaced.EndRef());
      if (atNBSPReplacedWithASCIIWhiteSpace.IsSet()) {
        AutoTransactionsConserveSelection dontChangeMySelection(aHTMLEditor);
        nsresult rv = aHTMLEditor.ReplaceTextWithTransaction(
+0 −1
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
<script class="testbody" type="application/javascript">

SimpleTest.waitForExplicitFinish();
SimpleTest.expectAssertions(1);  // Assertions in WSRunScanner::TextFragmentData::GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace()
SimpleTest.waitForFocus(runTests);

const kLF = !navigator.platform.indexOf("Win") ? "\r\n" : "\n";
+1 −2
Original line number Diff line number Diff line
@@ -24,8 +24,7 @@
// '!(GetStateBits() & NS_FRAME_FIRST_REFLOW) || (GetParent()->GetStateBits() &
// NS_FRAME_TOO_DEEP_IN_FRAME_TREE)'" in nsTextFrame.cpp.
// Strangely, this doesn't occur with RDP on Windows.
// 16 assertions are: assertions in WSRunScanner::TextFragmentData::GetInclusiveNextNBSPPointIfNeedToReplaceWithASCIIWhiteSpace()
SimpleTest.expectAssertions(0, 3 + 16);
SimpleTest.expectAssertions(0, 3);
SimpleTest.waitForExplicitFinish();
window.openDialog("window_composition_text_querycontent.xhtml", "_blank", 
                  "chrome,width=600,height=600,noopener", window);