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

--HG--
extra : source : 48dcb7fee1a27fe8d925fe59534261635a67928d
This commit is contained in:
Xidorn Quan 2015-12-04 12:02:41 +11:00
Родитель 45ebb9aa0e
Коммит abc8fa2f7d
1 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -52,6 +52,7 @@
#include "nsExpirationTracker.h"
#include "nsUnicodeProperties.h"
#include "nsStyleUtil.h"
#include "nsRubyBaseContainerFrame.h"
#include "nsTextFragment.h"
#include "nsGkAtoms.h"
@ -5155,6 +5156,19 @@ GenerateTextRunForEmphasisMarks(nsTextFrame* aFrame, nsFontMetrics* aFontMetrics
ctx, appUnitsPerDevUnit, flags, nullptr);
}
static nsRubyBaseContainerFrame*
FindRubyBaseContainerAncestor(nsTextFrame* aFrame)
{
for (nsIFrame* frame = aFrame->GetParent();
frame && frame->IsFrameOfType(nsIFrame::eLineParticipant);
frame = frame->GetParent()) {
if (frame->GetType() == nsGkAtoms::rubyBaseContainerFrame) {
return static_cast<nsRubyBaseContainerFrame*>(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 (nsRubyBaseContainerFrame* rbc = FindRubyBaseContainerAncestor(this)) {
rbc->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);