Bug 1278010 - Add WritingMode convenience methods for determining whether to use central or alphabetical baselines. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Fri, 03 Jun 2016 17:43:00 +0200
changeset 375472 b8b0f46e3811071923c137964af94fe021934500
parent 375471 ac2aaa6bcb4a80476d8c19dd6482ac119779f8b9
child 375473 ff6684c07cc67aaf0fe5a8f3ba6ade75e2df5d33
push id20276
push usersledru@mozilla.com
push dateSun, 05 Jun 2016 13:47:10 +0000
reviewersjfkthame
bugs1278010
milestone49.0a1
Bug 1278010 - Add WritingMode convenience methods for determining whether to use central or alphabetical baselines. r=jfkthame
layout/generic/WritingModes.h
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -264,16 +264,28 @@ public:
 
 #ifdef DEBUG // Used by CHECK_WRITING_MODE to compare modes without regard
              // for the eSidewaysMask flag.
   WritingMode IgnoreSideways() const {
     return WritingMode(mWritingMode & ~eSidewaysMask);
   }
 #endif
 
+  /**
+   * Return true if boxes with this writing mode should use central baselines.
+   */
+  bool IsCentralBaseline() const { return IsVertical() && !IsSideways(); }
+
+  /**
+   * Return true if boxes with this writing mode should use alphabetical
+   * baselines.
+   */
+  bool IsAlphabeticalBaseline() const { return !IsCentralBaseline(); }
+
+
   static mozilla::PhysicalAxis PhysicalAxisForLogicalAxis(
                                               uint8_t aWritingModeValue,
                                               LogicalAxis aAxis)
   {
     // This relies on bit 0 of a writing-value mode indicating vertical
     // orientation and bit 0 of a LogicalAxis value indicating the inline axis,
     // so that it can correctly form mozilla::PhysicalAxis values using bit
     // manipulation.