From c243829674557e97cb819cb462739a9ec6bb48fd Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Mon, 10 Aug 2020 09:07:48 +0300 Subject: [PATCH] Backed out 5 changesets (bug 1623764) for WPT failures in /editing/run/forwarddelete.html. CLOSED TREE Backed out changeset 838b1a256f25 (bug 1623764) Backed out changeset 00911e3c92c3 (bug 1623764) Backed out changeset 5f7d278953d7 (bug 1623764) Backed out changeset 0059379a3c29 (bug 1623764) Backed out changeset 6e3a9276ec41 (bug 1623764) --- .../tests/test_selection_move_commands.html | 19 +- layout/generic/nsIFrame.cpp | 50 +-- layout/generic/nsIFrame.h | 8 +- layout/generic/nsILineIterator.h | 2 - layout/generic/nsLineBox.cpp | 1 - layout/generic/nsTextFrame.cpp | 32 +- layout/generic/test/mochitest.ini | 1 - layout/generic/test/test_bug1623764.html | 292 ------------------ 8 files changed, 24 insertions(+), 381 deletions(-) delete mode 100644 layout/generic/test/test_bug1623764.html diff --git a/editor/libeditor/tests/test_selection_move_commands.html b/editor/libeditor/tests/test_selection_move_commands.html index b0207da0cfa2..9f239ae3ea70 100644 --- a/editor/libeditor/tests/test_selection_move_commands.html +++ b/editor/libeditor/tests/test_selection_move_commands.html @@ -42,13 +42,10 @@ async function* runTests() { yield; function testScrollCommand(cmd, expectTop) { - const { top } = root.getBoundingClientRect(); - - // XXX(krosylight): Android scrolls slightly more inside - // geckoview-test-verify-e10s CI job - const isAndroid = SpecialPowers.Services.appinfo.widgetToolkit == "android"; - const delta = isAndroid ? .134 : 0; - isfuzzy(top, -expectTop, delta, cmd); + // http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect + // doesn't explicitly rule out -0 here, but for now assume that only + // positive zeroes are permitted. + is(root.getBoundingClientRect().top, -expectTop + 0, cmd); } function testMoveCommand(cmd, expectNode, expectOffset) { @@ -135,7 +132,7 @@ async function* runTests() { yield; testScrollCommand("cmd_scrollLineUp", root.scrollHeight - 100 - lineHeight); - var runSelectionTests = function() { + var runSelectionTests = function(selectWordNextNode, selectWordNextOffset) { testMoveCommand("cmd_moveBottom", body, 23); testMoveCommand("cmd_moveTop", node(0), 0); testSelectCommand("cmd_selectBottom", body, 23); @@ -168,7 +165,7 @@ async function* runTests() { testMoveCommand("cmd_wordNext", body, 23); testSelectCommand("cmd_selectWordPrevious", node(22), 0); SpecialPowers.doCommand(window, "cmd_moveTop"); - testSelectCommand("cmd_selectWordNext", body, 1); + testSelectCommand("cmd_selectWordNext", selectWordNextNode, selectWordNextOffset); SpecialPowers.doCommand(window, "cmd_moveTop"); var lineNum = testPageMoveCommand("cmd_movePageDown", 0); @@ -185,9 +182,9 @@ async function* runTests() { }; await SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", false]]}); - runSelectionTests(); + runSelectionTests(body, 1); await SpecialPowers.pushPrefEnv({set: [["layout.word_select.eat_space_to_next_word", true]]}); - runSelectionTests(); + runSelectionTests(node(2), 0); } function cleanup() { diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 11d1a59f74a2..c4e942e931a4 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -8342,9 +8342,6 @@ nsresult nsIFrame::PeekOffsetForCharacter(nsPeekOffsetStruct* aPos, nsresult nsIFrame::PeekOffsetForWord(nsPeekOffsetStruct* aPos, int32_t aOffset) { SelectablePeekReport current{this, aOffset}; - bool shouldStopAtHardBreak = - aPos->mWordMovementType == eDefaultBehavior && - StaticPrefs::layout_word_select_eat_space_to_next_word(); bool wordSelectEatSpace = ShouldWordSelectionEatSpace(*aPos); PeekWordState state; @@ -8379,35 +8376,11 @@ nsresult nsIFrame::PeekOffsetForWord(nsPeekOffsetStruct* aPos, break; } - if (shouldStopAtHardBreak && next.mJumpedHardBreak) { - /** - * Prev, always: Jump and stop right there - * Next, saw inline: just stop - * Next, no inline: Jump and consume whitespaces - */ - if (aPos->mDirection == eDirPrevious) { - // Try moving to the previous line if exists - current.TransferTo(*aPos); - current.mFrame->PeekOffsetForCharacter(aPos, current.mOffset); - return NS_OK; - } - if (state.mSawInlineCharacter || current.mJumpedHardBreak) { - if (current.mFrame->HasSignificantTerminalNewline()) { - current.mOffset -= 1; - } - current.TransferTo(*aPos); - return NS_OK; - } - // Mark the state as whitespace and continue - state.Update(false, true); - } - if (next.mJumpedLine) { state.mContext.Truncate(); } current = next; // Jumping a line is equivalent to encountering whitespace - // This affects only when it already met an actual character if (wordSelectEatSpace && next.mJumpedLine) { state.SetSawBeforeType(); } @@ -8769,11 +8742,11 @@ Result nsIFrame::IsVisuallyAtLineEdge( nsIFrame* firstFrame; nsIFrame* lastFrame; - bool lineIsRTL = aLineIterator->GetDirection(); + nsAutoLineIterator it = aLineIterator; + bool lineIsRTL = it->GetDirection(); bool isReordered; - MOZ_TRY(aLineIterator->CheckLineOrder(aLine, &isReordered, &firstFrame, - &lastFrame)); + MOZ_TRY(it->CheckLineOrder(aLine, &isReordered, &firstFrame, &lastFrame)); nsIFrame** framePtr = aDirection == eDirPrevious ? &firstFrame : &lastFrame; if (!*framePtr) { @@ -8791,7 +8764,8 @@ Result nsIFrame::IsVisuallyAtLineEdge( Result nsIFrame::IsLogicallyAtLineEdge( nsILineIterator* aLineIterator, int32_t aLine, nsDirection aDirection) { - auto line = aLineIterator->GetLine(aLine).unwrap(); + nsAutoLineIterator it = aLineIterator; + auto line = it->GetLine(aLine).unwrap(); if (aDirection == eDirPrevious) { nsIFrame* firstFrame = line.mFirstFrameOnLine; @@ -8803,7 +8777,7 @@ Result nsIFrame::IsLogicallyAtLineEdge( nsIFrame* lastFrame = line.mFirstFrameOnLine; for (int32_t lineFrameCount = line.mNumFramesOnLine; lineFrameCount > 1; lineFrameCount--) { - MOZ_TRY(aLineIterator->GetNextSiblingOnLine(lastFrame, aLine)); + MOZ_TRY(it->GetNextSiblingOnLine(lastFrame, aLine)); if (!lastFrame) { NS_ERROR("should not be reached nsIFrame"); return Err(NS_ERROR_FAILURE); @@ -8838,7 +8812,7 @@ nsIFrame::SelectablePeekReport nsIFrame::GetFrameFromDirection( MOZ_TRY_VAR(thisLine, traversedFrame->GetLineNumber(aScrollViewStop, &blockFrame)); - nsAutoLineIterator it = blockFrame->GetLineIterator(); + nsILineIterator* it = blockFrame->GetLineIterator(); bool atLineEdge; MOZ_TRY_VAR( @@ -8851,12 +8825,6 @@ nsIFrame::SelectablePeekReport nsIFrame::GetFrameFromDirection( if (!aJumpLines) { return result; // we are done. cannot jump lines } - int32_t lineToCheckWrap = - aDirection == eDirPrevious ? thisLine - 1 : thisLine; - if (lineToCheckWrap < 0 || - !it->GetLine(lineToCheckWrap).unwrap().mIsWrapped) { - result.mJumpedHardBreak = true; - } } traversedFrame = frameTraversal->Traverse(aDirection == eDirNext); @@ -8879,9 +8847,7 @@ nsIFrame::SelectablePeekReport nsIFrame::GetFrameFromDirection( for (nsIFrame* current = traversedFrame->GetPrevSibling(); current; current = current->GetPrevSibling()) { if (!current->IsBlockOutside() && IsSelectable(current)) { - if (!current->IsBrFrame()) { - canSkipBr = true; - } + canSkipBr = true; break; } } diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 4e7a267eac6d..3885d8ce5d7b 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -3776,10 +3776,8 @@ class nsIFrame : public nsQueryFrame { * indicates that we arrived at its end. */ int32_t mOffset = 0; - /** whether the input frame and the returned frame are on different lines */ + /** whether this frame and the returned frame are on different lines */ bool mJumpedLine = false; - /** whether we met a hard break between the input and the returned frame */ - bool mJumpedHardBreak = false; /** whether we jumped over a non-selectable frame during the search */ bool mMovedOverNonSelectableText = false; @@ -5172,8 +5170,6 @@ class nsIFrame : public nsQueryFrame { // non-whitespace and whitespace), then mSawBeforeType==true means "we // already saw some non-whitespace". bool mSawBeforeType; - // true when we've encountered at least one non-newline character - bool mSawInlineCharacter; // true when the last character encountered was punctuation bool mLastCharWasPunctuation; // true when the last character encountered was whitespace @@ -5188,12 +5184,10 @@ class nsIFrame : public nsQueryFrame { PeekWordState() : mAtStart(true), mSawBeforeType(false), - mSawInlineCharacter(false), mLastCharWasPunctuation(false), mLastCharWasWhitespace(false), mSeenNonPunctuationSinceWhitespace(false) {} void SetSawBeforeType() { mSawBeforeType = true; } - void SetSawInlineCharacter() { mSawInlineCharacter = true; } void Update(bool aAfterPunctuation, bool aAfterWhitespace) { mLastCharWasPunctuation = aAfterPunctuation; mLastCharWasWhitespace = aAfterWhitespace; diff --git a/layout/generic/nsILineIterator.h b/layout/generic/nsILineIterator.h index 9999f12302b3..a93cb2b759e0 100644 --- a/layout/generic/nsILineIterator.h +++ b/layout/generic/nsILineIterator.h @@ -56,8 +56,6 @@ class nsILineIterator { * positioning then its coordinates may be outside the line bounds) */ nsRect mLineBounds; - /** Whether the line is wrapped at the end */ - bool mIsWrapped; }; // Return miscellaneous information about a line. diff --git a/layout/generic/nsLineBox.cpp b/layout/generic/nsLineBox.cpp index f119da8ed878..6edea19013d3 100644 --- a/layout/generic/nsLineBox.cpp +++ b/layout/generic/nsLineBox.cpp @@ -617,7 +617,6 @@ Result nsLineIterator::GetLine( structure.mFirstFrameOnLine = line->mFirstChild; structure.mNumFramesOnLine = line->GetChildCount(); structure.mLineBounds = line->GetPhysicalBounds(); - structure.mIsWrapped = line->IsLineWrapped(); return structure; } diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 52db495596f9..e035cfecf9cf 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -820,20 +820,12 @@ static bool IsTrimmableSpace(const nsTextFragment* aFrag, uint32_t aPos, } } -static bool IsSelectionInlineWhitespace(const nsTextFragment* aFrag, - uint32_t aPos) { - NS_ASSERTION(aPos < aFrag->GetLength(), - "No text for IsSelectionInlineWhitespace!"); +static bool IsSelectionSpace(const nsTextFragment* aFrag, uint32_t aPos) { + NS_ASSERTION(aPos < aFrag->GetLength(), "No text for IsSpace!"); char16_t ch = aFrag->CharAt(aPos); if (ch == ' ' || ch == CH_NBSP) return !IsSpaceCombiningSequenceTail(aFrag, aPos + 1); - return ch == '\t' || ch == '\f'; -} - -static bool IsSelectionNewline(const nsTextFragment* aFrag, uint32_t aPos) { - NS_ASSERTION(aPos < aFrag->GetLength(), "No text for IsSelectionNewline!"); - char16_t ch = aFrag->CharAt(aPos); - return ch == '\n' || ch == '\r'; + return ch == '\t' || ch == '\n' || ch == '\f' || ch == '\r'; } // Count the amount of trimmable whitespace (as per CSS @@ -7713,8 +7705,7 @@ class MOZ_STACK_CLASS ClusterIterator { bool aTrimSpaces = true); bool NextCluster(); - bool IsInlineWhitespace() const; - bool IsNewline() const; + bool IsWhitespace() const; bool IsPunctuation() const; bool HaveWordBreakBefore() const { return mHaveWordBreak; } @@ -7859,14 +7850,9 @@ nsIFrame::FrameSearchResult nsTextFrame::PeekOffsetCharacter( return CONTINUE; } -bool ClusterIterator::IsInlineWhitespace() const { +bool ClusterIterator::IsWhitespace() const { NS_ASSERTION(mCharIndex >= 0, "No cluster selected"); - return IsSelectionInlineWhitespace(mFrag, mCharIndex); -} - -bool ClusterIterator::IsNewline() const { - NS_ASSERTION(mCharIndex >= 0, "No cluster selected"); - return IsSelectionNewline(mFrag, mCharIndex); + return IsSelectionSpace(mFrag, mCharIndex); } bool ClusterIterator::IsPunctuation() const { @@ -8049,12 +8035,8 @@ nsIFrame::FrameSearchResult nsTextFrame::PeekOffsetWord( do { bool isPunctuation = cIter.IsPunctuation(); - bool isInlineWhitespace = cIter.IsInlineWhitespace(); - bool isWhitespace = isInlineWhitespace || cIter.IsNewline(); + bool isWhitespace = cIter.IsWhitespace(); bool isWordBreakBefore = cIter.HaveWordBreakBefore(); - if (!isWhitespace || isInlineWhitespace) { - aState->SetSawInlineCharacter(); - } if (aWordSelectEatSpace == isWhitespace && !aState->mSawBeforeType) { aState->SetSawBeforeType(); aState->Update(isPunctuation, isWhitespace); diff --git a/layout/generic/test/mochitest.ini b/layout/generic/test/mochitest.ini index 3298427efa5e..cb71315b9429 100644 --- a/layout/generic/test/mochitest.ini +++ b/layout/generic/test/mochitest.ini @@ -103,7 +103,6 @@ support-files = file_bug1307853.html [test_bug1499961.html] [test_bug1566783.html] support-files = file_bug1566783.html -[test_bug1623764.html] [test_bug1642588.html] [test_bug1644511.html] [test_contained_plugin_transplant.html] diff --git a/layout/generic/test/test_bug1623764.html b/layout/generic/test/test_bug1623764.html deleted file mode 100644 index eba1bbf85f9b..000000000000 --- a/layout/generic/test/test_bug1623764.html +++ /dev/null @@ -1,292 +0,0 @@ - -Test Windows conventional caret movement behavior - - - - -
- - -