2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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-20 21:42:14 +00: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 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
2001-08-20 21:42:14 +00:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsBoxFrame.h"
|
|
|
|
#include "nsStackLayout.h"
|
|
|
|
#include "nsIAnonymousContentCreator.h"
|
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2004-06-25 12:26:02 +00:00
|
|
|
#include "nsNodeInfoManager.h"
|
|
|
|
#include "nsContentCreatorFunctions.h"
|
2007-02-18 17:34:09 +00:00
|
|
|
#include "nsContentUtils.h"
|
2012-07-01 23:45:59 +00:00
|
|
|
#include "nsContentList.h"
|
2013-12-03 14:40:11 +00:00
|
|
|
#include "mozilla/dom/Element.h"
|
2001-08-20 21:42:14 +00:00
|
|
|
|
|
|
|
//#define DEBUG_REFLOW
|
|
|
|
|
2013-12-03 14:40:11 +00:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
class nsDocElementBoxFrame : public nsBoxFrame,
|
|
|
|
public nsIAnonymousContentCreator
|
|
|
|
{
|
2001-08-20 21:42:14 +00:00
|
|
|
public:
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
friend nsIFrame* NS_NewBoxFrame(nsIPresShell* aPresShell,
|
|
|
|
nsStyleContext* aContext);
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsDocElementBoxFrame(nsIPresShell* aShell, nsStyleContext* aContext)
|
2011-10-17 14:59:28 +00:00
|
|
|
:nsBoxFrame(aShell, aContext, true) {}
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_DECL_QUERYFRAME
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_DECL_FRAMEARENA_HELPERS
|
2001-08-20 21:42:14 +00:00
|
|
|
|
|
|
|
// nsIAnonymousContentCreator
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) MOZ_OVERRIDE;
|
2010-10-15 15:34:35 +00:00
|
|
|
virtual void AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2014-02-24 14:41:56 +00:00
|
|
|
uint32_t aFilter) MOZ_OVERRIDE;
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual bool IsFrameOfType(uint32_t aFlags) const MOZ_OVERRIDE
|
2007-02-24 18:33:33 +00:00
|
|
|
{
|
|
|
|
// Override nsBoxFrame.
|
|
|
|
if (aFlags & (nsIFrame::eReplacedContainsBlock | nsIFrame::eReplaced))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2007-02-24 18:33:33 +00:00
|
|
|
return nsBoxFrame::IsFrameOfType(aFlags);
|
|
|
|
}
|
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-24 14:41:56 +00:00
|
|
|
virtual nsresult GetFrameName(nsAString& aResult) const MOZ_OVERRIDE;
|
2001-08-20 21:42:14 +00:00
|
|
|
#endif
|
2007-02-18 17:34:09 +00:00
|
|
|
private:
|
2013-12-03 14:40:11 +00:00
|
|
|
nsCOMPtr<Element> mPopupgroupContent;
|
|
|
|
nsCOMPtr<Element> mTooltipContent;
|
2001-08-20 21:42:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewDocElementBoxFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2001-08-20 21:42:14 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsDocElementBoxFrame (aPresShell, aContext);
|
2001-08-20 21:42:14 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsDocElementBoxFrame)
|
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsDocElementBoxFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2007-02-18 17:34:09 +00:00
|
|
|
{
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mPopupgroupContent);
|
|
|
|
nsContentUtils::DestroyAnonymousContent(&mTooltipContent);
|
2009-12-24 05:21:15 +00:00
|
|
|
nsBoxFrame::DestroyFrom(aDestructRoot);
|
2007-02-18 17:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2011-05-06 20:04:44 +00:00
|
|
|
nsDocElementBoxFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
2001-08-20 21:42:14 +00:00
|
|
|
{
|
2003-07-28 21:25:13 +00:00
|
|
|
nsIDocument* doc = mContent->GetDocument();
|
2007-02-18 17:34:09 +00:00
|
|
|
if (!doc) {
|
2002-04-05 08:07:09 +00:00
|
|
|
// The page is currently being torn down. Why bother.
|
|
|
|
return NS_ERROR_FAILURE;
|
2007-02-18 17:34:09 +00:00
|
|
|
}
|
2004-06-25 12:26:02 +00:00
|
|
|
nsNodeInfoManager *nodeInfoManager = doc->NodeInfoManager();
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2001-12-04 22:32:49 +00:00
|
|
|
// create the top-secret popupgroup node. shhhhh!
|
2001-08-20 21:42:14 +00:00
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
2008-09-12 22:32:18 +00:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::popupgroup,
|
2012-07-30 14:20:58 +00:00
|
|
|
nullptr, kNameSpaceID_XUL,
|
2011-06-14 07:56:49 +00:00
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2008-09-25 22:46:52 +00:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2010-07-23 09:49:57 +00:00
|
|
|
nsresult rv = NS_NewXULElement(getter_AddRefs(mPopupgroupContent),
|
|
|
|
nodeInfo.forget());
|
2004-06-25 12:26:02 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2007-02-18 17:34:09 +00:00
|
|
|
if (!aElements.AppendElement(mPopupgroupContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2001-12-04 22:32:49 +00:00
|
|
|
// create the top-secret default tooltip node. shhhhh!
|
2012-07-30 14:20:58 +00:00
|
|
|
nodeInfo = nodeInfoManager->GetNodeInfo(nsGkAtoms::tooltip, nullptr,
|
2011-06-14 07:56:49 +00:00
|
|
|
kNameSpaceID_XUL,
|
|
|
|
nsIDOMNode::ELEMENT_NODE);
|
2008-09-25 22:46:52 +00:00
|
|
|
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
2004-01-18 10:22:22 +00:00
|
|
|
|
2010-07-23 09:49:57 +00:00
|
|
|
rv = NS_NewXULElement(getter_AddRefs(mTooltipContent), nodeInfo.forget());
|
2004-06-25 12:26:02 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-07-20 11:16:17 +00:00
|
|
|
mTooltipContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_default,
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_LITERAL_STRING("true"), false);
|
2007-02-18 17:34:09 +00:00
|
|
|
|
|
|
|
if (!aElements.AppendElement(mTooltipContent))
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
2001-08-20 21:42:14 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-11 17:34:01 +00:00
|
|
|
void
|
2010-10-15 15:34:35 +00:00
|
|
|
nsDocElementBoxFrame::AppendAnonymousContentTo(nsBaseContentList& aElements,
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t aFilter)
|
2010-02-11 17:34:01 +00:00
|
|
|
{
|
|
|
|
aElements.MaybeAppendElement(mPopupgroupContent);
|
|
|
|
aElements.MaybeAppendElement(mTooltipContent);
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsDocElementBoxFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsBoxFrame)
|
2001-08-20 21:42:14 +00:00
|
|
|
|
2014-01-05 23:31:14 +00:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 07:47:48 +00:00
|
|
|
nsresult
|
2001-11-14 01:33:42 +00:00
|
|
|
nsDocElementBoxFrame::GetFrameName(nsAString& aResult) const
|
2001-08-20 21:42:14 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("DocElementBox"), aResult);
|
2001-08-20 21:42:14 +00:00
|
|
|
}
|
|
|
|
#endif
|