diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 533fbb3d936..d65af8cf6ae 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -996,6 +996,8 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, } else { if (nsGkAtoms::letterFrame==frameType) { pfd->mIsLetterFrame = true; + } else if (nsGkAtoms::rubyFrame == frameType) { + SyncAnnotationContainersBounds(pfd); } if (pfd->mSpan) { isEmpty = !pfd->mSpan->mHasNonemptyContent && pfd->mFrame->IsSelfEmpty(); @@ -1205,6 +1207,30 @@ nsLineLayout::GetCurrentFrameInlineDistanceFromBlock() return x; } +/** + * This method syncs all ruby annotation containers' bounds in their + * PerFrameData from their rect. It is necessary to do so because the + * containers are not part of line in their levels, which means their + * bounds are not set properly before. + */ +void +nsLineLayout::SyncAnnotationContainersBounds(PerFrameData* aRubyFrame) +{ + MOZ_ASSERT(aRubyFrame->mFrame->GetType() == nsGkAtoms::rubyFrame); + MOZ_ASSERT(aRubyFrame->mSpan); + + PerSpanData* span = aRubyFrame->mSpan; + WritingMode lineWM = mRootSpan->mWritingMode; + nscoord containerWidth = ContainerWidthForSpan(span); + for (PerFrameData* pfd = span->mFirstFrame; pfd; pfd = pfd->mNext) { + for (PerFrameData* annotation = pfd->mNextAnnotation; + annotation; annotation = annotation->mNextAnnotation) { + LogicalRect bounds(lineWM, annotation->mFrame->GetRect(), containerWidth); + annotation->mBounds = bounds; + } + } +} + /** * See if the frame can be placed now that we know it's desired size. * We can always place the frame if the line is empty. Note that we @@ -2639,8 +2665,7 @@ nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD, PerSpanData* psd = aPFD->mSpan; WritingMode lineWM = mRootSpan->mWritingMode; - LogicalRect bounds(lineWM, frame->GetRect(), aContainerWidth); - bounds.IStart(lineWM) += aDeltaICoord; + aPFD->mBounds.IStart(lineWM) += aDeltaICoord; // Check whether this expansion should be counted into the reserved // isize or not. When it is a ruby text container, and it has some @@ -2659,10 +2684,9 @@ nsLineLayout::AdvanceAnnotationInlineBounds(PerFrameData* aPFD, } else { // It is a normal ruby text container. Its children will expand // themselves properly. We only need to expand its own size here. - bounds.ISize(lineWM) += aDeltaISize; + aPFD->mBounds.ISize(lineWM) += aDeltaISize; } - aPFD->mBounds = bounds; - aPFD->mFrame->SetRect(lineWM, bounds, aContainerWidth); + aPFD->mFrame->SetRect(lineWM, aPFD->mBounds, aContainerWidth); } /** diff --git a/layout/generic/nsLineLayout.h b/layout/generic/nsLineLayout.h index 95c91173737..5eb9fff79a6 100644 --- a/layout/generic/nsLineLayout.h +++ b/layout/generic/nsLineLayout.h @@ -646,6 +646,8 @@ protected: void AllowForStartMargin(PerFrameData* pfd, nsHTMLReflowState& aReflowState); + void SyncAnnotationContainersBounds(PerFrameData* aRubyFrame); + bool CanPlaceFrame(PerFrameData* pfd, bool aNotSafeToBreak, bool aFrameCanContinueTextRun, diff --git a/layout/reftests/css-ruby/reftest.list b/layout/reftests/css-ruby/reftest.list index 78843705ef6..e1767c93e5a 100644 --- a/layout/reftests/css-ruby/reftest.list +++ b/layout/reftests/css-ruby/reftest.list @@ -22,6 +22,7 @@ fuzzy-if(winWidget,28,1) == dynamic-removal-3.html dynamic-removal-3-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-span-1.html ruby-span-1-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 diff --git a/layout/reftests/css-ruby/ruby-span-1-ref.html b/layout/reftests/css-ruby/ruby-span-1-ref.html new file mode 100644 index 00000000000..e8b9d91e748 --- /dev/null +++ b/layout/reftests/css-ruby/ruby-span-1-ref.html @@ -0,0 +1,11 @@ + + + + + Bug 1117597 + + + + The Ruby Basespan + + diff --git a/layout/reftests/css-ruby/ruby-span-1.html b/layout/reftests/css-ruby/ruby-span-1.html new file mode 100644 index 00000000000..4862ecc1065 --- /dev/null +++ b/layout/reftests/css-ruby/ruby-span-1.html @@ -0,0 +1,11 @@ + + + + + Bug 1117597 + + + + The Ruby Basespan + +