Bug 1224013 part 2 - Render text-emphasis outside ruby. r=jfkthame

--HG--
extra : source : e725814ae1bb0ccdaf8852eccd3442a9103f7e3a
This commit is contained in:
Xidorn Quan 2015-12-04 15:16:54 +11:00
parent aa54c2e7ff
commit 8e300673ba

View File

@ -52,6 +52,7 @@
#include "nsExpirationTracker.h"
#include "nsUnicodeProperties.h"
#include "nsStyleUtil.h"
#include "nsRubyFrame.h"
#include "nsTextFragment.h"
#include "nsGkAtoms.h"
@ -5155,6 +5156,19 @@ GenerateTextRunForEmphasisMarks(nsTextFrame* aFrame, nsFontMetrics* aFontMetrics
ctx, appUnitsPerDevUnit, flags, nullptr);
}
static nsRubyFrame*
FindRubyAncestor(nsTextFrame* aFrame)
{
for (nsIFrame* frame = aFrame->GetParent();
frame && frame->IsFrameOfType(nsIFrame::eLineParticipant);
frame = frame->GetParent()) {
if (frame->GetType() == nsGkAtoms::rubyFrame) {
return static_cast<nsRubyFrame*>(frame);
}
}
return nullptr;
}
nsRect
nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider)
{
@ -5188,14 +5202,18 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider)
nscoord absOffset = (side == eLogicalSideBStart) != aWM.IsLineInverted() ?
baseFontMetrics->MaxAscent() + fm->MaxDescent() :
baseFontMetrics->MaxDescent() + fm->MaxAscent();
// XXX emphasis marks should be drawn outside ruby, see bug 1224013.
nscoord startLeading = 0;
nscoord endLeading = 0;
if (nsRubyFrame* ruby = FindRubyAncestor(this)) {
ruby->GetBlockLeadings(startLeading, endLeading);
}
if (side == eLogicalSideBStart) {
info->baselineOffset = -absOffset;
overflowRect.BStart(aWM) = -overflowRect.BSize(aWM);
info->baselineOffset = -absOffset - startLeading;
overflowRect.BStart(aWM) = -overflowRect.BSize(aWM) - startLeading;
} else {
MOZ_ASSERT(side == eLogicalSideBEnd);
info->baselineOffset = absOffset;
overflowRect.BStart(aWM) = frameSize.BSize(aWM);
info->baselineOffset = absOffset + endLeading;
overflowRect.BStart(aWM) = frameSize.BSize(aWM) + endLeading;
}
Properties().Set(EmphasisMarkProperty(), info);