Bug 1100071 patch 1: change uint8_t to nsBidiLevel in a few more places, r=dholbert
authorSimon Montagu <smontagu@smontagu.org>
Thu, 20 Nov 2014 12:45:22 +0200
changeset 216628 086c21f9b16fe8a497a64eb7b0c6813e56070a07
parent 216627 d90b4907a287547c46e18a2c10b1a5d24c142fb2
child 216629 53fb431ea9433f4c31517760502114dcea6fbc23
push id27858
push userkwierso@gmail.com
push dateFri, 21 Nov 2014 01:35:46 +0000
treeherdermozilla-central@6309710dd71d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1100071
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1100071 patch 1: change uint8_t to nsBidiLevel in a few more places, r=dholbert
editor/libeditor/nsTextEditRulesBidi.cpp
layout/base/nsCaret.cpp
layout/generic/nsFrameSelection.h
layout/generic/nsSelection.cpp
--- a/editor/libeditor/nsTextEditRulesBidi.cpp
+++ b/editor/libeditor/nsTextEditRulesBidi.cpp
@@ -40,31 +40,31 @@ nsTextEditRules::CheckBidiLevelForDeleti
   NS_ENSURE_TRUE(context, NS_ERROR_NULL_POINTER);
   
   if (!context->BidiEnabled())
     return NS_OK;
   
   nsCOMPtr<nsIContent> content = do_QueryInterface(aSelNode);
   NS_ENSURE_TRUE(content, NS_ERROR_NULL_POINTER);
 
-  uint8_t levelBefore;
-  uint8_t levelAfter;
+  nsBidiLevel levelBefore;
+  nsBidiLevel levelAfter;
   nsRefPtr<nsFrameSelection> frameSelection =
     static_cast<Selection*>(aSelection)->GetFrameSelection();
   NS_ENSURE_TRUE(frameSelection, NS_ERROR_NULL_POINTER);
   
   nsPrevNextBidiLevels levels = frameSelection->
     GetPrevNextBidiLevels(content, aSelOffset, true);
     
   levelBefore = levels.mLevelBefore;
   levelAfter = levels.mLevelAfter;
 
-  uint8_t currentCaretLevel = frameSelection->GetCaretBidiLevel();
+  nsBidiLevel currentCaretLevel = frameSelection->GetCaretBidiLevel();
 
-  uint8_t levelOfDeletion;
+  nsBidiLevel levelOfDeletion;
   levelOfDeletion =
     (nsIEditor::eNext==aAction || nsIEditor::eNextWord==aAction) ?
     levelAfter : levelBefore;
 
   if (currentCaretLevel == levelOfDeletion)
     ; // perform the deletion
   else
   {
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -376,17 +376,17 @@ GetFrameAndOffset(Selection* aSelection,
   }
 
   if (!focusNode || !focusNode->IsContent()) {
     return nullptr;
   }
 
   nsIContent* contentNode = focusNode->AsContent();
   nsFrameSelection* frameSelection = aSelection->GetFrameSelection();
-  uint8_t bidiLevel = frameSelection->GetCaretBidiLevel();
+  nsBidiLevel bidiLevel = frameSelection->GetCaretBidiLevel();
   nsIFrame* frame;
   nsresult rv = nsCaret::GetCaretFrameForNodeOffset(
       frameSelection, contentNode, focusOffset,
       frameSelection->GetHint(), bidiLevel, &frame, aFrameOffset);
   if (NS_FAILED(rv) || !frame) {
     return nullptr;
   }
 
@@ -602,22 +602,22 @@ void nsCaret::ResetBlinking()
 void nsCaret::StopBlinking()
 {
   if (mBlinkTimer)
   {
     mBlinkTimer->Cancel();
   }
 }
 
-nsresult 
+nsresult
 nsCaret::GetCaretFrameForNodeOffset(nsFrameSelection*    aFrameSelection,
                                     nsIContent*          aContentNode,
                                     int32_t              aOffset,
                                     CaretAssociationHint aFrameHint,
-                                    uint8_t              aBidiLevel,
+                                    nsBidiLevel          aBidiLevel,
                                     nsIFrame**           aReturnFrame,
                                     int32_t*             aReturnOffset)
 {
   if (!aFrameSelection)
     return NS_ERROR_FAILURE;
   nsIPresShell* presShell = aFrameSelection->GetShell();
   if (!presShell)
     return NS_ERROR_FAILURE;
@@ -651,18 +651,18 @@ nsCaret::GetCaretFrameForNodeOffset(nsFr
     // If there has been a reflow, take the caret Bidi level to be the level of the current frame
     if (aBidiLevel & BIDI_LEVEL_UNDEFINED)
       aBidiLevel = NS_GET_EMBEDDING_LEVEL(theFrame);
 
     int32_t start;
     int32_t end;
     nsIFrame* frameBefore;
     nsIFrame* frameAfter;
-    uint8_t levelBefore;     // Bidi level of the character before the caret
-    uint8_t levelAfter;      // Bidi level of the character after the caret
+    nsBidiLevel levelBefore; // Bidi level of the character before the caret
+    nsBidiLevel levelAfter;  // Bidi level of the character after the caret
 
     theFrame->GetOffsets(start, end);
     if (start == 0 || end == 0 || start == theFrameOffset || end == theFrameOffset)
     {
       nsPrevNextBidiLevels levels = aFrameSelection->
         GetPrevNextBidiLevels(aContentNode, aOffset, false);
     
       /* Boundary condition, we need to know the Bidi levels of the characters before and after the caret */
@@ -690,17 +690,17 @@ nsCaret::GetCaretFrameForNodeOffset(nsFr
                 theFrameOffset = end;
               }
               else 
               {
                 // if there is no frameBefore, we must be at the beginning of the line
                 // 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.
-                uint8_t baseLevel = NS_GET_BASE_LEVEL(frameAfter);
+                nsBidiLevel baseLevel = NS_GET_BASE_LEVEL(frameAfter);
                 if (baseLevel != levelAfter)
                 {
                   nsPeekOffsetStruct pos(eSelectBeginLine, eDirPrevious, 0, 0, false, true, false, true);
                   if (NS_SUCCEEDED(frameAfter->PeekOffset(&pos))) {
                     theFrame = pos.mResultFrame;
                     theFrameOffset = pos.mContentOffset;
                   }
                 }
@@ -721,17 +721,17 @@ nsCaret::GetCaretFrameForNodeOffset(nsFr
                 theFrameOffset = start;
               }
               else 
               {
                 // if there is no frameAfter, we must be at the end of the line
                 // 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.
-                uint8_t baseLevel = NS_GET_BASE_LEVEL(frameBefore);
+                nsBidiLevel baseLevel = NS_GET_BASE_LEVEL(frameBefore);
                 if (baseLevel != levelBefore)
                 {
                   nsPeekOffsetStruct pos(eSelectEndLine, eDirNext, 0, 0, false, true, false, true);
                   if (NS_SUCCEEDED(frameBefore->PeekOffset(&pos))) {
                     theFrame = pos.mResultFrame;
                     theFrameOffset = pos.mContentOffset;
                   }
                 }
--- a/layout/generic/nsFrameSelection.h
+++ b/layout/generic/nsFrameSelection.h
@@ -12,16 +12,17 @@
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsISelectionController.h"
 #include "nsISelectionListener.h"
 #include "nsITableCellLayout.h"
 #include "nsIDOMElement.h"
 #include "WordMovementType.h"
 #include "CaretAssociationHint.h"
+#include "nsBidiPresUtils.h"
 
 class nsRange;
 class nsTableOuterFrame;
 
 // IID for the nsFrameSelection interface
 // 3c6ae2d0-4cf1-44a1-9e9d-2411867f19c6
 #define NS_FRAME_SELECTION_IID      \
 { 0x3c6ae2d0, 0x4cf1, 0x44a1, \
@@ -140,28 +141,28 @@ struct MOZ_STACK_CLASS nsPeekOffsetStruc
   //                 Used with: eSelectLine, eSelectBeginLine, eSelectEndLine.
   mozilla::CaretAssociationHint mAttach;
 };
 
 struct nsPrevNextBidiLevels
 {
   void SetData(nsIFrame* aFrameBefore,
                nsIFrame* aFrameAfter,
-               uint8_t aLevelBefore,
-               uint8_t aLevelAfter)
+               nsBidiLevel aLevelBefore,
+               nsBidiLevel aLevelAfter)
   {
     mFrameBefore = aFrameBefore;
     mFrameAfter = aFrameAfter;
     mLevelBefore = aLevelBefore;
     mLevelAfter = aLevelAfter;
   }
   nsIFrame* mFrameBefore;
   nsIFrame* mFrameAfter;
-  uint8_t mLevelBefore;
-  uint8_t mLevelAfter;
+  nsBidiLevel mLevelBefore;
+  nsBidiLevel mLevelAfter;
 };
 
 namespace mozilla {
 namespace dom {
 class Selection;
 }
 }
 class nsIScrollableFrame;
@@ -398,21 +399,21 @@ public:
 
   void SetHint(CaretAssociateHint aHintRight) { mHint = aHintRight; }
   CaretAssociateHint GetHint() const { return mHint; }
 
   /** SetCaretBidiLevel sets the caret bidi level
    *  @param aLevel the caret bidi level
    *  This method is virtual since it gets called from outside of layout.
    */
-  virtual void SetCaretBidiLevel (uint8_t aLevel);
+  virtual void SetCaretBidiLevel(nsBidiLevel aLevel);
   /** GetCaretBidiLevel gets the caret bidi level
    *  This method is virtual since it gets called from outside of layout.
    */
-  virtual uint8_t GetCaretBidiLevel() const;
+  virtual nsBidiLevel GetCaretBidiLevel() const;
   /** UndefineCaretBidiLevel sets the caret bidi level to "undefined"
    *  This method is virtual since it gets called from outside of layout.
    */
   virtual void UndefineCaretBidiLevel();
 
   /** CharacterMove will generally be called from the nsiselectioncontroller implementations.
    *  the effect being the selection will move one character left or right.
    * @param aForward move forward in document.
@@ -549,17 +550,17 @@ public:
    *  @param aPresContext is the context to use
    *  @param aFrameIn is the frame to start from
    *  @param aDirection is the direction to scan
    *  @param aBidiLevel is the level to search for
    *  @param aFrameOut will hold the frame returned
    */
   nsresult GetFrameFromLevel(nsIFrame *aFrameIn,
                              nsDirection aDirection,
-                             uint8_t aBidiLevel,
+                             nsBidiLevel aBidiLevel,
                              nsIFrame **aFrameOut) const;
 
   /**
    * MaintainSelection will track the current selection as being "sticky".
    * Dragging or extending selection will never allow for a subset
    * (or the whole) of the maintained selection to become unselected.
    * Primary use: double click selecting then dragging on second click
    * @param aAmount the initial amount of text selected (word, line or paragraph).
@@ -700,17 +701,17 @@ private:
   nsCOMPtr<nsIContent> mAncestorLimiter;
 
   nsIPresShell *mShell;
 
   int16_t mSelectionChangeReason; // reason for notifications of selection changing
   int16_t mDisplaySelection; //for visual display purposes.
 
   CaretAssociateHint mHint;   //hint to tell if the selection is at the end of this line or beginning of next
-  uint8_t mCaretBidiLevel;
+  nsBidiLevel mCaretBidiLevel;
 
   int32_t mDesiredX;
   uint32_t mDelayedMouseEventClickCount;
   bool mDelayedMouseEventIsShift;
   bool mDelayedMouseEventValid;
 
   bool mChangesDuringBatching;
   bool mNotifyFrames;
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -621,25 +621,25 @@ nsFrameSelection::ConstrainFrameAndPoint
   //
 
   aRetPoint = aPoint + aFrame->GetOffsetTo(*aRetFrame);
 
   return NS_OK;
 }
 
 void
-nsFrameSelection::SetCaretBidiLevel(uint8_t aLevel)
+nsFrameSelection::SetCaretBidiLevel(nsBidiLevel aLevel)
 {
   // If the current level is undefined, we have just inserted new text.
   // In this case, we don't want to reset the keyboard language
   mCaretBidiLevel = aLevel;
   return;
 }
 
-uint8_t
+nsBidiLevel
 nsFrameSelection::GetCaretBidiLevel() const
 {
   return mCaretBidiLevel;
 }
 
 void
 nsFrameSelection::UndefineCaretBidiLevel()
 {
@@ -1164,19 +1164,19 @@ nsFrameSelection::GetPrevNextBidiLevels(
   int32_t offset;
   bool jumpedLine;
   nsresult rv = currentFrame->GetFrameFromDirection(direction, false,
                                                     aJumpLines, true,
                                                     &newFrame, &offset, &jumpedLine);
   if (NS_FAILED(rv))
     newFrame = nullptr;
 
-  uint8_t baseLevel = NS_GET_BASE_LEVEL(currentFrame);
-  uint8_t currentLevel = NS_GET_EMBEDDING_LEVEL(currentFrame);
-  uint8_t newLevel = newFrame ? NS_GET_EMBEDDING_LEVEL(newFrame) : baseLevel;
+  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.
   // XXX This could be removed once bug 339786 is fixed.
   if (!aJumpLines) {
     if (currentFrame->GetType() == nsGkAtoms::brFrame) {
       currentFrame = nullptr;
       currentLevel = baseLevel;
     }
@@ -1192,21 +1192,21 @@ nsFrameSelection::GetPrevNextBidiLevels(
     levels.SetData(newFrame, currentFrame, newLevel, currentLevel);
 
   return levels;
 }
 
 nsresult
 nsFrameSelection::GetFrameFromLevel(nsIFrame    *aFrameIn,
                                     nsDirection  aDirection,
-                                    uint8_t      aBidiLevel,
+                                    nsBidiLevel  aBidiLevel,
                                     nsIFrame   **aFrameOut) const
 {
   NS_ENSURE_STATE(mShell);
-  uint8_t foundLevel = 0;
+  nsBidiLevel foundLevel = 0;
   nsIFrame *foundFrame = aFrameIn;
 
   nsCOMPtr<nsIFrameEnumerator> frameTraversal;
   nsresult result;
   nsCOMPtr<nsIFrameTraversal> trav(do_CreateInstance(kFrameTraversalCID,&result));
   if (NS_FAILED(result))
       return result;
 
@@ -3949,17 +3949,17 @@ Selection::GetPrimaryFrameForFocusNode(n
   int32_t frameOffset = 0;
   *aReturnFrame = 0;
   if (!aOffsetUsed)
     aOffsetUsed = &frameOffset;
     
   CaretAssociationHint hint = mFrameSelection->GetHint();
 
   if (aVisual) {
-    uint8_t caretBidiLevel = mFrameSelection->GetCaretBidiLevel();
+    nsBidiLevel caretBidiLevel = mFrameSelection->GetCaretBidiLevel();
 
     return nsCaret::GetCaretFrameForNodeOffset(mFrameSelection,
       content, FocusOffset(), hint, caretBidiLevel, aReturnFrame, aOffsetUsed);
   }
   
   *aReturnFrame = mFrameSelection->
     GetFrameForNodeOffset(content, FocusOffset(),
                           hint, aOffsetUsed);
@@ -5881,22 +5881,22 @@ Selection::SelectionLanguageChange(bool 
   }
   if (!focusFrame) {
     return NS_ERROR_FAILURE;
   }
 
   int32_t frameStart, frameEnd;
   focusFrame->GetOffsets(frameStart, frameEnd);
   nsRefPtr<nsPresContext> context = GetPresContext();
-  uint8_t levelBefore, levelAfter;
+  nsBidiLevel levelBefore, levelAfter;
   if (!context) {
     return NS_ERROR_FAILURE;
   }
 
-  uint8_t level = NS_GET_EMBEDDING_LEVEL(focusFrame);
+  nsBidiLevel level = NS_GET_EMBEDDING_LEVEL(focusFrame);
   int32_t focusOffset = static_cast<int32_t>(FocusOffset());
   if ((focusOffset != frameStart) && (focusOffset != frameEnd))
     // the cursor is not at a frame boundary, so the level of both the characters (logically) before and after the cursor
     //  is equal to the frame level
     levelBefore = levelAfter = level;
   else {
     // the cursor is at a frame boundary, so use GetPrevNextBidiLevels to find the level of the characters
     //  before and after the cursor