mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 591737 - Provide a default summary element by DetailsFrame. r=bz
If a <details> lacks a direct <summary> child, we need to construct a default one.
This commit is contained in:
parent
cccd994b1c
commit
0d567179f1
@ -19,6 +19,7 @@ NS_IMPL_FRAMEARENA_HELPERS(DetailsFrame)
|
||||
|
||||
NS_QUERYFRAME_HEAD(DetailsFrame)
|
||||
NS_QUERYFRAME_ENTRY(DetailsFrame)
|
||||
NS_QUERYFRAME_ENTRY(nsIAnonymousContentCreator)
|
||||
NS_QUERYFRAME_TAIL_INHERITING(nsBlockFrame)
|
||||
|
||||
DetailsFrame*
|
||||
@ -80,3 +81,47 @@ DetailsFrame::SetInitialChildList(ChildListID aListID, nsFrameList& aChildList)
|
||||
|
||||
nsBlockFrame::SetInitialChildList(aListID, aChildList);
|
||||
}
|
||||
|
||||
void
|
||||
DetailsFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
||||
{
|
||||
nsContentUtils::DestroyAnonymousContent(&mDefaultSummary);
|
||||
nsBlockFrame::DestroyFrom(aDestructRoot);
|
||||
}
|
||||
|
||||
nsresult
|
||||
DetailsFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
|
||||
{
|
||||
auto* details = HTMLDetailsElement::FromContent(GetContent());
|
||||
if (details->GetFirstSummary()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// The <details> element lacks any direct <summary> child. Create a default
|
||||
// <summary> element as an anonymous content.
|
||||
nsNodeInfoManager* nodeInfoManager =
|
||||
GetContent()->NodeInfo()->NodeInfoManager();
|
||||
|
||||
already_AddRefed<NodeInfo> nodeInfo =
|
||||
nodeInfoManager->GetNodeInfo(nsGkAtoms::summary, nullptr, kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
mDefaultSummary = new HTMLSummaryElement(nodeInfo);
|
||||
|
||||
// TODO: Need to localize this "Details" string in bug 1225752.
|
||||
RefPtr<nsTextNode> description = new nsTextNode(nodeInfoManager);
|
||||
description->SetText(NS_LITERAL_STRING("Details"), false);
|
||||
mDefaultSummary->AppendChildTo(description, false);
|
||||
|
||||
aElements.AppendElement(mDefaultSummary);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
DetailsFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
||||
uint32_t aFilter)
|
||||
{
|
||||
if (mDefaultSummary) {
|
||||
aElements.AppendElement(mDefaultSummary);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define DetailsFrame_h
|
||||
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsIAnonymousContentCreator.h"
|
||||
|
||||
class nsContainerFrame;
|
||||
class nsStyleContext;
|
||||
@ -17,6 +18,7 @@ class nsStyleContext;
|
||||
// DetailsFrame.
|
||||
//
|
||||
class DetailsFrame final : public nsBlockFrame
|
||||
, public nsIAnonymousContentCreator
|
||||
{
|
||||
public:
|
||||
NS_DECL_FRAMEARENA_HELPERS
|
||||
@ -38,6 +40,17 @@ public:
|
||||
|
||||
void SetInitialChildList(ChildListID aListID,
|
||||
nsFrameList& aChildList) override;
|
||||
|
||||
void DestroyFrom(nsIFrame* aDestructRoot) override;
|
||||
|
||||
// nsIAnonymousContentCreator
|
||||
nsresult CreateAnonymousContent(nsTArray<ContentInfo>& aElements) override;
|
||||
|
||||
void AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
||||
uint32_t aFilter) override;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIContent> mDefaultSummary;
|
||||
};
|
||||
|
||||
#endif // DetailsFrame_h
|
||||
|
Loading…
Reference in New Issue
Block a user