2017-10-27 20:33:53 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-05-17 06:21:07 +04:00
|
|
|
|
|
|
|
#include "inLayoutUtils.h"
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2006-05-17 06:21:07 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIContentViewer.h"
|
2006-05-17 06:38:51 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2006-05-17 06:21:07 +04:00
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIPresShell.h"
|
2006-05-17 06:38:40 +04:00
|
|
|
#include "nsPresContext.h"
|
2014-04-01 08:09:23 +04:00
|
|
|
#include "mozilla/EventStateManager.h"
|
2013-07-24 03:39:17 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2006-05-17 06:21:07 +04:00
|
|
|
|
2014-04-01 08:09:23 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2006-05-17 06:21:07 +04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-01-11 07:38:01 +03:00
|
|
|
EventStateManager* inLayoutUtils::GetEventStateManagerFor(Element& aElement) {
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* doc = aElement.OwnerDoc();
|
2018-02-21 01:00:10 +03:00
|
|
|
nsPresContext* presContext = doc->GetPresContext();
|
|
|
|
if (!presContext) return nullptr;
|
2006-05-17 06:37:43 +04:00
|
|
|
|
2018-02-21 01:00:10 +03:00
|
|
|
return presContext->EventStateManager();
|
2006-05-17 06:21:07 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* inLayoutUtils::GetSubDocumentFor(nsINode* aNode) {
|
2006-05-17 06:21:07 +04:00
|
|
|
nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
|
2006-05-17 06:33:39 +04:00
|
|
|
if (content) {
|
2019-01-02 16:05:23 +03:00
|
|
|
nsCOMPtr<Document> doc = content->GetComposedDoc();
|
2006-05-17 06:33:39 +04:00
|
|
|
if (doc) {
|
2018-05-11 20:46:15 +03:00
|
|
|
return doc->GetSubDocumentFor(content);
|
2006-05-17 06:33:39 +04:00
|
|
|
}
|
2006-05-17 06:21:07 +04:00
|
|
|
}
|
2013-07-24 03:39:17 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-05-17 06:21:07 +04:00
|
|
|
}
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
nsINode* inLayoutUtils::GetContainerFor(const Document& aDoc) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowOuter* pwin = aDoc.GetWindow();
|
2013-07-24 03:39:17 +04:00
|
|
|
if (!pwin) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2006-05-17 06:33:39 +04:00
|
|
|
|
2018-01-11 07:38:00 +03:00
|
|
|
return pwin->GetFrameElementInternal();
|
2006-05-17 06:21:07 +04:00
|
|
|
}
|