author | Ehsan Akhgari <ehsan@mozilla.com> |
Tue, 27 Jan 2015 16:40:30 -0500 | |
changeset 239515 | 007fbd5bc4bdbdd63a375ecac60605249fa1b832 |
parent 239514 | ae5cd730766250aac5ac66511364ecc178e87328 |
child 239516 | a53de22d85ad7dffdbdd64b0aedd8ddaa0f60cf3 |
push id | 500 |
push user | joshua.m.grant@gmail.com |
push date | Thu, 29 Jan 2015 01:48:36 +0000 |
bugs | 989012 |
milestone | 38.0a1 |
backs out | 9698f6f3f72e98d8ddced3cee5cde812595ef33a 22fb05349a10681c74da313485dac594dc1d7a82 |
--- a/layout/base/SelectionCarets.cpp +++ b/layout/base/SelectionCarets.cpp @@ -692,17 +692,16 @@ CompareRangeWithContentOffset(nsRange* a // Move one character forward/backward from point and get offset nsPeekOffsetStruct pos(eSelectCluster, dir, offset, nsPoint(0, 0), true, true, //limit on scrolled views false, - false, false); nsresult rv = theFrame->PeekOffset(&pos); if (NS_FAILED(rv)) { pos.mResultContent = content; pos.mContentOffset = nodeOffset; } // Compare with current point
--- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -697,17 +697,17 @@ nsCaret::GetCaretFrameForNodeOffset(nsFr // so we stay with the current frame. // Exception: when the first frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the visually first frame on the line. nsBidiLevel baseLevel = NS_GET_BASE_LEVEL(frameAfter); if (baseLevel != levelAfter) { nsPeekOffsetStruct pos(eSelectBeginLine, eDirPrevious, 0, nsPoint(0, 0), false, true, false, - true, false); + true); if (NS_SUCCEEDED(frameAfter->PeekOffset(&pos))) { theFrame = pos.mResultFrame; theFrameOffset = pos.mContentOffset; } } } } } @@ -732,17 +732,17 @@ nsCaret::GetCaretFrameForNodeOffset(nsFr // so we stay with the current frame. // Exception: when the last frame on the line has a different Bidi level from the paragraph level, there is no // real frame for the caret to be in. We have to find the visually last frame on the line. nsBidiLevel baseLevel = NS_GET_BASE_LEVEL(frameBefore); if (baseLevel != levelBefore) { nsPeekOffsetStruct pos(eSelectEndLine, eDirNext, 0, nsPoint(0, 0), false, true, false, - true, false); + true); if (NS_SUCCEEDED(frameBefore->PeekOffset(&pos))) { theFrame = pos.mResultFrame; theFrameOffset = pos.mContentOffset; } } } } }
deleted file mode 100644 --- a/layout/base/tests/bug989012-1-ref.html +++ /dev/null @@ -1,21 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<img alt="IMAGE">bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - // Set the caret right before "bar" - sel.collapse(div.lastChild, 0); - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
deleted file mode 100644 --- a/layout/base/tests/bug989012-1.html +++ /dev/null @@ -1,24 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<img alt="IMAGE">bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - sel.collapse(div, 0); - // Press Right four times to set the caret right before "bar" - for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); - } - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
deleted file mode 100644 --- a/layout/base/tests/bug989012-2-ref.html +++ /dev/null @@ -1,26 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <style> - span:before { - content: "IMAGE"; - } - </style> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<span></span>bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - // Set the caret right before "bar" - sel.collapse(div.lastChild, 0); - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
deleted file mode 100644 --- a/layout/base/tests/bug989012-2.html +++ /dev/null @@ -1,29 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <style> - span:before { - content: "IMAGE"; - } - </style> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<span></span>bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - sel.collapse(div, 0); - // Press Right four times to set the caret right before "bar" - for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); - } - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
deleted file mode 100644 --- a/layout/base/tests/bug989012-3-ref.html +++ /dev/null @@ -1,28 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <style> - img { - border: solid 1px red; - mid-width: 1em; - display: inline-block; - } - </style> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<img>bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - // Set the caret right before "bar" - sel.collapse(div.lastChild, 0); - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
deleted file mode 100644 --- a/layout/base/tests/bug989012-3.html +++ /dev/null @@ -1,31 +0,0 @@ -<html class="reftest-wait"> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <style> - img { - border: solid 1px red; - mid-width: 1em; - display: inline-block; - } - </style> - </head> - <body onload="start()"> - <div onfocus="done()" contenteditable>foo<img>bar</div> - <script> - var div = document.querySelector("div"); - function start() { - div.focus(); - } - function done() { - var sel = getSelection(); - sel.collapse(div, 0); - // Press Right four times to set the caret right before "bar" - for (var i = 0; i < 4; ++i) { - synthesizeKey("VK_RIGHT", {}); - } - document.documentElement.removeAttribute("class"); - } - </script> - </body> -</html>
--- a/layout/base/tests/mochitest.ini +++ b/layout/base/tests/mochitest.ini @@ -48,22 +48,16 @@ support-files = bug570378-persian-2-ref.html bug570378-persian-3.html bug570378-persian-3-ref.html bug570378-persian-4.html bug570378-persian-4-ref.html bug570378-persian-5.html bug570378-persian-5-ref.html bug644768.html - bug989012-1.html - bug989012-1-ref.html - bug989012-2.html - bug989012-2-ref.html - bug989012-3.html - bug989012-3-ref.html bug1061468.html bug1061468-ref.html bug1109968-1-ref.html bug1109968-1.html bug1109968-2-ref.html bug1109968-2.html [test_preserve3d_sorting_hit_testing.html]
--- a/layout/base/tests/test_reftests_with_caret.html +++ b/layout/base/tests/test_reftests_with_caret.html @@ -102,19 +102,16 @@ function endTest() { SimpleTest.executeSoon(SimpleTest.finish); } var tests = [ [ 'bug106855-1.html' , 'bug106855-1-ref.html' ] , [ 'bug106855-2.html' , 'bug106855-1-ref.html' ] , [ 'bug389321-2.html' , 'bug389321-2-ref.html' ] , [ 'bug613807-1.html' , 'bug613807-1-ref.html' ] , - [ 'bug989012-1.html' , 'bug989012-1-ref.html' ] , - [ 'bug989012-2.html' , 'bug989012-2-ref.html' ] , - [ 'bug989012-3.html' , 'bug989012-3-ref.html' ] , [ 'bug1082486-1.html', 'bug1082486-1-ref.html'] , [ 'bug1082486-2.html', 'bug1082486-2-ref.html'] , // The following test cases are all involving with one sending // synthesizeKey(), the other without. They ought to be failed // when touch caret preference on. Test them with preference off. function() {SpecialPowers.setBoolPref("touchcaret.enabled", false);} , [ 'bug240933-1.html' , 'bug240933-1-ref.html' ] , [ 'bug240933-2.html' , 'bug240933-1-ref.html' ] ,
--- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -3094,47 +3094,44 @@ nsFrame::PeekBackwardAndForward(nsSelect // first move one character forward. nsPeekOffsetStruct pos(eSelectCharacter, eDirNext, aStartPos, nsPoint(0, 0), aJumpLines, true, //limit on scrolled views false, - false, false); rv = PeekOffset(&pos); if (NS_SUCCEEDED(rv)) { baseFrame = pos.mResultFrame; baseOffset = pos.mContentOffset; } } // Use peek offset one way then the other: nsPeekOffsetStruct startpos(aAmountBack, eDirPrevious, baseOffset, nsPoint(0, 0), aJumpLines, true, //limit on scrolled views false, - false, false); rv = baseFrame->PeekOffset(&startpos); if (NS_FAILED(rv)) return rv; nsPeekOffsetStruct endpos(aAmountForward, eDirNext, aStartPos, nsPoint(0, 0), aJumpLines, true, //limit on scrolled views false, - false, false); rv = PeekOffset(&endpos); if (NS_FAILED(rv)) return rv; // Keep frameSelection alive. nsRefPtr<nsFrameSelection> frameSelection = GetFrameSelection(); @@ -6489,41 +6486,32 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* peekSearchState = current->PeekOffsetNoAmount(movingInFrameDirection, &offset); else peekSearchState = current->PeekOffsetCharacter(movingInFrameDirection, &offset, aPos->mAmount == eSelectCluster); movedOverNonSelectableText |= (peekSearchState == CONTINUE_UNSELECTABLE); if (peekSearchState != FOUND) { - bool movedOverNonSelectable = false; result = current->GetFrameFromDirection(aPos->mDirection, aPos->mVisual, aPos->mJumpLines, aPos->mScrollViewStop, - ¤t, &offset, &jumpedLine, - &movedOverNonSelectable); + ¤t, &offset, &jumpedLine); if (NS_FAILED(result)) return result; // If we jumped lines, it's as if we found a character, but we still need // to eat non-renderable content on the new line. if (jumpedLine) eatingNonRenderableWS = true; - - // Remember if we moved over non-selectable text when finding another frame. - if (movedOverNonSelectable) { - movedOverNonSelectableText = true; - } } // Found frame, but because we moved over non selectable text we want the offset - // to be at the frame edge. Note that if we are extending the selection, this - // doesn't matter. - if (peekSearchState == FOUND && movedOverNonSelectableText && - !aPos->mExtend) + // to be at the frame edge. + if (peekSearchState == FOUND && movedOverNonSelectableText) { int32_t start, end; current->GetOffsets(start, end); offset = aPos->mDirection == eDirNext ? 0 : end - start; } } // Set outputs @@ -6591,22 +6579,21 @@ nsIFrame::PeekOffset(nsPeekOffsetStruct* IsMovingInFrameDirection(current, aPos->mDirection, aPos->mVisual); done = current->PeekOffsetWord(movingInFrameDirection, wordSelectEatSpace, aPos->mIsKeyboardSelect, &offset, &state) == FOUND; if (!done) { nsIFrame* nextFrame; int32_t nextFrameOffset; - bool jumpedLine, movedOverNonSelectableText; + bool jumpedLine; result = current->GetFrameFromDirection(aPos->mDirection, aPos->mVisual, aPos->mJumpLines, aPos->mScrollViewStop, - &nextFrame, &nextFrameOffset, &jumpedLine, - &movedOverNonSelectableText); + &nextFrame, &nextFrameOffset, &jumpedLine); // We can't jump lines if we're looking for whitespace following // non-whitespace, and we already encountered non-whitespace. if (NS_FAILED(result) || (jumpedLine && !wordSelectEatSpace && state.mSawBeforeType)) { done = true; // If we've crossed the line boundary, check to make sure that we // have not consumed a trailing newline as whitesapce if it's significant. if (jumpedLine && wordSelectEatSpace && @@ -6944,30 +6931,28 @@ nsFrame::GetLineNumber(nsIFrame *aFrame, if (aContainingBlock) *aContainingBlock = blockFrame; return it->FindLineContaining(thisBlock); } nsresult nsIFrame::GetFrameFromDirection(nsDirection aDirection, bool aVisual, - bool aJumpLines, bool aScrollViewStop, - nsIFrame** aOutFrame, int32_t* aOutOffset, - bool* aOutJumpedLine, bool* aOutMovedOverNonSelectableText) + bool aJumpLines, bool aScrollViewStop, + nsIFrame** aOutFrame, int32_t* aOutOffset, bool* aOutJumpedLine) { nsresult result; if (!aOutFrame || !aOutOffset || !aOutJumpedLine) return NS_ERROR_NULL_POINTER; nsPresContext* presContext = PresContext(); *aOutFrame = nullptr; *aOutOffset = 0; *aOutJumpedLine = false; - *aOutMovedOverNonSelectableText = false; // Find the prev/next selectable frame bool selectable = false; nsIFrame *traversedFrame = this; while (!selectable) { nsIFrame *blockFrame; int32_t thisLine = nsFrame::GetLineNumber(traversedFrame, aScrollViewStop, &blockFrame); @@ -7041,27 +7026,22 @@ nsIFrame::GetFrameFromDirection(nsDirect if (aDirection == eDirNext) frameTraversal->Next(); else frameTraversal->Prev(); traversedFrame = frameTraversal->CurrentItem(); - // Skip anonymous elements, but watch out for generated content + // Skip anonymous elements if (!traversedFrame || - (!traversedFrame->IsGeneratedContentFrame() && - traversedFrame->GetContent()->IsRootOfNativeAnonymousSubtree())) { + traversedFrame->GetContent()->IsRootOfNativeAnonymousSubtree()) return NS_ERROR_FAILURE; - } traversedFrame->IsSelectable(&selectable, nullptr); - if (!selectable) { - *aOutMovedOverNonSelectableText = true; - } } // while (!selectable) *aOutOffset = (aDirection == eDirNext) ? 0 : -1; if (aVisual && REVERSED_DIRECTION_FRAME(traversedFrame)) { // The new frame is reverse-direction, go to the other end *aOutOffset = -1 - *aOutOffset; }
--- a/layout/generic/nsFrameSelection.h +++ b/layout/generic/nsFrameSelection.h @@ -63,17 +63,16 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruc nsPeekOffsetStruct(nsSelectionAmount aAmount, nsDirection aDirection, int32_t aStartOffset, nsPoint aDesiredPos, bool aJumpLines, bool aScrollViewStop, bool aIsKeyboardSelect, bool aVisual, - bool aExtend, mozilla::EWordMovementType aWordMovementType = mozilla::eDefaultBehavior); // Note: Most arguments (input and output) are only used with certain values // of mAmount. These values are indicated for each argument below. // Arguments with no such indication are used with all values of mAmount. /*** Input arguments ***/ // Note: The value of some of the input arguments may be changed upon exit. @@ -119,19 +118,16 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruc // mIsKeyboardSelect: Whether the peeking is done in response to a keyboard action. // Used with: eSelectWord. bool mIsKeyboardSelect; // mVisual: Whether bidi caret behavior is visual (true) or logical (false). // Used with: eSelectCharacter, eSelectWord, eSelectBeginLine, eSelectEndLine. bool mVisual; - // mExtend: Whether the selection is being extended or moved. - bool mExtend; - /*** Output arguments ***/ // mResultContent: Content reached as a result of the peek. nsCOMPtr<nsIContent> mResultContent; // mResultFrame: Frame reached as a result of the peek. // Used with: eSelectCharacter, eSelectWord. nsIFrame *mResultFrame;
--- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -2445,23 +2445,20 @@ public: * @param aDirection [in] the direction to move in (eDirPrevious or eDirNext) * @param aVisual [in] whether bidi caret behavior is visual (true) or logical (false) * @param aJumpLines [in] whether to allow jumping across line boundaries * @param aScrollViewStop [in] whether to stop when reaching a scroll frame boundary * @param aOutFrame [out] the previous/next selectable leaf frame * @param aOutOffset [out] 0 indicates that we arrived at the beginning of the output frame; * -1 indicates that we arrived at its end. * @param aOutJumpedLine [out] whether this frame and the returned frame are on different lines - * @param aOutMovedOverNonSelectableText [out] whether we jumped over a non-selectable - * frame during the search */ nsresult GetFrameFromDirection(nsDirection aDirection, bool aVisual, - bool aJumpLines, bool aScrollViewStop, - nsIFrame** aOutFrame, int32_t* aOutOffset, - bool* aOutJumpedLine, bool* aOutMovedOverNonSelectableText); + bool aJumpLines, bool aScrollViewStop, + nsIFrame** aOutFrame, int32_t* aOutOffset, bool* aOutJumpedLine); /** * called to see if the children of the frame are visible from indexstart to index end. * this does not change any state. returns true only if the indexes are valid and any of * the children are visible. for textframes this index is the character index. * if aStart = aEnd result will be false * @param aStart start index of first child from 0-N (number of children) * @param aEnd end index of last child from 0-N
--- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -107,28 +107,26 @@ static void printRange(nsRange *aDomRang nsPeekOffsetStruct::nsPeekOffsetStruct(nsSelectionAmount aAmount, nsDirection aDirection, int32_t aStartOffset, nsPoint aDesiredPos, bool aJumpLines, bool aScrollViewStop, bool aIsKeyboardSelect, bool aVisual, - bool aExtend, EWordMovementType aWordMovementType) : mAmount(aAmount) , mDirection(aDirection) , mStartOffset(aStartOffset) , mDesiredPos(aDesiredPos) , mWordMovementType(aWordMovementType) , mJumpLines(aJumpLines) , mScrollViewStop(aScrollViewStop) , mIsKeyboardSelect(aIsKeyboardSelect) , mVisual(aVisual) - , mExtend(aExtend) , mResultContent() , mResultFrame(nullptr) , mContentOffset(0) , mAttach(CARET_ASSOCIATE_BEFORE) { } struct CachedOffsetForFrame { @@ -849,18 +847,17 @@ nsFrameSelection::MoveCaret(nsDirection visualMovement); if (NS_FAILED(result) || !frame) return NS_FAILED(result) ? result : NS_ERROR_FAILURE; //set data using mLimiter to stop on scroll views. If we have a limiter then we stop peeking //when we hit scrollable views. If no limiter then just let it go ahead nsPeekOffsetStruct pos(aAmount, eDirPrevious, offsetused, desiredPos, - true, mLimiter != nullptr, true, visualMovement, - aContinueSelection); + true, mLimiter != nullptr, true, visualMovement); nsBidiDirection paraDir = nsBidiPresUtils::ParagraphDirection(frame); CaretAssociateHint tHint(mHint); //temporary variable so we dont set mHint until it is necessary switch (aAmount){ case eSelectCharacter: case eSelectCluster: case eSelectWord: @@ -1137,21 +1134,20 @@ nsFrameSelection::GetPrevNextBidiLevels( levels.SetData(currentFrame, currentFrame, NS_GET_EMBEDDING_LEVEL(currentFrame), NS_GET_EMBEDDING_LEVEL(currentFrame)); return levels; } nsIFrame *newFrame; int32_t offset; - bool jumpedLine, movedOverNonSelectableText; + bool jumpedLine; nsresult rv = currentFrame->GetFrameFromDirection(direction, false, aJumpLines, true, - &newFrame, &offset, &jumpedLine, - &movedOverNonSelectableText); + &newFrame, &offset, &jumpedLine); if (NS_FAILED(rv)) newFrame = nullptr; nsBidiLevel baseLevel = NS_GET_BASE_LEVEL(currentFrame); nsBidiLevel currentLevel = NS_GET_EMBEDDING_LEVEL(currentFrame); nsBidiLevel newLevel = newFrame ? NS_GET_EMBEDDING_LEVEL(newFrame) : baseLevel; // If not jumping lines, disregard br frames, since they might be positioned incorrectly. @@ -1443,25 +1439,25 @@ nsFrameSelection::HandleDrag(nsIFrame *a nsIFrame* frame = GetFrameForNodeOffset(offsets.content, offsets.offset, CARET_ASSOCIATE_AFTER, &offset); if (frame && amount == eSelectWord && direction == eDirPrevious) { // To avoid selecting the previous word when at start of word, // first move one character forward. nsPeekOffsetStruct charPos(eSelectCharacter, eDirNext, offset, nsPoint(0, 0), false, mLimiter != nullptr, - false, false, false); + false, false); if (NS_SUCCEEDED(frame->PeekOffset(&charPos))) { frame = charPos.mResultFrame; offset = charPos.mContentOffset; } } nsPeekOffsetStruct pos(amount, direction, offset, nsPoint(0, 0), - false, mLimiter != nullptr, false, false, false); + false, mLimiter != nullptr, false, false); if (frame && NS_SUCCEEDED(frame->PeekOffset(&pos)) && pos.mResultContent) { offsets.content = pos.mResultContent; offsets.offset = pos.mContentOffset; } } HandleClick(offsets.content, offsets.offset, offsets.offset,