зеркало из https://github.com/mozilla/pjs.git
Implemented the correct content model for the TITLE element and allowed for dynamic change.
This commit is contained in:
Родитель
61cac4a59b
Коммит
5dddc5bcf8
|
@ -27,8 +27,13 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsXIFConverter.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLTitleElementIID, NS_IDOMHTMLTITLEELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
|
||||
|
||||
class nsHTMLTitleElement : public nsIDOMHTMLTitleElement,
|
||||
public nsIScriptObjectOwner,
|
||||
|
@ -123,8 +128,6 @@ nsHTMLTitleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTitleElement, Text, text)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
@ -157,6 +160,59 @@ nsHTMLTitleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) c
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::GetText(nsString& aTitle)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNode* child;
|
||||
|
||||
result = GetFirstChild(&child);
|
||||
if ((NS_OK == result) && (nsnull != child)) {
|
||||
nsIDOMText* text;
|
||||
|
||||
result = child->QueryInterface(kIDOMTextIID, (void**)&text);
|
||||
if (NS_OK == result) {
|
||||
text->GetData(aTitle);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::SetText(const nsString& aTitle)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNode* child;
|
||||
nsIDocument* document;
|
||||
|
||||
result = GetDocument(document);
|
||||
if (NS_OK == result) {
|
||||
nsIHTMLDocument* htmlDoc;
|
||||
result = document->QueryInterface(kIHTMLDocumentIID, (void**)&htmlDoc);
|
||||
if (NS_OK == result) {
|
||||
htmlDoc->SetTitle(aTitle);
|
||||
NS_RELEASE(htmlDoc);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
|
||||
result = GetFirstChild(&child);
|
||||
if ((NS_OK == result) && (nsnull != child)) {
|
||||
nsIDOMText* text;
|
||||
|
||||
result = child->QueryInterface(kIDOMTextIID, (void**)&text);
|
||||
if (NS_OK == result) {
|
||||
text->SetData(aTitle);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
|
|
|
@ -1603,11 +1603,18 @@ HTMLContentSink::SetTitle(const nsString& aValue)
|
|||
nsIHTMLContent* it = nsnull;
|
||||
nsresult rv = NS_NewHTMLTitleElement(&it, atom);
|
||||
if (NS_OK == rv) {
|
||||
nsIDOMHTMLTitleElement* domtitle = nsnull;
|
||||
it->QueryInterface(kIDOMHTMLTitleElementIID, (void**) &domtitle);
|
||||
if (nsnull != domtitle) {
|
||||
domtitle->SetText(aValue);
|
||||
NS_RELEASE(domtitle);
|
||||
nsIContent* text;
|
||||
rv = NS_NewTextNode(&text);
|
||||
if (NS_OK == rv) {
|
||||
nsIDOMText* tc;
|
||||
rv = text->QueryInterface(kIDOMTextIID, (void**)&tc);
|
||||
if (NS_OK == rv) {
|
||||
tc->SetData(aValue);
|
||||
NS_RELEASE(tc);
|
||||
}
|
||||
it->AppendChildTo(text, PR_FALSE);
|
||||
text->SetDocument(mDocument, PR_FALSE);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
mHead->AppendChildTo(it, PR_FALSE);
|
||||
NS_RELEASE(it);
|
||||
|
|
|
@ -27,8 +27,13 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsXIFConverter.h"
|
||||
#include "nsIDOMText.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIHTMLDocument.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMHTMLTitleElementIID, NS_IDOMHTMLTITLEELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIDOMTextIID, NS_IDOMTEXT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
|
||||
|
||||
class nsHTMLTitleElement : public nsIDOMHTMLTitleElement,
|
||||
public nsIScriptObjectOwner,
|
||||
|
@ -123,8 +128,6 @@ nsHTMLTitleElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
|
|||
return it->QueryInterface(kIDOMNodeIID, (void**) aReturn);
|
||||
}
|
||||
|
||||
NS_IMPL_STRING_ATTR(nsHTMLTitleElement, Text, text)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::StringToAttribute(nsIAtom* aAttribute,
|
||||
const nsString& aValue,
|
||||
|
@ -157,6 +160,59 @@ nsHTMLTitleElement::GetAttributeMappingFunction(nsMapAttributesFunc& aMapFunc) c
|
|||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::GetText(nsString& aTitle)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNode* child;
|
||||
|
||||
result = GetFirstChild(&child);
|
||||
if ((NS_OK == result) && (nsnull != child)) {
|
||||
nsIDOMText* text;
|
||||
|
||||
result = child->QueryInterface(kIDOMTextIID, (void**)&text);
|
||||
if (NS_OK == result) {
|
||||
text->GetData(aTitle);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::SetText(const nsString& aTitle)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
nsIDOMNode* child;
|
||||
nsIDocument* document;
|
||||
|
||||
result = GetDocument(document);
|
||||
if (NS_OK == result) {
|
||||
nsIHTMLDocument* htmlDoc;
|
||||
result = document->QueryInterface(kIHTMLDocumentIID, (void**)&htmlDoc);
|
||||
if (NS_OK == result) {
|
||||
htmlDoc->SetTitle(aTitle);
|
||||
NS_RELEASE(htmlDoc);
|
||||
}
|
||||
NS_RELEASE(document);
|
||||
}
|
||||
|
||||
result = GetFirstChild(&child);
|
||||
if ((NS_OK == result) && (nsnull != child)) {
|
||||
nsIDOMText* text;
|
||||
|
||||
result = child->QueryInterface(kIDOMTextIID, (void**)&text);
|
||||
if (NS_OK == result) {
|
||||
text->SetData(aTitle);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLTitleElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
||||
|
|
|
@ -1603,11 +1603,18 @@ HTMLContentSink::SetTitle(const nsString& aValue)
|
|||
nsIHTMLContent* it = nsnull;
|
||||
nsresult rv = NS_NewHTMLTitleElement(&it, atom);
|
||||
if (NS_OK == rv) {
|
||||
nsIDOMHTMLTitleElement* domtitle = nsnull;
|
||||
it->QueryInterface(kIDOMHTMLTitleElementIID, (void**) &domtitle);
|
||||
if (nsnull != domtitle) {
|
||||
domtitle->SetText(aValue);
|
||||
NS_RELEASE(domtitle);
|
||||
nsIContent* text;
|
||||
rv = NS_NewTextNode(&text);
|
||||
if (NS_OK == rv) {
|
||||
nsIDOMText* tc;
|
||||
rv = text->QueryInterface(kIDOMTextIID, (void**)&tc);
|
||||
if (NS_OK == rv) {
|
||||
tc->SetData(aValue);
|
||||
NS_RELEASE(tc);
|
||||
}
|
||||
it->AppendChildTo(text, PR_FALSE);
|
||||
text->SetDocument(mDocument, PR_FALSE);
|
||||
NS_RELEASE(text);
|
||||
}
|
||||
mHead->AppendChildTo(it, PR_FALSE);
|
||||
NS_RELEASE(it);
|
||||
|
|
Загрузка…
Ссылка в новой задаче