зеркало из https://github.com/mozilla/pjs.git
Don't start image loads for the if-visited style contexts. (Bug 557287) r=bzbarsky
This commit is contained in:
Родитель
5b84428964
Коммит
e45c14e624
|
@ -45,6 +45,7 @@
|
|||
#include "nsRuleData.h"
|
||||
#include "nsRuleNode.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsStyleContext.h"
|
||||
|
||||
/*
|
||||
* nsCSSCompressedDataBlock holds property-value pairs corresponding to
|
||||
|
@ -203,6 +204,20 @@ TryToStartImageLoad(const nsCSSValue& aValue, nsIDocument* aDocument,
|
|||
}
|
||||
}
|
||||
|
||||
static inline PRBool
|
||||
ShouldStartImageLoads(nsRuleData *aRuleData, nsCSSProperty aProperty)
|
||||
{
|
||||
// Don't initiate image loads for if-visited styles. This is
|
||||
// important because:
|
||||
// (1) it's a waste of CPU and bandwidth
|
||||
// (2) in some cases we'd start the image load on a style change
|
||||
// where we wouldn't have started the load initially, which makes
|
||||
// which links are visited detectable to Web pages (see bug
|
||||
// 557287)
|
||||
return !aRuleData->mStyleContext->IsStyleIfVisited() &&
|
||||
nsCSSProps::PropHasFlags(aProperty, CSS_PROPERTY_START_IMAGE_LOADS);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
||||
{
|
||||
|
@ -231,8 +246,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
if (target->GetUnit() == eCSSUnit_Null) {
|
||||
const nsCSSValue *val = ValueAtCursor(cursor);
|
||||
NS_ASSERTION(val->GetUnit() != eCSSUnit_Null, "oops");
|
||||
if (nsCSSProps::PropHasFlags(iProp,
|
||||
CSS_PROPERTY_START_IMAGE_LOADS)) {
|
||||
if (ShouldStartImageLoads(aRuleData, iProp)) {
|
||||
TryToStartImageLoad(*val, doc, iProp);
|
||||
}
|
||||
*target = *val;
|
||||
|
@ -301,8 +315,7 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
|
|||
case eCSSType_ValuePairList: {
|
||||
void** target = static_cast<void**>(prop);
|
||||
if (!*target) {
|
||||
if (nsCSSProps::PropHasFlags(iProp,
|
||||
CSS_PROPERTY_START_IMAGE_LOADS)) {
|
||||
if (ShouldStartImageLoads(aRuleData, iProp)) {
|
||||
for (nsCSSValueList* l = ValueListAtCursor(cursor);
|
||||
l; l = l->mNext) {
|
||||
TryToStartImageLoad(l->mValue, doc, iProp);
|
||||
|
|
|
@ -684,7 +684,12 @@ static void SetStyleImage(nsStyleContext* aStyleContext,
|
|||
case eCSSUnit_None:
|
||||
break;
|
||||
default:
|
||||
NS_NOTREACHED("unexpected unit; maybe nsCSSValue::Image::Image() failed?");
|
||||
// We might have eCSSUnit_URL values for if-visited style
|
||||
// contexts, which we can safely treat like 'none'. Otherwise
|
||||
// this is an unexpected unit.
|
||||
NS_ASSERTION(aStyleContext->IsStyleIfVisited() &&
|
||||
aValue.GetUnit() == eCSSUnit_URL,
|
||||
"unexpected unit; maybe nsCSSValue::Image::Image() failed?");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче