Bug 1540357 - Fix implicit int conversions in dom/canvas's layout/* includes. r=dholbert
authorJeff Gilbert <jgilbert@mozilla.com>
Tue, 02 Apr 2019 17:00:49 +0000
changeset 467623 c941cc70ee3e8a3f64c6c799535f63d48793c5d6
parent 467622 f4debce94b0003c8445be2eeae913790f6f65df1
child 467624 54d64288d7de94ed6ea0f1f6e5be9bdb605e3a29
push id35806
push userrgurzau@mozilla.com
push dateWed, 03 Apr 2019 04:07:39 +0000
treeherdermozilla-central@45808ab18609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1540357
milestone68.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 1540357 - Fix implicit int conversions in dom/canvas's layout/* includes. r=dholbert nsUnicodeProperties.h includes into ICU, which has implicit int truncation, so quarantine this include out of problematic headers. Depends on D25498 Differential Revision: https://phabricator.services.mozilla.com/D25499
layout/forms/nsFileControlFrame.cpp
layout/generic/WritingModes.h
layout/generic/nsTextFrameUtils.cpp
layout/generic/nsTextFrameUtils.h
layout/style/nsStyleUtil.h
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -20,16 +20,17 @@
 #include "mozilla/dom/HTMLButtonElement.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "mozilla/dom/MutationEventBinding.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/StaticPrefs.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
+#include "nsUnicodeProperties.h"
 #include "mozilla/EventStates.h"
 #include "nsTextNode.h"
 #include "nsTextFrame.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsIFrame* NS_NewFileControlFrame(nsIPresShell* aPresShell,
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -282,17 +282,17 @@ class WritingMode {
   }
 
   mozilla::PhysicalAxis PhysicalAxis(LogicalAxis aAxis) const {
     // This will set wm to either NS_STYLE_WRITING_MODE_HORIZONTAL_TB or
     // NS_STYLE_WRITING_MODE_VERTICAL_RL, and not the other two (real
     // and hypothetical) values.  But this is fine; we only need to
     // distinguish between vertical and horizontal in
     // PhysicalAxisForLogicalAxis.
-    int wm = mWritingMode & eOrientationMask;
+    const auto wm = static_cast<uint8_t>(mWritingMode & eOrientationMask);
     return PhysicalAxisForLogicalAxis(wm, aAxis);
   }
 
   static mozilla::Side PhysicalSideForBlockAxis(uint8_t aWritingModeValue,
                                                 LogicalEdge aEdge) {
     // indexes are NS_STYLE_WRITING_MODE_* values, which are the same as these
     // two-bit values:
     //   bit 0 = the eOrientationMask value
@@ -357,18 +357,18 @@ class WritingMode {
   /**
    * Returns the physical side corresponding to the specified logical side,
    * given the current writing mode.
    */
   mozilla::Side PhysicalSide(LogicalSide aSide) const {
     if (IsBlock(aSide)) {
       static_assert(eOrientationMask == 0x01 && eBlockFlowMask == 0x04,
                     "unexpected mask values");
-      int wm = ((mWritingMode & eBlockFlowMask) >> 1) |
-               (mWritingMode & eOrientationMask);
+      const auto wm = static_cast<uint8_t>(((mWritingMode & eBlockFlowMask) >> 1) |
+                                           (mWritingMode & eOrientationMask));
       return PhysicalSideForBlockAxis(wm, GetEdge(aSide));
     }
 
     return PhysicalSideForInlineAxis(GetEdge(aSide));
   }
 
   /**
    * Returns the logical side corresponding to the specified physical side,
--- a/layout/generic/nsTextFrameUtils.cpp
+++ b/layout/generic/nsTextFrameUtils.cpp
@@ -7,20 +7,30 @@
 #include "nsTextFrameUtils.h"
 
 #include "nsBidiUtils.h"
 #include "nsCharTraits.h"
 #include "nsIContent.h"
 #include "nsStyleStruct.h"
 #include "nsTextFragment.h"
 #include "nsUnicharUtils.h"
+#include "nsUnicodeProperties.h"
 #include <algorithm>
 
 using namespace mozilla;
 
+// static
+bool nsTextFrameUtils::IsSpaceCombiningSequenceTail(const char16_t* aChars,
+                                         int32_t aLength) {
+  return aLength > 0 &&
+         (mozilla::unicode::IsClusterExtender(aChars[0]) ||
+          (IsBidiControl(aChars[0]) &&
+           IsSpaceCombiningSequenceTail(aChars + 1, aLength - 1)));
+}
+
 static bool IsDiscardable(char16_t ch, nsTextFrameUtils::Flags* aFlags) {
   // Unlike IS_DISCARDABLE, we don't discard \r. \r will be ignored by
   // gfxTextRun and discarding it would force us to copy text in many cases of
   // preformatted text containing \r\n.
   if (ch == CH_SHY) {
     *aFlags |= nsTextFrameUtils::Flags::TEXT_HAS_SHY;
     return true;
   }
--- a/layout/generic/nsTextFrameUtils.h
+++ b/layout/generic/nsTextFrameUtils.h
@@ -4,17 +4,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef NSTEXTFRAMEUTILS_H_
 #define NSTEXTFRAMEUTILS_H_
 
 #include "gfxSkipChars.h"
 #include "nsBidiUtils.h"
-#include "nsUnicodeProperties.h"
 
 class nsIContent;
 struct nsStyleText;
 
 #define BIG_TEXT_NODE_SIZE 4096
 
 #define CH_NBSP 160
 #define CH_SHY 173
@@ -78,22 +77,17 @@ class nsTextFrameUtils {
 
   /**
    * Returns true if aChars/aLength are something that make a space
    * character not be whitespace when they follow the space character
    * (combining mark or join control, ignoring intervening direction
    * controls).
    */
   static bool IsSpaceCombiningSequenceTail(const char16_t* aChars,
-                                           int32_t aLength) {
-    return aLength > 0 &&
-           (mozilla::unicode::IsClusterExtender(aChars[0]) ||
-            (IsBidiControl(aChars[0]) &&
-             IsSpaceCombiningSequenceTail(aChars + 1, aLength - 1)));
-  }
+                                           int32_t aLength);
   static bool IsSpaceCombiningSequenceTail(const uint8_t* aChars,
                                            int32_t aLength) {
     return false;
   }
 
   enum CompressionMode {
     COMPRESS_NONE,
     COMPRESS_WHITESPACE,
--- a/layout/style/nsStyleUtil.h
+++ b/layout/style/nsStyleUtil.h
@@ -73,17 +73,17 @@ class nsStyleUtil {
   }
 
   /*
    * Convert an author-provided floating point number to an integer (0
    * ... 255) appropriate for use in the alpha component of a color.
    */
   static uint8_t FloatToColorComponent(float aAlpha) {
     NS_ASSERTION(0.0 <= aAlpha && aAlpha <= 1.0, "out of range");
-    return NSToIntRound(aAlpha * 255);
+    return static_cast<uint8_t>(NSToIntRound(aAlpha * 255));
   }
 
   /*
    * Convert the alpha component of an nscolor (0 ... 255) to the
    * floating point number with the least accurate *decimal*
    * representation that is converted to that color.
    *
    * Should be used only by serialization code.