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