зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1354772 - Part 2. Compute URLValueData::mMightHaveRef when need. r=heycam
MozReview-Commit-ID: 8t5tKrjB1cz --HG-- extra : rebase_source : cda9e15dcb51aeedf6bb532dd702247e60e59304
This commit is contained in:
Родитель
3509778fd7
Коммит
db1a6cab83
|
@ -45,6 +45,19 @@ IsLocalRefURL(nsStringBuffer* aString)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
MightHaveRef(nsStringBuffer* aString)
|
||||
{
|
||||
char16_t* current = static_cast<char16_t*>(aString->Data());
|
||||
for (; *current != '\0'; current++) {
|
||||
if (*current == '#') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
nsCSSValue::nsCSSValue(int32_t aValue, nsCSSUnit aUnit)
|
||||
: mUnit(aUnit)
|
||||
{
|
||||
|
@ -2895,6 +2908,18 @@ css::URLValueData::HasRef() const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
css::URLValueData::MightHaveRef() const
|
||||
{
|
||||
if (mMightHaveRef.isNothing()) {
|
||||
// ::MightHaveRef is O(N), use it only use it only when MightHaveRef is
|
||||
// called.
|
||||
mMightHaveRef.emplace(::MightHaveRef(mString));
|
||||
}
|
||||
|
||||
return mMightHaveRef.value();
|
||||
}
|
||||
|
||||
already_AddRefed<nsIURI>
|
||||
css::URLValueData::ResolveLocalRef(nsIURI* aURI) const
|
||||
{
|
||||
|
|
|
@ -135,6 +135,14 @@ public:
|
|||
|
||||
bool HasRef() const;
|
||||
|
||||
// This function takes a guess whether the URL has a fragment, by searching
|
||||
// for a hash character. It definitely returns false if we know it can't
|
||||
// have a fragment because it has no hash character.
|
||||
//
|
||||
// MightHaveRef can be used in any thread, whereas HasRef can only be used
|
||||
// in the main thread.
|
||||
bool MightHaveRef() const;
|
||||
|
||||
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(URLValueData)
|
||||
|
||||
// When matching a url with mIsLocalRef set, resolve it against aURI;
|
||||
|
@ -159,6 +167,7 @@ private:
|
|||
mutable bool mURIResolved;
|
||||
// mIsLocalRef is set when url starts with a U+0023 number sign(#) character.
|
||||
mutable Maybe<bool> mIsLocalRef;
|
||||
mutable Maybe<bool> mMightHaveRef;
|
||||
|
||||
protected:
|
||||
virtual ~URLValueData() = default;
|
||||
|
|
|
@ -3028,11 +3028,11 @@ nsStyleImageLayers::Layer::CalcDifference(const nsStyleImageLayers::Layer& aNewL
|
|||
// not, it "must" not link to a SVG mask.
|
||||
bool maybeSVGMask = false;
|
||||
if (mImage.GetURLValue()) {
|
||||
maybeSVGMask = mImage.GetURLValue()->HasRef();
|
||||
maybeSVGMask = mImage.GetURLValue()->MightHaveRef();
|
||||
}
|
||||
|
||||
if (!maybeSVGMask && aNewLayer.mImage.GetURLValue()) {
|
||||
maybeSVGMask = aNewLayer.mImage.GetURLValue()->HasRef();
|
||||
maybeSVGMask = aNewLayer.mImage.GetURLValue()->MightHaveRef();
|
||||
}
|
||||
|
||||
// Return nsChangeHint_UpdateOverflow if either URI might link to an SVG
|
||||
|
|
Загрузка…
Ссылка в новой задаче