Bug 1292275 - Stylo: Fix crash after failed stylesheet load. r=heycam

Fixes a crash ServoStyleSet::AddDocStyleSheet caused by
ServoStyleSheet::RawSheet returning null.

MozReview-Commit-ID: BdDosompqTv

--HG--
extra : rebase_source : 0b46c9f9327eec0bac3bb2ca697198887948e2e6
This commit is contained in:
Matt Brubeck 2016-10-25 10:15:38 -07:00
Родитель 88f78c89db
Коммит 9c2c0561df
4 изменённых файлов: 19 добавлений и 0 удалений

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

@ -1815,6 +1815,10 @@ Loader::SheetComplete(SheetLoadData* aLoadData, nsresult aStatus)
{
LOG(("css::Loader::SheetComplete"));
if (aLoadData->mSheet->IsServo() && NS_FAILED(aStatus)) {
aLoadData->mSheet->AsServo()->LoadFailed();
}
// 8 is probably big enough for all our common cases. It's not likely that
// imports will nest more than 8 deep, and multiple sheets with the same URI
// are rare.

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

@ -22,6 +22,8 @@
SERVO_BINDING_FUNC(Servo_Node_ClearNodeData, void, RawGeckoNodeBorrowed node)
// Styleset and Stylesheet management
SERVO_BINDING_FUNC(Servo_StyleSheet_Empty, RawServoStyleSheetStrong,
mozilla::css::SheetParsingMode parsing_mode)
SERVO_BINDING_FUNC(Servo_StyleSheet_FromUTF8Bytes, RawServoStyleSheetStrong,
const nsACString* data,
mozilla::css::SheetParsingMode parsing_mode,

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

@ -81,6 +81,12 @@ ServoStyleSheet::ParseSheet(const nsAString& aInput,
return NS_OK;
}
void
ServoStyleSheet::LoadFailed()
{
mSheet = Servo_StyleSheet_Empty(mParsingMode).Consume();
}
void
ServoStyleSheet::DropSheet()
{

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

@ -40,6 +40,13 @@ public:
nsIPrincipal* aSheetPrincipal,
uint32_t aLineNumber);
/**
* Called instead of ParseSheet to initialize the Servo stylesheet object
* for a failed load. Either ParseSheet or LoadFailed must be called before
* adding a ServoStyleSheet to a ServoStyleSet.
*/
void LoadFailed();
size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const;
#ifdef DEBUG