зеркало из https://github.com/mozilla/gecko-dev.git
Checking in a workaround for scrollbar code bug 55334, this bug causes scrollbars to not show up in pages that are completely generated with document.write(). r=brendan@mozilla.org/nisheeth@netscape.com, sr=vidur@netscape.com
This commit is contained in:
Родитель
d08c0be69e
Коммит
32fbbc9342
|
@ -1389,9 +1389,6 @@ SinkContext::OpenContainer(const nsIParserNode& aNode)
|
|||
mStack[mStackPos].mInsertionPoint = -1;
|
||||
content->SetDocument(mSink->mDocument, PR_FALSE, PR_TRUE);
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
|
||||
mSink->mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
|
||||
|
||||
rv = mSink->AddAttributes(aNode, content);
|
||||
|
||||
if (mPreAppend) {
|
||||
|
@ -2356,14 +2353,25 @@ HTMLContentSink::Init(nsIDocument* aDoc,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Make root part
|
||||
rv = NS_NewHTMLHtmlElement(&mRoot, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIContent> doc_root(dont_AddRef(mDocument->GetRootContent()));
|
||||
|
||||
if (doc_root) {
|
||||
// If the document already has a root we'll use it. This will
|
||||
// happen when we do document.open()/.write()/.close()...
|
||||
|
||||
CallQueryInterface(doc_root, &mRoot);
|
||||
} else {
|
||||
rv = NS_NewHTMLHtmlElement(&mRoot, nodeInfo);
|
||||
if (NS_OK != rv) {
|
||||
MOZ_TIMER_DEBUGLOG(("Stop: nsHTMLContentSink::Init()\n"));
|
||||
MOZ_TIMER_STOP(mWatch);
|
||||
return rv;
|
||||
}
|
||||
|
||||
mRoot->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
mDocument->SetRootContent(mRoot);
|
||||
}
|
||||
mRoot->SetDocument(mDocument, PR_FALSE, PR_TRUE);
|
||||
mDocument->SetRootContent(mRoot);
|
||||
|
||||
// Make head part
|
||||
rv = mNodeInfoManager->GetNodeInfo(NS_ConvertASCIItoUCS2("head"),
|
||||
|
|
|
@ -2186,10 +2186,68 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
|||
return result;
|
||||
}
|
||||
|
||||
// XXX This is a nasty workaround for a scrollbar code bug
|
||||
// (http://bugzilla.mozilla.org/show_bug.cgi?id=55334).
|
||||
|
||||
// Hold on to our root element
|
||||
nsCOMPtr<nsIContent> root(mRootContent);
|
||||
|
||||
if (root) {
|
||||
PRInt32 count;
|
||||
root->ChildCount(count);
|
||||
|
||||
// Remove all the children from the root.
|
||||
while (--count >= 0) {
|
||||
root->RemoveChildAt(count, PR_TRUE);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
|
||||
mRootContent->GetAttributeCount(count);
|
||||
|
||||
// Remove all attributes from the root element
|
||||
while (--count >= 0) {
|
||||
nsCOMPtr<nsIAtom> name, prefix;
|
||||
PRInt32 nsid;
|
||||
|
||||
root->GetAttributeNameAt(count, nsid, *getter_AddRefs(name),
|
||||
*getter_AddRefs(prefix));
|
||||
|
||||
root->UnsetAttribute(nsid, name, PR_FALSE);
|
||||
}
|
||||
|
||||
// Remove the root from the childlist
|
||||
if (mChildren) {
|
||||
mChildren->RemoveElement(root);
|
||||
}
|
||||
|
||||
mRootContent = nsnull;
|
||||
}
|
||||
|
||||
// Call Reset(), this will now do the full reset, except removing
|
||||
// the root from the document, doing that confuses the scrollbar
|
||||
// code in mozilla since the document in the root element and all
|
||||
// the anonymous content (i.e. scrollbar elements) is set to
|
||||
// null.
|
||||
|
||||
result = Reset(channel, group);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
|
||||
if (root) {
|
||||
// Tear down the frames for the root element.
|
||||
ContentRemoved(nsnull, root, 0);
|
||||
|
||||
// Put the root element back into the document, we don't notify
|
||||
// the document about this insertion since the sink will do that
|
||||
// for us, the sink will call InitialReflow() and that'll create
|
||||
// frames for the root element and the scrollbars work as expected
|
||||
// (since the document in the root element was never set to null)
|
||||
|
||||
mChildren->AppendElement(root);
|
||||
mRootContent = root;
|
||||
}
|
||||
|
||||
result = nsComponentManager::CreateInstance(kCParserCID, nsnull,
|
||||
NS_GET_IID(nsIParser),
|
||||
(void **)&mParser);
|
||||
|
|
Загрузка…
Ссылка в новой задаче