Bug 1055667 part 6 - Fix border/padding of ruby frame. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 15 Jan 2015 20:02:11 +1100
changeset 223924 f2f608193d38
parent 223923 1e83e832b46b
child 223925 297f99f0ed18
push id54078
push userxquan@mozilla.com
push date2015-01-15 09:03 +0000
treeherdermozilla-inbound@297f99f0ed18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1055667
milestone38.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 1055667 part 6 - Fix border/padding of ruby frame. r=dbaron
layout/base/nsCSSRendering.cpp
layout/generic/nsRubyFrame.cpp
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -52,16 +52,17 @@
 #include "nsCSSRenderingBorders.h"
 #include "mozilla/css/ImageLoader.h"
 #include "ImageContainer.h"
 #include "mozilla/Telemetry.h"
 #include "gfxUtils.h"
 #include "gfxColor.h"
 #include "gfxGradientCache.h"
 #include "GraphicsFilter.h"
+#include "nsInlineFrame.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::gfx;
 using mozilla::image::ImageOps;
 using mozilla::CSSSizeOrRatio;
 
@@ -92,17 +93,17 @@ struct InlineBackgroundData
 
   /**
    * Return a continuous rect for (an inline) aFrame relative to the
    * continuation that draws the left-most part of the background.
    * This is used when painting backgrounds.
    */
   nsRect GetContinuousRect(nsIFrame* aFrame)
   {
-    MOZ_ASSERT(aFrame->GetType() == nsGkAtoms::inlineFrame);
+    MOZ_ASSERT(static_cast<nsInlineFrame*>(do_QueryFrame(aFrame)));
 
     SetFrame(aFrame);
 
     nscoord pos; // an x coordinate if writing-mode is horizontal;
                  // y coordinate if vertical
     if (mBidiEnabled) {
       pos = mLineContinuationPoint;
 
@@ -540,17 +541,17 @@ JoinBoxesForVerticalSlice(nsIFrame* aFra
  * See "Joining Boxes for 'slice'" in
  * http://dev.w3.org/csswg/css-break/#break-decoration
  */
 enum InlineBoxOrder { eForBorder, eForBackground };
 static nsRect
 JoinBoxesForSlice(nsIFrame* aFrame, const nsRect& aBorderArea,
                   InlineBoxOrder aOrder)
 {
-  if (aFrame->GetType() == nsGkAtoms::inlineFrame) {
+  if (static_cast<nsInlineFrame*>(do_QueryFrame(aFrame))) {
     return (aOrder == eForBorder
             ? gInlineBGData->GetBorderContinuousRect(aFrame, aBorderArea)
             : gInlineBGData->GetContinuousRect(aFrame)) +
       aBorderArea.TopLeft();
   }
   return JoinBoxesForVerticalSlice(aFrame, aBorderArea);
 }
 
--- a/layout/generic/nsRubyFrame.cpp
+++ b/layout/generic/nsRubyFrame.cpp
@@ -144,22 +144,28 @@ nsRubyFrame::Reflow(nsPresContext* aPres
 
   // Clear leadings
   mBStartLeading = mBEndLeading = 0;
 
   // Begin the span for the ruby frame
   WritingMode frameWM = aReflowState.GetWritingMode();
   WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
   LogicalMargin borderPadding = aReflowState.ComputedLogicalBorderPadding();
-  nscoord startEdge = borderPadding.IStart(frameWM);
-  nscoord endEdge = aReflowState.AvailableISize() - borderPadding.IEnd(frameWM);
+  nscoord startEdge = 0;
+  const bool boxDecorationBreakClone =
+    StyleBorder()->mBoxDecorationBreak == NS_STYLE_BOX_DECORATION_BREAK_CLONE;
+  if (boxDecorationBreakClone || !GetPrevContinuation()) {
+    startEdge = borderPadding.IStart(frameWM);
+  }
   NS_ASSERTION(aReflowState.AvailableISize() != NS_UNCONSTRAINEDSIZE,
                "should no longer use available widths");
+  nscoord availableISize = aReflowState.AvailableISize();
+  availableISize -= startEdge + borderPadding.IEnd(frameWM);
   aReflowState.mLineLayout->BeginSpan(this, &aReflowState,
-                                      startEdge, endEdge, &mBaseline);
+                                      startEdge, availableISize, &mBaseline);
 
   aStatus = NS_FRAME_COMPLETE;
   for (SegmentEnumerator e(this); !e.AtEnd(); e.Next()) {
     ReflowSegment(aPresContext, aReflowState, e.GetBaseContainer(), aStatus);
 
     if (NS_INLINE_IS_BREAK(aStatus)) {
       // A break occurs when reflowing the segment.
       // Don't continue reflowing more segments.
@@ -175,16 +181,23 @@ nsRubyFrame::Reflow(nsPresContext* aPres
       break;
     }
     ReflowSegment(aPresContext, aReflowState, baseContainer, aStatus);
   }
   // We never handle overflow in ruby.
   MOZ_ASSERT(!NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus));
 
   aDesiredSize.ISize(lineWM) = aReflowState.mLineLayout->EndSpan(this);
+  if (boxDecorationBreakClone || !GetPrevContinuation()) {
+    aDesiredSize.ISize(lineWM) += borderPadding.IStart(frameWM);
+  }
+  if (boxDecorationBreakClone || NS_FRAME_IS_COMPLETE(aStatus)) {
+    aDesiredSize.ISize(lineWM) += borderPadding.IEnd(frameWM);
+  }
+
   nsLayoutUtils::SetBSizeFromFontMetrics(this, aDesiredSize,
                                          borderPadding, lineWM, frameWM);
 }
 
 #ifdef DEBUG
 static void
 SanityCheckRubyPosition(int8_t aRubyPosition)
 {