Backed out changeset 3304277f5bde (bug 1553252) for build bustages on Windows on a CLOSED TREE

This commit is contained in:
Oana Pop Rus 2019-05-23 17:52:21 +03:00
parent 84c0d92e4e
commit d020804eba
11 changed files with 178 additions and 56 deletions

View File

@ -152,7 +152,7 @@ class nsDisplayTextOverflowMarker final : public nsPaintedDisplayItem {
public:
nsDisplayTextOverflowMarker(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
const nsRect& aRect, nscoord aAscent,
const StyleTextOverflowSide& aStyle,
nsStyleTextOverflowSide aStyle,
uint32_t aLineNumber, uint16_t aIndex)
: nsPaintedDisplayItem(aBuilder, aFrame),
mRect(aRect),
@ -203,7 +203,7 @@ class nsDisplayTextOverflowMarker final : public nsPaintedDisplayItem {
NS_DISPLAY_DECL_NAME("TextOverflow", TYPE_TEXT_OVERFLOW)
private:
nsRect mRect; // in reference frame coordinates
const StyleTextOverflowSide mStyle;
const nsStyleTextOverflowSide mStyle;
nscoord mAscent; // baseline for the marker text in mRect
uint16_t mIndex;
};
@ -248,7 +248,7 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
}
pt += aOffsetFromRect;
if (mStyle.IsEllipsis()) {
if (mStyle.mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) {
gfxTextRun* textRun = GetEllipsisTextRun(mFrame);
if (textRun) {
NS_ASSERTION(!textRun->IsRightToLeft(),
@ -260,9 +260,8 @@ void nsDisplayTextOverflowMarker::PaintTextToContext(gfxContext* aCtx,
} else {
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetInflatedFontMetricsForFrame(mFrame);
NS_ConvertUTF8toUTF16 str16{mStyle.AsString().AsString()};
nsLayoutUtils::DrawString(mFrame, *fm, aCtx, str16.get(), str16.Length(),
pt);
nsLayoutUtils::DrawString(mFrame, *fm, aCtx, mStyle.mString.get(),
mStyle.mString.Length(), pt);
}
}
@ -331,21 +330,12 @@ TextOverflow::TextOverflow(nsDisplayListBuilder* aBuilder,
}
uint8_t direction = aBlockFrame->StyleVisibility()->mDirection;
const nsStyleTextReset* style = aBlockFrame->StyleTextReset();
const auto& textOverflow = style->mTextOverflow;
bool shouldToggleDirection =
textOverflow.sides_are_logical && (direction == NS_STYLE_DIRECTION_RTL);
const auto& leftSide =
shouldToggleDirection ? textOverflow.second : textOverflow.first;
const auto& rightSide =
shouldToggleDirection ? textOverflow.first : textOverflow.second;
if (mBlockWM.IsBidiLTR()) {
mIStart.Init(leftSide);
mIEnd.Init(rightSide);
mIStart.Init(style->mTextOverflow.GetLeft(direction));
mIEnd.Init(style->mTextOverflow.GetRight(direction));
} else {
mIStart.Init(rightSide);
mIEnd.Init(leftSide);
mIStart.Init(style->mTextOverflow.GetRight(direction));
mIEnd.Init(style->mTextOverflow.GetLeft(direction));
}
// The left/right marker string is setup in ExamineLineFrames when a line
// has overflow on that side.
@ -702,16 +692,18 @@ LogicalRect TextOverflow::ExamineLineFrames(nsLineBox* aLine,
void TextOverflow::ProcessLine(const nsDisplayListSet& aLists, nsLineBox* aLine,
uint32_t aLineNumber) {
if (mIStart.mStyle->IsClip() && mIEnd.mStyle->IsClip() &&
if (mIStart.mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP &&
mIEnd.mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP &&
!aLine->HasLineClampEllipsis()) {
return;
}
mIStart.Reset();
mIStart.mActive = !mIStart.mStyle->IsClip();
mIStart.mActive = mIStart.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP;
mIEnd.Reset();
mIEnd.mHasBlockEllipsis = aLine->HasLineClampEllipsis();
mIEnd.mActive = !mIEnd.mStyle->IsClip() || aLine->HasLineClampEllipsis();
mIEnd.mActive = mIEnd.mStyle->mType != NS_STYLE_TEXT_OVERFLOW_CLIP ||
aLine->HasLineClampEllipsis();
FrameHashtable framesToHide(64);
AlignmentEdges alignmentEdges;
@ -824,8 +816,8 @@ void TextOverflow::PruneDisplayListContents(
/* static */
bool TextOverflow::HasClippedTextOverflow(nsIFrame* aBlockFrame) {
const nsStyleTextReset* style = aBlockFrame->StyleTextReset();
return style->mTextOverflow.first.IsClip() &&
style->mTextOverflow.second.IsClip();
return style->mTextOverflow.mLeft.mType == NS_STYLE_TEXT_OVERFLOW_CLIP &&
style->mTextOverflow.mRight.mType == NS_STYLE_TEXT_OVERFLOW_CLIP;
}
/* static */
@ -904,7 +896,7 @@ void TextOverflow::CreateMarkers(const nsLineBox* aLine, bool aCreateIStart,
markerRect, clipState);
mMarkerList.AppendNewToTop<nsDisplayTextOverflowMarker>(
mBuilder, mBlock, markerRect, aLine->GetLogicalAscent(),
mIEnd.mHasBlockEllipsis ? StyleTextOverflowSide::Ellipsis()
mIEnd.mHasBlockEllipsis ? nsStyleTextOverflowSide::Ellipsis()
: *mIEnd.mStyle,
aLineNumber, 1);
}
@ -920,7 +912,8 @@ void TextOverflow::Marker::SetupString(nsIFrame* aFrame) {
// don't track the block ellipsis string and the text-overflow marker string
// separately, if both apply to the element, we will always use "…" as the
// string for text-overflow.
if (HasBlockEllipsis(aFrame) || mStyle->IsEllipsis()) {
if (HasBlockEllipsis(aFrame) ||
mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS) {
gfxTextRun* textRun = GetEllipsisTextRun(aFrame);
if (textRun) {
mISize = textRun->GetAdvanceWidth();
@ -932,8 +925,8 @@ void TextOverflow::Marker::SetupString(nsIFrame* aFrame) {
aFrame->PresShell()->CreateReferenceRenderingContext();
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetInflatedFontMetricsForFrame(aFrame);
mISize = nsLayoutUtils::AppUnitWidthOfStringBidi(
NS_ConvertUTF8toUTF16(mStyle->AsString().AsString()), aFrame, *fm, *rc);
mISize = nsLayoutUtils::AppUnitWidthOfStringBidi(mStyle->mString, aFrame,
*fm, *rc);
}
mIntrinsicISize = mISize;
mInitialized = true;

View File

@ -250,7 +250,7 @@ class TextOverflow final {
class Marker {
public:
void Init(const StyleTextOverflowSide& aStyle) {
void Init(const nsStyleTextOverflowSide& aStyle) {
mInitialized = false;
mISize = 0;
mStyle = &aStyle;
@ -267,7 +267,7 @@ class TextOverflow final {
void SetupString(nsIFrame* aFrame);
bool IsSuppressed() const {
return !mHasBlockEllipsis && mStyle->IsClip();
return !mHasBlockEllipsis && mStyle->mType == NS_STYLE_TEXT_OVERFLOW_CLIP;
}
bool IsNeeded() const { return mHasOverflow || mHasBlockEllipsis; }
void Reset() {
@ -282,7 +282,7 @@ class TextOverflow final {
nscoord mIntrinsicISize;
// The text-overflow style for this side. Ignored if we're rendering a
// block ellipsis.
const StyleTextOverflowSide* mStyle;
const nsStyleTextOverflowSide* mStyle;
// True if there is visible overflowing inline content on this side.
bool mHasOverflow;
// True if this side has a block ellipsis (from -webkit-line-clamp).

View File

@ -427,7 +427,6 @@ cbindgen-types = [
{ gecko = "StyleFloat", servo = "values::computed::Float" },
{ gecko = "StyleOverscrollBehavior", servo = "values::computed::OverscrollBehavior" },
{ gecko = "StyleTextAlign", servo = "values::computed::TextAlign" },
{ gecko = "StyleTextOverflow", servo = "values::computed::TextOverflow" },
{ gecko = "StyleOverflow", servo = "values::computed::Overflow" },
{ gecko = "StyleOverflowAnchor", servo = "values::computed::OverflowAnchor" },
{ gecko = "StyleLength", servo = "values::computed::CSSPixelLength" },

View File

@ -376,6 +376,11 @@ const KTableEntry nsCSSProps::kTextEmphasisStyleShapeKTable[] = {
{eCSSKeyword_sesame, NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME},
{eCSSKeyword_UNKNOWN, -1}};
const KTableEntry nsCSSProps::kTextOverflowKTable[] = {
{eCSSKeyword_clip, NS_STYLE_TEXT_OVERFLOW_CLIP},
{eCSSKeyword_ellipsis, NS_STYLE_TEXT_OVERFLOW_ELLIPSIS},
{eCSSKeyword_UNKNOWN, -1}};
// keyword tables for SVG properties
const KTableEntry nsCSSProps::kFilterFunctionKTable[] = {

View File

@ -310,6 +310,7 @@ class nsCSSProps {
static const KTableEntry kTextAlignKTable[];
static const KTableEntry kTextDecorationStyleKTable[];
static const KTableEntry kTextEmphasisStyleShapeKTable[];
static const KTableEntry kTextOverflowKTable[];
};
// MOZ_DBG support for nsCSSPropertyID

View File

@ -551,6 +551,11 @@ enum class StyleGridTrackBreadth : uint8_t {
#define NS_STYLE_TEXT_DECORATION_STYLE_WAVY 5
#define NS_STYLE_TEXT_DECORATION_STYLE_MAX NS_STYLE_TEXT_DECORATION_STYLE_WAVY
// See nsStyleTextOverflow
#define NS_STYLE_TEXT_OVERFLOW_CLIP 0
#define NS_STYLE_TEXT_OVERFLOW_ELLIPSIS 1
#define NS_STYLE_TEXT_OVERFLOW_STRING 2
// See nsStyleText
#define NS_STYLE_TEXT_TRANSFORM_NONE 0
#define NS_STYLE_TEXT_TRANSFORM_CAPITALIZE 1

View File

@ -1247,6 +1247,69 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePosition {
}
};
struct nsStyleTextOverflowSide {
nsStyleTextOverflowSide() : mType(NS_STYLE_TEXT_OVERFLOW_CLIP) {}
static nsStyleTextOverflowSide Ellipsis() {
nsStyleTextOverflowSide side;
side.mType = NS_STYLE_TEXT_OVERFLOW_ELLIPSIS;
return side;
}
bool operator==(const nsStyleTextOverflowSide& aOther) const {
return mType == aOther.mType && (mType != NS_STYLE_TEXT_OVERFLOW_STRING ||
mString == aOther.mString);
}
bool operator!=(const nsStyleTextOverflowSide& aOther) const {
return !(*this == aOther);
}
nsString mString;
uint8_t mType;
};
struct nsStyleTextOverflow {
nsStyleTextOverflow() : mLogicalDirections(true) {}
bool operator==(const nsStyleTextOverflow& aOther) const {
return mLeft == aOther.mLeft && mRight == aOther.mRight;
}
bool operator!=(const nsStyleTextOverflow& aOther) const {
return !(*this == aOther);
}
// Returns the value to apply on the left side.
const nsStyleTextOverflowSide& GetLeft(uint8_t aDirection) const {
NS_ASSERTION(aDirection == NS_STYLE_DIRECTION_LTR ||
aDirection == NS_STYLE_DIRECTION_RTL,
"bad direction");
return !mLogicalDirections || aDirection == NS_STYLE_DIRECTION_LTR ? mLeft
: mRight;
}
// Returns the value to apply on the right side.
const nsStyleTextOverflowSide& GetRight(uint8_t aDirection) const {
NS_ASSERTION(aDirection == NS_STYLE_DIRECTION_LTR ||
aDirection == NS_STYLE_DIRECTION_RTL,
"bad direction");
return !mLogicalDirections || aDirection == NS_STYLE_DIRECTION_LTR ? mRight
: mLeft;
}
// Returns the first value that was specified.
const nsStyleTextOverflowSide* GetFirstValue() const {
return mLogicalDirections ? &mRight : &mLeft;
}
// Returns the second value, or null if there was only one value specified.
const nsStyleTextOverflowSide* GetSecondValue() const {
return mLogicalDirections ? nullptr : &mRight;
}
nsStyleTextOverflowSide mLeft; // start side when mLogicalDirections is true
nsStyleTextOverflowSide mRight; // end side when mLogicalDirections is true
bool mLogicalDirections; // true when only one value was specified
};
struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset {
explicit nsStyleTextReset(const mozilla::dom::Document&);
nsStyleTextReset(const nsStyleTextReset& aOther);
@ -1264,7 +1327,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleTextReset {
nsChangeHint CalcDifference(const nsStyleTextReset& aNewData) const;
mozilla::StyleTextOverflow mTextOverflow;
nsStyleTextOverflow mTextOverflow; // enum, string
mozilla::StyleTextDecorationLine mTextDecorationLine;
uint8_t mTextDecorationStyle; // NS_STYLE_TEXT_DECORATION_STYLE_*

View File

@ -3342,7 +3342,83 @@ fn static_assert() {
</%self:impl_trait>
<%self:impl_trait style_struct_name="Text" skip_longhands="initial-letter">
<%self:impl_trait style_struct_name="Text"
skip_longhands="text-overflow initial-letter">
fn clear_overflow_sides_if_string(&mut self) {
use crate::gecko_bindings::structs::nsStyleTextOverflowSide;
fn clear_if_string(side: &mut nsStyleTextOverflowSide) {
if side.mType == structs::NS_STYLE_TEXT_OVERFLOW_STRING as u8 {
side.mString.truncate();
side.mType = structs::NS_STYLE_TEXT_OVERFLOW_CLIP as u8;
}
}
clear_if_string(&mut self.gecko.mTextOverflow.mLeft);
clear_if_string(&mut self.gecko.mTextOverflow.mRight);
}
pub fn set_text_overflow(&mut self, v: longhands::text_overflow::computed_value::T) {
use crate::gecko_bindings::structs::nsStyleTextOverflowSide;
use crate::values::specified::text::TextOverflowSide;
fn set(side: &mut nsStyleTextOverflowSide, value: &TextOverflowSide) {
let ty = match *value {
TextOverflowSide::Clip => structs::NS_STYLE_TEXT_OVERFLOW_CLIP,
TextOverflowSide::Ellipsis => structs::NS_STYLE_TEXT_OVERFLOW_ELLIPSIS,
TextOverflowSide::String(ref s) => {
side.mString.assign_str(s);
structs::NS_STYLE_TEXT_OVERFLOW_STRING
}
};
side.mType = ty as u8;
}
self.clear_overflow_sides_if_string();
self.gecko.mTextOverflow.mLogicalDirections = v.sides_are_logical;
set(&mut self.gecko.mTextOverflow.mLeft, &v.first);
set(&mut self.gecko.mTextOverflow.mRight, &v.second);
}
pub fn copy_text_overflow_from(&mut self, other: &Self) {
use crate::gecko_bindings::structs::nsStyleTextOverflowSide;
fn set(side: &mut nsStyleTextOverflowSide, other: &nsStyleTextOverflowSide) {
if other.mType == structs::NS_STYLE_TEXT_OVERFLOW_STRING as u8 {
side.mString.assign(&*other.mString)
}
side.mType = other.mType
}
self.clear_overflow_sides_if_string();
set(&mut self.gecko.mTextOverflow.mLeft, &other.gecko.mTextOverflow.mLeft);
set(&mut self.gecko.mTextOverflow.mRight, &other.gecko.mTextOverflow.mRight);
self.gecko.mTextOverflow.mLogicalDirections = other.gecko.mTextOverflow.mLogicalDirections;
}
pub fn reset_text_overflow(&mut self, other: &Self) {
self.copy_text_overflow_from(other)
}
pub fn clone_text_overflow(&self) -> longhands::text_overflow::computed_value::T {
use crate::gecko_bindings::structs::nsStyleTextOverflowSide;
use crate::values::specified::text::TextOverflowSide;
fn to_servo(side: &nsStyleTextOverflowSide) -> TextOverflowSide {
match side.mType as u32 {
structs::NS_STYLE_TEXT_OVERFLOW_CLIP => TextOverflowSide::Clip,
structs::NS_STYLE_TEXT_OVERFLOW_ELLIPSIS => TextOverflowSide::Ellipsis,
structs::NS_STYLE_TEXT_OVERFLOW_STRING =>
TextOverflowSide::String(side.mString.to_string().into_boxed_str()),
_ => panic!("Found unexpected value in style struct for text_overflow property"),
}
}
longhands::text_overflow::computed_value::T {
first: to_servo(&self.gecko.mTextOverflow.mLeft),
second: to_servo(&self.gecko.mTextOverflow.mRight),
sides_are_logical: self.gecko.mTextOverflow.mLogicalDirections
}
}
pub fn set_initial_letter(&mut self, v: longhands::initial_letter::computed_value::T) {
use crate::values::generics::text::InitialLetter;
match v {

View File

@ -105,7 +105,6 @@ impl ToComputedValue for specified::WordSpacing {
pub type LineHeight = GenericLineHeight<NonNegativeNumber, NonNegativeLength>;
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue)]
#[repr(C)]
/// text-overflow.
/// When the specified value only has one side, that's the "second"
/// side, and the sides are logical, so "second" means "end". The

View File

@ -134,16 +134,14 @@ impl ToComputedValue for LineHeight {
}
/// A generic value for the `text-overflow` property.
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[repr(C, u8)]
pub enum TextOverflowSide {
/// Clip inline content.
Clip,
/// Render ellipsis to represent clipped inline content.
Ellipsis,
/// Render a given string to represent clipped inline content.
String(crate::OwnedStr),
String(Box<str>),
}
impl Parse for TextOverflowSide {
@ -163,7 +161,7 @@ impl Parse for TextOverflowSide {
}
},
Token::QuotedString(ref v) => Ok(TextOverflowSide::String(
v.as_ref().to_owned().into(),
v.as_ref().to_owned().into_boxed_str(),
)),
ref t => Err(location.new_unexpected_token_error(t.clone())),
}

View File

@ -114,7 +114,6 @@ include = [
"WillChange",
"TextDecorationLine",
"TextTransform",
"TextOverflow",
"MozListReversed",
"Owned",
"OwnedOrNull",
@ -453,19 +452,3 @@ renaming_overrides_prefixing = true
StyleOffsetPath() {}
public:
"""
"TextOverflowSide" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleTextOverflowSide() {}
public:
"""
"TextOverflow" = """
StyleTextOverflow()
: first(StyleTextOverflowSide::Clip()),
second(StyleTextOverflowSide::Clip()),
sides_are_logical(true) {}
"""