tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

inLayoutUtils.cpp (1464B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "inLayoutUtils.h"
      8 
      9 #include "mozilla/EventStateManager.h"
     10 #include "mozilla/dom/Document.h"
     11 #include "mozilla/dom/DocumentInlines.h"
     12 #include "mozilla/dom/Element.h"
     13 #include "nsIContent.h"
     14 #include "nsPIDOMWindow.h"
     15 #include "nsPresContext.h"
     16 
     17 using namespace mozilla;
     18 using namespace mozilla::dom;
     19 
     20 ///////////////////////////////////////////////////////////////////////////////
     21 
     22 EventStateManager* inLayoutUtils::GetEventStateManagerFor(Element& aElement) {
     23  Document* doc = aElement.OwnerDoc();
     24  nsPresContext* presContext = doc->GetPresContext();
     25  if (!presContext) {
     26    return nullptr;
     27  }
     28 
     29  return presContext->EventStateManager();
     30 }
     31 
     32 Document* inLayoutUtils::GetSubDocumentFor(nsINode* aNode) {
     33  nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
     34  if (content) {
     35    nsCOMPtr<Document> doc = content->GetComposedDoc();
     36    if (doc) {
     37      return doc->GetSubDocumentFor(content);
     38    }
     39  }
     40 
     41  return nullptr;
     42 }
     43 
     44 nsINode* inLayoutUtils::GetContainerFor(const Document& aDoc) {
     45  nsPIDOMWindowOuter* pwin = aDoc.GetWindow();
     46  if (!pwin) {
     47    return nullptr;
     48  }
     49 
     50  return pwin->GetFrameElementInternal();
     51 }