Bug 1239899. Part 1 - Remove ElementInTreeState for ELEMENT_NOT_INTREE and ELEMENT_INTREE are not used at all. We can use a bool flag to do the job. r=cpearce

MozReview-Commit-ID: 4htNy1dZODF
This commit is contained in:
JW Wang
2016-09-23 14:51:52 +08:00
parent d41a5a0f02
commit 19ae50ff0f
2 changed files with 11 additions and 20 deletions

View File

@@ -2907,7 +2907,6 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mAudioChannelVolume(1.0),
mPlayingThroughTheAudioChannel(false),
mDisableVideo(false),
mElementInTreeState(ELEMENT_NOT_INTREE),
mHasUserInteraction(false),
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0),
@@ -3408,6 +3407,9 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
aParent,
aBindingParent,
aCompileEventHandlers);
mUnboundFromTree = false;
if (aDocument) {
mAutoplayEnabled =
IsAutoplayEnabled() && (!aDocument || !aDocument->IsStaticDocument()) &&
@@ -3416,7 +3418,6 @@ nsresult HTMLMediaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParen
// It's value may have changed, so update it.
UpdatePreloadAction();
}
mElementInTreeState = ELEMENT_INTREE;
if (mDecoder) {
// When the MediaElement is binding to tree, the dormant status is
@@ -3650,12 +3651,12 @@ HTMLMediaElement::ReportTelemetry()
void HTMLMediaElement::UnbindFromTree(bool aDeep,
bool aNullParent)
{
mUnboundFromTree = true;
if (!mPaused && mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
Pause();
}
mElementInTreeState = ELEMENT_NOT_INTREE_HAD_INTREE;
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
if (mDecoder) {
@@ -4989,11 +4990,8 @@ bool HTMLMediaElement::IsActive() const
bool HTMLMediaElement::IsHidden() const
{
if (mElementInTreeState == ELEMENT_NOT_INTREE_HAD_INTREE) {
return true;
}
nsIDocument* ownerDoc = OwnerDoc();
return !ownerDoc || ownerDoc->Hidden();
nsIDocument* ownerDoc;
return mUnboundFromTree || !(ownerDoc = OwnerDoc()) || ownerDoc->Hidden();
}
VideoFrameContainer* HTMLMediaElement::GetVideoFrameContainer()