Bug 1140264 part 1 - Avoid expanding auto-hidden ruby annotations. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 11 Mar 2015 10:28:21 +1100
changeset 232886 6ee3e7424d3ab853916d4ffe202dc87426152d70
parent 232885 69c682891670e5f6dee1ced41ad68455c2841b94
child 232887 a71446331ce6bbaf195f70a84774d3827402ef4d
push id56673
push userxquan@mozilla.com
push dateTue, 10 Mar 2015 23:30:22 +0000
treeherdermozilla-inbound@144ea3057b66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1140264
milestone39.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 1140264 part 1 - Avoid expanding auto-hidden ruby annotations. r=dbaron This could sometimes cause undesired overflow area.
layout/generic/nsLineLayout.cpp
layout/generic/nsRubyBaseContainerFrame.cpp
layout/generic/nsRubyTextFrame.cpp
layout/generic/nsRubyTextFrame.h
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2785,18 +2785,23 @@ nsLineLayout::AdvanceAnnotationInlineBou
   // expansion should be reserved.  There are two cases a ruby text
   // container does not have children linked to the base:
   // 1. it is a container for span; 2. its children are collapsed.
   // See bug 1055674 for the second case.
   if (frameType == nsGkAtoms::rubyTextFrame ||
       // This ruby text container is a span.
       (psd->mFirstFrame == psd->mLastFrame && psd->mFirstFrame &&
        !psd->mFirstFrame->mIsLinkedToBase)) {
-    nscoord reservedISize = RubyUtils::GetReservedISize(frame);
-    RubyUtils::SetReservedISize(frame, reservedISize + aDeltaISize);
+    // For ruby text frames, only increase frames
+    // which are not auto-hidden.
+    if (frameType != nsGkAtoms::rubyTextFrame ||
+        !static_cast<nsRubyTextFrame*>(frame)->IsAutoHidden()) {
+      nscoord reservedISize = RubyUtils::GetReservedISize(frame);
+      RubyUtils::SetReservedISize(frame, reservedISize + aDeltaISize);
+    }
   } else {
     // It is a normal ruby text container. Its children will expand
     // themselves properly. We only need to expand its own size here.
     aPFD->mBounds.ISize(lineWM) += aDeltaISize;
   }
   aPFD->mFrame->SetRect(lineWM, aPFD->mBounds, aContainerWidth);
 }
 
--- a/layout/generic/nsRubyBaseContainerFrame.cpp
+++ b/layout/generic/nsRubyBaseContainerFrame.cpp
@@ -820,17 +820,17 @@ nsRubyBaseContainerFrame::ReflowOneColum
     if (aReflowState.mTextContainers[i]->IsSpanContainer()) {
       continue;
     }
     nsLineLayout* lineLayout = textReflowStates[i]->mLineLayout;
     nsRubyTextFrame* textFrame = aColumn.mTextFrames[i];
     nscoord deltaISize = icoord - lineLayout->GetCurrentICoord();
     if (deltaISize > 0) {
       lineLayout->AdvanceICoord(deltaISize);
-      if (textFrame) {
+      if (textFrame && !textFrame->IsAutoHidden()) {
         RubyUtils::SetReservedISize(textFrame, deltaISize);
       }
     }
     if (aColumn.mBaseFrame && textFrame) {
       lineLayout->AttachLastFrameToBaseLineLayout();
     }
   }
 
--- a/layout/generic/nsRubyTextFrame.cpp
+++ b/layout/generic/nsRubyTextFrame.cpp
@@ -60,17 +60,17 @@ nsRubyTextFrame::GetFrameName(nsAString&
 
 
 
 /* virtual */ void
 nsRubyTextFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                   const nsRect&           aDirtyRect,
                                   const nsDisplayListSet& aLists)
 {
-  if (GetStateBits() & NS_RUBY_TEXT_FRAME_AUTOHIDE) {
+  if (IsAutoHidden()) {
     return;
   }
 
   nsRubyTextFrameSuper::BuildDisplayList(aBuilder, aDirtyRect, aLists);
 }
 
 /* virtual */ void
 nsRubyTextFrame::Reflow(nsPresContext* aPresContext,
@@ -82,16 +82,16 @@ nsRubyTextFrame::Reflow(nsPresContext* a
   // If we leave it dirty, changes to its content will never be
   // propagated to the ancestors, then it won't be displayed even if
   // the content is no longer the same, until next reflow triggered by
   // some other change. In general, we always reflow all the frames we
   // created. There might be other problems if we don't do that.
   nsRubyTextFrameSuper::Reflow(aPresContext, aDesiredSize,
                                aReflowState, aStatus);
 
-  if (GetStateBits() & NS_RUBY_TEXT_FRAME_AUTOHIDE) {
+  if (IsAutoHidden()) {
     // Reset the ISize. The BSize is not changed so that it won't
     // affect vertical positioning in unexpected way.
     WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
     aDesiredSize.ISize(lineWM) = 0;
     aDesiredSize.SetOverflowAreasToDesiredBounds();
   }
 }
--- a/layout/generic/nsRubyTextFrame.h
+++ b/layout/generic/nsRubyTextFrame.h
@@ -39,16 +39,21 @@ public:
                                 const nsRect&           aDirtyRect,
                                 const nsDisplayListSet& aLists) MOZ_OVERRIDE;
 
   virtual void Reflow(nsPresContext* aPresContext,
                       nsHTMLReflowMetrics& aDesiredSize,
                       const nsHTMLReflowState& aReflowState,
                       nsReflowStatus& aStatus) MOZ_OVERRIDE;
 
+  bool IsAutoHidden() const
+  {
+    return GetStateBits() & NS_RUBY_TEXT_FRAME_AUTOHIDE;
+  }
+
 protected:
   friend nsContainerFrame* NS_NewRubyTextFrame(nsIPresShell* aPresShell,
                                                nsStyleContext* aContext);
   explicit nsRubyTextFrame(nsStyleContext* aContext)
     : nsRubyTextFrameSuper(aContext) {}
 };
 
 #endif /* nsRubyTextFrame_h___ */