From 9a562a2e2b1c074498d6299f44117966731d9a29 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Wed, 7 Jan 2015 12:47:09 +1100 Subject: [PATCH] Bug 1116635 - Fix interaction between ruby alignment and trimmed whitespace. r=roc --HG-- extra : rebase_source : 02452c197129f05cee9ebf1a868c166c3b5c7880 extra : source : 0d467e9425a4a48d358e65227d6f5f0812e8dd0c --- layout/generic/nsLineLayout.cpp | 21 +++++++++++++++- layout/generic/nsLineLayout.h | 6 +---- .../css-ruby/justification-2-ref.html | 20 ++++++++++++++++ layout/reftests/css-ruby/justification-2.html | 24 +++++++++++++++++++ layout/reftests/css-ruby/reftest.list | 1 + 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 layout/reftests/css-ruby/justification-2-ref.html create mode 100644 layout/reftests/css-ruby/justification-2.html diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index bacc2c6f1b09..533fbb3d9368 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -2504,6 +2504,21 @@ nsLineLayout::TrimTrailingWhiteSpace() 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(mFrame)->IsAtEndOfLine()) { + // Skip trimmed whitespaces + return false; + } + return true; +} + struct nsLineLayout::JustificationComputationState { PerFrameData* mFirstParticipant; @@ -2578,6 +2593,7 @@ nsLineLayout::ComputeFrameJustification(PerSpanData* aPSD, // 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; @@ -2592,7 +2608,10 @@ nsLineLayout::ComputeFrameJustification(PerSpanData* aPSD, } aState.mLastParticipant = pfd; - aState.mCrossingRubyBaseBoundary = isRubyBase; + } + + if (isRubyBase) { + aState.mCrossingRubyBaseBoundary = true; } if (firstChild) { diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index 868ae7cd6347..95c911737376 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -496,11 +496,7 @@ protected: return mJustificationInfo.mIsEndJustifiable; } - bool ParticipatesInJustification() const - { - // Skip bullets and empty frames - return !mIsBullet && !mIsEmpty; - } + bool ParticipatesInJustification() const; }; PerFrameData* mFrameFreeList; diff --git a/layout/reftests/css-ruby/justification-2-ref.html b/layout/reftests/css-ruby/justification-2-ref.html new file mode 100644 index 000000000000..c6ce6eac209e --- /dev/null +++ b/layout/reftests/css-ruby/justification-2-ref.html @@ -0,0 +1,20 @@ + + + + + Bug 1116631 - Justification with ruby span + + + + +
+ + diff --git a/layout/reftests/css-ruby/justification-2.html b/layout/reftests/css-ruby/justification-2.html new file mode 100644 index 000000000000..3b752b95058c --- /dev/null +++ b/layout/reftests/css-ruby/justification-2.html @@ -0,0 +1,24 @@ + + + + + Bug 1116631 - Justification with ruby span + + + + +
+ + + +
+ + diff --git a/layout/reftests/css-ruby/reftest.list b/layout/reftests/css-ruby/reftest.list index 372191ad9151..78843705ef6a 100644 --- a/layout/reftests/css-ruby/reftest.list +++ b/layout/reftests/css-ruby/reftest.list @@ -21,6 +21,7 @@ fuzzy-if(winWidget,28,1) == dynamic-removal-3.html dynamic-removal-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