Backed out changeset 3b956ceaaf8b (bug 1369815)

This commit is contained in:
Sebastian Hengst 2017-08-15 18:30:29 +02:00
Родитель 6d278c7bee
Коммит c5721643b5
4 изменённых файлов: 17 добавлений и 87 удалений

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

@ -842,7 +842,6 @@ nsDocShell::nsDocShell()
, mDefaultLoadFlags(nsIRequest::LOAD_NORMAL) , mDefaultLoadFlags(nsIRequest::LOAD_NORMAL)
, mFrameType(FRAME_TYPE_REGULAR) , mFrameType(FRAME_TYPE_REGULAR)
, mPrivateBrowsingId(0) , mPrivateBrowsingId(0)
, mDisplayMode(nsIDocShell::DISPLAY_MODE_BROWSER)
, mForcedCharset(nullptr) , mForcedCharset(nullptr)
, mParentCharset(nullptr) , mParentCharset(nullptr)
, mParentCharsetSource(0) , mParentCharsetSource(0)
@ -15089,33 +15088,3 @@ nsIDocShell::SetHTMLEditor(HTMLEditor* aHTMLEditor)
nsDocShell* docShell = static_cast<nsDocShell*>(this); nsDocShell* docShell = static_cast<nsDocShell*>(this);
return docShell->SetHTMLEditorInternal(aHTMLEditor); 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;
}

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

@ -1054,18 +1054,6 @@ protected:
nsString mInterceptedDocumentId; nsString mInterceptedDocumentId;
// This represents the CSS display-mode we are currently using.
// It can be any of the following values from nsIDocShell.idl:
//
// DISPLAY_MODE_BROWSER = 0
// DISPLAY_MODE_MINIMAL_UI = 1
// DISPLAY_MODE_STANDALONE = 2
// DISPLAY_MODE_FULLSCREEN = 3
//
// This is mostly used for media queries. The integer values above
// match those used in nsStyleConsts.h
uint32_t mDisplayMode;
private: private:
const Encoding* mForcedCharset; const Encoding* mForcedCharset;
const Encoding* mParentCharset; const Encoding* mParentCharset;

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

@ -1164,19 +1164,4 @@ interface nsIDocShell : nsIDocShellTreeItem
mozilla::HTMLEditor* GetHTMLEditor(); mozilla::HTMLEditor* GetHTMLEditor();
nsresult SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor); nsresult SetHTMLEditor(mozilla::HTMLEditor* aHTMLEditor);
%} %}
/**
* Allowed CSS display modes. This needs to be kept in
* sync with similar values in nsStyleConsts.h
*/
const unsigned long DISPLAY_MODE_BROWSER = 0;
const unsigned long DISPLAY_MODE_MINIMAL_UI = 1;
const unsigned long DISPLAY_MODE_STANDALONE = 2;
const unsigned long DISPLAY_MODE_FULLSCREEN = 3;
/**
* Display mode for this docshell. Defaults to DISPLAY_MODE_BROWSER.
* Media queries only look at the value in the parent docshell.
*/
attribute unsigned long displayMode;
}; };

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

@ -18,7 +18,6 @@
#include "nsCSSRuleProcessor.h" #include "nsCSSRuleProcessor.h"
#include "nsDeviceContext.h" #include "nsDeviceContext.h"
#include "nsIBaseWindow.h" #include "nsIBaseWindow.h"
#include "nsIDocShell.h"
#include "nsIDocument.h" #include "nsIDocument.h"
#include "nsIWidget.h" #include "nsIWidget.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
@ -305,44 +304,33 @@ GetDisplayMode(nsPresContext* aPresContext, const nsMediaFeature*,
nsCSSValue& aResult) nsCSSValue& aResult)
{ {
nsCOMPtr<nsISupports> container; nsCOMPtr<nsISupports> container;
RefPtr<nsIDocShell> docShell;
if (!aPresContext) {
aResult.SetIntValue(NS_STYLE_DISPLAY_MODE_BROWSER, eCSSUnit_Enumerated);
return;
}
if (aPresContext) { if (aPresContext) {
// Calling GetRootPresContext() can be slow, so make sure to call it // Calling GetRootPresContext() can be slow, so make sure to call it
// just once. // just once.
nsRootPresContext* root = aPresContext->GetRootPresContext(); nsRootPresContext* root = aPresContext->GetRootPresContext();
if (root && root->Document()) { if (root && root->Document()) {
container = root->Document()->GetContainer(); container = root->Document()->GetContainer();
docShell = root->GetDocShell();
} }
} }
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container); nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
if (baseWindow) { if (!baseWindow) {
nsCOMPtr<nsIWidget> mainWidget; aResult.SetIntValue(NS_STYLE_DISPLAY_MODE_BROWSER, eCSSUnit_Enumerated);
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
nsSizeMode mode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
if (mode == nsSizeMode_Fullscreen) {
aResult.SetIntValue(NS_STYLE_DISPLAY_MODE_FULLSCREEN, eCSSUnit_Enumerated);
return; return;
} }
} nsCOMPtr<nsIWidget> mainWidget;
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
static_assert(nsIDocShell::DISPLAY_MODE_BROWSER == NS_STYLE_DISPLAY_MODE_BROWSER && int32_t displayMode;
nsIDocShell::DISPLAY_MODE_MINIMAL_UI == NS_STYLE_DISPLAY_MODE_MINIMAL_UI && nsSizeMode mode = mainWidget ? mainWidget->SizeMode() : nsSizeMode_Normal;
nsIDocShell::DISPLAY_MODE_STANDALONE == NS_STYLE_DISPLAY_MODE_STANDALONE && // Background tabs are always in 'browser' mode for now.
nsIDocShell::DISPLAY_MODE_FULLSCREEN == NS_STYLE_DISPLAY_MODE_FULLSCREEN, // If new modes are supported, please ensure not cause the regression in
"nsIDocShell display modes must mach nsStyleConsts.h"); // Bug 1259641.
switch (mode) {
uint32_t displayMode = NS_STYLE_DISPLAY_MODE_BROWSER; case nsSizeMode_Fullscreen:
if (docShell) { displayMode = NS_STYLE_DISPLAY_MODE_FULLSCREEN;
docShell->GetDisplayMode(&displayMode); break;
default:
displayMode = NS_STYLE_DISPLAY_MODE_BROWSER;
break;
} }
aResult.SetIntValue(displayMode, eCSSUnit_Enumerated); aResult.SetIntValue(displayMode, eCSSUnit_Enumerated);