Bug 1121350 - Fix extra space on right from whitespace. r=roc, a=sledru
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 15 Jan 2015 19:14:00 +1100
changeset 242959 598cd9c2e480
parent 242958 1f392909ff1f
child 242960 1b21115851ef
push id4345
push userryanvm@gmail.com
push date2015-01-20 17:32 +0000
treeherdermozilla-beta@598cd9c2e480 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, sledru
bugs1121350, 1116635
milestone36.0
Bug 1121350 - Fix extra space on right from whitespace. r=roc, a=sledru This patch is backported from bug 1116635.
layout/generic/nsLineLayout.cpp
layout/generic/nsLineLayout.h
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2440,16 +2440,32 @@ bool
 nsLineLayout::TrimTrailingWhiteSpace()
 {
   PerSpanData* psd = mRootSpan;
   nscoord deltaISize;
   TrimTrailingWhiteSpaceIn(psd, &deltaISize);
   return 0 != deltaISize;
 }
 
+bool
+nsLineLayout::PerFrameData::ParticipatesInJustification() const
+{
+  if (GetFlag(PFD_ISBULLET) || GetFlag(PFD_ISEMPTY) ||
+      GetFlag(PFD_SKIPWHENTRIMMINGWHITESPACE)) {
+    // Skip bullets, empty frames, and placeholders
+    return false;
+  }
+  if (GetFlag(PFD_ISTEXTFRAME) && !GetFlag(PFD_ISNONWHITESPACETEXTFRAME) &&
+      static_cast<nsTextFrame*>(mFrame)->IsAtEndOfLine()) {
+    // Skip trimmed whitespaces
+    return false;
+  }
+  return true;
+}
+
 struct nsLineLayout::JustificationComputationState
 {
   PerFrameData* mLastParticipant;
 };
 
 /**
  * This function returns the total number of
  * expansion opportunities in the given span.
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -455,21 +455,17 @@ protected:
       return mJustificationInfo.mIsStartJustifiable;
     }
 
     bool IsEndJustifiable() const
     {
       return mJustificationInfo.mIsEndJustifiable;
     }
 
-    bool ParticipatesInJustification() const
-    {
-      // Skip bullets and empty frames
-      return !GetFlag(PFD_ISBULLET) && !GetFlag(PFD_ISEMPTY);
-    }
+    bool ParticipatesInJustification() const;
   };
   PerFrameData* mFrameFreeList;
 
   struct PerSpanData {
     union {
       PerSpanData* mParent;
       PerSpanData* mNextFreeSpan;
     };