зеркало из https://github.com/mozilla/gecko-dev.git
No bug - Remove CRs from nsDocument.cpp
This commit is contained in:
Родитель
46cd4d655a
Коммит
21a5651912
|
@ -8467,114 +8467,114 @@ nsIDocument::SizeOf() const
|
|||
return size;
|
||||
}
|
||||
|
||||
// Returns the root document in a document hierarchy.
|
||||
static nsIDocument*
|
||||
GetRootDocument(nsIDocument* aDoc)
|
||||
{
|
||||
if (!aDoc) {
|
||||
return nsnull;
|
||||
}
|
||||
nsCOMPtr<nsIPresShell> shell = aDoc->GetShell();
|
||||
if (!shell) {
|
||||
return nsnull;
|
||||
}
|
||||
nsPresContext* ctx = shell->GetPresContext();
|
||||
if (!ctx) {
|
||||
return nsnull;
|
||||
}
|
||||
nsRootPresContext* rpc = ctx->GetRootPresContext();
|
||||
if (!rpc) {
|
||||
return nsnull;
|
||||
}
|
||||
return rpc->Document();
|
||||
}
|
||||
|
||||
class nsDispatchFullScreenChange : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsDispatchFullScreenChange(nsIDocument *aDoc)
|
||||
: mDoc(aDoc)
|
||||
{
|
||||
mTarget = aDoc->GetFullScreenElement();
|
||||
if (!mTarget) {
|
||||
mTarget = aDoc;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsContentUtils::DispatchTrustedEvent(mDoc,
|
||||
mTarget,
|
||||
NS_LITERAL_STRING("mozfullscreenchange"),
|
||||
PR_TRUE,
|
||||
PR_FALSE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
nsCOMPtr<nsISupports> mTarget;
|
||||
};
|
||||
|
||||
void
|
||||
nsDocument::UpdateFullScreenStatus(bool aIsFullScreen)
|
||||
{
|
||||
if (mIsFullScreen != aIsFullScreen) {
|
||||
nsCOMPtr<nsIRunnable> event(new nsDispatchFullScreenChange(this));
|
||||
NS_DispatchToCurrentThread(event);
|
||||
}
|
||||
mIsFullScreen = aIsFullScreen;
|
||||
if (!mIsFullScreen) {
|
||||
// Full-screen is being turned off. Reset the full-screen element, to
|
||||
// save us from having to traverse the document hierarchy again in
|
||||
// MozCancelFullScreen().
|
||||
ResetFullScreenElement();
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
UpdateFullScreenStatus(nsIDocument* aDocument, void* aData)
|
||||
{
|
||||
aDocument->UpdateFullScreenStatus(*static_cast<bool*>(aData));
|
||||
aDocument->EnumerateSubDocuments(UpdateFullScreenStatus, aData);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateFullScreenStatusInDocTree(nsIDocument* aDoc, bool aIsFullScreen)
|
||||
{
|
||||
nsIDocument* root = GetRootDocument(aDoc);
|
||||
if (root) {
|
||||
UpdateFullScreenStatus(root, static_cast<void*>(&aIsFullScreen));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::ResetFullScreenElement()
|
||||
{
|
||||
// Returns the root document in a document hierarchy.
|
||||
static nsIDocument*
|
||||
GetRootDocument(nsIDocument* aDoc)
|
||||
{
|
||||
if (!aDoc) {
|
||||
return nsnull;
|
||||
}
|
||||
nsCOMPtr<nsIPresShell> shell = aDoc->GetShell();
|
||||
if (!shell) {
|
||||
return nsnull;
|
||||
}
|
||||
nsPresContext* ctx = shell->GetPresContext();
|
||||
if (!ctx) {
|
||||
return nsnull;
|
||||
}
|
||||
nsRootPresContext* rpc = ctx->GetRootPresContext();
|
||||
if (!rpc) {
|
||||
return nsnull;
|
||||
}
|
||||
return rpc->Document();
|
||||
}
|
||||
|
||||
class nsDispatchFullScreenChange : public nsRunnable
|
||||
{
|
||||
public:
|
||||
nsDispatchFullScreenChange(nsIDocument *aDoc)
|
||||
: mDoc(aDoc)
|
||||
{
|
||||
mTarget = aDoc->GetFullScreenElement();
|
||||
if (!mTarget) {
|
||||
mTarget = aDoc;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHOD Run()
|
||||
{
|
||||
nsContentUtils::DispatchTrustedEvent(mDoc,
|
||||
mTarget,
|
||||
NS_LITERAL_STRING("mozfullscreenchange"),
|
||||
PR_TRUE,
|
||||
PR_FALSE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
nsCOMPtr<nsISupports> mTarget;
|
||||
};
|
||||
|
||||
void
|
||||
nsDocument::UpdateFullScreenStatus(bool aIsFullScreen)
|
||||
{
|
||||
if (mIsFullScreen != aIsFullScreen) {
|
||||
nsCOMPtr<nsIRunnable> event(new nsDispatchFullScreenChange(this));
|
||||
NS_DispatchToCurrentThread(event);
|
||||
}
|
||||
mIsFullScreen = aIsFullScreen;
|
||||
if (!mIsFullScreen) {
|
||||
// Full-screen is being turned off. Reset the full-screen element, to
|
||||
// save us from having to traverse the document hierarchy again in
|
||||
// MozCancelFullScreen().
|
||||
ResetFullScreenElement();
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
UpdateFullScreenStatus(nsIDocument* aDocument, void* aData)
|
||||
{
|
||||
aDocument->UpdateFullScreenStatus(*static_cast<bool*>(aData));
|
||||
aDocument->EnumerateSubDocuments(UpdateFullScreenStatus, aData);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
UpdateFullScreenStatusInDocTree(nsIDocument* aDoc, bool aIsFullScreen)
|
||||
{
|
||||
nsIDocument* root = GetRootDocument(aDoc);
|
||||
if (root) {
|
||||
UpdateFullScreenStatus(root, static_cast<void*>(&aIsFullScreen));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::ResetFullScreenElement()
|
||||
{
|
||||
if (mFullScreenElement) {
|
||||
nsEventStateManager::SetFullScreenState(mFullScreenElement, PR_FALSE);
|
||||
}
|
||||
mFullScreenElement = nsnull;
|
||||
}
|
||||
|
||||
static bool
|
||||
ResetFullScreenElement(nsIDocument* aDocument, void* aData)
|
||||
{
|
||||
aDocument->ResetFullScreenElement();
|
||||
aDocument->EnumerateSubDocuments(ResetFullScreenElement, aData);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ResetFullScreenElementInDocTree(nsIDocument* aDoc)
|
||||
{
|
||||
nsIDocument* root = GetRootDocument(aDoc);
|
||||
if (root) {
|
||||
ResetFullScreenElement(root, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
}
|
||||
mFullScreenElement = nsnull;
|
||||
}
|
||||
|
||||
static bool
|
||||
ResetFullScreenElement(nsIDocument* aDocument, void* aData)
|
||||
{
|
||||
aDocument->ResetFullScreenElement();
|
||||
aDocument->EnumerateSubDocuments(ResetFullScreenElement, aData);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
ResetFullScreenElementInDocTree(nsIDocument* aDoc)
|
||||
{
|
||||
nsIDocument* root = GetRootDocument(aDoc);
|
||||
if (root) {
|
||||
ResetFullScreenElement(root, nsnull);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::MozCancelFullScreen()
|
||||
{
|
||||
if (!nsContentUtils::IsRequestFullScreenAllowed()) {
|
||||
|
@ -8582,104 +8582,104 @@ nsDocument::MozCancelFullScreen()
|
|||
}
|
||||
CancelFullScreen();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::CancelFullScreen()
|
||||
{
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() ||
|
||||
!IsFullScreenDoc() ||
|
||||
!GetWindow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable full-screen mode in all documents in this hierarchy.
|
||||
UpdateFullScreenStatusInDocTree(this, PR_FALSE);
|
||||
|
||||
// Move the window out of full-screen mode.
|
||||
GetWindow()->SetFullScreen(PR_FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsFullScreenDoc()
|
||||
{
|
||||
return nsContentUtils::IsFullScreenApiEnabled() && mIsFullScreen;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RequestFullScreen(Element* aElement)
|
||||
{
|
||||
if (!aElement || !nsContentUtils::IsFullScreenApiEnabled() || !GetWindow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the full-screen elements of every document in this document
|
||||
// hierarchy.
|
||||
ResetFullScreenElementInDocTree(this);
|
||||
|
||||
if (aElement->IsInDoc()) {
|
||||
// Propagate up the document hierarchy, setting the full-screen element as
|
||||
// the element's container in ancestor documents. Note we don't propagate
|
||||
// down the document hierarchy, the full-screen element (or its container)
|
||||
// is not visible there.
|
||||
mFullScreenElement = aElement;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::CancelFullScreen()
|
||||
{
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() ||
|
||||
!IsFullScreenDoc() ||
|
||||
!GetWindow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable full-screen mode in all documents in this hierarchy.
|
||||
UpdateFullScreenStatusInDocTree(this, PR_FALSE);
|
||||
|
||||
// Move the window out of full-screen mode.
|
||||
GetWindow()->SetFullScreen(PR_FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool
|
||||
nsDocument::IsFullScreenDoc()
|
||||
{
|
||||
return nsContentUtils::IsFullScreenApiEnabled() && mIsFullScreen;
|
||||
}
|
||||
|
||||
void
|
||||
nsDocument::RequestFullScreen(Element* aElement)
|
||||
{
|
||||
if (!aElement || !nsContentUtils::IsFullScreenApiEnabled() || !GetWindow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset the full-screen elements of every document in this document
|
||||
// hierarchy.
|
||||
ResetFullScreenElementInDocTree(this);
|
||||
|
||||
if (aElement->IsInDoc()) {
|
||||
// Propagate up the document hierarchy, setting the full-screen element as
|
||||
// the element's container in ancestor documents. Note we don't propagate
|
||||
// down the document hierarchy, the full-screen element (or its container)
|
||||
// is not visible there.
|
||||
mFullScreenElement = aElement;
|
||||
// Set the full-screen state on the element, so the css-pseudo class
|
||||
// applies to the element.
|
||||
nsEventStateManager::SetFullScreenState(mFullScreenElement, PR_TRUE);
|
||||
nsIDocument* child = this;
|
||||
nsIDocument* parent;
|
||||
while (parent = child->GetParentDocument()) {
|
||||
nsIContent* content = parent->FindContentForSubDocument(child);
|
||||
nsCOMPtr<Element> element(do_QueryInterface(content));
|
||||
nsEventStateManager::SetFullScreenState(mFullScreenElement, PR_TRUE);
|
||||
nsIDocument* child = this;
|
||||
nsIDocument* parent;
|
||||
while (parent = child->GetParentDocument()) {
|
||||
nsIContent* content = parent->FindContentForSubDocument(child);
|
||||
nsCOMPtr<Element> element(do_QueryInterface(content));
|
||||
// Containing frames also need the css-pseudo class applied.
|
||||
nsEventStateManager::SetFullScreenState(element, PR_TRUE);
|
||||
static_cast<nsDocument*>(parent)->mFullScreenElement = element;
|
||||
child = parent;
|
||||
}
|
||||
}
|
||||
|
||||
// Set all documents in hierarchy to full-screen mode.
|
||||
UpdateFullScreenStatusInDocTree(this, PR_TRUE);
|
||||
|
||||
// Make the window full-screen. Note we must make the state changes above
|
||||
// before making the window full-screen, as then the document reports as
|
||||
// being in full-screen mode when the Chrome "fullscreen" event fires,
|
||||
// enabling browser.js to distinguish between browser and dom full-screen
|
||||
// modes.
|
||||
GetWindow()->SetFullScreen(PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozFullScreenElement(nsIDOMHTMLElement **aFullScreenElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFullScreenElement);
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() || !IsFullScreenDoc()) {
|
||||
*aFullScreenElement = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLElement> e(do_QueryInterface(GetFullScreenElement()));
|
||||
NS_IF_ADDREF(*aFullScreenElement = e);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
nsDocument::GetFullScreenElement()
|
||||
{
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() ||
|
||||
(mFullScreenElement && !mFullScreenElement->IsInDoc())) {
|
||||
return nsnull;
|
||||
}
|
||||
return mFullScreenElement;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozFullScreen(bool *aFullScreen)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFullScreen);
|
||||
*aFullScreen = nsContentUtils::IsFullScreenApiEnabled() && IsFullScreenDoc();
|
||||
return NS_OK;
|
||||
nsEventStateManager::SetFullScreenState(element, PR_TRUE);
|
||||
static_cast<nsDocument*>(parent)->mFullScreenElement = element;
|
||||
child = parent;
|
||||
}
|
||||
}
|
||||
|
||||
// Set all documents in hierarchy to full-screen mode.
|
||||
UpdateFullScreenStatusInDocTree(this, PR_TRUE);
|
||||
|
||||
// Make the window full-screen. Note we must make the state changes above
|
||||
// before making the window full-screen, as then the document reports as
|
||||
// being in full-screen mode when the Chrome "fullscreen" event fires,
|
||||
// enabling browser.js to distinguish between browser and dom full-screen
|
||||
// modes.
|
||||
GetWindow()->SetFullScreen(PR_TRUE);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozFullScreenElement(nsIDOMHTMLElement **aFullScreenElement)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFullScreenElement);
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() || !IsFullScreenDoc()) {
|
||||
*aFullScreenElement = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsIDOMHTMLElement> e(do_QueryInterface(GetFullScreenElement()));
|
||||
NS_IF_ADDREF(*aFullScreenElement = e);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Element*
|
||||
nsDocument::GetFullScreenElement()
|
||||
{
|
||||
if (!nsContentUtils::IsFullScreenApiEnabled() ||
|
||||
(mFullScreenElement && !mFullScreenElement->IsInDoc())) {
|
||||
return nsnull;
|
||||
}
|
||||
return mFullScreenElement;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocument::GetMozFullScreen(bool *aFullScreen)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aFullScreen);
|
||||
*aFullScreen = nsContentUtils::IsFullScreenApiEnabled() && IsFullScreenDoc();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt64
|
||||
|
|
Загрузка…
Ссылка в новой задаче