Bug 1382964 - Part 1: Don't cache URLValueData::mMightHaveRef when in a traversal. r=xidorn

MozReview-Commit-ID: 2ucnu4vuaVg

--HG--
extra : rebase_source : 5f4f51d302f5d6ba03ecf7ea2ee938acdb36d0c8
This commit is contained in:
Cameron McCormack 2017-07-21 16:34:20 +08:00
Родитель ed9d1ad184
Коммит d20edaf0df
1 изменённых файлов: 19 добавлений и 15 удалений

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

@ -2892,31 +2892,35 @@ css::URLValueData::IsLocalRef() const
bool
css::URLValueData::HasRef() const
{
bool result = false;
if (IsLocalRef()) {
return true;
result = true;
} else {
if (nsIURI* uri = GetURI()) {
nsAutoCString ref;
nsresult rv = uri->GetRef(ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
result = true;
}
}
}
nsIURI* uri = GetURI();
if (!uri) {
return false;
}
mMightHaveRef = Some(result);
nsAutoCString ref;
nsresult rv = uri->GetRef(ref);
if (NS_SUCCEEDED(rv) && !ref.IsEmpty()) {
return true;
}
return false;
return result;
}
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));
bool result = ::MightHaveRef(mString);
if (!ServoStyleSet::IsInServoTraversal()) {
// Can only cache the result if we're not on a style worker thread.
mMightHaveRef.emplace(result);
}
return result;
}
return mMightHaveRef.value();