Bug 1288302 - Part 6: Add FFI function to set nsStyleImageRequest values. r=xidorn

MozReview-Commit-ID: 448vAeDiKX7
This commit is contained in:
Cameron McCormack 2016-10-20 08:36:26 +08:00
Родитель 74fdb2a2bf
Коммит 3b86d2992f
2 изменённых файлов: 40 добавлений и 5 удалений

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

@ -734,6 +734,35 @@ Gecko_SetGradientImageValue(nsStyleImage* aImage, nsStyleGradient* aGradient)
aImage->SetGradientData(aGradient);
}
void
Gecko_SetUrlImageValue(nsStyleImage* aImage,
const uint8_t* aURLString, uint32_t aURLStringLength,
ThreadSafeURIHolder* aBaseURI,
ThreadSafeURIHolder* aReferrer,
ThreadSafePrincipalHolder* aPrincipal)
{
MOZ_ASSERT(aImage);
MOZ_ASSERT(aURLString);
MOZ_ASSERT(aBaseURI);
MOZ_ASSERT(aReferrer);
MOZ_ASSERT(aPrincipal);
nsString url;
nsDependentCSubstring urlString(reinterpret_cast<const char*>(aURLString),
aURLStringLength);
AppendUTF8toUTF16(urlString, url);
RefPtr<nsStringBuffer> urlBuffer = nsCSSValue::BufferFromString(url);
RefPtr<nsStyleImageRequest> req =
new nsStyleImageRequest(nsStyleImageRequest::Mode::Track |
nsStyleImageRequest::Mode::Lock,
urlBuffer,
do_AddRef(aBaseURI),
do_AddRef(aReferrer),
do_AddRef(aPrincipal));
aImage->SetImageRequest(req.forget());
}
void
Gecko_CopyImageValueFrom(nsStyleImage* aImage, const nsStyleImage* aOther)
{

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

@ -156,6 +156,10 @@ DECL_BORROWED_MUT_REF_TYPE_FOR(StyleChildrenIterator)
extern "C" {
// Object refcounting.
NS_DECL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal)
NS_DECL_HOLDER_FFI_REFCOUNTING(nsIURI, URI)
// DOM Traversal.
uint32_t Gecko_ChildrenCount(RawGeckoNodeBorrowed node);
bool Gecko_NodeIsElement(RawGeckoNodeBorrowed node);
@ -246,9 +250,15 @@ void Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type);
void Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src);
// background-image style.
// TODO: support url() values (and maybe element() too?).
// TODO: support element() and -moz-image()
void Gecko_SetNullImageValue(nsStyleImage* image);
void Gecko_SetGradientImageValue(nsStyleImage* image, nsStyleGradient* gradient);
void Gecko_SetUrlImageValue(nsStyleImage* image,
const uint8_t* url_bytes,
uint32_t url_length,
ThreadSafeURIHolder* base_uri,
ThreadSafeURIHolder* referrer,
ThreadSafePrincipalHolder* principal);
void Gecko_CopyImageValueFrom(nsStyleImage* image, const nsStyleImage* other);
nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
@ -257,10 +267,6 @@ nsStyleGradient* Gecko_CreateGradient(uint8_t shape,
bool legacy_syntax,
uint32_t stops);
// Object refcounting.
NS_DECL_HOLDER_FFI_REFCOUNTING(nsIPrincipal, Principal)
NS_DECL_HOLDER_FFI_REFCOUNTING(nsIURI, URI)
// Display style.
void Gecko_SetMozBinding(nsStyleDisplay* style_struct,
const uint8_t* string_bytes, uint32_t string_length,