Use a 1-byte enum class for TextDirection
[WebKit-https.git] / Source / WebCore / editing / FrameSelection.cpp
index ce31fb9..36c79ad 100644 (file)
@@ -633,7 +633,7 @@ void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
     } else {
         switch (direction) {
         case DirectionRight:
-            if (directionOfSelection() == LTR)
+            if (directionOfSelection() == TextDirection::LTR)
                 baseIsStart = true;
             else
                 baseIsStart = false;
@@ -642,7 +642,7 @@ void FrameSelection::willBeModified(EAlteration alter, SelectionDirection direct
             baseIsStart = true;
             break;
         case DirectionLeft:
-            if (directionOfSelection() == LTR)
+            if (directionOfSelection() == TextDirection::LTR)
                 baseIsStart = false;
             else
                 baseIsStart = true;
@@ -718,23 +718,23 @@ VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity
     // The difference between modifyExtendingRight and modifyExtendingForward is:
     // modifyExtendingForward always extends forward logically.
     // modifyExtendingRight behaves the same as modifyExtendingForward except for extending character or word,
-    // it extends forward logically if the enclosing block is LTR direction,
-    // but it extends backward logically if the enclosing block is RTL direction.
+    // it extends forward logically if the enclosing block is TextDirection::LTR,
+    // but it extends backward logically if the enclosing block is TextDirection::RTL.
     switch (granularity) {
     case CharacterGranularity:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = pos.next(CannotCrossEditingBoundary);
         else
             pos = pos.previous(CannotCrossEditingBoundary);
         break;
     case WordGranularity:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = nextWordPositionForPlatform(pos);
         else
             pos = previousWordPosition(pos);
         break;
     case LineBoundary:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = modifyExtendingForward(granularity);
         else
             pos = modifyExtendingBackward(granularity);
@@ -753,7 +753,7 @@ VisiblePosition FrameSelection::modifyExtendingRight(TextGranularity granularity
         break;
     }
 #if ENABLE(USERSELECT_ALL)
-    adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
+    adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == TextDirection::LTR);
 #endif
     return pos;
 }
@@ -798,7 +798,7 @@ VisiblePosition FrameSelection::modifyExtendingForward(TextGranularity granulari
         break;
     }
 #if ENABLE(USERSELECT_ALL)
-     adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == LTR);
+    adjustPositionForUserSelectAll(pos, directionOfEnclosingBlock() == TextDirection::LTR);
 #endif
     return pos;
 }
@@ -811,7 +811,7 @@ VisiblePosition FrameSelection::modifyMovingRight(TextGranularity granularity, b
     switch (granularity) {
     case CharacterGranularity:
         if (isRange()) {
-            if (directionOfSelection() == LTR)
+            if (directionOfSelection() == TextDirection::LTR)
                 pos = VisiblePosition(m_selection.end(), m_selection.affinity());
             else
                 pos = VisiblePosition(m_selection.start(), m_selection.affinity());
@@ -935,23 +935,23 @@ VisiblePosition FrameSelection::modifyExtendingLeft(TextGranularity granularity)
     // The difference between modifyExtendingLeft and modifyExtendingBackward is:
     // modifyExtendingBackward always extends backward logically.
     // modifyExtendingLeft behaves the same as modifyExtendingBackward except for extending character or word,
-    // it extends backward logically if the enclosing block is LTR direction,
-    // but it extends forward logically if the enclosing block is RTL direction.
+    // it extends backward logically if the enclosing block is TextDirection::LTR,
+    // but it extends forward logically if the enclosing block is TextDirection::RTL.
     switch (granularity) {
     case CharacterGranularity:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = pos.previous(CannotCrossEditingBoundary);
         else
             pos = pos.next(CannotCrossEditingBoundary);
         break;
     case WordGranularity:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = previousWordPosition(pos);
         else
             pos = nextWordPositionForPlatform(pos);
         break;
     case LineBoundary:
-        if (directionOfEnclosingBlock() == LTR)
+        if (directionOfEnclosingBlock() == TextDirection::LTR)
             pos = modifyExtendingBackward(granularity);
         else
             pos = modifyExtendingForward(granularity);
@@ -969,7 +969,7 @@ VisiblePosition FrameSelection::modifyExtendingLeft(TextGranularity granularity)
         break;
     }
 #if ENABLE(USERSELECT_ALL)
-    adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
+    adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == TextDirection::LTR));
 #endif
     return pos;
 }
@@ -1019,7 +1019,7 @@ VisiblePosition FrameSelection::modifyExtendingBackward(TextGranularity granular
         break;
     }
 #if ENABLE(USERSELECT_ALL)
-    adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == LTR));
+    adjustPositionForUserSelectAll(pos, !(directionOfEnclosingBlock() == TextDirection::LTR));
 #endif
     return pos;
 }
@@ -1032,7 +1032,7 @@ VisiblePosition FrameSelection::modifyMovingLeft(TextGranularity granularity, bo
     switch (granularity) {
     case CharacterGranularity:
         if (isRange())
-            if (directionOfSelection() == LTR)
+            if (directionOfSelection() == TextDirection::LTR)
                 pos = VisiblePosition(m_selection.start(), m_selection.affinity());
             else
                 pos = VisiblePosition(m_selection.end(), m_selection.affinity());
@@ -1154,7 +1154,7 @@ AXTextStateChangeIntent FrameSelection::textSelectionIntent(EAlteration alter, S
     bool flip = false;
     if (alter == FrameSelection::AlterationMove) {
         intent.type = AXTextStateChangeTypeSelectionMove;
-        flip = isRange() && directionOfSelection() == RTL;
+        flip = isRange() && directionOfSelection() == TextDirection::RTL;
     } else
         intent.type = AXTextStateChangeTypeSelectionExtend;
     switch (granularity) {
@@ -1375,7 +1375,7 @@ bool FrameSelection::modify(EAlteration alter, SelectionDirection direction, Tex
             setExtent(position, userTriggered);
         else {
             TextDirection textDirection = directionOfEnclosingBlock();
-            if (direction == DirectionForward || (textDirection == LTR && direction == DirectionRight) || (textDirection == RTL && direction == DirectionLeft))
+            if (direction == DirectionForward || (textDirection == TextDirection::LTR && direction == DirectionRight) || (textDirection == TextDirection::RTL && direction == DirectionLeft))
                 setEnd(position, userTriggered);
             else
                 setStart(position, userTriggered);