зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1135954 part 1 - Create empty border/padding style struct for rbc/rtc. r=heycam
--HG-- extra : source : 036de96aecb8a5e2c40e4d722b689c3db81583b7
This commit is contained in:
Родитель
f77129f4f8
Коммит
b11baf4acb
|
@ -438,8 +438,6 @@ nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
|
|||
|
||||
UNIQUE_CASE(Display)
|
||||
UNIQUE_CASE(Background)
|
||||
UNIQUE_CASE(Border)
|
||||
UNIQUE_CASE(Padding)
|
||||
UNIQUE_CASE(Text)
|
||||
UNIQUE_CASE(TextReset)
|
||||
|
||||
|
@ -456,6 +454,41 @@ nsStyleContext::GetUniqueStyleData(const nsStyleStructID& aSID)
|
|||
return result;
|
||||
}
|
||||
|
||||
// This is an evil function, but less evil than GetUniqueStyleData. It
|
||||
// creates an empty style struct for this nsStyleContext.
|
||||
void*
|
||||
nsStyleContext::CreateEmptyStyleData(const nsStyleStructID& aSID)
|
||||
{
|
||||
MOZ_ASSERT(!mChild && !mEmptyChild &&
|
||||
!(mBits & nsCachedStyleData::GetBitForSID(aSID)) &&
|
||||
!GetCachedStyleData(aSID),
|
||||
"This style should not have been computed");
|
||||
|
||||
void* result;
|
||||
nsPresContext* presContext = PresContext();
|
||||
switch (aSID) {
|
||||
#define UNIQUE_CASE(c_, ...) \
|
||||
case eStyleStruct_##c_: \
|
||||
result = new (presContext) nsStyle##c_(__VA_ARGS__); \
|
||||
break;
|
||||
|
||||
UNIQUE_CASE(Border, presContext)
|
||||
UNIQUE_CASE(Padding)
|
||||
|
||||
#undef UNIQUE_CASE
|
||||
|
||||
default:
|
||||
NS_ERROR("Struct type not supported.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// The new struct is owned by this style context, but that we don't
|
||||
// need to clear the bit in mBits because we've asserted that at the
|
||||
// top of this function.
|
||||
SetStyle(aSID, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
nsStyleContext::SetStyle(nsStyleStructID aSID, void* aStruct)
|
||||
{
|
||||
|
@ -620,25 +653,8 @@ nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
|
|||
// Suppress border/padding of ruby level containers
|
||||
if (disp->mDisplay == NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER ||
|
||||
disp->mDisplay == NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) {
|
||||
if (StyleBorder()->GetComputedBorder() != nsMargin(0, 0, 0, 0)) {
|
||||
nsStyleBorder* border =
|
||||
static_cast<nsStyleBorder*>(GetUniqueStyleData(eStyleStruct_Border));
|
||||
NS_FOR_CSS_SIDES(side) {
|
||||
border->SetBorderWidth(side, 0);
|
||||
}
|
||||
}
|
||||
|
||||
nsMargin computedPadding;
|
||||
if (!StylePadding()->GetPadding(computedPadding) ||
|
||||
computedPadding != nsMargin(0, 0, 0, 0)) {
|
||||
const nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
|
||||
nsStylePadding* padding =
|
||||
static_cast<nsStylePadding*>(GetUniqueStyleData(eStyleStruct_Padding));
|
||||
NS_FOR_CSS_SIDES(side) {
|
||||
padding->mPadding.Set(side, zero);
|
||||
}
|
||||
padding->RecalcData();
|
||||
}
|
||||
CreateEmptyStyleData(eStyleStruct_Border);
|
||||
CreateEmptyStyleData(eStyleStruct_Padding);
|
||||
}
|
||||
|
||||
// Compute User Interface style, to trigger loads of cursors
|
||||
|
|
|
@ -435,6 +435,8 @@ private:
|
|||
void AddChild(nsStyleContext* aChild);
|
||||
void RemoveChild(nsStyleContext* aChild);
|
||||
|
||||
void* CreateEmptyStyleData(const nsStyleStructID& aSID);
|
||||
|
||||
void ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup);
|
||||
|
||||
// Helper function for HasChildThatUsesGrandancestorStyle.
|
||||
|
|
Загрузка…
Ссылка в новой задаче