Skip to content

Commit

Permalink
Bug 1282484 - Cache the value of PreferFallback() because ShouldPlay(…
Browse files Browse the repository at this point in the history
…) is called several times during the load process. r=qDot

MozReview-Commit-ID: DqjCHssaJde
  • Loading branch information
felipc committed Jan 24, 2017
1 parent 917ff06 commit cedca66
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dom/base/nsObjectLoadingContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,9 @@ nsObjectLoadingContent::nsObjectLoadingContent()
, mIsStopping(false)
, mIsLoading(false)
, mScriptRequested(false)
, mRewrittenYoutubeEmbed(false) {}
, mRewrittenYoutubeEmbed(false)
, mPreferFallback(false)
, mPreferFallbackKnown(false) {}

nsObjectLoadingContent::~nsObjectLoadingContent()
{
Expand Down Expand Up @@ -3457,7 +3459,13 @@ nsObjectLoadingContent::HasGoodFallback() {

bool
nsObjectLoadingContent::PreferFallback(bool aIsPluginClickToPlay) {
return FavorFallbackMode(aIsPluginClickToPlay) && HasGoodFallback();
if (mPreferFallbackKnown) {
return mPreferFallback;
}

mPreferFallbackKnown = true;
mPreferFallback = FavorFallbackMode(aIsPluginClickToPlay) && HasGoodFallback();
return mPreferFallback;
}

nsIDocument*
Expand Down
5 changes: 5 additions & 0 deletions dom/base/nsObjectLoadingContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,11 @@ class nsObjectLoadingContent : public nsImageLoadingContent
// videos.
bool mRewrittenYoutubeEmbed : 1;

// Cache the answer of PreferFallback() because ShouldPlay is called several
// times during the load process.
bool mPreferFallback : 1;
bool mPreferFallbackKnown : 1;

nsWeakFrame mPrintFrame;

RefPtr<nsPluginInstanceOwner> mInstanceOwner;
Expand Down

0 comments on commit cedca66

Please sign in to comment.