Bug 1116635 - Fix interaction between ruby alignment and trimmed whitespace. r=roc
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 07 Jan 2015 12:47:09 +1100
changeset 248158 6af6f0cea6fb8adc2534b6b0ff681fc790adf574
parent 248157 80f15029ae68eef0d3b299097284780c1bab1a91
child 248159 93ea6d35aa6475e7aa81afa9937b792a49aaaf1e
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1116635
milestone37.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 1116635 - Fix interaction between ruby alignment and trimmed whitespace. r=roc
layout/generic/nsLineLayout.cpp
layout/generic/nsLineLayout.h
layout/reftests/css-ruby/justification-2-ref.html
layout/reftests/css-ruby/justification-2.html
layout/reftests/css-ruby/reftest.list
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2499,16 +2499,31 @@ bool
 nsLineLayout::TrimTrailingWhiteSpace()
 {
   PerSpanData* psd = mRootSpan;
   nscoord deltaISize;
   TrimTrailingWhiteSpaceIn(psd, &deltaISize);
   return 0 != deltaISize;
 }
 
+bool
+nsLineLayout::PerFrameData::ParticipatesInJustification() const
+{
+  if (mIsBullet || mIsEmpty || mSkipWhenTrimmingWhitespace) {
+    // Skip bullets, empty frames, and placeholders
+    return false;
+  }
+  if (mIsTextFrame && !mIsNonWhitespaceTextFrame &&
+      static_cast<nsTextFrame*>(mFrame)->IsAtEndOfLine()) {
+    // Skip trimmed whitespaces
+    return false;
+  }
+  return true;
+}
+
 struct nsLineLayout::JustificationComputationState
 {
   PerFrameData* mFirstParticipant;
   PerFrameData* mLastParticipant;
   // Whether we are going across a boundary of ruby base, i.e.
   // entering one, leaving one, or both.
   bool mCrossingRubyBaseBoundary;
 
@@ -2573,31 +2588,35 @@ nsLineLayout::ComputeFrameJustification(
           if (aState.mCrossingRubyBaseBoundary) {
             // For ruby alignment with value space-around, there is
             // always an expansion opportunity at the boundary of a ruby
             // base, and it always generates one gap at each side. If we
             // don't do it here, the interaction between text align and
             // and ruby align could be strange.
             prevAssign.mGapsAtEnd = 1;
             assign.mGapsAtStart = 1;
+            aState.mCrossingRubyBaseBoundary = false;
           } else if (!info.mIsStartJustifiable) {
             prevAssign.mGapsAtEnd = 2;
             assign.mGapsAtStart = 0;
           } else if (!prevInfo.mIsEndJustifiable) {
             prevAssign.mGapsAtEnd = 0;
             assign.mGapsAtStart = 2;
           } else {
             prevAssign.mGapsAtEnd = 1;
             assign.mGapsAtStart = 1;
           }
         }
       }
 
       aState.mLastParticipant = pfd;
-      aState.mCrossingRubyBaseBoundary = isRubyBase;
+    }
+
+    if (isRubyBase) {
+      aState.mCrossingRubyBaseBoundary = true;
     }
 
     if (firstChild) {
       outerOpportunities = extraOpportunities;
       firstChild = false;
     } else {
       innerOpportunities += extraOpportunities;
     }
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -491,21 +491,17 @@ protected:
       return mJustificationInfo.mIsStartJustifiable;
     }
 
     bool IsEndJustifiable() const
     {
       return mJustificationInfo.mIsEndJustifiable;
     }
 
-    bool ParticipatesInJustification() const
-    {
-      // Skip bullets and empty frames
-      return !mIsBullet && !mIsEmpty;
-    }
+    bool ParticipatesInJustification() const;
   };
   PerFrameData* mFrameFreeList;
 
   struct PerSpanData {
     union {
       PerSpanData* mParent;
       PerSpanData* mNextFreeSpan;
     };
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-ruby/justification-2-ref.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="ja">
+<head>
+  <meta charset="UTF-8">
+  <title>Bug 1116631 - Justification with ruby span</title>
+  <link rel="stylesheet" href="common.css">
+  <style>
+    div {
+      ruby-position: under left;
+      width: 300px; height: 100px;
+      -moz-text-align-last: justify;
+      overflow: auto;
+      text-decoration: underline;
+    }
+  </style>
+</head>
+<body>
+  <div><rb>仮</rb><rb>名</rb><rt>が</rt><rt>な</rt></div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-ruby/justification-2.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="ja">
+<head>
+  <meta charset="UTF-8">
+  <title>Bug 1116631 - Justification with ruby span</title>
+  <link rel="stylesheet" href="common.css">
+  <style>
+    div {
+      ruby-position: under left;
+      width: 300px; height: 100px;
+      -moz-text-align-last: justify;
+      overflow: auto;
+      text-decoration: underline;
+    }
+  </style>
+</head>
+<body>
+  <div>
+    <rb>仮</rb><rb>名</rb>
+    <rt>が</rt><rt>な</rt>
+    <!-- -->
+  </div>
+</body>
+</html>
--- a/layout/reftests/css-ruby/reftest.list
+++ b/layout/reftests/css-ruby/reftest.list
@@ -16,15 +16,16 @@ fails == autohiding-3.html autohiding-3-
 fuzzy-if(winWidget,28,1) == dynamic-removal-3.html dynamic-removal-3-ref.html # bug 1111891
 == float-handling.html float-handling-ref.html
 == inlinize-blocks-1.html inlinize-blocks-1-ref.html
 == inlinize-blocks-2.html inlinize-blocks-2-ref.html
 == inlinize-blocks-3.html inlinize-blocks-3-ref.html
 == inlinize-blocks-4.html inlinize-blocks-4-ref.html
 == inlinize-blocks-5.html inlinize-blocks-5-ref.html
 == justification-1.html justification-1-ref.html
+== justification-2.html justification-2-ref.html
 == ruby-whitespace-1.html ruby-whitespace-1-ref.html
 == ruby-whitespace-2.html ruby-whitespace-2-ref.html
 == ruby-position-horizontal.html ruby-position-horizontal-ref.html
 pref(layout.css.vertical-text.enabled,true) fails == ruby-position-vertical-lr.html ruby-position-vertical-lr-ref.html # bug 1112474
 pref(layout.css.vertical-text.enabled,true) fails == ruby-position-vertical-rl.html ruby-position-vertical-rl-ref.html # bug 1112474
 != ruby-reflow-1-opaqueruby.html ruby-reflow-1-noruby.html
 == ruby-reflow-1-transparentruby.html ruby-reflow-1-noruby.html