Bug 1251496 - Forward stylesheet management to RawServoStyleSet. r=heycam

This commit is contained in:
Bobby Holley 2016-02-25 18:57:42 -08:00
parent f576acf3a2
commit d4b0049e46
5 changed files with 51 additions and 3 deletions

View File

@ -170,6 +170,31 @@ Servo_ReleaseStylesheet(RawServoStyleSheet* sheet)
"non-MOZ_STYLO build");
}
void
Servo_AppendStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set)
{
MOZ_CRASH("stylo: shouldn't be calling Servo_AppendStyleSheet in a "
"non-MOZ_STYLO build");
}
void Servo_PrependStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set)
{
MOZ_CRASH("stylo: shouldn't be calling Servo_PrependStyleSheet in a "
"non-MOZ_STYLO build");
}
void Servo_RemoveStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set)
{
MOZ_CRASH("stylo: shouldn't be calling Servo_RemoveStyleSheet in a "
"non-MOZ_STYLO build");
}
int Servo_StyleSheetHasRules(RawServoStyleSheet* sheet)
{
MOZ_CRASH("stylo: shouldn't be calling Servo_StyleSheetHasRules in a "
"non-MOZ_STYLO build");
}
RawServoStyleSet*
Servo_InitStyleSet()
{

View File

@ -82,6 +82,10 @@ void Servo_DropNodeData(ServoNodeData* data);
// generator is smart enough to handle them.
RawServoStyleSheet* Servo_StylesheetFromUTF8Bytes(const uint8_t* bytes, uint32_t length);
void Servo_ReleaseStylesheet(RawServoStyleSheet* sheet);
void Servo_AppendStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
void Servo_PrependStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
void Servo_RemoveStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
int Servo_StyleSheetHasRules(RawServoStyleSheet* sheet);
RawServoStyleSet* Servo_InitStyleSet();
void Servo_DropStyleSet(RawServoStyleSet* set);

View File

@ -123,6 +123,9 @@ ServoStyleSet::AppendStyleSheet(SheetType aType,
mSheets[aType].RemoveElement(aSheet);
mSheets[aType].AppendElement(aSheet);
// Maintain a mirrored list of sheets on the servo side.
Servo_AppendStyleSheet(aSheet->RawSheet(), mRawSet.get());
return NS_OK;
}
@ -137,6 +140,9 @@ ServoStyleSet::PrependStyleSheet(SheetType aType,
mSheets[aType].RemoveElement(aSheet);
mSheets[aType].InsertElementAt(0, aSheet);
// Maintain a mirrored list of sheets on the servo side.
Servo_PrependStyleSheet(aSheet->RawSheet(), mRawSet.get());
return NS_OK;
}
@ -144,7 +150,16 @@ nsresult
ServoStyleSet::RemoveStyleSheet(SheetType aType,
ServoStyleSheet* aSheet)
{
MOZ_CRASH("stylo: not implemented");
MOZ_ASSERT(aSheet);
MOZ_ASSERT(aSheet->IsApplicable());
MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
mSheets[aType].RemoveElement(aSheet);
// Maintain a mirrored list of sheets on the servo side.
Servo_RemoveStyleSheet(aSheet->RawSheet(), mRawSet.get());
return NS_OK;
}
nsresult
@ -187,7 +202,9 @@ nsresult
ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet,
nsIDocument* aDocument)
{
MOZ_CRASH("stylo: not implemented");
// XXXbholley: Implement this.
NS_ERROR("stylo: no support for adding doc stylesheets to ServoStyleSet");
return NS_OK;
}
already_AddRefed<nsStyleContext>

View File

@ -40,7 +40,7 @@ ServoStyleSheet::SetComplete()
bool
ServoStyleSheet::HasRules() const
{
MOZ_CRASH("stylo: not implemented");
return Servo_StyleSheetHasRules(RawSheet());
}
nsIDocument*

View File

@ -53,6 +53,8 @@ public:
void List(FILE* aOut = stdout, int32_t aIndex = 0) const;
#endif
RawServoStyleSheet* RawSheet() const { return mSheet; }
protected:
~ServoStyleSheet();