summaryrefslogtreecommitdiffstats
path: root/layout/generic
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-16 16:37:28 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-16 16:37:28 -0400
commit4375774c901bac4bd1ecaa35b40f55397044b7e9 (patch)
tree5c1a39a427b89390ee5ae54f75b04fa6536fb4a4 /layout/generic
parentc66ed1275f1039fdf23a8f2c172d7c0b4691d1c2 (diff)
downloadUXP-4375774c901bac4bd1ecaa35b40f55397044b7e9.tar
UXP-4375774c901bac4bd1ecaa35b40f55397044b7e9.tar.gz
UXP-4375774c901bac4bd1ecaa35b40f55397044b7e9.tar.lz
UXP-4375774c901bac4bd1ecaa35b40f55397044b7e9.tar.xz
UXP-4375774c901bac4bd1ecaa35b40f55397044b7e9.zip
Bug 1331322 - Allow tagging of pseudo-implementing native anonymous content with the pseudo type at creation time
* Stop using a node bit for HasExplicitBaseURI * Move MAY_HAVE_CLASS to mBoolFlags * Add a flag to indicate that a node is native anonymous content * Allow tagging of pseudo-implementing native anonymous content with the pseudo type at creation time, and eliminate explicit style contexts in nsIAnonymousContentCreator::ContentInfo Tag #1375
Diffstat (limited to 'layout/generic')
-rw-r--r--layout/generic/nsFrame.cpp30
-rw-r--r--layout/generic/nsIAnonymousContentCreator.h5
2 files changed, 30 insertions, 5 deletions
diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
index 0d0c7108c..ba1e9567a 100644
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -8918,6 +8918,8 @@ GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame)
*
* Also skip anonymous scrolled-content parents; inherit directly from the
* outer scroll frame.
+ *
+ * Also skip NAC parents if the child frame is NAC.
*/
static nsIFrame*
GetCorrectedParent(const nsIFrame* aFrame)
@@ -8943,6 +8945,31 @@ GetCorrectedParent(const nsIFrame* aFrame)
if (pseudo == nsCSSAnonBoxes::tableWrapper) {
pseudo = aFrame->PrincipalChildList().FirstChild()->StyleContext()->GetPseudo();
}
+
+ // Prevent NAC from inheriting NAC. This partially duplicates the logic
+ // implemented in nsCSSFrameConstructor::AddFCItemsForAnonymousContent, and is
+ // necessary so that restyle inherits style contexts in the same way as the
+ // initial styling performed in frame construction.
+ //
+ // It would be nice to put it in CorrectStyleParentFrame and therefore share
+ // it, but that would lose the information of whether the _child_ is NAC,
+ // since CorrectStyleParentFrame only knows about the prospective _parent_.
+ // This duplication and complexity will go away when we fully switch to the
+ // Servo style system, where all this can be handled much more naturally.
+ //
+ // We need to take special care not to disrupt the style inheritance of frames
+ // whose content is NAC but who implement a pseudo (like an anonymous
+ // box, or a non-NAC-backed pseudo like ::first-line) that does not match the
+ // one that the NAC implements, if any.
+ nsIContent* content = aFrame->GetContent();
+ Element* element = content->IsElement() ? content->AsElement() : nullptr;
+ if (element && element->IsNativeAnonymous() &&
+ element->GetPseudoElementType() == aFrame->StyleContext()->GetPseudoType()) {
+ while (parent->GetContent() && parent->GetContent()->IsNativeAnonymous()) {
+ parent = parent->GetParent();
+ }
+ }
+
return nsFrame::CorrectStyleParentFrame(parent, pseudo);
}
@@ -9013,6 +9040,9 @@ nsFrame::DoGetParentStyleContext(nsIFrame** aProviderFrame) const
{
*aProviderFrame = nullptr;
nsFrameManager* fm = PresContext()->FrameManager();
+
+ // Handle display:contents and the root frame, when there's no parent frame
+ // to inherit from.
if (MOZ_LIKELY(mContent)) {
nsIContent* parentContent = mContent->GetFlattenedTreeParent();
if (MOZ_LIKELY(parentContent)) {
diff --git a/layout/generic/nsIAnonymousContentCreator.h b/layout/generic/nsIAnonymousContentCreator.h
index 2728bb4bb..5167178b8 100644
--- a/layout/generic/nsIAnonymousContentCreator.h
+++ b/layout/generic/nsIAnonymousContentCreator.h
@@ -34,12 +34,7 @@ public:
mContent(aContent)
{}
- ContentInfo(nsIContent* aContent, nsStyleContext* aStyleContext) :
- mContent(aContent), mStyleContext(aStyleContext)
- {}
-
nsIContent* mContent;
- RefPtr<nsStyleContext> mStyleContext;
nsTArray<ContentInfo> mChildren;
};