Bug 1157951 patch 1 - Rename fields and variables in nsCharClipDisplayItem etc using VisIStart/End instead of left/right. r=roc

This commit is contained in:
Jonathan Kew 2015-04-29 08:18:53 +01:00
Родитель 6fb015cbfb
Коммит ed4f94f6c0
9 изменённых файлов: 113 добавлений и 102 удалений

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

@ -5539,8 +5539,8 @@ nsCharClipDisplayItem::ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
bool snap;
nsRect newRect = geometry->mBounds;
nsRect oldRect = GetBounds(aBuilder, &snap);
if (mLeftEdge != geometry->mLeftEdge ||
mRightEdge != geometry->mRightEdge ||
if (mVisIStartEdge != geometry->mVisIStartEdge ||
mVisIEndEdge != geometry->mVisIEndEdge ||
!oldRect.IsEqualInterior(newRect) ||
!geometry->mBorderRect.IsEqualInterior(GetBorderRect())) {
aInvalidRegion->Or(oldRect, newRect);

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

@ -3595,11 +3595,12 @@ private:
};
/**
* This class adds basic support for limiting the rendering to the part inside
* the specified edges. It's a base class for the display item classes that
* does the actual work. The two members, mLeftEdge and mRightEdge, are
* relative to the edges of the frame's scrollable overflow rectangle and is
* the amount to suppress on each side.
* This class adds basic support for limiting the rendering (in the inline axis
* of the writing mode) to the part inside the specified edges. It's a base
* class for the display item classes that do the actual work.
* The two members, mVisIStartEdge and mVisIEndEdge, are relative to the edges
* of the frame's scrollable overflow rectangle and are the amount to suppress
* on each side.
*
* Setting none, both or only one edge is allowed.
* The values must be non-negative.
@ -3608,7 +3609,7 @@ private:
class nsCharClipDisplayItem : public nsDisplayItem {
public:
nsCharClipDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame), mLeftEdge(0), mRightEdge(0) {}
: nsDisplayItem(aBuilder, aFrame), mVisIStartEdge(0), mVisIEndEdge(0) {}
explicit nsCharClipDisplayItem(nsIFrame* aFrame)
: nsDisplayItem(aFrame) {}
@ -3621,22 +3622,25 @@ public:
struct ClipEdges {
ClipEdges(const nsDisplayItem& aItem,
nscoord aLeftEdge, nscoord aRightEdge) {
nscoord aVisIStartEdge, nscoord aVisIEndEdge) {
nsRect r = aItem.Frame()->GetScrollableOverflowRect() +
aItem.ToReferenceFrame();
mX = aLeftEdge > 0 ? r.x + aLeftEdge : nscoord_MIN;
mXMost = aRightEdge > 0 ? std::max(r.XMost() - aRightEdge, mX) : nscoord_MAX;
mVisIStart = aVisIStartEdge > 0 ? r.x + aVisIStartEdge : nscoord_MIN;
mVisIEnd = aVisIEndEdge > 0
? std::max(r.XMost() - aVisIEndEdge, mVisIStart) : nscoord_MAX;
}
void Intersect(nscoord* aX, nscoord* aWidth) const {
nscoord xmost1 = *aX + *aWidth;
*aX = std::max(*aX, mX);
*aWidth = std::max(std::min(xmost1, mXMost) - *aX, 0);
void Intersect(nscoord* aVisIStart, nscoord* aVisISize) const {
nscoord end = *aVisIStart + *aVisISize;
*aVisIStart = std::max(*aVisIStart, mVisIStart);
*aVisISize = std::max(std::min(end, mVisIEnd) - *aVisIStart, 0);
}
nscoord mX;
nscoord mXMost;
nscoord mVisIStart;
nscoord mVisIEnd;
};
ClipEdges Edges() const { return ClipEdges(*this, mLeftEdge, mRightEdge); }
ClipEdges Edges() const {
return ClipEdges(*this, mVisIStartEdge, mVisIEndEdge);
}
static nsCharClipDisplayItem* CheckCast(nsDisplayItem* aItem) {
nsDisplayItem::Type t = aItem->GetType();
@ -3646,8 +3650,11 @@ public:
? static_cast<nsCharClipDisplayItem*>(aItem) : nullptr;
}
nscoord mLeftEdge; // length from the left side
nscoord mRightEdge; // length from the right side
// Lengths measured from the visual inline start and end sides
// (i.e. left and right respectively in horizontal writing modes,
// regardless of bidi directionality; top and bottom in vertical modes).
nscoord mVisIStartEdge;
nscoord mVisIEndEdge;
};
/**

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

@ -118,8 +118,8 @@ nsDisplaySVGEffectsGeometry::MoveBy(const nsPoint& aOffset)
nsCharClipGeometry::nsCharClipGeometry(nsCharClipDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
: nsDisplayItemGenericGeometry(aItem, aBuilder)
, mLeftEdge(aItem->mLeftEdge)
, mRightEdge(aItem->mRightEdge)
, mVisIStartEdge(aItem->mVisIStartEdge)
, mVisIEndEdge(aItem->mVisIEndEdge)
{}
nsDisplayTableItemGeometry::nsDisplayTableItemGeometry(nsDisplayTableItem* aItem,

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

@ -255,8 +255,8 @@ class nsCharClipGeometry : public nsDisplayItemGenericGeometry
public:
nsCharClipGeometry(nsCharClipDisplayItem* aItem, nsDisplayListBuilder* aBuilder);
nscoord mLeftEdge;
nscoord mRightEdge;
nscoord mVisIStartEdge;
nscoord mVisIEndEdge;
};
class nsDisplayTableItemGeometry

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

@ -687,14 +687,14 @@ TextOverflow::PruneDisplayListContents(nsDisplayList* aList,
aInsideMarkersArea.IStart(mBlockWM) - rect.IStart(mBlockWM);
if (istart > 0) {
(mBlockWM.IsBidiLTR() ?
charClip->mLeftEdge : charClip->mRightEdge) = istart;
charClip->mVisIStartEdge : charClip->mVisIEndEdge) = istart;
}
}
if (mIEnd.IsNeeded()) {
nscoord iend = rect.IEnd(mBlockWM) - aInsideMarkersArea.IEnd(mBlockWM);
if (iend > 0) {
(mBlockWM.IsBidiLTR() ?
charClip->mRightEdge : charClip->mLeftEdge) = iend;
charClip->mVisIEndEdge : charClip->mVisIStartEdge) = iend;
}
}
}

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

@ -184,8 +184,8 @@ class TextOverflow {
/**
* Clip or remove items given the final marker edges. ("clip" here just means
* assigning mLeftEdge/mRightEdge for any nsCharClipDisplayItem that needs it,
* see nsDisplayList.h for a description of that item).
* assigning mVisIStartEdge/mVisIEndEdge for any nsCharClipDisplayItem that
* needs it; see nsDisplayList.h for a description of that item).
* @param aFramesToHide remove display items for these frames
* @param aInsideMarkersArea is the area inside the markers
*/

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

@ -4629,8 +4629,8 @@ public:
nsRect newRect = geometry->mBounds;
nsRect oldRect = GetBounds(aBuilder, &snap);
if (decorations != geometry->mDecorations ||
mLeftEdge != geometry->mLeftEdge ||
mRightEdge != geometry->mRightEdge ||
mVisIStartEdge != geometry->mVisIStartEdge ||
mVisIEndEdge != geometry->mVisIEndEdge ||
!oldRect.IsEqualInterior(newRect) ||
!geometry->mBorderRect.IsEqualInterior(GetBorderRect())) {
aInvalidRegion->Or(oldRect, newRect);
@ -4672,8 +4672,8 @@ nsDisplayText::Paint(nsDisplayListBuilder* aBuilder,
ctx->Rectangle(pixelVisible);
ctx->Clip();
NS_ASSERTION(mLeftEdge >= 0, "illegal left edge");
NS_ASSERTION(mRightEdge >= 0, "illegal right edge");
NS_ASSERTION(mVisIStartEdge >= 0, "illegal start edge");
NS_ASSERTION(mVisIEndEdge >= 0, "illegal end edge");
f->PaintText(aCtx, ToReferenceFrame(), extraVisible, *this);
}
@ -5744,13 +5744,13 @@ nsTextFrame::PaintTextWithSelectionColors(gfxContext* aCtx,
nsCSSShadowArray* shadow = textStyle->GetTextShadow();
GetSelectionTextShadow(this, type, aTextPaintStyle, &shadow);
if (shadow) {
nscoord leftEdge = iOffset;
nscoord startEdge = iOffset;
if (mTextRun->IsRightToLeft()) {
leftEdge -= mTextRun->GetAdvanceWidth(offset, length, &aProvider) +
startEdge -= mTextRun->GetAdvanceWidth(offset, length, &aProvider) +
hyphenWidth;
}
PaintShadows(shadow, offset, length, dirtyRect, aFramePt, textBaselinePt,
leftEdge, aProvider, foreground, aClipEdges, aCtx);
startEdge, aProvider, foreground, aClipEdges, aCtx);
}
// Draw text segment
@ -5972,9 +5972,10 @@ ComputeTransformedLength(PropertyProvider& aProvider)
}
bool
nsTextFrame::MeasureCharClippedText(nscoord aLeftEdge, nscoord aRightEdge,
nscoord* aSnappedLeftEdge,
nscoord* aSnappedRightEdge)
nsTextFrame::MeasureCharClippedText(nscoord aVisIStartEdge,
nscoord aVisIEndEdge,
nscoord* aSnappedStartEdge,
nscoord* aSnappedEndEdge)
{
// We need a *reference* rendering context (not one that might have a
// transform), so we don't have a rendering context argument.
@ -5989,9 +5990,9 @@ nsTextFrame::MeasureCharClippedText(nscoord aLeftEdge, nscoord aRightEdge,
uint32_t startOffset = provider.GetStart().GetSkippedOffset();
uint32_t maxLength = ComputeTransformedLength(provider);
return MeasureCharClippedText(provider, aLeftEdge, aRightEdge,
return MeasureCharClippedText(provider, aVisIStartEdge, aVisIEndEdge,
&startOffset, &maxLength,
aSnappedLeftEdge, aSnappedRightEdge);
aSnappedStartEdge, aSnappedEndEdge);
}
static uint32_t GetClusterLength(gfxTextRun* aTextRun,
@ -6014,15 +6015,16 @@ static uint32_t GetClusterLength(gfxTextRun* aTextRun,
bool
nsTextFrame::MeasureCharClippedText(PropertyProvider& aProvider,
nscoord aLeftEdge, nscoord aRightEdge,
nscoord aVisIStartEdge,
nscoord aVisIEndEdge,
uint32_t* aStartOffset,
uint32_t* aMaxLength,
nscoord* aSnappedLeftEdge,
nscoord* aSnappedRightEdge)
nscoord* aSnappedStartEdge,
nscoord* aSnappedEndEdge)
{
*aSnappedLeftEdge = 0;
*aSnappedRightEdge = 0;
if (aLeftEdge <= 0 && aRightEdge <= 0) {
*aSnappedStartEdge = 0;
*aSnappedEndEdge = 0;
if (aVisIStartEdge <= 0 && aVisIEndEdge <= 0) {
return true;
}
@ -6031,7 +6033,7 @@ nsTextFrame::MeasureCharClippedText(PropertyProvider& aProvider,
const nscoord frameISize = ISize();
const bool rtl = mTextRun->IsRightToLeft();
gfxFloat advanceWidth = 0;
const nscoord startEdge = rtl ? aRightEdge : aLeftEdge;
const nscoord startEdge = rtl ? aVisIEndEdge : aVisIStartEdge;
if (startEdge > 0) {
const gfxFloat maxAdvance = gfxFloat(startEdge);
while (maxLength > 0) {
@ -6045,12 +6047,12 @@ nsTextFrame::MeasureCharClippedText(PropertyProvider& aProvider,
break;
}
}
nscoord* snappedStartEdge = rtl ? aSnappedRightEdge : aSnappedLeftEdge;
nscoord* snappedStartEdge = rtl ? aSnappedEndEdge : aSnappedStartEdge;
*snappedStartEdge = NSToCoordFloor(advanceWidth);
*aStartOffset = offset;
}
const nscoord endEdge = rtl ? aLeftEdge : aRightEdge;
const nscoord endEdge = rtl ? aVisIStartEdge : aVisIEndEdge;
if (endEdge > 0) {
const gfxFloat maxAdvance = gfxFloat(frameISize - endEdge);
while (maxLength > 0) {
@ -6067,7 +6069,7 @@ nsTextFrame::MeasureCharClippedText(PropertyProvider& aProvider,
offset += clusterLength;
}
maxLength = offset - *aStartOffset;
nscoord* snappedEndEdge = rtl ? aSnappedLeftEdge : aSnappedRightEdge;
nscoord* snappedEndEdge = rtl ? aSnappedStartEdge : aSnappedEndEdge;
*snappedEndEdge = NSToCoordFloor(gfxFloat(frameISize) - advanceWidth);
}
*aMaxLength = maxLength;
@ -6178,18 +6180,18 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
}
uint32_t startOffset = provider.GetStart().GetSkippedOffset();
uint32_t maxLength = ComputeTransformedLength(provider);
nscoord snappedLeftEdge, snappedRightEdge;
if (!MeasureCharClippedText(provider, aItem.mLeftEdge, aItem.mRightEdge,
&startOffset, &maxLength, &snappedLeftEdge, &snappedRightEdge)) {
nscoord snappedStartEdge, snappedEndEdge;
if (!MeasureCharClippedText(provider, aItem.mVisIStartEdge, aItem.mVisIEndEdge,
&startOffset, &maxLength, &snappedStartEdge, &snappedEndEdge)) {
return;
}
if (verticalRun) {
textBaselinePt.y += rtl ? -snappedRightEdge : snappedLeftEdge;
textBaselinePt.y += rtl ? -snappedEndEdge : snappedStartEdge;
} else {
textBaselinePt.x += rtl ? -snappedRightEdge : snappedLeftEdge;
textBaselinePt.x += rtl ? -snappedEndEdge : snappedStartEdge;
}
nsCharClipDisplayItem::ClipEdges clipEdges(aItem, snappedLeftEdge,
snappedRightEdge);
nsCharClipDisplayItem::ClipEdges clipEdges(aItem, snappedStartEdge,
snappedEndEdge);
nsTextPaintStyle textPaintStyle(this);
textPaintStyle.SetResolveColors(!aCallbacks);
@ -6213,7 +6215,7 @@ nsTextFrame::PaintText(nsRenderingContext* aRenderingContext, nsPoint aPt,
if (!aCallbacks) {
const nsStyleText* textStyle = StyleText();
PaintShadows(textStyle->mTextShadow, startOffset, maxLength,
aDirtyRect, framePt, textBaselinePt, snappedLeftEdge, provider,
aDirtyRect, framePt, textBaselinePt, snappedStartEdge, provider,
foregroundColor, clipEdges, ctx);
}

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

@ -273,15 +273,15 @@ public:
/**
* Calculate the horizontal bounds of the grapheme clusters that fit entirely
* inside the given left/right edges (which are positive lengths from the
* respective frame edge). If an input value is zero it is ignored and the
* result for that edge is zero. All out parameter values are undefined when
* the method returns false.
* inside the given left[top]/right[bottom] edges (which are positive lengths
* from the respective frame edge). If an input value is zero it is ignored
* and the result for that edge is zero. All out parameter values are
* undefined when the method returns false.
* @return true if at least one whole grapheme cluster fit between the edges
*/
bool MeasureCharClippedText(nscoord aLeftEdge, nscoord aRightEdge,
nscoord* aSnappedLeftEdge,
nscoord* aSnappedRightEdge);
bool MeasureCharClippedText(nscoord aVisIStartEdge, nscoord aVisIEndEdge,
nscoord* aSnappedStartEdge,
nscoord* aSnappedEndEdge);
/**
* Same as above; this method also the returns the corresponding text run
* offset and number of characters that fit. All out parameter values are
@ -289,10 +289,10 @@ public:
* @return true if at least one whole grapheme cluster fit between the edges
*/
bool MeasureCharClippedText(PropertyProvider& aProvider,
nscoord aLeftEdge, nscoord aRightEdge,
nscoord aVisIStartEdge, nscoord aVisIEndEdge,
uint32_t* aStartOffset, uint32_t* aMaxLength,
nscoord* aSnappedLeftEdge,
nscoord* aSnappedRightEdge);
nscoord* aSnappedStartEdge,
nscoord* aSnappedEndEdge);
/**
* Object with various callbacks for PaintText() to invoke for different parts

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

@ -733,7 +733,7 @@ struct TextRenderedRun
* a selection mechanism for which glyphs will be painted, rather
* than a geometric clip.
*/
void GetClipEdges(nscoord& aLeftEdge, nscoord& aRightEdge) const;
void GetClipEdges(nscoord& aVisIStartEdge, nscoord& aVisIEndEdge) const;
/**
* Returns the advance width of the whole rendered run.
@ -837,12 +837,12 @@ TextRenderedRun::GetTransformFromUserSpaceForPainting(
if (IsVertical()) {
t = nsPoint(-mBaseline,
IsRightToLeft()
? -mFrame->GetRect().height + aItem.mRightEdge
: -aItem.mLeftEdge);
? -mFrame->GetRect().height + aItem.mVisIEndEdge
: -aItem.mVisIStartEdge);
} else {
t = nsPoint(IsRightToLeft()
? -mFrame->GetRect().width + aItem.mRightEdge
: -aItem.mLeftEdge,
? -mFrame->GetRect().width + aItem.mVisIEndEdge
: -aItem.mVisIStartEdge,
-mBaseline);
}
m.Translate(AppUnitsToGfxUnits(t, aContext));
@ -862,8 +862,8 @@ TextRenderedRun::GetTransformFromRunUserSpaceToUserSpace(
float cssPxPerDevPx = aContext->
AppUnitsToFloatCSSPixels(aContext->AppUnitsPerDevPixel());
nscoord left, right;
GetClipEdges(left, right);
nscoord start, end;
GetClipEdges(start, end);
// Glyph position in user space.
m.Translate(mPosition);
@ -879,11 +879,11 @@ TextRenderedRun::GetTransformFromRunUserSpaceToUserSpace(
if (IsVertical()) {
t = nsPoint(-mBaseline,
IsRightToLeft()
? -mFrame->GetRect().height + left + right
? -mFrame->GetRect().height + start + end
: 0);
} else {
t = nsPoint(IsRightToLeft()
? -mFrame->GetRect().width + left + right
? -mFrame->GetRect().width + start + end
: 0,
-mBaseline);
}
@ -902,14 +902,14 @@ TextRenderedRun::GetTransformFromRunUserSpaceToFrameUserSpace(
return m;
}
nscoord left, right;
GetClipEdges(left, right);
nscoord start, end;
GetClipEdges(start, end);
// Translate by the horizontal distance into the text frame this
// rendered run is.
gfxFloat appPerCssPx = aContext->AppUnitsPerCSSPixel();
gfxPoint t = IsVertical() ? gfxPoint(0, left / appPerCssPx)
: gfxPoint(left / appPerCssPx, 0);
gfxPoint t = IsVertical() ? gfxPoint(0, start / appPerCssPx)
: gfxPoint(start / appPerCssPx, 0);
return m.Translate(t);
}
@ -1041,15 +1041,16 @@ TextRenderedRun::GetUserSpaceRect(nsPresContext* aContext,
}
void
TextRenderedRun::GetClipEdges(nscoord& aLeftEdge, nscoord& aRightEdge) const
TextRenderedRun::GetClipEdges(nscoord& aVisIStartEdge,
nscoord& aVisIEndEdge) const
{
uint32_t contentLength = mFrame->GetContentLength();
if (mTextFrameContentOffset == 0 &&
mTextFrameContentLength == contentLength) {
// If the rendered run covers the entire content, we know we don't need
// to clip without having to measure anything.
aLeftEdge = 0;
aRightEdge = 0;
aVisIStartEdge = 0;
aVisIEndEdge = 0;
return;
}
@ -1079,22 +1080,22 @@ TextRenderedRun::GetClipEdges(nscoord& aLeftEdge, nscoord& aRightEdge) const
// Measure the advance width in the text run between the start of
// frame's content and the start of the rendered run's content,
nscoord leftEdge =
nscoord startEdge =
textRun->GetAdvanceWidth(frameOffset, runOffset - frameOffset, nullptr);
// and between the end of the rendered run's content and the end
// of the frame's content.
nscoord rightEdge =
nscoord endEdge =
textRun->GetAdvanceWidth(runOffset + runLength,
frameOffset + frameLength - (runOffset + runLength),
nullptr);
if (textRun->IsRightToLeft()) {
aLeftEdge = rightEdge;
aRightEdge = leftEdge;
aVisIStartEdge = endEdge;
aVisIEndEdge = startEdge;
} else {
aLeftEdge = leftEdge;
aRightEdge = rightEdge;
aVisIStartEdge = startEdge;
aVisIEndEdge = endEdge;
}
}
@ -2740,7 +2741,7 @@ public:
explicit SVGCharClipDisplayItem(const TextRenderedRun& aRun)
: nsCharClipDisplayItem(aRun.mFrame)
{
aRun.GetClipEdges(mLeftEdge, mRightEdge);
aRun.GetClipEdges(mVisIStartEdge, mVisIEndEdge);
}
NS_DISPLAY_DECL_NAME("SVGText", TYPE_TEXT)
@ -4771,36 +4772,37 @@ ConvertLogicalTextAnchorToPhysical(uint8_t aTextAnchor, bool aIsRightToLeft)
* character's initial position is the anchor point.
* @param aChunkEnd The character index just after the end of the anchored
* chunk.
* @param aLeftEdge The left-most edge of any of the glyphs within the
* anchored chunk.
* @param aRightEdge The right-most edge of any of the glyphs within the
* @param aVisIStartEdge The left/top-most edge of any of the glyphs within the
* anchored chunk.
* @param aVisIEndEdge The right/bottom-most edge of any of the glyphs within
* the anchored chunk.
* @param aAnchorSide The direction to anchor.
*/
static void
ShiftAnchoredChunk(nsTArray<mozilla::CharPosition>& aCharPositions,
uint32_t aChunkStart,
uint32_t aChunkEnd,
gfxFloat aLeftEdge,
gfxFloat aRightEdge,
gfxFloat aVisIStartEdge,
gfxFloat aVisIEndEdge,
TextAnchorSide aAnchorSide,
bool aVertical)
{
NS_ASSERTION(aLeftEdge <= aRightEdge, "unexpected anchored chunk edges");
NS_ASSERTION(aChunkStart < aChunkEnd, "unexpected values for aChunkStart and "
"aChunkEnd");
NS_ASSERTION(aVisIStartEdge <= aVisIEndEdge,
"unexpected anchored chunk edges");
NS_ASSERTION(aChunkStart < aChunkEnd,
"unexpected values for aChunkStart and aChunkEnd");
gfxFloat shift = aVertical ? aCharPositions[aChunkStart].mPosition.y
: aCharPositions[aChunkStart].mPosition.x;
switch (aAnchorSide) {
case eAnchorLeft:
shift -= aLeftEdge;
shift -= aVisIStartEdge;
break;
case eAnchorMiddle:
shift -= (aLeftEdge + aRightEdge) / 2;
shift -= (aVisIStartEdge + aVisIEndEdge) / 2;
break;
case eAnchorRight:
shift -= aRightEdge;
shift -= aVisIEndEdge;
break;
default:
NS_NOTREACHED("unexpected value for aAnchorSide");