Additional cleanup after bug 56117: prevent :first-letter from leading to style resolution on text nodes and stop all style resolution for placeholder frames (formerly :placeholder-frame pseudo-element) and for text following a :first-line pseudo-element (formerly :-moz-letter-frame pseudo-element). b=107534 r=waterson, attinasi sr=hyatt

This commit is contained in:
dbaron%fas.harvard.edu 2001-10-31 02:53:47 +00:00
Родитель 29077ba289
Коммит 978c81f4e8
12 изменённых файлов: 83 добавлений и 100 удалений

Просмотреть файл

@ -55,7 +55,6 @@
HTML_ATOM(mozAnonymousBlock, ":-moz-anonymous-block")
HTML_ATOM(mozAnonymousPositionedBlock, ":-moz-anonymous-positioned-block")
HTML_ATOM(mozFirstLineFixup, ":-moz-first-line-fixup")
HTML_ATOM(mozLetterFrame, ":-moz-letter-frame")
HTML_ATOM(mozLineFrame, ":-moz-line-frame")
HTML_ATOM(mozListBulletPseudo, ":-moz-list-bullet")
HTML_ATOM(mozSingleLineTextControlFrame, ":-moz-singleline-textcontrol-frame")
@ -231,7 +230,6 @@ HTML_ATOM(p, "p")
HTML_ATOM(pagex, "pagex")
HTML_ATOM(pagey, "pagey")
HTML_ATOM(param, "param")
HTML_ATOM(placeholderPseudo, ":placeholder-frame")
HTML_ATOM(pointSize, "point-size")
HTML_ATOM(pre, "pre")
HTML_ATOM(profile, "profile")

Просмотреть файл

@ -55,7 +55,6 @@
HTML_ATOM(mozAnonymousBlock, ":-moz-anonymous-block")
HTML_ATOM(mozAnonymousPositionedBlock, ":-moz-anonymous-positioned-block")
HTML_ATOM(mozFirstLineFixup, ":-moz-first-line-fixup")
HTML_ATOM(mozLetterFrame, ":-moz-letter-frame")
HTML_ATOM(mozLineFrame, ":-moz-line-frame")
HTML_ATOM(mozListBulletPseudo, ":-moz-list-bullet")
HTML_ATOM(mozSingleLineTextControlFrame, ":-moz-singleline-textcontrol-frame")
@ -231,7 +230,6 @@ HTML_ATOM(p, "p")
HTML_ATOM(pagex, "pagex")
HTML_ATOM(pagey, "pagey")
HTML_ATOM(param, "param")
HTML_ATOM(placeholderPseudo, ":placeholder-frame")
HTML_ATOM(pointSize, "point-size")
HTML_ATOM(pre, "pre")
HTML_ATOM(profile, "profile")

Просмотреть файл

@ -3790,7 +3790,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsresult
nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsIFrameManager* aFrameManager,
nsIContent* aContent,
@ -3804,13 +3804,11 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell
if (NS_SUCCEEDED(rv)) {
// The placeholder frame gets a pseudo style context
nsCOMPtr<nsIStyleContext> placeholderPseudoStyle;
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::placeholderPseudo,
aStyleContext,
PR_FALSE,
getter_AddRefs(placeholderPseudoStyle));
nsCOMPtr<nsIStyleContext> placeholderStyle;
aPresContext->ResolveStyleContextForNonElement(aStyleContext, PR_FALSE,
getter_AddRefs(placeholderStyle));
placeholderFrame->Init(aPresContext, aContent, aParentFrame,
placeholderPseudoStyle, nsnull);
placeholderStyle, nsnull);
// Add mapping from absolutely positioned frame to its placeholder frame
aFrameManager->SetPlaceholderFrameFor(aFrame, placeholderFrame);
@ -12003,8 +12001,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
// letter frame and will have the float property set on it; the text
// frame shouldn't have that set).
nsCOMPtr<nsIStyleContext> textSC;
aPresContext->ResolveStyleContextFor(aTextContent, aStyleContext, PR_FALSE,
getter_AddRefs(textSC));
aPresContext->ResolveStyleContextForNonElement(aStyleContext, PR_FALSE,
getter_AddRefs(textSC));
InitAndRestoreFrame(aPresContext, aState, aTextContent,
letterFrame, textSC, nsnull, aTextFrame);
@ -12013,8 +12011,9 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
// Now make the placeholder
nsIFrame* placeholderFrame;
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aTextContent,
letterFrame, aStyleContext, aParentFrame,
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager,
aTextContent, letterFrame,
aStyleContext, aParentFrame,
&placeholderFrame);
// See if we will need to continue the text frame (does it contain
@ -12031,8 +12030,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
parentStyleContext = getter_AddRefs(aStyleContext->GetParent());
if (parentStyleContext) {
nsCOMPtr<nsIStyleContext> newSC;
aPresContext->ResolveStyleContextFor(aTextContent, parentStyleContext,
PR_FALSE, getter_AddRefs(newSC));
aPresContext->ResolveStyleContextForNonElement(parentStyleContext,
PR_FALSE, getter_AddRefs(newSC));
if (newSC) {
nextTextFrame->SetStyleContext(aPresContext, newSC);
}
@ -12059,6 +12058,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
nsIFrame* aParentFrame,
nsFrameItems& aResult)
{
NS_PRECONDITION(aTextContent->IsContentOfType(nsIContent::eTEXT),
"aTextContent isn't text");
nsCOMPtr<nsIContent> parentContent;
aParentFrame->GetContent(getter_AddRefs(parentContent));
@ -12099,8 +12100,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
letterFrame->Init(aPresContext, aTextContent, aParentFrame,
sc, nsnull);
nsCOMPtr<nsIStyleContext> textSC;
aPresContext->ResolveStyleContextFor(aTextContent, sc, PR_FALSE,
getter_AddRefs(textSC));
aPresContext->ResolveStyleContextForNonElement(sc, PR_FALSE,
getter_AddRefs(textSC));
InitAndRestoreFrame(aPresContext, aState, aTextContent,
letterFrame, textSC, nsnull, textFrame);
letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame);
@ -12115,7 +12116,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
nsresult
nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsIPresShell* aPresShell,
nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aBlockContent,
@ -12176,7 +12177,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsresult
nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsIPresShell* aPresShell,
nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIFrame* aParentFrame,

Просмотреть файл

@ -206,7 +206,10 @@ public:
* the rule matching.
*
* XXX This is temporary. It should go away when we stop creating
* style contexts for text nodes.
* style contexts for text nodes and placeholder frames. (We also use
* it once to create a style context for the nsFirstLetterFrame that
* represents everything except the first letter.)
*
*/
NS_IMETHOD ResolveStyleContextForNonElement(
nsIStyleContext* aParentContext,

Просмотреть файл

@ -206,7 +206,10 @@ public:
* the rule matching.
*
* XXX This is temporary. It should go away when we stop creating
* style contexts for text nodes.
* style contexts for text nodes and placeholder frames. (We also use
* it once to create a style context for the nsFirstLetterFrame that
* represents everything except the first letter.)
*
*/
NS_IMETHOD ResolveStyleContextForNonElement(
nsIStyleContext* aParentContext,

Просмотреть файл

@ -131,7 +131,9 @@ public:
// matching for them is a first step.
//
// XXX This is temporary. It should go away when we stop creating
// style contexts for text nodes.
// style contexts for text nodes and placeholder frames. (We also use
// it once to create a style context for the nsFirstLetterFrame that
// represents everything except the first letter.)
//
virtual nsIStyleContext* ResolveStyleForNonElement(
nsIPresContext* aPresContext,

Просмотреть файл

@ -206,7 +206,10 @@ public:
* the rule matching.
*
* XXX This is temporary. It should go away when we stop creating
* style contexts for text nodes.
* style contexts for text nodes and placeholder frames. (We also use
* it once to create a style context for the nsFirstLetterFrame that
* represents everything except the first letter.)
*
*/
NS_IMETHOD ResolveStyleContextForNonElement(
nsIStyleContext* aParentContext,

Просмотреть файл

@ -134,36 +134,27 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext,
nsIFrame* aPrevInFlow)
{
nsresult rv;
nsIStyleContext* newSC = nsnull;
nsCOMPtr<nsIStyleContext> newSC;
if (aPrevInFlow) {
// Get proper style context for ourselves
nsIStyleContext* parentStyleContext;
parentStyleContext = aContext->GetParent();
// Get proper style context for ourselves. We're creating the frame
// that represents everything *except* the first letter, so just create
// a style context like we would for a text node.
nsIStyleContext* parentStyleContext = aContext->GetParent();
if (parentStyleContext) {
nsIAtom* atom = aPrevInFlow
? nsHTMLAtoms::mozLetterFrame
: nsHTMLAtoms::firstLetterPseudo;
rv = aPresContext->ResolvePseudoStyleContextFor(aContent, atom,
parentStyleContext,
PR_FALSE, &newSC);
rv = aPresContext->ResolveStyleContextForNonElement(
parentStyleContext,
PR_FALSE,
getter_AddRefs(newSC));
NS_RELEASE(parentStyleContext);
if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
return rv;
}
if (nsnull != newSC) {
if (newSC == aContext) {
NS_RELEASE(newSC);
}
else {
aContext = newSC;
}
}
if (newSC)
aContext = newSC;
}
}
rv = nsFirstLetterFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
NS_IF_RELEASE(newSC);
return rv;
}
@ -372,8 +363,10 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext)
nsCOMPtr<nsIContent> kidContent;
kid->GetContent(getter_AddRefs(kidContent));
if (kidContent) {
aPresContext->ResolveStyleContextFor(kidContent, mStyleContext,
PR_FALSE, getter_AddRefs(sc));
NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT),
"should contain only text nodes");
aPresContext->ResolveStyleContextForNonElement(mStyleContext,
PR_FALSE, getter_AddRefs(sc));
if (sc) {
kid->SetStyleContext(aPresContext, sc);
}

Просмотреть файл

@ -134,36 +134,27 @@ nsFirstLetterFrame::Init(nsIPresContext* aPresContext,
nsIFrame* aPrevInFlow)
{
nsresult rv;
nsIStyleContext* newSC = nsnull;
nsCOMPtr<nsIStyleContext> newSC;
if (aPrevInFlow) {
// Get proper style context for ourselves
nsIStyleContext* parentStyleContext;
parentStyleContext = aContext->GetParent();
// Get proper style context for ourselves. We're creating the frame
// that represents everything *except* the first letter, so just create
// a style context like we would for a text node.
nsIStyleContext* parentStyleContext = aContext->GetParent();
if (parentStyleContext) {
nsIAtom* atom = aPrevInFlow
? nsHTMLAtoms::mozLetterFrame
: nsHTMLAtoms::firstLetterPseudo;
rv = aPresContext->ResolvePseudoStyleContextFor(aContent, atom,
parentStyleContext,
PR_FALSE, &newSC);
rv = aPresContext->ResolveStyleContextForNonElement(
parentStyleContext,
PR_FALSE,
getter_AddRefs(newSC));
NS_RELEASE(parentStyleContext);
if (NS_FAILED(rv)) {
if (NS_FAILED(rv))
return rv;
}
if (nsnull != newSC) {
if (newSC == aContext) {
NS_RELEASE(newSC);
}
else {
aContext = newSC;
}
}
if (newSC)
aContext = newSC;
}
}
rv = nsFirstLetterFrameSuper::Init(aPresContext, aContent, aParent,
aContext, aPrevInFlow);
NS_IF_RELEASE(newSC);
return rv;
}
@ -372,8 +363,10 @@ nsFirstLetterFrame::DrainOverflowFrames(nsIPresContext* aPresContext)
nsCOMPtr<nsIContent> kidContent;
kid->GetContent(getter_AddRefs(kidContent));
if (kidContent) {
aPresContext->ResolveStyleContextFor(kidContent, mStyleContext,
PR_FALSE, getter_AddRefs(sc));
NS_ASSERTION(kidContent->IsContentOfType(nsIContent::eTEXT),
"should contain only text nodes");
aPresContext->ResolveStyleContextForNonElement(mStyleContext,
PR_FALSE, getter_AddRefs(sc));
if (sc) {
kid->SetStyleContext(aPresContext, sc);
}

Просмотреть файл

@ -456,12 +456,6 @@ noembed, noscript, param {
display: inherit;
}
*|*:placeholder-frame {
display: inline;
width: 0;
height: 0;
}
*|*:-moz-page, *|*:-moz-page-sequence {
display: block;
background: transparent;

Просмотреть файл

@ -3790,7 +3790,7 @@ nsCSSFrameConstructor::ConstructRootFrame(nsIPresShell* aPresShell,
nsresult
nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsIFrameManager* aFrameManager,
nsIContent* aContent,
@ -3804,13 +3804,11 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell
if (NS_SUCCEEDED(rv)) {
// The placeholder frame gets a pseudo style context
nsCOMPtr<nsIStyleContext> placeholderPseudoStyle;
aPresContext->ResolvePseudoStyleContextFor(aContent, nsHTMLAtoms::placeholderPseudo,
aStyleContext,
PR_FALSE,
getter_AddRefs(placeholderPseudoStyle));
nsCOMPtr<nsIStyleContext> placeholderStyle;
aPresContext->ResolveStyleContextForNonElement(aStyleContext, PR_FALSE,
getter_AddRefs(placeholderStyle));
placeholderFrame->Init(aPresContext, aContent, aParentFrame,
placeholderPseudoStyle, nsnull);
placeholderStyle, nsnull);
// Add mapping from absolutely positioned frame to its placeholder frame
aFrameManager->SetPlaceholderFrameFor(aFrame, placeholderFrame);
@ -12003,8 +12001,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
// letter frame and will have the float property set on it; the text
// frame shouldn't have that set).
nsCOMPtr<nsIStyleContext> textSC;
aPresContext->ResolveStyleContextFor(aTextContent, aStyleContext, PR_FALSE,
getter_AddRefs(textSC));
aPresContext->ResolveStyleContextForNonElement(aStyleContext, PR_FALSE,
getter_AddRefs(textSC));
InitAndRestoreFrame(aPresContext, aState, aTextContent,
letterFrame, textSC, nsnull, aTextFrame);
@ -12013,8 +12011,9 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
// Now make the placeholder
nsIFrame* placeholderFrame;
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager, aTextContent,
letterFrame, aStyleContext, aParentFrame,
CreatePlaceholderFrameFor(aPresShell, aPresContext, aState.mFrameManager,
aTextContent, letterFrame,
aStyleContext, aParentFrame,
&placeholderFrame);
// See if we will need to continue the text frame (does it contain
@ -12031,8 +12030,8 @@ nsCSSFrameConstructor::CreateFloatingLetterFrame(
parentStyleContext = getter_AddRefs(aStyleContext->GetParent());
if (parentStyleContext) {
nsCOMPtr<nsIStyleContext> newSC;
aPresContext->ResolveStyleContextFor(aTextContent, parentStyleContext,
PR_FALSE, getter_AddRefs(newSC));
aPresContext->ResolveStyleContextForNonElement(parentStyleContext,
PR_FALSE, getter_AddRefs(newSC));
if (newSC) {
nextTextFrame->SetStyleContext(aPresContext, newSC);
}
@ -12059,6 +12058,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
nsIFrame* aParentFrame,
nsFrameItems& aResult)
{
NS_PRECONDITION(aTextContent->IsContentOfType(nsIContent::eTEXT),
"aTextContent isn't text");
nsCOMPtr<nsIContent> parentContent;
aParentFrame->GetContent(getter_AddRefs(parentContent));
@ -12099,8 +12100,8 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
letterFrame->Init(aPresContext, aTextContent, aParentFrame,
sc, nsnull);
nsCOMPtr<nsIStyleContext> textSC;
aPresContext->ResolveStyleContextFor(aTextContent, sc, PR_FALSE,
getter_AddRefs(textSC));
aPresContext->ResolveStyleContextForNonElement(sc, PR_FALSE,
getter_AddRefs(textSC));
InitAndRestoreFrame(aPresContext, aState, aTextContent,
letterFrame, textSC, nsnull, textFrame);
letterFrame->SetInitialChildList(aPresContext, nsnull, textFrame);
@ -12115,7 +12116,7 @@ nsCSSFrameConstructor::CreateLetterFrame(nsIPresShell* aPresShell, nsIPresContex
nsresult
nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsIPresShell* aPresShell,
nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIContent* aBlockContent,
@ -12176,7 +12177,7 @@ nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsresult
nsCSSFrameConstructor::WrapFramesInFirstLetterFrame(
nsIPresShell* aPresShell,
nsIPresShell* aPresShell,
nsIPresContext* aPresContext,
nsFrameConstructorState& aState,
nsIFrame* aParentFrame,

Просмотреть файл

@ -456,12 +456,6 @@ noembed, noscript, param {
display: inherit;
}
*|*:placeholder-frame {
display: inline;
width: 0;
height: 0;
}
*|*:-moz-page, *|*:-moz-page-sequence {
display: block;
background: transparent;