From 021e20ff2cc97d1f1e6cb184cb9b15d8582fa55b Mon Sep 17 00:00:00 2001 From: peterl Date: Mon, 18 May 1998 21:06:33 +0000 Subject: [PATCH] added pseudo style support git-svn-id: svn://10.0.0.236/trunk@1843 18797224-902f-48f8-a5cc-f745e15eee43 --- .../content/html/content/src/nsHTMLAtoms.cpp | 6 ++++ .../content/html/content/src/nsHTMLAtoms.h | 2 ++ mozilla/content/shared/public/nsHTMLAtoms.h | 2 ++ mozilla/content/shared/src/nsHTMLAtoms.cpp | 6 ++++ mozilla/layout/base/nsPresContext.cpp | 30 +++++++++++++++++++ mozilla/layout/base/src/nsPresContext.cpp | 30 +++++++++++++++++++ mozilla/layout/base/src/nsPresContext.h | 4 +++ mozilla/layout/html/base/src/nsBodyFrame.cpp | 3 +- mozilla/layout/html/base/src/nsHTMLAtoms.cpp | 6 ++++ mozilla/layout/html/base/src/nsHTMLAtoms.h | 2 ++ mozilla/layout/html/base/src/nsRootPart.cpp | 3 +- 11 files changed, 92 insertions(+), 2 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.cpp b/mozilla/content/html/content/src/nsHTMLAtoms.cpp index 7b54160e509..a2f90fafe73 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.cpp +++ b/mozilla/content/html/content/src/nsHTMLAtoms.cpp @@ -44,6 +44,7 @@ nsIAtom* nsHTMLAtoms::codebase; nsIAtom* nsHTMLAtoms::color; nsIAtom* nsHTMLAtoms::cols; nsIAtom* nsHTMLAtoms::colspan; +nsIAtom* nsHTMLAtoms::columnPseudo; nsIAtom* nsHTMLAtoms::compact; nsIAtom* nsHTMLAtoms::coords; nsIAtom* nsHTMLAtoms::data; @@ -103,6 +104,7 @@ nsIAtom* nsHTMLAtoms::prompt; nsIAtom* nsHTMLAtoms::readonly; nsIAtom* nsHTMLAtoms::rel; nsIAtom* nsHTMLAtoms::rightpadding; +nsIAtom* nsHTMLAtoms::rootContentPseudo; nsIAtom* nsHTMLAtoms::rows; nsIAtom* nsHTMLAtoms::rowspan; nsIAtom* nsHTMLAtoms::scrolling; @@ -165,6 +167,7 @@ void nsHTMLAtoms::AddrefAtoms() color = NS_NewAtom("COLOR"); cols = NS_NewAtom("COLS"); colspan = NS_NewAtom("COLSPAN"); + columnPseudo = NS_NewAtom(":BODY-COLUMN"); compact = NS_NewAtom("COMPACT"); coords = NS_NewAtom("COORDS"); dir = NS_NewAtom("DIR"); @@ -224,6 +227,7 @@ void nsHTMLAtoms::AddrefAtoms() readonly = NS_NewAtom("READONLY"); rel = NS_NewAtom("REL"); rightpadding = NS_NewAtom("RIGHTPADDING"); + rootContentPseudo = NS_NewAtom(":ROOT-CONTENT"); rows = NS_NewAtom("ROWS"); rowspan = NS_NewAtom("ROWSPAN"); scrolling = NS_NewAtom("SCROLLING"); @@ -287,6 +291,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(color); NS_RELEASE(cols); NS_RELEASE(colspan); + NS_RELEASE(columnPseudo); NS_RELEASE(compact); NS_RELEASE(coords); NS_RELEASE(dir); @@ -346,6 +351,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(readonly); NS_RELEASE(rel); NS_RELEASE(rightpadding); + NS_RELEASE(rootContentPseudo); NS_RELEASE(rows); NS_RELEASE(rowspan); NS_RELEASE(scrolling); diff --git a/mozilla/content/html/content/src/nsHTMLAtoms.h b/mozilla/content/html/content/src/nsHTMLAtoms.h index f9d697f6fc4..49e3f5d2572 100644 --- a/mozilla/content/html/content/src/nsHTMLAtoms.h +++ b/mozilla/content/html/content/src/nsHTMLAtoms.h @@ -62,6 +62,7 @@ public: static nsIAtom* color; static nsIAtom* cols; static nsIAtom* colspan; + static nsIAtom* columnPseudo; static nsIAtom* compact; static nsIAtom* coords; @@ -133,6 +134,7 @@ public: static nsIAtom* readonly; static nsIAtom* rel; static nsIAtom* rightpadding; + static nsIAtom* rootContentPseudo; static nsIAtom* rows; static nsIAtom* rowspan; diff --git a/mozilla/content/shared/public/nsHTMLAtoms.h b/mozilla/content/shared/public/nsHTMLAtoms.h index f9d697f6fc4..49e3f5d2572 100644 --- a/mozilla/content/shared/public/nsHTMLAtoms.h +++ b/mozilla/content/shared/public/nsHTMLAtoms.h @@ -62,6 +62,7 @@ public: static nsIAtom* color; static nsIAtom* cols; static nsIAtom* colspan; + static nsIAtom* columnPseudo; static nsIAtom* compact; static nsIAtom* coords; @@ -133,6 +134,7 @@ public: static nsIAtom* readonly; static nsIAtom* rel; static nsIAtom* rightpadding; + static nsIAtom* rootContentPseudo; static nsIAtom* rows; static nsIAtom* rowspan; diff --git a/mozilla/content/shared/src/nsHTMLAtoms.cpp b/mozilla/content/shared/src/nsHTMLAtoms.cpp index 7b54160e509..a2f90fafe73 100644 --- a/mozilla/content/shared/src/nsHTMLAtoms.cpp +++ b/mozilla/content/shared/src/nsHTMLAtoms.cpp @@ -44,6 +44,7 @@ nsIAtom* nsHTMLAtoms::codebase; nsIAtom* nsHTMLAtoms::color; nsIAtom* nsHTMLAtoms::cols; nsIAtom* nsHTMLAtoms::colspan; +nsIAtom* nsHTMLAtoms::columnPseudo; nsIAtom* nsHTMLAtoms::compact; nsIAtom* nsHTMLAtoms::coords; nsIAtom* nsHTMLAtoms::data; @@ -103,6 +104,7 @@ nsIAtom* nsHTMLAtoms::prompt; nsIAtom* nsHTMLAtoms::readonly; nsIAtom* nsHTMLAtoms::rel; nsIAtom* nsHTMLAtoms::rightpadding; +nsIAtom* nsHTMLAtoms::rootContentPseudo; nsIAtom* nsHTMLAtoms::rows; nsIAtom* nsHTMLAtoms::rowspan; nsIAtom* nsHTMLAtoms::scrolling; @@ -165,6 +167,7 @@ void nsHTMLAtoms::AddrefAtoms() color = NS_NewAtom("COLOR"); cols = NS_NewAtom("COLS"); colspan = NS_NewAtom("COLSPAN"); + columnPseudo = NS_NewAtom(":BODY-COLUMN"); compact = NS_NewAtom("COMPACT"); coords = NS_NewAtom("COORDS"); dir = NS_NewAtom("DIR"); @@ -224,6 +227,7 @@ void nsHTMLAtoms::AddrefAtoms() readonly = NS_NewAtom("READONLY"); rel = NS_NewAtom("REL"); rightpadding = NS_NewAtom("RIGHTPADDING"); + rootContentPseudo = NS_NewAtom(":ROOT-CONTENT"); rows = NS_NewAtom("ROWS"); rowspan = NS_NewAtom("ROWSPAN"); scrolling = NS_NewAtom("SCROLLING"); @@ -287,6 +291,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(color); NS_RELEASE(cols); NS_RELEASE(colspan); + NS_RELEASE(columnPseudo); NS_RELEASE(compact); NS_RELEASE(coords); NS_RELEASE(dir); @@ -346,6 +351,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(readonly); NS_RELEASE(rel); NS_RELEASE(rightpadding); + NS_RELEASE(rootContentPseudo); NS_RELEASE(rows); NS_RELEASE(rowspan); NS_RELEASE(scrolling); diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index 5bce3411f90..d955fc0e8ac 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -128,6 +128,36 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent, return result; } +nsIStyleContext* +nsPresContext::ResolvePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame) +{ + nsIStyleContext* result = nsnull; + + nsIStyleSet* set = mShell->GetStyleSet(); + if (nsnull != set) { + result = set->ResolvePseudoStyleFor(this, aPseudoTag, aParentFrame); + NS_RELEASE(set); + } + + return result; +} + +nsIStyleContext* +nsPresContext::ProbePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame) +{ + nsIStyleContext* result = nsnull; + + nsIStyleSet* set = mShell->GetStyleSet(); + if (nsnull != set) { + result = set->ProbePseudoStyleFor(this, aPseudoTag, aParentFrame); + NS_RELEASE(set); + } + + return result; +} + nsIFontMetrics* nsPresContext::GetMetricsFor(const nsFont& aFont) { diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index 5bce3411f90..d955fc0e8ac 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -128,6 +128,36 @@ nsPresContext::ResolveStyleContextFor(nsIContent* aContent, return result; } +nsIStyleContext* +nsPresContext::ResolvePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame) +{ + nsIStyleContext* result = nsnull; + + nsIStyleSet* set = mShell->GetStyleSet(); + if (nsnull != set) { + result = set->ResolvePseudoStyleFor(this, aPseudoTag, aParentFrame); + NS_RELEASE(set); + } + + return result; +} + +nsIStyleContext* +nsPresContext::ProbePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame) +{ + nsIStyleContext* result = nsnull; + + nsIStyleSet* set = mShell->GetStyleSet(); + if (nsnull != set) { + result = set->ProbePseudoStyleFor(this, aPseudoTag, aParentFrame); + NS_RELEASE(set); + } + + return result; +} + nsIFontMetrics* nsPresContext::GetMetricsFor(const nsFont& aFont) { diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index 734a4e81d02..87f112511be 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -35,6 +35,10 @@ public: virtual nsIPresShell* GetShell(); virtual nsIStyleContext* ResolveStyleContextFor(nsIContent* aContent, nsIFrame* aParentFrame); + virtual nsIStyleContext* ResolvePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame); + virtual nsIStyleContext* ProbePseudoStyleContextFor(nsIAtom* aPseudoTag, + nsIFrame* aParentFrame); virtual nsIFontMetrics* GetMetricsFor(const nsFont& aFont); virtual const nsFont& GetDefaultFont(void); NS_IMETHOD GetImageGroup(nsIImageGroup*& aGroupResult); diff --git a/mozilla/layout/html/base/src/nsBodyFrame.cpp b/mozilla/layout/html/base/src/nsBodyFrame.cpp index 74d7c21806f..319eedb0bc0 100644 --- a/mozilla/layout/html/base/src/nsBodyFrame.cpp +++ b/mozilla/layout/html/base/src/nsBodyFrame.cpp @@ -28,6 +28,7 @@ #include "nsIDeviceContext.h" #include "nsBlockFrame.h" #include "nsSpaceManager.h" +#include "nsHTMLAtoms.h" static NS_DEFINE_IID(kIRunaroundIID, NS_IRUNAROUND_IID); static NS_DEFINE_IID(kIAnchoredItemsIID, NS_IANCHOREDITEMS_IID); @@ -86,7 +87,7 @@ void nsBodyFrame::CreateColumnFrame(nsIPresContext* aPresContext) // Resolve style and set the style context nsIStyleContext* styleContext = - aPresContext->ResolveStyleContextFor(mContent, this); + aPresContext->ResolvePseudoStyleContextFor(nsHTMLAtoms::columnPseudo, this); mFirstChild->SetStyleContext(aPresContext,styleContext); NS_RELEASE(styleContext); } else { diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp index 7b54160e509..a2f90fafe73 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.cpp +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.cpp @@ -44,6 +44,7 @@ nsIAtom* nsHTMLAtoms::codebase; nsIAtom* nsHTMLAtoms::color; nsIAtom* nsHTMLAtoms::cols; nsIAtom* nsHTMLAtoms::colspan; +nsIAtom* nsHTMLAtoms::columnPseudo; nsIAtom* nsHTMLAtoms::compact; nsIAtom* nsHTMLAtoms::coords; nsIAtom* nsHTMLAtoms::data; @@ -103,6 +104,7 @@ nsIAtom* nsHTMLAtoms::prompt; nsIAtom* nsHTMLAtoms::readonly; nsIAtom* nsHTMLAtoms::rel; nsIAtom* nsHTMLAtoms::rightpadding; +nsIAtom* nsHTMLAtoms::rootContentPseudo; nsIAtom* nsHTMLAtoms::rows; nsIAtom* nsHTMLAtoms::rowspan; nsIAtom* nsHTMLAtoms::scrolling; @@ -165,6 +167,7 @@ void nsHTMLAtoms::AddrefAtoms() color = NS_NewAtom("COLOR"); cols = NS_NewAtom("COLS"); colspan = NS_NewAtom("COLSPAN"); + columnPseudo = NS_NewAtom(":BODY-COLUMN"); compact = NS_NewAtom("COMPACT"); coords = NS_NewAtom("COORDS"); dir = NS_NewAtom("DIR"); @@ -224,6 +227,7 @@ void nsHTMLAtoms::AddrefAtoms() readonly = NS_NewAtom("READONLY"); rel = NS_NewAtom("REL"); rightpadding = NS_NewAtom("RIGHTPADDING"); + rootContentPseudo = NS_NewAtom(":ROOT-CONTENT"); rows = NS_NewAtom("ROWS"); rowspan = NS_NewAtom("ROWSPAN"); scrolling = NS_NewAtom("SCROLLING"); @@ -287,6 +291,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(color); NS_RELEASE(cols); NS_RELEASE(colspan); + NS_RELEASE(columnPseudo); NS_RELEASE(compact); NS_RELEASE(coords); NS_RELEASE(dir); @@ -346,6 +351,7 @@ void nsHTMLAtoms::ReleaseAtoms() NS_RELEASE(readonly); NS_RELEASE(rel); NS_RELEASE(rightpadding); + NS_RELEASE(rootContentPseudo); NS_RELEASE(rows); NS_RELEASE(rowspan); NS_RELEASE(scrolling); diff --git a/mozilla/layout/html/base/src/nsHTMLAtoms.h b/mozilla/layout/html/base/src/nsHTMLAtoms.h index f9d697f6fc4..49e3f5d2572 100644 --- a/mozilla/layout/html/base/src/nsHTMLAtoms.h +++ b/mozilla/layout/html/base/src/nsHTMLAtoms.h @@ -62,6 +62,7 @@ public: static nsIAtom* color; static nsIAtom* cols; static nsIAtom* colspan; + static nsIAtom* columnPseudo; static nsIAtom* compact; static nsIAtom* coords; @@ -133,6 +134,7 @@ public: static nsIAtom* readonly; static nsIAtom* rel; static nsIAtom* rightpadding; + static nsIAtom* rootContentPseudo; static nsIAtom* rows; static nsIAtom* rowspan; diff --git a/mozilla/layout/html/base/src/nsRootPart.cpp b/mozilla/layout/html/base/src/nsRootPart.cpp index bb718461386..d8289934865 100644 --- a/mozilla/layout/html/base/src/nsRootPart.cpp +++ b/mozilla/layout/html/base/src/nsRootPart.cpp @@ -34,6 +34,7 @@ #include "nsGUIEvent.h" #include "nsStyleConsts.h" #include "nsIViewManager.h" +#include "nsHTMLAtoms.h" class RootFrame : public nsContainerFrame { public: @@ -104,7 +105,7 @@ NS_METHOD RootFrame::ResizeReflow(nsIPresContext* aPresContext, // No. Create a pseudo frame mFirstChild = new RootContentFrame(mContent, this); mChildCount = 1; - nsIStyleContext* style = aPresContext->ResolveStyleContextFor(mContent, this); + nsIStyleContext* style = aPresContext->ResolvePseudoStyleContextFor(nsHTMLAtoms::rootContentPseudo, this); mFirstChild->SetStyleContext(aPresContext,style); NS_RELEASE(style); }