Bug 1369815 - Add display mode to nsIDocShell and use it for media queries r=heycam

MozReview-Commit-ID: EVT0fTk6GfC
This commit is contained in:
James Willcox
2017-08-09 08:54:06 -05:00
parent c49fcbeb58
commit b54f5823a2
4 changed files with 87 additions and 17 deletions

View File

@@ -842,6 +842,7 @@ nsDocShell::nsDocShell()
, mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
, mFrameType(FRAME_TYPE_REGULAR)
, mPrivateBrowsingId(0)
, mDisplayMode(nsIDocShell::DISPLAY_MODE_BROWSER)
, mForcedCharset(nullptr)
, mParentCharset(nullptr)
, mParentCharsetSource(0)
@@ -15088,3 +15089,33 @@ nsIDocShell::SetHTMLEditor(HTMLEditor* aHTMLEditor)
nsDocShell* docShell = static_cast<nsDocShell*>(this);
return docShell->SetHTMLEditorInternal(aHTMLEditor);
}
NS_IMETHODIMP
nsDocShell::GetDisplayMode(uint32_t* aDisplayMode)
{
NS_ENSURE_ARG_POINTER(aDisplayMode);
*aDisplayMode = mDisplayMode;
return NS_OK;
}
NS_IMETHODIMP
nsDocShell::SetDisplayMode(uint32_t aDisplayMode)
{
if (!(aDisplayMode == nsIDocShell::DISPLAY_MODE_BROWSER ||
aDisplayMode == nsIDocShell::DISPLAY_MODE_STANDALONE ||
aDisplayMode == nsIDocShell::DISPLAY_MODE_FULLSCREEN ||
aDisplayMode == nsIDocShell::DISPLAY_MODE_MINIMAL_UI)) {
return NS_ERROR_INVALID_ARG;
}
if (aDisplayMode != mDisplayMode) {
mDisplayMode = aDisplayMode;
nsPresContext* presContext;
if (NS_SUCCEEDED(GetPresContext(&presContext))) {
presContext->MediaFeatureValuesChangedAllDocuments(nsRestyleHint(0));
}
}
return NS_OK;
}