Bugs 38399, 40889, 44211. Also fix two compiler warnings (mismatched signed/unsigned). r=jst (bug 44211 r=harishd).

This commit is contained in:
heikki%netscape.com 2000-07-28 21:48:08 +00:00
Родитель 6fa3a323a0
Коммит 4df9edb205
15 изменённых файлов: 111 добавлений и 128 удалений

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

@ -447,23 +447,25 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
}
// Focus the DOM window.
if(focusedWindow)
NS_WARN_IF_FALSE(focusedWindow,"check why focusedWindow is null!!!");
if(focusedWindow) {
focusedWindow->Focus();
if (focusedElement) {
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(focusedElement);
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> document;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
if (domDoc) {
document = do_QueryInterface(domDoc);
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIPresContext> context;
shell = getter_AddRefs(document->GetShellAt(0));
shell->GetPresContext(getter_AddRefs(context));
focusContent->SetFocus(context);
}
}
if (focusedElement) {
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(focusedElement);
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> document;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
if (domDoc) {
document = do_QueryInterface(domDoc);
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIPresContext> context;
shell = getter_AddRefs(document->GetShellAt(0));
shell->GetPresContext(getter_AddRefs(context));
focusContent->SetFocus(context);
}
}
}
if (commandDispatcher) {
commandDispatcher->SetActive(PR_TRUE);

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

@ -2204,20 +2204,23 @@ nsHTMLDocument::MatchName(nsIContent *aContent, const nsString& aName)
NS_IMETHODIMP
nsHTMLDocument::GetElementById(const nsString& aElementId, nsIDOMElement** aReturn)
{
nsIContent *content;
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
NS_WARN_IF_FALSE(!aElementId.IsEmpty(),"getElementById(\"\"), fix caller?");
if (aElementId.IsEmpty())
return NS_OK;
// XXX For now, we do a brute force search of the content tree.
// We should come up with a more efficient solution.
content = MatchName(mRootContent, aElementId);
nsCOMPtr<nsIContent> content = do_QueryInterface(MatchName(mRootContent,aElementId));
if (nsnull != content) {
return content->QueryInterface(kIDOMElementIID, (void **)aReturn);
nsresult rv = NS_OK;
if (content) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
else {
*aReturn = nsnull;
}
return NS_OK;
return rv;
}
NS_IMETHODIMP

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

@ -43,9 +43,6 @@ class nsIXMLDocument : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXMLDOCUMENT_IID; return iid; }
// XXX This (or a variant thereof) should be in a DOM interface.
// Since it isn't, we add it here temporarily
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent)=0;
#ifdef MOZ_XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
#endif

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

@ -444,7 +444,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
// should we be doing that? If so then it needs to live in two places (bad)
// so we should add a translate numeric entity method from the parser...
char cbuf[100];
PRInt32 index = 0;
PRUint32 index = 0;
while (index < aResult.Length()) {
// If we have the start of an entity (and it's not at the end of
// our string) then translate the entity into it's unicode value.
@ -457,7 +457,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
char* cp = cbuf;
char* limit = cp + sizeof(cbuf) - 1;
PRBool ok = PR_FALSE;
PRInt32 slen = aResult.Length();
PRUint32 slen = aResult.Length();
while ((index < slen) && (cp < limit)) {
PRUnichar ch = aResult.CharAt(index);
if (ch == ';') {
@ -498,7 +498,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
char* limit = cp + sizeof(cbuf) - 1;
*cp++ = char(e);
PRBool ok = PR_FALSE;
PRInt32 slen = aResult.Length();
PRUint32 slen = aResult.Length();
while ((index < slen) && (cp < limit)) {
PRUnichar ch = aResult.CharAt(index);
if (ch == ';') {

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

@ -907,23 +907,6 @@ nsXMLDocument::CreateElementNS(const nsString& aNamespaceURI,
return content->QueryInterface(kIDOMElementIID, (void**)aReturn);
}
NS_IMETHODIMP
nsXMLDocument::GetElementById(const nsString& aElementId,
nsIDOMElement** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
nsCOMPtr<nsIContent> cont;
nsresult rv = GetContentById(aElementId,getter_AddRefs(cont));
if (NS_SUCCEEDED(rv) && cont) {
rv = cont->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
return rv;
}
// nsIXMLDocument interface
static nsIContent *
MatchName(nsIContent *aContent, const nsString& aName)
{
@ -955,21 +938,32 @@ MatchName(nsIContent *aContent, const nsString& aName)
return result;
}
NS_IMETHODIMP
nsXMLDocument::GetContentById(const nsString& aName, nsIContent** aContent)
NS_IMETHODIMP
nsXMLDocument::GetElementById(const nsString& aElementId,
nsIDOMElement** aReturn)
{
// XXX Since we don't have a validating parser, the only content
// that this applies to is HTML content.
nsIContent *content;
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
content = MatchName(mRootContent, aName);
NS_WARN_IF_FALSE(!aElementId.IsEmpty(),"getElementById(\"\"), fix caller?");
if (aElementId.IsEmpty())
return NS_OK;
NS_IF_ADDREF(content);
*aContent = content;
// XXX For now, we do a brute force search of the content tree.
// We should come up with a more efficient solution.
nsCOMPtr<nsIContent> content = do_QueryInterface(MatchName(mRootContent,aElementId));
return NS_OK;
nsresult rv = NS_OK;
if (content) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
return rv;
}
// nsIXMLDocument
#ifdef MOZ_XSL
NS_IMETHODIMP
nsXMLDocument::SetTransformMediator(nsITransformMediator* aMediator)

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

@ -86,7 +86,6 @@ public:
NS_IMETHOD Load(const nsString& aUrl);
// nsIXMLDocument interface
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
#ifdef MOZ_XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
#endif

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

@ -2643,17 +2643,16 @@ PresShell::CantRenderReplacedElement(nsIPresContext* aPresContext,
NS_IMETHODIMP
PresShell::GoToAnchor(const nsString& aAnchorName) const
{
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc;
nsCOMPtr<nsIXMLDocument> xmlDoc;
nsCOMPtr<nsIDOMDocument> doc;
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> content;
if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIDOMHTMLDocument),
getter_AddRefs(htmlDoc)))) {
if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIDOMDocument),
getter_AddRefs(doc)))) {
nsCOMPtr<nsIDOMElement> element;
// Find the element with the specified id
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
rv = doc->GetElementById(aAnchorName, getter_AddRefs(element));
if (NS_SUCCEEDED(rv) && element) {
// Get the nsIContent interface, because that's what we need to
// get the primary frame
@ -2661,10 +2660,6 @@ PresShell::GoToAnchor(const nsString& aAnchorName) const
getter_AddRefs(content));
}
}
else if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIXMLDocument),
getter_AddRefs(xmlDoc)))) {
rv = xmlDoc->GetContentById(aAnchorName, getter_AddRefs(content));
}
if (NS_SUCCEEDED(rv) && content) {
nsIFrame* frame;

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

@ -447,23 +447,25 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
}
// Focus the DOM window.
if(focusedWindow)
NS_WARN_IF_FALSE(focusedWindow,"check why focusedWindow is null!!!");
if(focusedWindow) {
focusedWindow->Focus();
if (focusedElement) {
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(focusedElement);
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> document;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
if (domDoc) {
document = do_QueryInterface(domDoc);
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIPresContext> context;
shell = getter_AddRefs(document->GetShellAt(0));
shell->GetPresContext(getter_AddRefs(context));
focusContent->SetFocus(context);
}
}
if (focusedElement) {
nsCOMPtr<nsIContent> focusContent = do_QueryInterface(focusedElement);
nsCOMPtr<nsIDOMDocument> domDoc;
nsCOMPtr<nsIDocument> document;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
if (domDoc) {
document = do_QueryInterface(domDoc);
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIPresContext> context;
shell = getter_AddRefs(document->GetShellAt(0));
shell->GetPresContext(getter_AddRefs(context));
focusContent->SetFocus(context);
}
}
}
if (commandDispatcher) {
commandDispatcher->SetActive(PR_TRUE);

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

@ -2643,17 +2643,16 @@ PresShell::CantRenderReplacedElement(nsIPresContext* aPresContext,
NS_IMETHODIMP
PresShell::GoToAnchor(const nsString& aAnchorName) const
{
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc;
nsCOMPtr<nsIXMLDocument> xmlDoc;
nsCOMPtr<nsIDOMDocument> doc;
nsresult rv = NS_OK;
nsCOMPtr<nsIContent> content;
if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIDOMHTMLDocument),
getter_AddRefs(htmlDoc)))) {
if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIDOMDocument),
getter_AddRefs(doc)))) {
nsCOMPtr<nsIDOMElement> element;
// Find the element with the specified id
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
rv = doc->GetElementById(aAnchorName, getter_AddRefs(element));
if (NS_SUCCEEDED(rv) && element) {
// Get the nsIContent interface, because that's what we need to
// get the primary frame
@ -2661,10 +2660,6 @@ PresShell::GoToAnchor(const nsString& aAnchorName) const
getter_AddRefs(content));
}
}
else if (NS_SUCCEEDED(mDocument->QueryInterface(NS_GET_IID(nsIXMLDocument),
getter_AddRefs(xmlDoc)))) {
rv = xmlDoc->GetContentById(aAnchorName, getter_AddRefs(content));
}
if (NS_SUCCEEDED(rv) && content) {
nsIFrame* frame;

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

@ -2204,20 +2204,23 @@ nsHTMLDocument::MatchName(nsIContent *aContent, const nsString& aName)
NS_IMETHODIMP
nsHTMLDocument::GetElementById(const nsString& aElementId, nsIDOMElement** aReturn)
{
nsIContent *content;
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
NS_WARN_IF_FALSE(!aElementId.IsEmpty(),"getElementById(\"\"), fix caller?");
if (aElementId.IsEmpty())
return NS_OK;
// XXX For now, we do a brute force search of the content tree.
// We should come up with a more efficient solution.
content = MatchName(mRootContent, aElementId);
nsCOMPtr<nsIContent> content = do_QueryInterface(MatchName(mRootContent,aElementId));
if (nsnull != content) {
return content->QueryInterface(kIDOMElementIID, (void **)aReturn);
nsresult rv = NS_OK;
if (content) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
else {
*aReturn = nsnull;
}
return NS_OK;
return rv;
}
NS_IMETHODIMP

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

@ -43,9 +43,6 @@ class nsIXMLDocument : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IXMLDOCUMENT_IID; return iid; }
// XXX This (or a variant thereof) should be in a DOM interface.
// Since it isn't, we add it here temporarily
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent)=0;
#ifdef MOZ_XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator)=0;
#endif

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

@ -444,7 +444,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
// should we be doing that? If so then it needs to live in two places (bad)
// so we should add a translate numeric entity method from the parser...
char cbuf[100];
PRInt32 index = 0;
PRUint32 index = 0;
while (index < aResult.Length()) {
// If we have the start of an entity (and it's not at the end of
// our string) then translate the entity into it's unicode value.
@ -457,7 +457,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
char* cp = cbuf;
char* limit = cp + sizeof(cbuf) - 1;
PRBool ok = PR_FALSE;
PRInt32 slen = aResult.Length();
PRUint32 slen = aResult.Length();
while ((index < slen) && (cp < limit)) {
PRUnichar ch = aResult.CharAt(index);
if (ch == ';') {
@ -498,7 +498,7 @@ nsXMLContentSink::GetAttributeValueAt(const nsIParserNode& aNode,
char* limit = cp + sizeof(cbuf) - 1;
*cp++ = char(e);
PRBool ok = PR_FALSE;
PRInt32 slen = aResult.Length();
PRUint32 slen = aResult.Length();
while ((index < slen) && (cp < limit)) {
PRUnichar ch = aResult.CharAt(index);
if (ch == ';') {

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

@ -907,23 +907,6 @@ nsXMLDocument::CreateElementNS(const nsString& aNamespaceURI,
return content->QueryInterface(kIDOMElementIID, (void**)aReturn);
}
NS_IMETHODIMP
nsXMLDocument::GetElementById(const nsString& aElementId,
nsIDOMElement** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
nsCOMPtr<nsIContent> cont;
nsresult rv = GetContentById(aElementId,getter_AddRefs(cont));
if (NS_SUCCEEDED(rv) && cont) {
rv = cont->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
return rv;
}
// nsIXMLDocument interface
static nsIContent *
MatchName(nsIContent *aContent, const nsString& aName)
{
@ -955,21 +938,32 @@ MatchName(nsIContent *aContent, const nsString& aName)
return result;
}
NS_IMETHODIMP
nsXMLDocument::GetContentById(const nsString& aName, nsIContent** aContent)
NS_IMETHODIMP
nsXMLDocument::GetElementById(const nsString& aElementId,
nsIDOMElement** aReturn)
{
// XXX Since we don't have a validating parser, the only content
// that this applies to is HTML content.
nsIContent *content;
NS_ENSURE_ARG_POINTER(aReturn);
*aReturn = nsnull;
content = MatchName(mRootContent, aName);
NS_WARN_IF_FALSE(!aElementId.IsEmpty(),"getElementById(\"\"), fix caller?");
if (aElementId.IsEmpty())
return NS_OK;
NS_IF_ADDREF(content);
*aContent = content;
// XXX For now, we do a brute force search of the content tree.
// We should come up with a more efficient solution.
nsCOMPtr<nsIContent> content = do_QueryInterface(MatchName(mRootContent,aElementId));
return NS_OK;
nsresult rv = NS_OK;
if (content) {
rv = content->QueryInterface(NS_GET_IID(nsIDOMElement),(void**)aReturn);
}
return rv;
}
// nsIXMLDocument
#ifdef MOZ_XSL
NS_IMETHODIMP
nsXMLDocument::SetTransformMediator(nsITransformMediator* aMediator)

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

@ -86,7 +86,6 @@ public:
NS_IMETHOD Load(const nsString& aUrl);
// nsIXMLDocument interface
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
#ifdef MOZ_XSL
NS_IMETHOD SetTransformMediator(nsITransformMediator* aMediator);
#endif

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

@ -1316,6 +1316,9 @@ nsMenuFrame::BuildAcceleratorText(nsString& aAccelString)
nsAutoString keyValue;
mContent->GetAttribute(kNameSpaceID_None, nsXULAtoms::key, keyValue);
if (keyValue.IsEmpty())
return;
nsCOMPtr<nsIDocument> document;
mContent->GetDocument(*getter_AddRefs(document));