mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-30 01:59:29 +00:00
Checking in patch from psolanki@myrealbox.com for bug 232417. DeCOMtaminating nsIHTMLDocument. r+sr=jst@mozilla.jstenback.com
This commit is contained in:
parent
d1a3fa5b1d
commit
f894d79c80
@ -68,7 +68,7 @@ nsLinkableAccessible(aDOMNode, aShell)
|
||||
if (htmlDoc && !mapElementName.IsEmpty()) {
|
||||
if (mapElementName.CharAt(0) == '#')
|
||||
mapElementName.Cut(0,1);
|
||||
htmlDoc->GetImageMap(mapElementName, getter_AddRefs(mMapElement));
|
||||
mMapElement = htmlDoc->GetImageMap(mapElementName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1409,8 +1409,10 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
domHtmlDocument->GetForms(getter_AddRefs(forms));
|
||||
nsCOMPtr<nsIContentList> htmlForms(do_QueryInterface(forms));
|
||||
|
||||
nsCOMPtr<nsIDOMNodeList> formControls;
|
||||
htmlDocument->GetFormControlElements(getter_AddRefs(formControls));
|
||||
nsCOMPtr<nsIDOMNodeList> formControls =
|
||||
htmlDocument->GetFormControlElements();
|
||||
NS_ENSURE_TRUE(formControls, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIContentList> htmlFormControls(do_QueryInterface(formControls));
|
||||
|
||||
// If we have a form control and can calculate form information, use
|
||||
@ -1452,8 +1454,7 @@ nsContentUtils::GenerateStateKey(nsIContent* aContent,
|
||||
// guess that the highest form parsed so far is the one.
|
||||
// This code should not be on trunk, only branch.
|
||||
//
|
||||
htmlDocument->GetNumFormsSynchronous(&index);
|
||||
index--;
|
||||
index = htmlDocument->GetNumFormsSynchronous() - 1;
|
||||
}
|
||||
if (index > -1) {
|
||||
KeyAppendInt(index, aKey);
|
||||
|
@ -544,9 +544,7 @@ nsHTMLValue::ParseColor(const nsAString& aString, nsIDocument* aDocument)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLDocument> doc(do_QueryInterface(aDocument));
|
||||
if (doc) {
|
||||
nsCompatibility mode;
|
||||
doc->GetCompatibilityMode(mode);
|
||||
inNavQuirksMode = (mode == eCompatibility_NavQuirks);
|
||||
inNavQuirksMode = (doc->GetCompatibilityMode() == eCompatibility_NavQuirks);
|
||||
} else {
|
||||
inNavQuirksMode = PR_FALSE;
|
||||
}
|
||||
|
@ -2513,9 +2513,7 @@ nsRange::CreateContextualFragment(const nsAString& aFragment,
|
||||
nsDTDMode mode = eDTDMode_autodetect;
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(domDocument));
|
||||
if (htmlDoc) {
|
||||
nsCompatibility compatMode;
|
||||
htmlDoc->GetCompatibilityMode(compatMode);
|
||||
switch (compatMode) {
|
||||
switch (htmlDoc->GetCompatibilityMode()) {
|
||||
case eCompatibility_NavQuirks:
|
||||
mode = eDTDMode_quirks;
|
||||
break;
|
||||
|
@ -1249,9 +1249,7 @@ nsGenericHTMLElement::InNavQuirksMode(nsIDocument* aDoc)
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCompatibility mode;
|
||||
doc->GetCompatibilityMode(mode);
|
||||
return mode == eCompatibility_NavQuirks;
|
||||
return doc->GetCompatibilityMode() == eCompatibility_NavQuirks;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -503,7 +503,7 @@ nsHTMLFrameSetElement::ParseRowColSpec(nsString& aSpec,
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDocument =
|
||||
do_QueryInterface(nsGenericHTMLContainerElement::GetOwnerDocument());
|
||||
if (htmlDocument) {
|
||||
htmlDocument->GetCompatibilityMode(mode);
|
||||
mode = htmlDocument->GetCompatibilityMode();
|
||||
}
|
||||
|
||||
if (eCompatibility_NavQuirks == mode) {
|
||||
|
@ -81,7 +81,8 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
||||
if (htmlDoc) {
|
||||
htmlDoc->GetImageMap(usemap, aMap);
|
||||
*aMap = htmlDoc->GetImageMap(usemap);
|
||||
NS_IF_ADDREF(*aMap);
|
||||
} else {
|
||||
// For XHTML elements embedded in non-XHTML documents we get the
|
||||
// map by id since XHTML requires that where a "name" attribute
|
||||
|
@ -1033,7 +1033,7 @@ nsHTMLDocument::SetTitle(const nsAString& aTitle)
|
||||
return nsDocument::SetTitle(aTitle);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsHTMLDocument::AddImageMap(nsIDOMHTMLMapElement* aMap)
|
||||
{
|
||||
// XXX We should order the maps based on their order in the document.
|
||||
@ -1049,33 +1049,21 @@ nsHTMLDocument::AddImageMap(nsIDOMHTMLMapElement* aMap)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLDocument::RemoveImageMap(nsIDOMHTMLMapElement* aMap)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aMap, "null ptr");
|
||||
if (nsnull == aMap) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
mImageMaps.RemoveObject(aMap);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult)
|
||||
nsIDOMHTMLMapElement *
|
||||
nsHTMLDocument::GetImageMap(const nsAString& aMapName)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsAutoString name;
|
||||
PRUint32 i, n = mImageMaps.Count();
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
nsCOMPtr<nsIDOMHTMLMapElement> map = mImageMaps[i];
|
||||
nsIDOMHTMLMapElement *map = mImageMaps[i];
|
||||
NS_ASSERTION(map, "Null map in map list!");
|
||||
|
||||
PRBool match;
|
||||
@ -1091,16 +1079,12 @@ nsHTMLDocument::GetImageMap(const nsAString& aMapName,
|
||||
match = name.Equals(aMapName, nsCaseInsensitiveStringComparator());
|
||||
}
|
||||
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (match) {
|
||||
*aResult = map;
|
||||
NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
if (match && NS_SUCCEEDED(rv)) {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// subclass hooks for sheet ordering
|
||||
@ -1190,14 +1174,13 @@ nsHTMLDocument::GetCSSLoader()
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetCompatibilityMode(nsCompatibility& aMode)
|
||||
nsCompatibility
|
||||
nsHTMLDocument::GetCompatibilityMode()
|
||||
{
|
||||
aMode = mCompatMode;
|
||||
return NS_OK;
|
||||
return mCompatMode;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
|
||||
{
|
||||
NS_ASSERTION(!IsXHTML() || aMode == eCompatibility_FullStandards,
|
||||
@ -1215,8 +1198,6 @@ nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
|
||||
pc->SetCompatibilityMode(mCompatMode);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
@ -1875,12 +1856,10 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::WasDomainSet(PRBool* aDomainWasSet)
|
||||
PRBool
|
||||
nsHTMLDocument::WasDomainSet()
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDomainWasSet);
|
||||
*aDomainWasSet = mDomainWasSet;
|
||||
return NS_OK;
|
||||
return mDomainWasSet;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -2682,25 +2661,22 @@ nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLDocument::AddedForm()
|
||||
{
|
||||
++mNumForms;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
nsHTMLDocument::RemovedForm()
|
||||
{
|
||||
--mNumForms;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetNumFormsSynchronous(PRInt32* aNumForms)
|
||||
PRInt32
|
||||
nsHTMLDocument::GetNumFormsSynchronous()
|
||||
{
|
||||
*aNumForms = mNumForms;
|
||||
return NS_OK;
|
||||
return mNumForms;
|
||||
}
|
||||
|
||||
PRBool
|
||||
@ -2709,17 +2685,14 @@ nsHTMLDocument::MatchFormControls(nsIContent* aContent, nsString* aData)
|
||||
return aContent->IsContentOfType(nsIContent::eHTML_FORM_CONTROL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::GetFormControlElements(nsIDOMNodeList** aReturn)
|
||||
already_AddRefed<nsIDOMNodeList>
|
||||
nsHTMLDocument::GetFormControlElements()
|
||||
{
|
||||
nsContentList* elements = nsnull;
|
||||
elements = new nsContentList(this, MatchFormControls, nsString());
|
||||
NS_ENSURE_TRUE(elements, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsIDOMNodeList *list = new nsContentList(this, MatchFormControls,
|
||||
EmptyString());
|
||||
NS_IF_ADDREF(list);
|
||||
|
||||
*aReturn = elements;
|
||||
NS_ADDREF(*aReturn);
|
||||
|
||||
return NS_OK;
|
||||
return list;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -3457,7 +3430,7 @@ FindNamedItems(const nsAString& aName, nsIContent *aContent,
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsresult
|
||||
nsHTMLDocument::ResolveName(const nsAString& aName,
|
||||
nsIDOMHTMLFormElement *aForm,
|
||||
nsISupports **aResult)
|
||||
|
@ -104,19 +104,18 @@ public:
|
||||
|
||||
virtual void EndLoad();
|
||||
|
||||
NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap);
|
||||
virtual nsresult AddImageMap(nsIDOMHTMLMapElement* aMap);
|
||||
|
||||
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap);
|
||||
virtual void RemoveImageMap(nsIDOMHTMLMapElement* aMap);
|
||||
|
||||
NS_IMETHOD GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult);
|
||||
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName);
|
||||
|
||||
virtual nsICSSLoader* GetCSSLoader();
|
||||
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility& aMode);
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode);
|
||||
virtual nsCompatibility GetCompatibilityMode();
|
||||
virtual void SetCompatibilityMode(nsCompatibility aMode);
|
||||
|
||||
NS_IMETHOD_(PRBool) IsWriting()
|
||||
virtual PRBool IsWriting()
|
||||
{
|
||||
return mWriteLevel != PRUint32(0);
|
||||
}
|
||||
@ -189,16 +188,16 @@ public:
|
||||
/*
|
||||
* Returns true if document.domain was set for this document
|
||||
*/
|
||||
NS_IMETHOD WasDomainSet(PRBool* aDomainWasSet);
|
||||
virtual PRBool WasDomainSet();
|
||||
|
||||
NS_IMETHOD ResolveName(const nsAString& aName,
|
||||
virtual nsresult ResolveName(const nsAString& aName,
|
||||
nsIDOMHTMLFormElement *aForm,
|
||||
nsISupports **aResult);
|
||||
|
||||
NS_IMETHOD GetFormControlElements(nsIDOMNodeList** aReturn);
|
||||
NS_IMETHOD AddedForm();
|
||||
NS_IMETHOD RemovedForm();
|
||||
NS_IMETHOD GetNumFormsSynchronous(PRInt32* aNumForms);
|
||||
virtual already_AddRefed<nsIDOMNodeList> GetFormControlElements();
|
||||
virtual void AddedForm();
|
||||
virtual void RemovedForm();
|
||||
virtual PRInt32 GetNumFormsSynchronous();
|
||||
|
||||
PRBool IsXHTML()
|
||||
{
|
||||
|
@ -61,50 +61,55 @@ class nsIDOMHTMLBodyElement;
|
||||
/**
|
||||
* HTML document extensions to nsIDocument.
|
||||
*/
|
||||
class nsIHTMLDocument : public nsISupports {
|
||||
class nsIHTMLDocument : public nsISupports
|
||||
{
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IHTMLDOCUMENT_IID)
|
||||
|
||||
NS_IMETHOD AddImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
virtual nsresult AddImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
|
||||
NS_IMETHOD GetImageMap(const nsAString& aMapName,
|
||||
nsIDOMHTMLMapElement** aResult) = 0;
|
||||
virtual nsIDOMHTMLMapElement *GetImageMap(const nsAString& aMapName) = 0;
|
||||
|
||||
NS_IMETHOD RemoveImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
virtual void RemoveImageMap(nsIDOMHTMLMapElement* aMap) = 0;
|
||||
|
||||
/**
|
||||
* Access compatibility mode for this document
|
||||
*/
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility& aMode) = 0;
|
||||
NS_IMETHOD SetCompatibilityMode(nsCompatibility aMode) = 0;
|
||||
virtual nsCompatibility GetCompatibilityMode() = 0;
|
||||
virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
|
||||
|
||||
/*
|
||||
* Returns true if document.domain was set for this document
|
||||
*/
|
||||
NS_IMETHOD WasDomainSet(PRBool* aDomainWasSet) = 0;
|
||||
virtual PRBool WasDomainSet() = 0;
|
||||
|
||||
NS_IMETHOD ResolveName(const nsAString& aName,
|
||||
nsIDOMHTMLFormElement *aForm,
|
||||
nsISupports **aResult) = 0;
|
||||
virtual nsresult ResolveName(const nsAString& aName,
|
||||
nsIDOMHTMLFormElement *aForm,
|
||||
nsISupports **aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetFormControlElements(nsIDOMNodeList** aReturn) = 0;
|
||||
/*
|
||||
* This method returns null if we run out of memory. Callers should
|
||||
* check for null.
|
||||
*/
|
||||
virtual already_AddRefed<nsIDOMNodeList> GetFormControlElements() = 0;
|
||||
|
||||
/**
|
||||
* Called when form->SetDocument() is called so that document knows
|
||||
* immediately when a form is added
|
||||
*/
|
||||
NS_IMETHOD AddedForm() = 0;
|
||||
virtual void AddedForm() = 0;
|
||||
/**
|
||||
* Called when form->SetDocument() is called so that document knows
|
||||
* immediately when a form is removed
|
||||
*/
|
||||
NS_IMETHOD RemovedForm() = 0;
|
||||
virtual void RemovedForm() = 0;
|
||||
/**
|
||||
* Called to get a better count of forms than document.forms can provide
|
||||
* without calling FlushPendingNotifications (bug 138892).
|
||||
*/
|
||||
NS_IMETHOD GetNumFormsSynchronous(PRInt32* aNumForms) = 0;
|
||||
virtual PRInt32 GetNumFormsSynchronous() = 0;
|
||||
|
||||
NS_IMETHOD_(PRBool) IsWriting() = 0;
|
||||
virtual PRBool IsWriting() = 0;
|
||||
};
|
||||
|
||||
#endif /* nsIHTMLDocument_h___ */
|
||||
|
@ -544,9 +544,7 @@ nsHTMLValue::ParseColor(const nsAString& aString, nsIDocument* aDocument)
|
||||
{
|
||||
nsCOMPtr<nsIHTMLDocument> doc(do_QueryInterface(aDocument));
|
||||
if (doc) {
|
||||
nsCompatibility mode;
|
||||
doc->GetCompatibilityMode(mode);
|
||||
inNavQuirksMode = (mode == eCompatibility_NavQuirks);
|
||||
inNavQuirksMode = (doc->GetCompatibilityMode() == eCompatibility_NavQuirks);
|
||||
} else {
|
||||
inNavQuirksMode = PR_FALSE;
|
||||
}
|
||||
|
@ -81,7 +81,8 @@ nsresult nsImageMapUtils::FindImageMap(nsIDocument *aDocument,
|
||||
|
||||
nsCOMPtr<nsIHTMLDocument> htmlDoc(do_QueryInterface(aDocument));
|
||||
if (htmlDoc) {
|
||||
htmlDoc->GetImageMap(usemap, aMap);
|
||||
*aMap = htmlDoc->GetImageMap(usemap);
|
||||
NS_IF_ADDREF(*aMap);
|
||||
} else {
|
||||
// For XHTML elements embedded in non-XHTML documents we get the
|
||||
// map by id since XHTML requires that where a "name" attribute
|
||||
|
@ -965,7 +965,7 @@ PRBool ValidateOrigin(nsIDocShellTreeItem* aOriginTreeItem, nsIDocShellTreeItem*
|
||||
|
||||
// If we don't have an HTML document, fall through with documentDomainSet false
|
||||
if (targetHTMLDocument) {
|
||||
targetHTMLDocument->WasDomainSet(&documentDomainSet);
|
||||
documentDomainSet = targetHTMLDocument->WasDomainSet();
|
||||
}
|
||||
|
||||
// Is origin same principal or a subdomain of target's document.domain
|
||||
|
Loading…
x
Reference in New Issue
Block a user