mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 764996 - Determine directionality. r=karlt
This commit is contained in:
parent
405d8678b1
commit
533bbe8811
@ -296,9 +296,6 @@ struct nsPresentationData {
|
||||
// This bit is set if the frame is "space-like", as defined by the spec.
|
||||
#define NS_MATHML_SPACE_LIKE 0x00000040U
|
||||
|
||||
// This bit is set if the directionality of the frame is right-to-left
|
||||
#define NS_MATHML_RTL 0x00000080U
|
||||
|
||||
// This bit is set when the frame cannot be formatted due to an
|
||||
// error (e.g., invalid markup such as a <msup> without an overscript).
|
||||
// When set, a visual feedback will be provided to the user.
|
||||
@ -333,9 +330,6 @@ struct nsPresentationData {
|
||||
#define NS_MATHML_IS_SPACE_LIKE(_flags) \
|
||||
(NS_MATHML_SPACE_LIKE == ((_flags) & NS_MATHML_SPACE_LIKE))
|
||||
|
||||
#define NS_MATHML_IS_RTL(_flags) \
|
||||
(NS_MATHML_RTL == ((_flags) & NS_MATHML_RTL))
|
||||
|
||||
#define NS_MATHML_HAS_ERROR(_flags) \
|
||||
(NS_MATHML_ERROR == ((_flags) & NS_MATHML_ERROR))
|
||||
|
||||
|
@ -416,7 +416,7 @@ nsMathMLContainerFrame::Stretch(nsRenderingContext& aRenderingContext,
|
||||
aDesiredStretchSize.width = mBoundingMetrics.width;
|
||||
aDesiredStretchSize.mBoundingMetrics.width = mBoundingMetrics.width;
|
||||
|
||||
nscoord dx = (NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
nscoord dx = (StyleVisibility()->mDirection ?
|
||||
coreData.trailingSpace : coreData.leadingSpace);
|
||||
if (dx != 0) {
|
||||
mBoundingMetrics.leftBearing += dx;
|
||||
@ -1173,7 +1173,7 @@ public:
|
||||
mX(0),
|
||||
mCarrySpace(0),
|
||||
mFromFrameType(eMathMLFrameType_UNKNOWN),
|
||||
mRTL(NS_MATHML_IS_RTL(aParentFrame->mPresentationData.flags))
|
||||
mRTL(aParentFrame->StyleVisibility()->mDirection)
|
||||
{
|
||||
if (!mRTL) {
|
||||
mChildFrame = aParentFrame->mFrames.FirstChild();
|
||||
|
@ -162,7 +162,7 @@ public:
|
||||
nscoord
|
||||
MirrorIfRTL(nscoord aParentWidth, nscoord aChildWidth, nscoord aChildLeading)
|
||||
{
|
||||
return (NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
return (StyleVisibility()->mDirection ?
|
||||
aParentWidth - aChildWidth - aChildLeading : aChildLeading);
|
||||
}
|
||||
|
||||
|
@ -57,37 +57,6 @@ nsMathMLFrame::FindAttrDisplaystyle(nsIContent* aContent,
|
||||
// no reset if the attr isn't found. so be sure to call it on inherited flags
|
||||
}
|
||||
|
||||
// snippet of code used by the tags where the dir attribute is allowed.
|
||||
/* static */ void
|
||||
nsMathMLFrame::FindAttrDirectionality(nsIContent* aContent,
|
||||
nsPresentationData& aPresentationData)
|
||||
{
|
||||
NS_ASSERTION(aContent->Tag() == nsGkAtoms::math ||
|
||||
aContent->Tag() == nsGkAtoms::mrow_ ||
|
||||
aContent->Tag() == nsGkAtoms::mstyle_ ||
|
||||
aContent->Tag() == nsGkAtoms::mi_ ||
|
||||
aContent->Tag() == nsGkAtoms::mn_ ||
|
||||
aContent->Tag() == nsGkAtoms::mo_ ||
|
||||
aContent->Tag() == nsGkAtoms::mtext_ ||
|
||||
aContent->Tag() == nsGkAtoms::ms_, "bad caller");
|
||||
|
||||
static nsIContent::AttrValuesArray strings[] =
|
||||
{&nsGkAtoms::ltr, &nsGkAtoms::rtl, nullptr};
|
||||
|
||||
// see if the explicit dir attribute is there
|
||||
switch (aContent->FindAttrValueIn(kNameSpaceID_None,
|
||||
nsGkAtoms::dir, strings, eCaseMatters))
|
||||
{
|
||||
case 0:
|
||||
aPresentationData.flags &= ~NS_MATHML_RTL;
|
||||
break;
|
||||
case 1:
|
||||
aPresentationData.flags |= NS_MATHML_RTL;
|
||||
break;
|
||||
}
|
||||
// no reset if the attr isn't found. so be sure to call it on inherited flags
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent)
|
||||
{
|
||||
@ -108,9 +77,6 @@ nsMathMLFrame::InheritAutomaticData(nsIFrame* aParent)
|
||||
if (NS_MATHML_IS_DISPLAYSTYLE(parentData.flags)) {
|
||||
mPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
|
||||
}
|
||||
if (NS_MATHML_IS_RTL(parentData.flags)) {
|
||||
mPresentationData.flags |= NS_MATHML_RTL;
|
||||
}
|
||||
|
||||
#if defined(DEBUG) && defined(SHOW_BOUNDING_BOX)
|
||||
mPresentationData.flags |= NS_MATHML_SHOW_BOUNDING_METRICS;
|
||||
@ -228,7 +194,6 @@ nsMathMLFrame::GetPresentationDataFrom(nsIFrame* aFrame,
|
||||
aPresentationData.flags |= NS_MATHML_DISPLAYSTYLE;
|
||||
}
|
||||
FindAttrDisplaystyle(content, aPresentationData);
|
||||
FindAttrDirectionality(content, aPresentationData);
|
||||
aPresentationData.mstyle = frame->GetFirstContinuation();
|
||||
break;
|
||||
}
|
||||
|
@ -136,11 +136,6 @@ public:
|
||||
FindAttrDisplaystyle(nsIContent* aContent,
|
||||
nsPresentationData& aPresentationData);
|
||||
|
||||
// helper used to see if an element has a dir attribute
|
||||
static void
|
||||
FindAttrDirectionality(nsIContent* aContent,
|
||||
nsPresentationData& aPresentationData);
|
||||
|
||||
// helper to check if a content has an attribute. If content is nullptr or if
|
||||
// the attribute is not there, check if the attribute is on the mstyle hierarchy
|
||||
// @return true --if attribute exists
|
||||
|
@ -32,12 +32,6 @@ nsMathMLTokenFrame::InheritAutomaticData(nsIFrame* aParent)
|
||||
// let the base class get the default from our parent
|
||||
nsMathMLContainerFrame::InheritAutomaticData(aParent);
|
||||
|
||||
if (mContent->Tag() != nsGkAtoms::mspace_ &&
|
||||
mContent->Tag() != nsGkAtoms::annotation_) {
|
||||
// see if the directionality attribute is there
|
||||
nsMathMLFrame::FindAttrDirectionality(mContent, mPresentationData);
|
||||
}
|
||||
|
||||
ProcessTextData();
|
||||
|
||||
return NS_OK;
|
||||
|
@ -200,8 +200,7 @@ nsMathMLmencloseFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
nsRect rect;
|
||||
mMathMLChar[mRadicalCharIndex].GetRect(rect);
|
||||
rect.MoveBy(NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
-mContentWidth : rect.width, 0);
|
||||
rect.MoveBy(StyleVisibility()->mDirection ? -mContentWidth : rect.width, 0);
|
||||
rect.SizeTo(mContentWidth, mRuleThickness);
|
||||
DisplayBar(aBuilder, this, rect, aLists);
|
||||
}
|
||||
@ -464,8 +463,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
///////////////
|
||||
// radical notation:
|
||||
if (IsToDraw(NOTATION_RADICAL)) {
|
||||
nscoord *dx_leading =
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags) ? &dx_right : &dx_left;
|
||||
nscoord *dx_leading = StyleVisibility()->mDirection ? &dx_right : &dx_left;
|
||||
|
||||
if (aWidthOnly) {
|
||||
nscoord radical_width = mMathMLChar[mRadicalCharIndex].
|
||||
@ -485,7 +483,7 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
NS_STRETCH_DIRECTION_VERTICAL,
|
||||
contSize, bmRadicalChar,
|
||||
NS_STRETCH_LARGER,
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags));
|
||||
StyleVisibility()->mDirection);
|
||||
mMathMLChar[mRadicalCharIndex].GetBoundingMetrics(bmRadicalChar);
|
||||
|
||||
// Update horizontal parameters
|
||||
@ -604,8 +602,8 @@ nsMathMLmencloseFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
bmLongdivChar.descent));
|
||||
|
||||
if (IsToDraw(NOTATION_RADICAL)) {
|
||||
nscoord dx = NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
dx_left + bmBase.width : dx_left - bmRadicalChar.width;
|
||||
nscoord dx = (StyleVisibility()->mDirection ?
|
||||
dx_left + bmBase.width : dx_left - bmRadicalChar.width);
|
||||
|
||||
mMathMLChar[mRadicalCharIndex].SetRect(nsRect(dx,
|
||||
aDesiredSize.ascent -
|
||||
|
@ -317,7 +317,7 @@ nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
|
||||
containerSize.ascent = delta + axisHeight;
|
||||
containerSize.descent = delta - axisHeight;
|
||||
|
||||
bool isRTL = NS_MATHML_IS_RTL(mPresentationData.flags);
|
||||
bool isRTL = StyleVisibility()->mDirection;
|
||||
|
||||
/////////////////
|
||||
// opening fence ...
|
||||
|
@ -240,11 +240,9 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
// container (we fetch values from the core since they may use units that
|
||||
// depend on style data, and style changes could have occurred in the
|
||||
// core since our last visit there)
|
||||
nscoord leftSpace = std::max(onePixel,
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
nscoord leftSpace = std::max(onePixel, StyleVisibility()->mDirection ?
|
||||
coreData.trailingSpace : coreData.leadingSpace);
|
||||
nscoord rightSpace = std::max(onePixel,
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
nscoord rightSpace = std::max(onePixel, StyleVisibility()->mDirection ?
|
||||
coreData.leadingSpace : coreData.trailingSpace);
|
||||
|
||||
//////////////////
|
||||
@ -456,7 +454,7 @@ nsMathMLmfracFrame::PlaceInternal(nsRenderingContext& aRenderingContext,
|
||||
}
|
||||
|
||||
// Set horizontal bounding metrics
|
||||
if (NS_MATHML_IS_RTL(mPresentationData.flags)) {
|
||||
if (StyleVisibility()->mDirection) {
|
||||
mBoundingMetrics.leftBearing = trailingSpace + bmDen.leftBearing;
|
||||
mBoundingMetrics.rightBearing = trailingSpace + bmDen.width + mLineRect.width + bmNum.rightBearing;
|
||||
} else {
|
||||
@ -595,5 +593,5 @@ nsMathMLmfracFrame::DisplaySlash(nsDisplayListBuilder* aBuilder,
|
||||
|
||||
aLists.Content()->AppendNewToTop(new (aBuilder)
|
||||
nsDisplayMathMLSlash(aBuilder, aFrame, aRect, aThickness,
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags)));
|
||||
StyleVisibility()->mDirection));
|
||||
}
|
||||
|
@ -751,8 +751,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
|
||||
nsresult res = mMathMLChar.Stretch(PresContext(), aRenderingContext,
|
||||
aStretchDirection, container, charSize,
|
||||
stretchHint,
|
||||
NS_MATHML_IS_RTL(mPresentationData.
|
||||
flags));
|
||||
StyleVisibility()->mDirection);
|
||||
if (NS_FAILED(res)) {
|
||||
// gracefully handle cases where stretching the char failed (i.e., GetBoundingMetrics failed)
|
||||
// clear our 'form' to behave as if the operator wasn't in the dictionary
|
||||
@ -876,7 +875,7 @@ nsMathMLmoFrame::Stretch(nsRenderingContext& aRenderingContext,
|
||||
aDesiredStretchSize.width = mBoundingMetrics.width;
|
||||
aDesiredStretchSize.mBoundingMetrics.width = mBoundingMetrics.width;
|
||||
|
||||
nscoord dx = (NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
nscoord dx = (StyleVisibility()->mDirection ?
|
||||
trailingSpace : leadingSpace);
|
||||
if (dx) {
|
||||
// adjust the offsets
|
||||
|
@ -417,14 +417,14 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||
// attributes, tweak our metrics and move children to achieve the desired visual
|
||||
// effects.
|
||||
|
||||
if ((NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
if ((StyleVisibility()->mDirection ?
|
||||
mWidthSign : mLeadingSpaceSign) != NS_MATHML_SIGN_INVALID) {
|
||||
// there was padding on the left. dismiss the left italic correction now
|
||||
// (so that our parent won't correct us)
|
||||
mBoundingMetrics.leftBearing = 0;
|
||||
}
|
||||
|
||||
if ((NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
if ((StyleVisibility()->mDirection ?
|
||||
mLeadingSpaceSign : mWidthSign) != NS_MATHML_SIGN_INVALID) {
|
||||
// there was padding on the right. dismiss the right italic correction now
|
||||
// (so that our parent won't correct us)
|
||||
@ -433,8 +433,8 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext,
|
||||
}
|
||||
|
||||
nscoord dy = height - mBoundingMetrics.ascent;
|
||||
nscoord dx = NS_MATHML_IS_RTL(mPresentationData.flags) ?
|
||||
width - initialWidth - lspace : lspace;
|
||||
nscoord dx = (StyleVisibility()->mDirection ?
|
||||
width - initialWidth - lspace : lspace);
|
||||
|
||||
aDesiredSize.ascent += dy;
|
||||
aDesiredSize.width = mBoundingMetrics.width;
|
||||
|
@ -271,7 +271,7 @@ nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
|
||||
NS_STRETCH_DIRECTION_VERTICAL,
|
||||
contSize, radicalSize,
|
||||
NS_STRETCH_LARGER,
|
||||
NS_MATHML_IS_RTL(mPresentationData.flags));
|
||||
StyleVisibility()->mDirection);
|
||||
// radicalSize have changed at this point, and should match with
|
||||
// the bounding metrics of the char
|
||||
mSqrChar.GetBoundingMetrics(bmSqr);
|
||||
|
@ -35,11 +35,6 @@ nsMathMLmrowFrame::InheritAutomaticData(nsIFrame* aParent)
|
||||
|
||||
mPresentationData.flags |= NS_MATHML_STRETCH_ALL_CHILDREN_VERTICALLY;
|
||||
|
||||
if (mContent->Tag() == nsGkAtoms::mrow_) {
|
||||
// see if the directionality attribute is there
|
||||
nsMathMLFrame::FindAttrDirectionality(mContent, mPresentationData);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,6 @@ nsMathMLmstyleFrame::InheritAutomaticData(nsIFrame* aParent)
|
||||
// see if the displaystyle attribute is there
|
||||
nsMathMLFrame::FindAttrDisplaystyle(mContent, mPresentationData);
|
||||
|
||||
// see if the directionality attribute is there
|
||||
nsMathMLFrame::FindAttrDirectionality(mContent, mPresentationData);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user