зеркало из https://github.com/mozilla/pjs.git
Implemented ID targetting for HTML in XML documents. Changed name of GetNameSpacePrefix to avoid clash.
This commit is contained in:
Родитель
39842b054b
Коммит
60c2b1e433
|
@ -112,8 +112,8 @@ public:
|
|||
* @param aNameSpaceID identifier of the namespace
|
||||
* @param aPrefix out parameter representing the prefix for the namespace
|
||||
*/
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) = 0;
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) = 0;
|
||||
|
||||
/**
|
||||
* Set attribute values. All attribute values are assumed to have a
|
||||
|
|
|
@ -214,7 +214,7 @@ nsDOMAttributeMap::GetNormalizedName(PRInt32 aNameSpaceID,
|
|||
{
|
||||
nsIAtom* prefix;
|
||||
aAttrName.Truncate();
|
||||
mContent->GetNameSpacePrefix(aNameSpaceID, prefix);
|
||||
mContent->GetNameSpacePrefixFromId(aNameSpaceID, prefix);
|
||||
|
||||
if (nsnull != prefix) {
|
||||
prefix->ToString(aAttrName);
|
||||
|
|
|
@ -99,8 +99,8 @@ public:
|
|||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
|
|
|
@ -132,8 +132,8 @@ struct nsGenericDOMDataNode {
|
|||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -395,9 +395,9 @@ struct nsGenericDOMDataNode {
|
|||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefix(aNameSpaceID, aPrefix); \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
|
|
|
@ -442,9 +442,9 @@ public:
|
|||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefix(aNameSpaceID, aPrefix); \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
|
|
|
@ -473,8 +473,8 @@ nsGenericHTMLElement::ParseAttributeString(const nsString& aStr,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
nsGenericHTMLElement::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
|
|
|
@ -87,8 +87,8 @@ public:
|
|||
nsresult ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID);
|
||||
nsresult GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
|
|
|
@ -117,9 +117,9 @@ public:
|
|||
PRInt32& aNameSpaceID) {
|
||||
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
|
||||
return mInner.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsString& aValue, PRBool aNotify) {
|
||||
|
|
|
@ -1654,20 +1654,28 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
|
|||
{
|
||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||
"HTMLContentSink::OpenHead", aNode);
|
||||
nsresult rv = NS_OK;
|
||||
if (nsnull == mHeadContext) {
|
||||
mHeadContext = new SinkContext(this);
|
||||
if (nsnull == mHeadContext) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mHeadContext->SetPreAppend(PR_TRUE);
|
||||
nsresult rv = mHeadContext->Begin(eHTMLTag_head, mHead);
|
||||
rv = mHeadContext->Begin(eHTMLTag_head, mHead);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
mContextStack.AppendElement(mCurrentContext);
|
||||
mCurrentContext = mHeadContext;
|
||||
return NS_OK;
|
||||
|
||||
if (nsnull != mHead) {
|
||||
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
|
||||
rv = AddAttributes(aNode, mHead, sco);
|
||||
NS_IF_RELEASE(sco);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -107,9 +107,9 @@ public:
|
|||
PRInt32& aNameSpaceID) {
|
||||
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
NS_IMETHOD EpilogElementAt(PRUint32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD EpilogCount(PRUint32* aCount)=0;
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent)=0;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
||||
|
|
|
@ -656,5 +656,51 @@ nsXMLDocument::AppendToEpilog(nsIContent* aContent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIContent *
|
||||
MatchName(nsIContent *aContent, const nsString& aName)
|
||||
{
|
||||
nsAutoString value;
|
||||
nsIContent *result = nsnull;
|
||||
PRInt32 ns;
|
||||
|
||||
aContent->GetNameSpaceID(ns);
|
||||
if (kNameSpaceID_HTML == ns) {
|
||||
if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, value)) &&
|
||||
aName.Equals(value)) {
|
||||
return aContent;
|
||||
}
|
||||
else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::name, value)) &&
|
||||
aName.Equals(value)) {
|
||||
return aContent;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
aContent->ChildCount(count);
|
||||
for (i = 0; i < count && result == nsnull; i++) {
|
||||
nsIContent *child;
|
||||
aContent->ChildAt(i, child);
|
||||
result = MatchName(child, aName);
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetContentById(const nsString& aName, nsIContent** aContent)
|
||||
{
|
||||
// XXX Since we don't have a validating parser, the only content
|
||||
// that this applies to is HTML content.
|
||||
nsIContent *content;
|
||||
|
||||
content = MatchName(mRootContent, aName);
|
||||
|
||||
NS_IF_ADDREF(content);
|
||||
*aContent = content;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
NS_IMETHOD EpilogCount(PRUint32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
|
|
|
@ -190,7 +190,7 @@ public:
|
|||
NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpeceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID);
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
|
||||
|
@ -1579,8 +1579,8 @@ static char kNameSpaceSeparator[] = ":";
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
RDFElementImpl::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -479,6 +479,8 @@ public:
|
|||
NS_IMETHOD EpilogCount(PRUint32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
||||
// nsIRDFDocument interface
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* resource);
|
||||
NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag);
|
||||
|
@ -1818,6 +1820,13 @@ XULDocumentImpl::AppendToEpilog(nsIContent* aContent)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetContentById(const nsString& aName, nsIContent** aContent)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDocument interface
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "nsICaret.h"
|
||||
#include "nsCaretProperties.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIDOMSelectionListener.h"
|
||||
#include "nsISelectionMgr.h"
|
||||
|
@ -68,7 +69,6 @@
|
|||
static PRBool gsNoisyRefs = PR_FALSE;
|
||||
#undef NOISY
|
||||
|
||||
|
||||
// comment out to hide caret
|
||||
#define SHOW_CARET
|
||||
|
||||
|
@ -186,6 +186,7 @@ static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
|||
static NS_DEFINE_IID(kICaretIID, NS_ICARET_IID);
|
||||
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||
|
||||
|
@ -1369,29 +1370,33 @@ NS_IMETHODIMP
|
|||
PresShell::GoToAnchor(const nsString& aAnchorName) const
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc;
|
||||
nsCOMPtr<nsIXMLDocument> xmlDoc;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(kIDOMHTMLDocumentIID,
|
||||
getter_AddRefs(htmlDoc)))) {
|
||||
// Find the element with the specified id
|
||||
getter_AddRefs(htmlDoc)))) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
|
||||
|
||||
// Find the element with the specified id
|
||||
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Get the nsIContent interface, because that's what we need to
|
||||
// get the primary frame
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = element->QueryInterface(kIContentIID, getter_AddRefs(content));
|
||||
}
|
||||
}
|
||||
else if (NS_SUCCEEDED(mDocument->QueryInterface(kIXMLDocumentIID,
|
||||
getter_AddRefs(xmlDoc)))) {
|
||||
rv = xmlDoc->GetContentById(aAnchorName, getter_AddRefs(content));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(element->QueryInterface(kIContentIID, getter_AddRefs(content)))) {
|
||||
nsIFrame* frame;
|
||||
|
||||
// Get the primary frame
|
||||
if (NS_SUCCEEDED(GetPrimaryFrameFor(content, &frame))) {
|
||||
rv = ScrollFrameIntoView(frame, NS_PRESSHELL_SCROLL_TOP, 0, NS_PRESSHELL_SCROLL_LEFT, 0);
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIFrame* frame;
|
||||
|
||||
// Get the primary frame
|
||||
if (NS_SUCCEEDED(GetPrimaryFrameFor(content, &frame))) {
|
||||
rv = ScrollFrameIntoView(frame, NS_PRESSHELL_SCROLL_TOP, 0, NS_PRESSHELL_SCROLL_LEFT, 0);
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -112,8 +112,8 @@ public:
|
|||
* @param aNameSpaceID identifier of the namespace
|
||||
* @param aPrefix out parameter representing the prefix for the namespace
|
||||
*/
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) = 0;
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) = 0;
|
||||
|
||||
/**
|
||||
* Set attribute values. All attribute values are assumed to have a
|
||||
|
|
|
@ -214,7 +214,7 @@ nsDOMAttributeMap::GetNormalizedName(PRInt32 aNameSpaceID,
|
|||
{
|
||||
nsIAtom* prefix;
|
||||
aAttrName.Truncate();
|
||||
mContent->GetNameSpacePrefix(aNameSpaceID, prefix);
|
||||
mContent->GetNameSpacePrefixFromId(aNameSpaceID, prefix);
|
||||
|
||||
if (nsnull != prefix) {
|
||||
prefix->ToString(aAttrName);
|
||||
|
|
|
@ -99,8 +99,8 @@ public:
|
|||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
|
|
|
@ -132,8 +132,8 @@ struct nsGenericDOMDataNode {
|
|||
aNameSpaceID = kNameSpaceID_None;
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -395,9 +395,9 @@ struct nsGenericDOMDataNode {
|
|||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefix(aNameSpaceID, aPrefix); \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom *aAttribute, \
|
||||
nsString &aResult) const { \
|
||||
|
|
|
@ -442,9 +442,9 @@ public:
|
|||
PRInt32& aNameSpaceID) { \
|
||||
return _g.ParseAttributeString(aStr, aName, aNameSpaceID); \
|
||||
} \
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, \
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, \
|
||||
nsIAtom*& aPrefix) { \
|
||||
return _g.GetNameSpacePrefix(aNameSpaceID, aPrefix); \
|
||||
return _g.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix); \
|
||||
} \
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, \
|
||||
const nsString& aValue, PRBool aNotify) { \
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "nsICaret.h"
|
||||
#include "nsCaretProperties.h"
|
||||
#include "nsIDOMHTMLDocument.h"
|
||||
#include "nsIXMLDocument.h"
|
||||
#include "nsIScrollableView.h"
|
||||
#include "nsIDOMSelectionListener.h"
|
||||
#include "nsISelectionMgr.h"
|
||||
|
@ -68,7 +69,6 @@
|
|||
static PRBool gsNoisyRefs = PR_FALSE;
|
||||
#undef NOISY
|
||||
|
||||
|
||||
// comment out to hide caret
|
||||
#define SHOW_CARET
|
||||
|
||||
|
@ -186,6 +186,7 @@ static NS_DEFINE_IID(kIEventQueueServiceIID, NS_IEVENTQUEUESERVICE_IID);
|
|||
static NS_DEFINE_IID(kICaretIID, NS_ICARET_IID);
|
||||
static NS_DEFINE_IID(kICaretID, NS_ICARET_IID);
|
||||
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIXMLDocumentIID, NS_IXMLDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIContentIID, NS_ICONTENT_IID);
|
||||
static NS_DEFINE_IID(kIScrollableViewIID, NS_ISCROLLABLEVIEW_IID);
|
||||
|
||||
|
@ -1369,29 +1370,33 @@ NS_IMETHODIMP
|
|||
PresShell::GoToAnchor(const nsString& aAnchorName) const
|
||||
{
|
||||
nsCOMPtr<nsIDOMHTMLDocument> htmlDoc;
|
||||
nsCOMPtr<nsIXMLDocument> xmlDoc;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
||||
if (NS_SUCCEEDED(mDocument->QueryInterface(kIDOMHTMLDocumentIID,
|
||||
getter_AddRefs(htmlDoc)))) {
|
||||
// Find the element with the specified id
|
||||
getter_AddRefs(htmlDoc)))) {
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
|
||||
|
||||
// Find the element with the specified id
|
||||
rv = htmlDoc->GetElementById(aAnchorName, getter_AddRefs(element));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Get the nsIContent interface, because that's what we need to
|
||||
// get the primary frame
|
||||
nsCOMPtr<nsIContent> content;
|
||||
rv = element->QueryInterface(kIContentIID, getter_AddRefs(content));
|
||||
}
|
||||
}
|
||||
else if (NS_SUCCEEDED(mDocument->QueryInterface(kIXMLDocumentIID,
|
||||
getter_AddRefs(xmlDoc)))) {
|
||||
rv = xmlDoc->GetContentById(aAnchorName, getter_AddRefs(content));
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(element->QueryInterface(kIContentIID, getter_AddRefs(content)))) {
|
||||
nsIFrame* frame;
|
||||
|
||||
// Get the primary frame
|
||||
if (NS_SUCCEEDED(GetPrimaryFrameFor(content, &frame))) {
|
||||
rv = ScrollFrameIntoView(frame, NS_PRESSHELL_SCROLL_TOP, 0, NS_PRESSHELL_SCROLL_LEFT, 0);
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsIFrame* frame;
|
||||
|
||||
// Get the primary frame
|
||||
if (NS_SUCCEEDED(GetPrimaryFrameFor(content, &frame))) {
|
||||
rv = ScrollFrameIntoView(frame, NS_PRESSHELL_SCROLL_TOP, 0, NS_PRESSHELL_SCROLL_LEFT, 0);
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -473,8 +473,8 @@ nsGenericHTMLElement::ParseAttributeString(const nsString& aStr,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericHTMLElement::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
nsGenericHTMLElement::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
aPrefix = nsnull;
|
||||
return NS_OK;
|
||||
|
|
|
@ -87,8 +87,8 @@ public:
|
|||
nsresult ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID);
|
||||
nsresult GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
nsresult GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
|
|
|
@ -117,9 +117,9 @@ public:
|
|||
PRInt32& aNameSpaceID) {
|
||||
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
|
||||
return mInner.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName,
|
||||
const nsString& aValue, PRBool aNotify) {
|
||||
|
|
|
@ -1654,20 +1654,28 @@ HTMLContentSink::OpenHead(const nsIParserNode& aNode)
|
|||
{
|
||||
SINK_TRACE_NODE(SINK_TRACE_CALLS,
|
||||
"HTMLContentSink::OpenHead", aNode);
|
||||
nsresult rv = NS_OK;
|
||||
if (nsnull == mHeadContext) {
|
||||
mHeadContext = new SinkContext(this);
|
||||
if (nsnull == mHeadContext) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mHeadContext->SetPreAppend(PR_TRUE);
|
||||
nsresult rv = mHeadContext->Begin(eHTMLTag_head, mHead);
|
||||
rv = mHeadContext->Begin(eHTMLTag_head, mHead);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
mContextStack.AppendElement(mCurrentContext);
|
||||
mCurrentContext = mHeadContext;
|
||||
return NS_OK;
|
||||
|
||||
if (nsnull != mHead) {
|
||||
nsIScriptContextOwner* sco = mDocument->GetScriptContextOwner();
|
||||
rv = AddAttributes(aNode, mHead, sco);
|
||||
NS_IF_RELEASE(sco);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -141,8 +141,8 @@ nsGenericXMLElement::ParseAttributeString(const nsString& aStr,
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsGenericXMLElement::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
nsGenericXMLElement::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
if (nsnull != mNameSpace) {
|
||||
return mNameSpace->FindNameSpacePrefix(aNameSpaceID, aPrefix);
|
||||
|
|
|
@ -63,8 +63,8 @@ public:
|
|||
nsresult ParseAttributeString(const nsString& aStr,
|
||||
nsIAtom*& aName,
|
||||
PRInt32& aNameSpaceID);
|
||||
nsresult GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
nsresult GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix);
|
||||
|
||||
|
||||
// nsIXMLContent
|
||||
|
|
|
@ -107,9 +107,9 @@ public:
|
|||
PRInt32& aNameSpaceID) {
|
||||
return mInner.ParseAttributeString(aStr, aName, aNameSpaceID);
|
||||
}
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefix(aNameSpaceID, aPrefix);
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix) {
|
||||
return mInner.GetNameSpacePrefixFromId(aNameSpaceID, aPrefix);
|
||||
}
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue,
|
||||
PRBool aNotify);
|
||||
|
|
|
@ -41,6 +41,10 @@ public:
|
|||
NS_IMETHOD EpilogElementAt(PRUint32 aOffset, nsIContent** aContent)=0;
|
||||
NS_IMETHOD EpilogCount(PRUint32* aCount)=0;
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent)=0;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
#endif // nsIXMLDocument_h___
|
||||
|
|
|
@ -656,5 +656,51 @@ nsXMLDocument::AppendToEpilog(nsIContent* aContent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsIContent *
|
||||
MatchName(nsIContent *aContent, const nsString& aName)
|
||||
{
|
||||
nsAutoString value;
|
||||
nsIContent *result = nsnull;
|
||||
PRInt32 ns;
|
||||
|
||||
aContent->GetNameSpaceID(ns);
|
||||
if (kNameSpaceID_HTML == ns) {
|
||||
if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, value)) &&
|
||||
aName.Equals(value)) {
|
||||
return aContent;
|
||||
}
|
||||
else if ((NS_CONTENT_ATTR_HAS_VALUE == aContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::name, value)) &&
|
||||
aName.Equals(value)) {
|
||||
return aContent;
|
||||
}
|
||||
}
|
||||
|
||||
PRInt32 i, count;
|
||||
aContent->ChildCount(count);
|
||||
for (i = 0; i < count && result == nsnull; i++) {
|
||||
nsIContent *child;
|
||||
aContent->ChildAt(i, child);
|
||||
result = MatchName(child, aName);
|
||||
NS_RELEASE(child);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::GetContentById(const nsString& aName, nsIContent** aContent)
|
||||
{
|
||||
// XXX Since we don't have a validating parser, the only content
|
||||
// that this applies to is HTML content.
|
||||
nsIContent *content;
|
||||
|
||||
content = MatchName(mRootContent, aName);
|
||||
|
||||
NS_IF_ADDREF(content);
|
||||
*aContent = content;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
NS_IMETHOD EpilogCount(PRUint32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
||||
// nsIHTMLContentContainer
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
|
|
|
@ -295,6 +295,8 @@ public:
|
|||
NS_IMETHOD EpilogCount(PRUint32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
||||
// nsIHTMLContentContainer interface
|
||||
NS_IMETHOD GetAttributeStyleSheet(nsIHTMLStyleSheet** aResult);
|
||||
NS_IMETHOD GetInlineStyleSheet(nsIHTMLCSSStyleSheet** aResult);
|
||||
|
@ -1558,6 +1560,13 @@ RDFDocumentImpl::AppendToEpilog(nsIContent* aContent)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFDocumentImpl::GetContentById(const nsString& aName, nsIContent** aContent)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ public:
|
|||
NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpeceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID);
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
|
||||
|
@ -1579,8 +1579,8 @@ static char kNameSpaceSeparator[] = ":";
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
RDFElementImpl::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
|
@ -479,6 +479,8 @@ public:
|
|||
NS_IMETHOD EpilogCount(PRUint32* aCount);
|
||||
NS_IMETHOD AppendToEpilog(nsIContent* aContent);
|
||||
|
||||
NS_IMETHOD GetContentById(const nsString& aName, nsIContent** aContent);
|
||||
|
||||
// nsIRDFDocument interface
|
||||
NS_IMETHOD SetRootResource(nsIRDFResource* resource);
|
||||
NS_IMETHOD SplitProperty(nsIRDFResource* aResource, PRInt32* aNameSpaceID, nsIAtom** aTag);
|
||||
|
@ -1818,6 +1820,13 @@ XULDocumentImpl::AppendToEpilog(nsIContent* aContent)
|
|||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetContentById(const nsString& aName, nsIContent** aContent)
|
||||
{
|
||||
PR_ASSERT(0);
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIRDFDocument interface
|
||||
|
|
|
@ -190,7 +190,7 @@ public:
|
|||
NS_IMETHOD GetNameSpaceID(PRInt32& aNameSpeceID) const;
|
||||
NS_IMETHOD GetTag(nsIAtom*& aResult) const;
|
||||
NS_IMETHOD ParseAttributeString(const nsString& aStr, nsIAtom*& aName, PRInt32& aNameSpaceID);
|
||||
NS_IMETHOD GetNameSpacePrefix(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD GetNameSpacePrefixFromId(PRInt32 aNameSpaceID, nsIAtom*& aPrefix);
|
||||
NS_IMETHOD SetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, const nsString& aValue, PRBool aNotify);
|
||||
NS_IMETHOD GetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, nsString& aResult) const;
|
||||
NS_IMETHOD UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNotify);
|
||||
|
@ -1579,8 +1579,8 @@ static char kNameSpaceSeparator[] = ":";
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RDFElementImpl::GetNameSpacePrefix(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
RDFElementImpl::GetNameSpacePrefixFromId(PRInt32 aNameSpaceID,
|
||||
nsIAtom*& aPrefix)
|
||||
{
|
||||
NS_NOTYETIMPLEMENTED("write me!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
|
Загрузка…
Ссылка в новой задаче