Fix for 115919, r=dbaron for me, r=hyatt for dbaron, sr=brendan, a=brendan

This commit is contained in:
hyatt%netscape.com 2002-01-22 05:30:28 +00:00
parent 1346d2dbe8
commit 2f697efac8
6 changed files with 226 additions and 224 deletions

View File

@ -175,25 +175,8 @@ nsContentDLF::CreateInstance(const char* aCommand,
nsIContentViewer** aDocViewer)
{
nsresult rv = NS_OK;
if (!gUAStyleSheet) {
// Load the UA style sheet
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), UA_CSS_URL);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICSSLoader> cssLoader;
NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (cssLoader) {
PRBool complete;
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
}
}
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
}
EnsureUAStyleSheet();
// Check aContentType to see if it's a view-source type
//
@ -301,6 +284,8 @@ nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer,
{
nsresult rv = NS_ERROR_FAILURE;
EnsureUAStyleSheet();
do {
nsCOMPtr<nsIDocumentViewer> docv;
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
@ -457,6 +442,8 @@ nsContentDLF::CreateInstance(nsIInputStream& aInputStream,
{
nsresult status = NS_ERROR_FAILURE;
EnsureUAStyleSheet();
// Try RDF
int typeIndex = 0;
while (gRDFTypes[typeIndex]) {
@ -680,3 +667,31 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath);
}
/* static */ nsresult
nsContentDLF::EnsureUAStyleSheet()
{
if (gUAStyleSheet)
return NS_OK;
// Load the UA style sheet
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), UA_CSS_URL);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
nsCOMPtr<nsICSSLoader> cssLoader;
NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (!cssLoader)
return NS_ERROR_OUT_OF_MEMORY;
PRBool complete;
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
#ifdef DEBUG
if (NS_FAILED(rv))
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}

View File

@ -95,6 +95,9 @@ public:
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo);
private:
static nsresult EnsureUAStyleSheet();
};
nsresult

View File

@ -9097,82 +9097,67 @@ RemoveGeneratedContentFrameSiblings(nsIPresContext *aPresContext, nsIPresShell *
if (!content || !content->IsContentOfType(nsIContent::eELEMENT) || !styleContext)
return;
//
// Remove any :before generated content frame that precedes aFrame.
//
// Note that we don't want to check |HasPseudoStyle| since the
// pseudo-style may have just been removed (and thus we want to remove
// the frames).
if (HasPseudoStyle(aPresContext, content, styleContext,
nsCSSAtoms::beforePseudo)) {
nsIFrame *beforeFrame = nsnull;
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
nsIFrame *beforeFrame = nsnull;
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
NS_ASSERTION(frame, "No parent frame!");
// Find aFrame's previous sibling.
// XXX: Is there a better way to do this?
// Find aFrame's previous sibling.
// XXX: Is there a better way to do this?
if (frame) {
nsIFrame *prev = nsnull;
frame->FirstChild(aPresContext, nsnull, &frame);
if (frame) {
nsIFrame *prev = nsnull;
frame->FirstChild(aPresContext, nsnull, &frame);
while (frame) {
if (frame == aFrame) {
beforeFrame = prev;
break;
}
prev = frame;
frame->GetNextSibling(&frame);
while (frame) {
if (frame == aFrame) {
beforeFrame = prev;
break;
}
}
if (beforeFrame &&
IsGeneratedContentFor(content, beforeFrame, nsCSSAtoms::beforePseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
beforeFrame);
prev = frame;
frame->GetNextSibling(&frame);
}
}
//
if (beforeFrame &&
IsGeneratedContentFor(content, beforeFrame, nsCSSAtoms::beforePseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
beforeFrame);
}
// Remove any :after generated content frame that follows aFrame.
//
nsIFrame *afterFrame = nsnull;
aFrame->GetNextSibling(&afterFrame);
if (HasPseudoStyle(aPresContext, content, styleContext,
nsCSSAtoms::afterPseudo)) {
nsIFrame *afterFrame = nsnull;
aFrame->GetNextSibling(&afterFrame);
if (!afterFrame)
{
// At this point we know that aFrame has a :after frame,
// but it has no next sibling, so it's possible that it's
// :after frame was pushed into a continuing frame for it's parent.
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
if (!afterFrame) {
// At this point we know that aFrame has a :after frame,
// but it has no next sibling, so it's possible that it's
// :after frame was pushed into a continuing frame for it's parent.
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
if (frame) {
// Now get the first child of the parent's next-in-flow.
frame->GetNextInFlow(&frame);
if (frame)
{
// Now get the first child of the parent's next-in-flow.
frame->GetNextInFlow(&frame);
if (frame)
frame->FirstChild(aPresContext, nsnull, &afterFrame);
}
frame->FirstChild(aPresContext, nsnull, &afterFrame);
}
}
if (afterFrame &&
IsGeneratedContentFor(content, afterFrame, nsCSSAtoms::afterPseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
afterFrame);
}
if (afterFrame &&
IsGeneratedContentFor(content, afterFrame, nsCSSAtoms::afterPseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
afterFrame);
}
}
@ -9521,44 +9506,42 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
nsnull, placeholderFrame);
}
}
else {
// See if it's absolutely or fixed positioned
if (display->IsAbsolutelyPositioned()) {
// Get the placeholder frame
nsPlaceholderFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame,
(nsIFrame**)&placeholderFrame);
// See if it's absolutely or fixed positioned
else if (display->IsAbsolutelyPositioned()) {
// Get the placeholder frame
nsPlaceholderFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame,
(nsIFrame**)&placeholderFrame);
// Remove the mapping from the frame to its placeholder
if (placeholderFrame)
frameManager->UnregisterPlaceholderFrame(placeholderFrame);
// Remove the mapping from the frame to its placeholder
if (placeholderFrame)
frameManager->UnregisterPlaceholderFrame(placeholderFrame);
// Generate two notifications. First for the absolutely positioned
// frame
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
(NS_STYLE_POSITION_FIXED == display->mPosition) ?
nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame);
// Generate two notifications. First for the absolutely positioned
// frame
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
(NS_STYLE_POSITION_FIXED == display->mPosition) ?
nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame);
// Now the placeholder frame
if (nsnull != placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame, nsnull,
placeholderFrame);
}
// Now the placeholder frame
if (nsnull != placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame, nsnull,
placeholderFrame);
}
} else {
// Notify the parent frame that it should delete the frame
// check for a table caption which goes on an additional child list with a different parent
nsIFrame* outerTableFrame;
if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) {
rv = frameManager->RemoveFrame(aPresContext, *shell, outerTableFrame,
nsLayoutAtoms::captionList, childFrame);
}
else {
RemoveGeneratedContentFrameSiblings(aPresContext, shell, frameManager, insertionPoint, childFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, insertionPoint,
nsnull, childFrame);
}
} else {
// Notify the parent frame that it should delete the frame
// check for a table caption which goes on an additional child list with a different parent
nsIFrame* outerTableFrame;
if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) {
rv = frameManager->RemoveFrame(aPresContext, *shell, outerTableFrame,
nsLayoutAtoms::captionList, childFrame);
}
else {
RemoveGeneratedContentFrameSiblings(aPresContext, shell, frameManager, insertionPoint, childFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, insertionPoint,
nsnull, childFrame);
}
}

View File

@ -175,25 +175,8 @@ nsContentDLF::CreateInstance(const char* aCommand,
nsIContentViewer** aDocViewer)
{
nsresult rv = NS_OK;
if (!gUAStyleSheet) {
// Load the UA style sheet
nsCOMPtr<nsIURI> uri;
rv = NS_NewURI(getter_AddRefs(uri), UA_CSS_URL);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsICSSLoader> cssLoader;
NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (cssLoader) {
PRBool complete;
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
}
}
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
}
EnsureUAStyleSheet();
// Check aContentType to see if it's a view-source type
//
@ -301,6 +284,8 @@ nsContentDLF::CreateInstanceForDocument(nsISupports* aContainer,
{
nsresult rv = NS_ERROR_FAILURE;
EnsureUAStyleSheet();
do {
nsCOMPtr<nsIDocumentViewer> docv;
rv = NS_NewDocumentViewer(getter_AddRefs(docv));
@ -457,6 +442,8 @@ nsContentDLF::CreateInstance(nsIInputStream& aInputStream,
{
nsresult status = NS_ERROR_FAILURE;
EnsureUAStyleSheet();
// Try RDF
int typeIndex = 0;
while (gRDFTypes[typeIndex]) {
@ -680,3 +667,31 @@ nsContentDLF::UnregisterDocumentFactories(nsIComponentManager* aCompMgr,
return obsoleteManager->UnregisterComponentSpec(kDocumentFactoryImplCID, aPath);
}
/* static */ nsresult
nsContentDLF::EnsureUAStyleSheet()
{
if (gUAStyleSheet)
return NS_OK;
// Load the UA style sheet
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), UA_CSS_URL);
if (NS_FAILED(rv)) {
#ifdef DEBUG
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}
nsCOMPtr<nsICSSLoader> cssLoader;
NS_NewCSSLoader(getter_AddRefs(cssLoader));
if (!cssLoader)
return NS_ERROR_OUT_OF_MEMORY;
PRBool complete;
rv = cssLoader->LoadAgentSheet(uri, gUAStyleSheet, complete, nsnull);
#ifdef DEBUG
if (NS_FAILED(rv))
printf("*** open of %s failed: error=%x\n", UA_CSS_URL, rv);
#endif
return rv;
}

View File

@ -95,6 +95,9 @@ public:
nsIFile* aPath,
const char* aRegistryLocation,
const nsModuleComponentInfo* aInfo);
private:
static nsresult EnsureUAStyleSheet();
};
nsresult

View File

@ -9097,82 +9097,67 @@ RemoveGeneratedContentFrameSiblings(nsIPresContext *aPresContext, nsIPresShell *
if (!content || !content->IsContentOfType(nsIContent::eELEMENT) || !styleContext)
return;
//
// Remove any :before generated content frame that precedes aFrame.
//
// Note that we don't want to check |HasPseudoStyle| since the
// pseudo-style may have just been removed (and thus we want to remove
// the frames).
if (HasPseudoStyle(aPresContext, content, styleContext,
nsCSSAtoms::beforePseudo)) {
nsIFrame *beforeFrame = nsnull;
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
nsIFrame *beforeFrame = nsnull;
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
NS_ASSERTION(frame, "No parent frame!");
// Find aFrame's previous sibling.
// XXX: Is there a better way to do this?
// Find aFrame's previous sibling.
// XXX: Is there a better way to do this?
if (frame) {
nsIFrame *prev = nsnull;
frame->FirstChild(aPresContext, nsnull, &frame);
if (frame) {
nsIFrame *prev = nsnull;
frame->FirstChild(aPresContext, nsnull, &frame);
while (frame) {
if (frame == aFrame) {
beforeFrame = prev;
break;
}
prev = frame;
frame->GetNextSibling(&frame);
while (frame) {
if (frame == aFrame) {
beforeFrame = prev;
break;
}
}
if (beforeFrame &&
IsGeneratedContentFor(content, beforeFrame, nsCSSAtoms::beforePseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
beforeFrame);
prev = frame;
frame->GetNextSibling(&frame);
}
}
//
if (beforeFrame &&
IsGeneratedContentFor(content, beforeFrame, nsCSSAtoms::beforePseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
beforeFrame);
}
// Remove any :after generated content frame that follows aFrame.
//
nsIFrame *afterFrame = nsnull;
aFrame->GetNextSibling(&afterFrame);
if (HasPseudoStyle(aPresContext, content, styleContext,
nsCSSAtoms::afterPseudo)) {
nsIFrame *afterFrame = nsnull;
aFrame->GetNextSibling(&afterFrame);
if (!afterFrame)
{
// At this point we know that aFrame has a :after frame,
// but it has no next sibling, so it's possible that it's
// :after frame was pushed into a continuing frame for it's parent.
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
if (!afterFrame) {
// At this point we know that aFrame has a :after frame,
// but it has no next sibling, so it's possible that it's
// :after frame was pushed into a continuing frame for it's parent.
nsIFrame *frame = nsnull;
aFrame->GetParent(&frame);
NS_ASSERTION(frame, "No parent frame!");
if (frame) {
// Now get the first child of the parent's next-in-flow.
frame->GetNextInFlow(&frame);
if (frame)
{
// Now get the first child of the parent's next-in-flow.
frame->GetNextInFlow(&frame);
if (frame)
frame->FirstChild(aPresContext, nsnull, &afterFrame);
}
frame->FirstChild(aPresContext, nsnull, &afterFrame);
}
}
if (afterFrame &&
IsGeneratedContentFor(content, afterFrame, nsCSSAtoms::afterPseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
afterFrame);
}
if (afterFrame &&
IsGeneratedContentFor(content, afterFrame, nsCSSAtoms::afterPseudo)) {
aFrameManager->RemoveFrame(aPresContext, *aPresShell,
aInsertionPoint, nsnull,
afterFrame);
}
}
@ -9521,44 +9506,42 @@ nsCSSFrameConstructor::ContentRemoved(nsIPresContext* aPresContext,
nsnull, placeholderFrame);
}
}
else {
// See if it's absolutely or fixed positioned
if (display->IsAbsolutelyPositioned()) {
// Get the placeholder frame
nsPlaceholderFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame,
(nsIFrame**)&placeholderFrame);
// See if it's absolutely or fixed positioned
else if (display->IsAbsolutelyPositioned()) {
// Get the placeholder frame
nsPlaceholderFrame* placeholderFrame;
frameManager->GetPlaceholderFrameFor(childFrame,
(nsIFrame**)&placeholderFrame);
// Remove the mapping from the frame to its placeholder
if (placeholderFrame)
frameManager->UnregisterPlaceholderFrame(placeholderFrame);
// Remove the mapping from the frame to its placeholder
if (placeholderFrame)
frameManager->UnregisterPlaceholderFrame(placeholderFrame);
// Generate two notifications. First for the absolutely positioned
// frame
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
(NS_STYLE_POSITION_FIXED == display->mPosition) ?
nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame);
// Generate two notifications. First for the absolutely positioned
// frame
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame,
(NS_STYLE_POSITION_FIXED == display->mPosition) ?
nsLayoutAtoms::fixedList : nsLayoutAtoms::absoluteList, childFrame);
// Now the placeholder frame
if (nsnull != placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame, nsnull,
placeholderFrame);
}
// Now the placeholder frame
if (nsnull != placeholderFrame) {
placeholderFrame->GetParent(&parentFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, parentFrame, nsnull,
placeholderFrame);
}
} else {
// Notify the parent frame that it should delete the frame
// check for a table caption which goes on an additional child list with a different parent
nsIFrame* outerTableFrame;
if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) {
rv = frameManager->RemoveFrame(aPresContext, *shell, outerTableFrame,
nsLayoutAtoms::captionList, childFrame);
}
else {
RemoveGeneratedContentFrameSiblings(aPresContext, shell, frameManager, insertionPoint, childFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, insertionPoint,
nsnull, childFrame);
}
} else {
// Notify the parent frame that it should delete the frame
// check for a table caption which goes on an additional child list with a different parent
nsIFrame* outerTableFrame;
if (GetCaptionAdjustedParent(parentFrame, childFrame, &outerTableFrame)) {
rv = frameManager->RemoveFrame(aPresContext, *shell, outerTableFrame,
nsLayoutAtoms::captionList, childFrame);
}
else {
RemoveGeneratedContentFrameSiblings(aPresContext, shell, frameManager, insertionPoint, childFrame);
rv = frameManager->RemoveFrame(aPresContext, *shell, insertionPoint,
nsnull, childFrame);
}
}