Bug 1296477 - Part 2: stylo: Implement remaining `content` values; r=heycam

MozReview-Commit-ID: 9fLM5bdR8hr

--HG--
extra : rebase_source : f1397129408e7e9763733c026855a99321b09656
This commit is contained in:
Manish Goregaokar 2017-03-11 22:40:54 -08:00
Родитель 471d940ebc
Коммит 8b8d456955
5 изменённых файлов: 56 добавлений и 8 удалений

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

@ -920,6 +920,21 @@ Gecko_CopyCursorArrayFrom(nsStyleUserInterface* aDest,
aDest->mCursorImages = aSrc->mCursorImages;
}
void
Gecko_SetContentDataImage(nsStyleContentData* aContent, ServoBundledURI aURI)
{
RefPtr<nsStyleImageRequest> req = CreateStyleImageRequest(nsStyleImageRequest::Mode::Track, aURI);
aContent->SetImageRequest(req.forget());
}
void
Gecko_SetContentDataArray(nsStyleContentData* aContent,
nsStyleContentType aType, uint32_t aLen)
{
nsCSSValue::Array* arr = nsCSSValue::Array::Create(aLen);
aContent->SetCounters(aType, arr);
}
nsStyleGradient*
Gecko_CreateGradient(uint8_t aShape,
uint8_t aSize,
@ -1312,10 +1327,25 @@ Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut aCSSValue, int32_t aLen)
}
void
Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue, const nsString aString)
Gecko_CSSValue_SetString(nsCSSValueBorrowedMut aCSSValue, const uint8_t* aString, uint32_t aLength)
{
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
aCSSValue->SetStringValue(aString, eCSSUnit_String);
nsString string;
nsDependentCSubstring slice(reinterpret_cast<const char*>(aString),
aLength);
AppendUTF8toUTF16(slice, string);
aCSSValue->SetStringValue(string, eCSSUnit_String);
}
void
Gecko_CSSValue_SetIdent(nsCSSValueBorrowedMut aCSSValue, const uint8_t* aString, uint32_t aLength)
{
MOZ_ASSERT(aCSSValue->GetUnit() == eCSSUnit_Null);
nsString string;
nsDependentCSubstring slice(reinterpret_cast<const char*>(aString),
aLength);
AppendUTF8toUTF16(slice, string);
aCSSValue->SetStringValue(string, eCSSUnit_Ident);
}
void

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

@ -245,6 +245,9 @@ void Gecko_SetCursorImage(nsCursorImage* cursor,
void Gecko_CopyCursorArrayFrom(nsStyleUserInterface* dest,
const nsStyleUserInterface* src);
void Gecko_SetContentDataImage(nsStyleContentData* content_data, ServoBundledURI uri);
void Gecko_SetContentDataArray(nsStyleContentData* content_data, nsStyleContentType type, uint32_t len);
// Dirtiness tracking.
uint32_t Gecko_GetNodeFlags(RawGeckoNodeBorrowed node);
void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
@ -348,7 +351,8 @@ void Gecko_CSSValue_SetPercentage(nsCSSValueBorrowedMut css_value, float percent
void Gecko_CSSValue_SetAngle(nsCSSValueBorrowedMut css_value, float radians);
void Gecko_CSSValue_SetCalc(nsCSSValueBorrowedMut css_value, nsStyleCoord::CalcValue calc);
void Gecko_CSSValue_SetFunction(nsCSSValueBorrowedMut css_value, int32_t len);
void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value, const nsString string);
void Gecko_CSSValue_SetString(nsCSSValueBorrowedMut css_value, const uint8_t* string, uint32_t len);
void Gecko_CSSValue_SetIdent(nsCSSValueBorrowedMut css_value, const uint8_t* string, uint32_t len);
void Gecko_CSSValue_SetArray(nsCSSValueBorrowedMut css_value, int32_t len);
void Gecko_CSSValue_SetURL(nsCSSValueBorrowedMut css_value, ServoBundledURI uri);
void Gecko_CSSValue_SetLocal(nsCSSValueBorrowedMut css_value, const nsString family);

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

@ -429,7 +429,7 @@ nscoord nsCSSValue::GetPixelLength() const
void nsCSSValue::DoReset()
{
if (UnitHasStringValue()) {
DO_RELEASE(mString);
mValue.mString->Release();
} else if (IsFloatColorUnit()) {
DO_RELEASE(mFloatColor);
} else if (eCSSUnit_ComplexColor == mUnit) {

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

@ -3682,11 +3682,10 @@ nsStyleContentData::~nsStyleContentData()
MOZ_COUNT_DTOR(nsStyleContentData);
if (mType == eStyleContentType_Image) {
MOZ_ASSERT(NS_IsMainThread());
mContent.mImage->Release();
NS_ReleaseOnMainThread(dont_AddRef(mContent.mImage));
mContent.mImage = nullptr;
} else if (mType == eStyleContentType_Counter ||
mType == eStyleContentType_Counters) {
MOZ_ASSERT(NS_IsMainThread());
mContent.mCounters->Release();
} else if (mContent.mString) {
free(mContent.mString);
@ -3761,6 +3760,14 @@ nsStyleContent::Destroy(nsPresContext* aContext)
aContext->PresShell()->FreeByObjectID(eArenaObjectID_nsStyleContent, this);
}
void
nsStyleContent::FinishStyle(nsPresContext* aPresContext)
{
for (nsStyleContentData& data : mContents) {
data.Resolve(aPresContext);
}
}
nsStyleContent::nsStyleContent(const nsStyleContent& aSource)
: mContents(aSource.mContents)
, mIncrements(aSource.mIncrements)

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

@ -3206,6 +3206,7 @@ public:
MOZ_ASSERT(aType == eStyleContentType_Counter ||
aType == eStyleContentType_Counters);
MOZ_ASSERT(aCounters);
MOZ_ASSERT(aCounters->Count() == 2 || aCounters->Count() == 3);
MOZ_ASSERT(mType == eStyleContentType_Uninitialized,
"should only initialize nsStyleContentData once");
mType = aType;
@ -3222,6 +3223,12 @@ public:
MOZ_ASSERT(mContent.mImage);
}
void Resolve(nsPresContext* aPresContext) {
if (mType == eStyleContentType_Image) {
mContent.mImage->Resolve(aPresContext);
}
}
private:
nsStyleContentType mType;
union {
@ -3250,7 +3257,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleContent
explicit nsStyleContent(const nsPresContext* aContext);
nsStyleContent(const nsStyleContent& aContent);
~nsStyleContent();
void FinishStyle(nsPresContext* aPresContext) {}
void FinishStyle(nsPresContext* aPresContext);
void* operator new(size_t sz, nsStyleContent* aSelf) { return aSelf; }
void* operator new(size_t sz, nsPresContext* aContext) {