2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
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 "nsIDOMEvent.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"
|
2007-02-18 20:34:09 +03:00
|
|
|
#include "nsContentUtils.h"
|
2012-07-02 03:45:59 +04:00
|
|
|
#include "nsContentList.h"
|
2013-12-03 18:40:11 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2001-08-21 01:42:14 +04:00
|
|
|
|
|
|
|
//#define DEBUG_REFLOW
|
|
|
|
|
2013-12-03 18:40:11 +04:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
class nsDocElementBoxFrame : public nsBoxFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
2001-08-21 01:42:14 +04:00
|
|
|
public:
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) override;
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2015-01-06 12:27:56 +03:00
|
|
|
explicit nsDocElementBoxFrame(nsStyleContext* aContext)
|
|
|
|
:nsBoxFrame(aContext, true) {}
|
2001-08-21 01:42:14 +04:00
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
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
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsContainerFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewDocElementBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2001-08-21 01:42:14 +04:00
|
|
|
{
|
2015-01-06 12:27:56 +03:00
|
|
|
return new (aPresShell) nsDocElementBoxFrame(aContext);
|
2001-08-21 01:42:14 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
|
|
|
|
|
2007-02-18 20:34:09 +03:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2007-02-18 20:34:09 +03:00
|
|
|
{
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mPopupgroupContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mTooltipContent);
|
2009-12-24 08:21:15 +03:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
2007-02-18 20:34:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-05-07 00:04:44 +04:00
|
|
|
nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
2001-08-21 01:42:14 +04:00
|
|
|
{
|
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!
|
2014-06-20 06:01:40 +04:00
|
|
|
nsRefPtr<NodeInfo> nodeInfo;
|
2008-09-13 02:32:18 +04:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup,
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr, kNameSpaceID_XUL,
|
2011-06-14 11:56:49 +04:00
|
|
|
nsIDOMNode::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),
|
|
|
|
nodeInfo.forget());
|
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,
|
2011-06-14 11:56:49 +04:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::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
|
|
|
|
2010-07-23 13:49:57 +04:00
|
|
|
rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget());
|
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;
|
|
|
|
}
|
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
void
|
2014-07-16 22:41:57 +04:00
|
|
|
nsDocElementBoxFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t aFilter)
|
2010-02-11 20:34:01 +03:00
|
|
|
{
|
2014-07-16 22:41:57 +04:00
|
|
|
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
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsDocElementBoxFrame::GetFrameName(nsAString& aResult) const
|
2001-08-21 01:42:14 +04:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("DocElementBox"), aResult);
|
2001-08-21 01:42:14 +04:00
|
|
|
}
|
|
|
|
#endif
|