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/. */
|
2001-08-21 01:42:14 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsPageFrame.h"
|
|
|
|
#include "nsStyleConsts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2001-08-21 01:42:14 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsBoxFrame.h"
|
|
|
|
#include "nsStackLayout.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
2014-06-20 06:01:40 +04:00
|
|
|
#include "mozilla/dom/NodeInfo.h"
|
2001-08-21 01:42:14 +04:00
|
|
|
#include "nsIServiceManager.h"
|
2004-06-25 16:26:02 +04:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2013-12-03 18:40:11 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2017-10-11 01:25:10 +03:00
|
|
|
#include "mozilla/dom/FromParser.h"
|
2001-08-21 01:42:14 +04:00
|
|
|
|
|
|
|
//#define DEBUG_REFLOW
|
|
|
|
|
2018-11-13 01:20:52 +03:00
|
|
|
using namespace mozilla;
|
2013-12-03 18:40:11 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2017-05-02 04:50:16 +03:00
|
|
|
class nsDocElementBoxFrame final : public nsBoxFrame,
|
|
|
|
public nsIAnonymousContentCreator {
|
2001-08-21 01:42:14 +04:00
|
|
|
public:
|
2017-11-07 03:20:33 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) override;
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
2018-03-22 21:20:41 +03:00
|
|
|
ComputedStyle* aStyle);
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
explicit nsDocElementBoxFrame(ComputedStyle* aStyle)
|
|
|
|
: nsBoxFrame(aStyle, kClassID, true) {}
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2017-05-26 13:11:11 +03:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
|
2001-08-21 01:42:14 +04:00
|
|
|
|
|
|
|
// nsIAnonymousContentCreator
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult CreateAnonymousContent(
|
|
|
|
nsTArray<ContentInfo>& aElements) override;
|
2014-07-16 22:41:57 +04:00
|
|
|
virtual void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
2015-03-21 19:28:04 +03:00
|
|
|
uint32_t aFilter) override;
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const override {
|
2007-02-24 21:33:33 +03:00
|
|
|
// Override nsBoxFrame.
|
|
|
|
if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2007-02-24 21:33:33 +03:00
|
|
|
return nsBoxFrame::IsFrameOfType(aFlags);
|
|
|
|
}
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const override;
|
2001-08-21 01:42:14 +04:00
|
|
|
#endif
|
2007-02-18 20:34:09 +03:00
|
|
|
private:
|
2013-12-03 18:40:11 +04:00
|
|
|
nsCOMPtr<Element> mPopupgroupContent;
|
|
|
|
nsCOMPtr<Element> mTooltipContent;
|
2001-08-21 01:42:14 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2018-03-22 21:20:41 +03:00
|
|
|
nsContainerFrame* NS_NewDocElementBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
ComputedStyle* aStyle) {
|
|
|
|
return new (aPresShell) nsDocElementBoxFrame(aStyle);
|
2001-08-21 01:42:14 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
|
|
|
|
|
2017-11-07 03:20:33 +03:00
|
|
|
void nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
|
|
|
PostDestroyData& aPostDestroyData) {
|
|
|
|
aPostDestroyData.AddAnonymousContent(mPopupgroupContent.forget());
|
|
|
|
aPostDestroyData.AddAnonymousContent(mTooltipContent.forget());
|
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot, aPostDestroyData);
|
2007-02-18 20:34:09 +03:00
|
|
|
}
|
|
|
|
|
2011-05-07 00:04:44 +04:00
|
|
|
nsresult nsDocElementBoxFrame::CreateAnonymousContent(
|
|
|
|
nsTArray<ContentInfo>& aElements) {
|
2014-08-23 00:11:27 +04:00
|
|
|
nsIDocument* doc = mContent->GetComposedDoc();
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!doc) {
|
2002-04-05 12:07:09 +04:00
|
|
|
// The page is currently being torn down. Why bother.
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-02-18 20:34:09 +03:00
|
|
|
}
|
2004-06-25 16:26:02 +04:00
|
|
|
nsNodeInfoManager* nodeInfoManager = doc->NodeInfoManager();
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2001-12-05 01:32:49 +03:00
|
|
|
// create the top-secret popupgroup node. shhhhh!
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<NodeInfo> nodeInfo;
|
2008-09-13 02:32:18 +04:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(
|
2012-07-30 18:20:58 +04:00
|
|
|
nsGkAtoms::popupgroup, nullptr, kNameSpaceID_XUL, nsINode::ELEMENT_NODE);
|
2008-09-26 02:46:52 +04:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2010-07-23 13:49:57 +04:00
|
|
|
nsresult rv = NS_NewXULElement(getter_AddRefs(mPopupgroupContent),
|
2017-10-11 01:25:10 +03:00
|
|
|
nodeInfo.forget(), dom::NOT_FROM_PARSER);
|
2004-06-25 16:26:02 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
if (!aElements.AppendElement(mPopupgroupContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2001-12-05 01:32:49 +03:00
|
|
|
// create the top-secret default tooltip node. shhhhh!
|
2012-07-30 18:20:58 +04:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(
|
|
|
|
nsGkAtoms::tooltip, nullptr, kNameSpaceID_XUL, nsINode::ELEMENT_NODE);
|
2008-09-26 02:46:52 +04:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2004-01-18 13:22:22 +03:00
|
|
|
|
2017-10-11 01:25:10 +03:00
|
|
|
rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget(),
|
|
|
|
dom::NOT_FROM_PARSER);
|
2004-06-25 16:26:02 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-07-20 15:16:17 +04:00
|
|
|
mTooltipContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_default,
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_LITERAL_STRING("true"), false);
|
2007-02-18 20:34:09 +03:00
|
|
|
|
|
|
|
if (!aElements.AppendElement(mTooltipContent)) return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2001-08-21 01:42:14 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-16 22:41:57 +04:00
|
|
|
void nsDocElementBoxFrame::AppendAnonymousContentTo(
|
|
|
|
nsTArray<nsIContent*>& aElements, uint32_t aFilter) {
|
|
|
|
if (mPopupgroupContent) {
|
|
|
|
aElements.AppendElement(mPopupgroupContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTooltipContent) {
|
|
|
|
aElements.AppendElement(mTooltipContent);
|
|
|
|
}
|
2010-02-11 20:34:01 +03:00
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsDocElementBoxFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsresult nsDocElementBoxFrame::GetFrameName(nsAString& aResult) const {
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("DocElementBox"), aResult);
|
2001-08-21 01:42:14 +04:00
|
|
|
}
|
|
|
|
#endif
|