Bug 1363572 Part 2: Change ServoStyleSet to use uint64_t for entry unique IDs. r=heycam

MozReview-Commit-ID: 50whQ71j4B5

--HG--
extra : rebase_source : 9f4fa6aa77d43c609c9b9c3af9d10dac54ced649
This commit is contained in:
Brad Werth 2017-05-10 11:20:57 -07:00
Родитель cb93fc35dd
Коммит 1abf09eb7e
3 изменённых файлов: 39 добавлений и 39 удалений

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

@ -52,19 +52,19 @@ SERVO_BINDING_FUNC(Servo_StyleSet_Drop, void, RawServoStyleSetOwned set)
SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void, SERVO_BINDING_FUNC(Servo_StyleSet_AppendStyleSheet, void,
RawServoStyleSetBorrowed set, RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet, RawServoStyleSheetBorrowed sheet,
uint32_t unique_id) uint64_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void, SERVO_BINDING_FUNC(Servo_StyleSet_PrependStyleSheet, void,
RawServoStyleSetBorrowed set, RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet, RawServoStyleSheetBorrowed sheet,
uint32_t unique_id) uint64_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void, SERVO_BINDING_FUNC(Servo_StyleSet_RemoveStyleSheet, void,
RawServoStyleSetBorrowed set, RawServoStyleSetBorrowed set,
uint32_t unique_id) uint64_t unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void, SERVO_BINDING_FUNC(Servo_StyleSet_InsertStyleSheetBefore, void,
RawServoStyleSetBorrowed set, RawServoStyleSetBorrowed set,
RawServoStyleSheetBorrowed sheet, RawServoStyleSheetBorrowed sheet,
uint32_t unique_id, uint64_t unique_id,
uint32_t before_unique_id) uint64_t before_unique_id)
SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set) SERVO_BINDING_FUNC(Servo_StyleSet_FlushStyleSheets, void, RawServoStyleSetBorrowed set)
SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void, SERVO_BINDING_FUNC(Servo_StyleSet_NoteStyleSheetsChanged, void,
RawServoStyleSetBorrowed set, bool author_style_disabled) RawServoStyleSetBorrowed set, bool author_style_disabled)

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

@ -575,8 +575,8 @@ ServoStyleSet::AppendStyleSheet(SheetType aType,
// If we were already tracking aSheet, the newUniqueID will be the same // If we were already tracking aSheet, the newUniqueID will be the same
// as the oldUniqueID. In that case, Servo will remove aSheet from its // as the oldUniqueID. In that case, Servo will remove aSheet from its
// original position as part of the call to Servo_StyleSet_AppendStyleSheet. // original position as part of the call to Servo_StyleSet_AppendStyleSheet.
uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet); uint64_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
uint32_t newUniqueID = AppendSheetOfType(aType, aSheet, oldUniqueID); uint64_t newUniqueID = AppendSheetOfType(aType, aSheet, oldUniqueID);
if (mRawSet) { if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side. // Maintain a mirrored list of sheets on the servo side.
@ -601,8 +601,8 @@ ServoStyleSet::PrependStyleSheet(SheetType aType,
// If we were already tracking aSheet, the newUniqueID will be the same // If we were already tracking aSheet, the newUniqueID will be the same
// as the oldUniqueID. In that case, Servo will remove aSheet from its // as the oldUniqueID. In that case, Servo will remove aSheet from its
// original position as part of the call to Servo_StyleSet_PrependStyleSheet. // original position as part of the call to Servo_StyleSet_PrependStyleSheet.
uint32_t oldUniqueID = RemoveSheetOfType(aType, aSheet); uint64_t oldUniqueID = RemoveSheetOfType(aType, aSheet);
uint32_t newUniqueID = PrependSheetOfType(aType, aSheet, oldUniqueID); uint64_t newUniqueID = PrependSheetOfType(aType, aSheet, oldUniqueID);
if (mRawSet) { if (mRawSet) {
// Maintain a mirrored list of sheets on the servo side. // Maintain a mirrored list of sheets on the servo side.
@ -622,7 +622,7 @@ ServoStyleSet::RemoveStyleSheet(SheetType aType,
MOZ_ASSERT(aSheet); MOZ_ASSERT(aSheet);
MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType)); MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
uint32_t uniqueID = RemoveSheetOfType(aType, aSheet); uint64_t uniqueID = RemoveSheetOfType(aType, aSheet);
if (mRawSet && uniqueID) { if (mRawSet && uniqueID) {
// Maintain a mirrored list of sheets on the servo side. // Maintain a mirrored list of sheets on the servo side.
Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), uniqueID); Servo_StyleSet_RemoveStyleSheet(mRawSet.get(), uniqueID);
@ -653,7 +653,7 @@ ServoStyleSet::ReplaceSheets(SheetType aType,
// Add in all the new sheets. // Add in all the new sheets.
for (auto& sheet : aNewSheets) { for (auto& sheet : aNewSheets) {
uint32_t uniqueID = AppendSheetOfType(aType, sheet); uint64_t uniqueID = AppendSheetOfType(aType, sheet);
if (mRawSet) { if (mRawSet) {
MOZ_ASSERT(sheet->RawSheet(), "Raw sheet should be in place before replacement."); MOZ_ASSERT(sheet->RawSheet(), "Raw sheet should be in place before replacement.");
Servo_StyleSet_AppendStyleSheet(mRawSet.get(), Servo_StyleSet_AppendStyleSheet(mRawSet.get(),
@ -677,7 +677,7 @@ ServoStyleSet::InsertStyleSheetBefore(SheetType aType,
MOZ_ASSERT(aNewSheet->RawSheet(), "Raw sheet should be in place before insertion."); MOZ_ASSERT(aNewSheet->RawSheet(), "Raw sheet should be in place before insertion.");
MOZ_ASSERT(aReferenceSheet->RawSheet(), "Reference sheet should have a raw sheet."); MOZ_ASSERT(aReferenceSheet->RawSheet(), "Reference sheet should have a raw sheet.");
uint32_t beforeUniqueID = FindSheetOfType(aType, aReferenceSheet); uint64_t beforeUniqueID = FindSheetOfType(aType, aReferenceSheet);
if (beforeUniqueID == 0) { if (beforeUniqueID == 0) {
return NS_ERROR_INVALID_ARG; return NS_ERROR_INVALID_ARG;
} }
@ -685,8 +685,8 @@ ServoStyleSet::InsertStyleSheetBefore(SheetType aType,
// If we were already tracking aNewSheet, the newUniqueID will be the same // If we were already tracking aNewSheet, the newUniqueID will be the same
// as the oldUniqueID. In that case, Servo will remove aNewSheet from its // as the oldUniqueID. In that case, Servo will remove aNewSheet from its
// original position as part of the call to Servo_StyleSet_InsertStyleSheetBefore. // original position as part of the call to Servo_StyleSet_InsertStyleSheetBefore.
uint32_t oldUniqueID = RemoveSheetOfType(aType, aNewSheet); uint64_t oldUniqueID = RemoveSheetOfType(aType, aNewSheet);
uint32_t newUniqueID = InsertSheetOfType(aType, uint64_t newUniqueID = InsertSheetOfType(aType,
aNewSheet, aNewSheet,
beforeUniqueID, beforeUniqueID,
oldUniqueID); oldUniqueID);
@ -733,15 +733,15 @@ ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet,
RefPtr<StyleSheet> strong(aSheet); RefPtr<StyleSheet> strong(aSheet);
uint32_t oldUniqueID = RemoveSheetOfType(SheetType::Doc, aSheet); uint64_t oldUniqueID = RemoveSheetOfType(SheetType::Doc, aSheet);
size_t index = size_t index =
aDocument->FindDocStyleSheetInsertionPoint(mEntries[SheetType::Doc], aSheet); aDocument->FindDocStyleSheetInsertionPoint(mEntries[SheetType::Doc], aSheet);
if (index < mEntries[SheetType::Doc].Length()) { if (index < mEntries[SheetType::Doc].Length()) {
// This case is insert before. // This case is insert before.
uint32_t beforeUniqueID = mEntries[SheetType::Doc][index].uniqueID; uint64_t beforeUniqueID = mEntries[SheetType::Doc][index].uniqueID;
uint32_t newUniqueID = InsertSheetOfType(SheetType::Doc, uint64_t newUniqueID = InsertSheetOfType(SheetType::Doc,
aSheet, aSheet,
beforeUniqueID, beforeUniqueID,
oldUniqueID); oldUniqueID);
@ -756,7 +756,7 @@ ServoStyleSet::AddDocStyleSheet(ServoStyleSheet* aSheet,
} }
} else { } else {
// This case is append. // This case is append.
uint32_t newUniqueID = AppendSheetOfType(SheetType::Doc, uint64_t newUniqueID = AppendSheetOfType(SheetType::Doc,
aSheet, aSheet,
oldUniqueID); oldUniqueID);
@ -1073,7 +1073,7 @@ ServoStyleSet::RebuildStylist()
mStylistMayNeedRebuild = false; mStylistMayNeedRebuild = false;
} }
uint32_t uint64_t
ServoStyleSet::FindSheetOfType(SheetType aType, ServoStyleSet::FindSheetOfType(SheetType aType,
ServoStyleSheet* aSheet) ServoStyleSheet* aSheet)
{ {
@ -1085,10 +1085,10 @@ ServoStyleSet::FindSheetOfType(SheetType aType,
return 0; return 0;
} }
uint32_t uint64_t
ServoStyleSet::PrependSheetOfType(SheetType aType, ServoStyleSet::PrependSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aReuseUniqueID) uint64_t aReuseUniqueID)
{ {
Entry* entry = mEntries[aType].InsertElementAt(0); Entry* entry = mEntries[aType].InsertElementAt(0);
entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter; entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter;
@ -1096,10 +1096,10 @@ ServoStyleSet::PrependSheetOfType(SheetType aType,
return entry->uniqueID; return entry->uniqueID;
} }
uint32_t uint64_t
ServoStyleSet::AppendSheetOfType(SheetType aType, ServoStyleSet::AppendSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aReuseUniqueID) uint64_t aReuseUniqueID)
{ {
Entry* entry = mEntries[aType].AppendElement(); Entry* entry = mEntries[aType].AppendElement();
entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter; entry->uniqueID = aReuseUniqueID ? aReuseUniqueID : ++mUniqueIDCounter;
@ -1107,11 +1107,11 @@ ServoStyleSet::AppendSheetOfType(SheetType aType,
return entry->uniqueID; return entry->uniqueID;
} }
uint32_t uint64_t
ServoStyleSet::InsertSheetOfType(SheetType aType, ServoStyleSet::InsertSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aBeforeUniqueID, uint64_t aBeforeUniqueID,
uint32_t aReuseUniqueID) uint64_t aReuseUniqueID)
{ {
for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) { for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) {
if (mEntries[aType][i].uniqueID == aBeforeUniqueID) { if (mEntries[aType][i].uniqueID == aBeforeUniqueID) {
@ -1124,13 +1124,13 @@ ServoStyleSet::InsertSheetOfType(SheetType aType,
return 0; return 0;
} }
uint32_t uint64_t
ServoStyleSet::RemoveSheetOfType(SheetType aType, ServoStyleSet::RemoveSheetOfType(SheetType aType,
ServoStyleSheet* aSheet) ServoStyleSheet* aSheet)
{ {
for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) { for (uint32_t i = 0; i < mEntries[aType].Length(); ++i) {
if (mEntries[aType][i].sheet == aSheet) { if (mEntries[aType][i].sheet == aSheet) {
uint32_t uniqueID = mEntries[aType][i].uniqueID; uint64_t uniqueID = mEntries[aType][i].uniqueID;
mEntries[aType].RemoveElementAt(i); mEntries[aType].RemoveElementAt(i);
return uniqueID; return uniqueID;
} }

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

@ -440,27 +440,27 @@ private:
void RunPostTraversalTasks(); void RunPostTraversalTasks();
uint32_t FindSheetOfType(SheetType aType, uint64_t FindSheetOfType(SheetType aType,
ServoStyleSheet* aSheet); ServoStyleSheet* aSheet);
uint32_t PrependSheetOfType(SheetType aType, uint64_t PrependSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aReuseUniqueID = 0); uint64_t aReuseUniqueID = 0);
uint32_t AppendSheetOfType(SheetType aType, uint64_t AppendSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aReuseUniqueID = 0); uint64_t aReuseUniqueID = 0);
uint32_t InsertSheetOfType(SheetType aType, uint64_t InsertSheetOfType(SheetType aType,
ServoStyleSheet* aSheet, ServoStyleSheet* aSheet,
uint32_t aBeforeUniqueID, uint64_t aBeforeUniqueID,
uint32_t aReuseUniqueID = 0); uint64_t aReuseUniqueID = 0);
uint32_t RemoveSheetOfType(SheetType aType, uint64_t RemoveSheetOfType(SheetType aType,
ServoStyleSheet* aSheet); ServoStyleSheet* aSheet);
struct Entry { struct Entry {
uint32_t uniqueID; uint64_t uniqueID;
RefPtr<ServoStyleSheet> sheet; RefPtr<ServoStyleSheet> sheet;
// Provide a cast operator to simplify calling // Provide a cast operator to simplify calling
@ -472,7 +472,7 @@ private:
UniquePtr<RawServoStyleSet> mRawSet; UniquePtr<RawServoStyleSet> mRawSet;
EnumeratedArray<SheetType, SheetType::Count, EnumeratedArray<SheetType, SheetType::Count,
nsTArray<Entry>> mEntries; nsTArray<Entry>> mEntries;
uint32_t mUniqueIDCounter; uint64_t mUniqueIDCounter;
bool mAllowResolveStaleStyles; bool mAllowResolveStaleStyles;
bool mAuthorStyleDisabled; bool mAuthorStyleDisabled;
bool mStylistMayNeedRebuild; bool mStylistMayNeedRebuild;