зеркало из https://github.com/mozilla/pjs.git
better base url support
Checkin during red tree approved by sar
This commit is contained in:
Родитель
095a999ae8
Коммит
b735f84565
|
@ -45,6 +45,7 @@ class nsIDOMScriptObjectFactory;
|
|||
class nsChildContentList;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIURL;
|
||||
|
||||
class nsGenericHTMLElement : public nsGenericElement {
|
||||
public:
|
||||
|
@ -106,6 +107,8 @@ public:
|
|||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
nsresult GetContentStyleRule(nsIStyleRule*& aResult);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aResult);
|
||||
nsresult GetBaseURL(nsIURL*& aBaseURL) const;
|
||||
nsresult GetBaseTarget(nsString& aBaseTarget) const;
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
|
||||
|
@ -426,6 +429,12 @@ public:
|
|||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult) { \
|
||||
return _g.GetInlineStyleRule(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
|
@ -465,6 +474,12 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult); \
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult); \
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
@ -271,14 +272,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (activeLink == this) {
|
||||
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
nsAutoString base, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
base, href, target, PR_TRUE);
|
||||
baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
@ -291,14 +294,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsAutoString base, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
base, href, target, PR_FALSE);
|
||||
baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
@ -306,7 +311,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, empty, empty, empty, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
@ -333,14 +334,16 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (activeLink == this) {
|
||||
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
nsAutoString base, href, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_TRUE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
@ -354,14 +357,16 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_ENTER:
|
||||
//mouse enter doesn't work yet. Use move until then.
|
||||
{
|
||||
nsAutoString base, href, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
@ -370,7 +375,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, empty, empty, empty, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -518,6 +518,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint);
|
||||
virtual nsresult GetParent(nsISupports **aParent);
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL);
|
||||
|
||||
protected:
|
||||
nsICSSStyleRule *mRule;
|
||||
|
@ -583,6 +584,26 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMCSSDeclarationImpl::GetBaseURL(nsIURL** aURL)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aURL, "null pointer");
|
||||
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull != aURL) {
|
||||
*aURL = nsnull;
|
||||
if (nsnull != mRule) {
|
||||
nsIStyleSheet* sheet = nsnull;
|
||||
result = mRule->GetStyleSheet(sheet);
|
||||
if (nsnull != sheet) {
|
||||
result = sheet->GetURL(*aURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// -- nsCSSStyleRule -------------------------------
|
||||
|
||||
class CSSStyleRuleImpl : public nsICSSStyleRule,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
|
||||
{
|
||||
|
@ -214,7 +215,10 @@ nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName,
|
|||
result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
PRInt32 hint;
|
||||
result = css->ParseAndAppendDeclaration(declString, nsnull, decl, &hint);
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(&baseURL);
|
||||
result = css->ParseAndAppendDeclaration(declString, baseURL, decl, &hint);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
if (NS_OK == result) {
|
||||
result = StylePropertyChanged(aPropertyName, hint);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
class nsICSSDeclaration;
|
||||
class nsIURL;
|
||||
|
||||
class nsDOMCSSDeclaration : public nsIDOMCSS2Properties,
|
||||
public nsIScriptObjectOwner
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint) = 0;
|
||||
virtual nsresult GetParent(nsISupports **aParent) = 0;
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL) = 0; // get URL that style URLs are realtive to
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMCSSDeclaration();
|
||||
|
|
|
@ -242,7 +242,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
|
|||
nsIDocument* doc = mShell->GetDocument();
|
||||
NS_ASSERTION(nsnull != doc, "expect document here");
|
||||
if (nsnull != doc) {
|
||||
mBaseURL = doc->GetDocumentURL();
|
||||
doc->GetBaseURL(mBaseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ nsPresContext::SetShell(nsIPresShell* aShell)
|
|||
nsIDocument* doc = mShell->GetDocument();
|
||||
NS_ASSERTION(nsnull != doc, "expect document here");
|
||||
if (nsnull != doc) {
|
||||
mBaseURL = doc->GetDocumentURL();
|
||||
doc->GetBaseURL(mBaseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -605,20 +605,23 @@ nsHTMLFrameInnerFrame::GetParentContent(nsIContent*& aContent)
|
|||
PRIVATE
|
||||
void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
||||
{
|
||||
nsIURL* docURL = nsnull;
|
||||
nsIDocument* doc = nsnull;
|
||||
aContent->GetDocument(doc);
|
||||
if (nsnull != doc) {
|
||||
docURL = doc->GetDocumentURL();
|
||||
NS_RELEASE(doc);
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
if (NS_SUCCEEDED(aContent->GetDocument(doc))) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString base;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base)) {
|
||||
base.Truncate();
|
||||
}
|
||||
nsresult rv = NS_MakeAbsoluteURL(docURL, base, aRelURL, aAbsURL);
|
||||
NS_IF_RELEASE(docURL);
|
||||
nsString empty;
|
||||
nsresult rv = NS_MakeAbsoluteURL(baseURL, empty, aRelURL, aAbsURL);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ class nsIDOMScriptObjectFactory;
|
|||
class nsChildContentList;
|
||||
class nsDOMCSSDeclaration;
|
||||
class nsIDOMCSSStyleDeclaration;
|
||||
class nsIURL;
|
||||
|
||||
class nsGenericHTMLElement : public nsGenericElement {
|
||||
public:
|
||||
|
@ -106,6 +107,8 @@ public:
|
|||
nsresult HasClass(nsIAtom* aClass) const;
|
||||
nsresult GetContentStyleRule(nsIStyleRule*& aResult);
|
||||
nsresult GetInlineStyleRule(nsIStyleRule*& aResult);
|
||||
nsresult GetBaseURL(nsIURL*& aBaseURL) const;
|
||||
nsresult GetBaseTarget(nsString& aBaseTarget) const;
|
||||
nsresult ToHTMLString(nsString& aResult) const;
|
||||
nsresult ToHTML(FILE* out) const;
|
||||
|
||||
|
@ -426,6 +429,12 @@ public:
|
|||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult) { \
|
||||
return _g.GetInlineStyleRule(aResult); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
|
@ -465,6 +474,12 @@ public:
|
|||
} \
|
||||
NS_IMETHOD GetContentStyleRule(nsIStyleRule*& aResult); \
|
||||
NS_IMETHOD GetInlineStyleRule(nsIStyleRule*& aResult); \
|
||||
NS_IMETHOD GetBaseURL(nsIURL*& aBaseURL) const { \
|
||||
return _g.GetBaseURL(aBaseURL); \
|
||||
} \
|
||||
NS_IMETHOD GetBaseTarget(nsString& aBaseTarget) const { \
|
||||
return _g.GetBaseTarget(aBaseTarget); \
|
||||
} \
|
||||
NS_IMETHOD ToHTMLString(nsString& aResult) const { \
|
||||
return _g.ToHTMLString(aResult); \
|
||||
} \
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "nsStyleConsts.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
@ -271,14 +272,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (activeLink == this) {
|
||||
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
nsAutoString base, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
base, href, target, PR_TRUE);
|
||||
baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
@ -291,14 +294,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
case NS_MOUSE_ENTER:
|
||||
{
|
||||
nsAutoString base, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace,
|
||||
base, href, target, PR_FALSE);
|
||||
baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
@ -306,7 +311,7 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, empty, empty, empty, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "nsIPresContext.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIForm.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsDOMEvent.h"
|
||||
|
@ -333,14 +334,16 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
|
||||
if (activeLink == this) {
|
||||
if (nsEventStatus_eConsumeNoDefault != aEventStatus) {
|
||||
nsAutoString base, href, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_TRUE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_TRUE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
@ -354,14 +357,16 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_ENTER:
|
||||
//mouse enter doesn't work yet. Use move until then.
|
||||
{
|
||||
nsAutoString base, href, target;
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base);
|
||||
nsAutoString href, target;
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(baseURL);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::href, href);
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::target, target);
|
||||
if (target.Length() == 0) {
|
||||
GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseTarget, target);
|
||||
GetBaseTarget(target);
|
||||
}
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, base, href, target, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, baseURL, href, target, PR_FALSE);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
@ -370,7 +375,7 @@ nsHTMLButtonElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
case NS_MOUSE_EXIT:
|
||||
{
|
||||
nsAutoString empty;
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, empty, empty, empty, PR_FALSE);
|
||||
mInner.TriggerLink(aPresContext, eLinkVerb_Replace, nsnull, empty, empty, PR_FALSE);
|
||||
aEventStatus = nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -605,20 +605,23 @@ nsHTMLFrameInnerFrame::GetParentContent(nsIContent*& aContent)
|
|||
PRIVATE
|
||||
void TempMakeAbsURL(nsIContent* aContent, nsString& aRelURL, nsString& aAbsURL)
|
||||
{
|
||||
nsIURL* docURL = nsnull;
|
||||
nsIDocument* doc = nsnull;
|
||||
aContent->GetDocument(doc);
|
||||
if (nsnull != doc) {
|
||||
docURL = doc->GetDocumentURL();
|
||||
NS_RELEASE(doc);
|
||||
nsIURL* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
if (NS_SUCCEEDED(aContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent))) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
if (NS_SUCCEEDED(aContent->GetDocument(doc))) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
}
|
||||
|
||||
nsAutoString base;
|
||||
if (NS_CONTENT_ATTR_HAS_VALUE != aContent->GetAttribute(kNameSpaceID_HTML, nsHTMLAtoms::_baseHref, base)) {
|
||||
base.Truncate();
|
||||
}
|
||||
nsresult rv = NS_MakeAbsoluteURL(docURL, base, aRelURL, aAbsURL);
|
||||
NS_IF_RELEASE(docURL);
|
||||
nsString empty;
|
||||
nsresult rv = NS_MakeAbsoluteURL(baseURL, empty, aRelURL, aAbsURL);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
nsIDocument* doc = nsnull;
|
||||
mContent->GetDocument(doc);
|
||||
if (nsnull != doc) {
|
||||
docURL = doc->GetDocumentURL();
|
||||
doc->GetBaseURL(docURL);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
||||
|
@ -621,6 +621,7 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
|
|||
(void)docURL->GetSpec(&spec);
|
||||
URLName = (char*)PR_Malloc(PL_strlen(spec)+1);
|
||||
PL_strcpy(URLName, spec);
|
||||
NS_RELEASE(docURL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -518,6 +518,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint);
|
||||
virtual nsresult GetParent(nsISupports **aParent);
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL);
|
||||
|
||||
protected:
|
||||
nsICSSStyleRule *mRule;
|
||||
|
@ -583,6 +584,26 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMCSSDeclarationImpl::GetBaseURL(nsIURL** aURL)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aURL, "null pointer");
|
||||
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull != aURL) {
|
||||
*aURL = nsnull;
|
||||
if (nsnull != mRule) {
|
||||
nsIStyleSheet* sheet = nsnull;
|
||||
result = mRule->GetStyleSheet(sheet);
|
||||
if (nsnull != sheet) {
|
||||
result = sheet->GetURL(*aURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// -- nsCSSStyleRule -------------------------------
|
||||
|
||||
class CSSStyleRuleImpl : public nsICSSStyleRule,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
|
||||
{
|
||||
|
@ -214,7 +215,10 @@ nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName,
|
|||
result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
PRInt32 hint;
|
||||
result = css->ParseAndAppendDeclaration(declString, nsnull, decl, &hint);
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(&baseURL);
|
||||
result = css->ParseAndAppendDeclaration(declString, baseURL, decl, &hint);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
if (NS_OK == result) {
|
||||
result = StylePropertyChanged(aPropertyName, hint);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
class nsICSSDeclaration;
|
||||
class nsIURL;
|
||||
|
||||
class nsDOMCSSDeclaration : public nsIDOMCSS2Properties,
|
||||
public nsIScriptObjectOwner
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint) = 0;
|
||||
virtual nsresult GetParent(nsISupports **aParent) = 0;
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL) = 0; // get URL that style URLs are realtive to
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMCSSDeclaration();
|
||||
|
|
|
@ -518,6 +518,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint);
|
||||
virtual nsresult GetParent(nsISupports **aParent);
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL);
|
||||
|
||||
protected:
|
||||
nsICSSStyleRule *mRule;
|
||||
|
@ -583,6 +584,26 @@ DOMCSSDeclarationImpl::GetParent(nsISupports **aParent)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
DOMCSSDeclarationImpl::GetBaseURL(nsIURL** aURL)
|
||||
{
|
||||
NS_ASSERTION(nsnull != aURL, "null pointer");
|
||||
|
||||
nsresult result = NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (nsnull != aURL) {
|
||||
*aURL = nsnull;
|
||||
if (nsnull != mRule) {
|
||||
nsIStyleSheet* sheet = nsnull;
|
||||
result = mRule->GetStyleSheet(sheet);
|
||||
if (nsnull != sheet) {
|
||||
result = sheet->GetURL(*aURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// -- nsCSSStyleRule -------------------------------
|
||||
|
||||
class CSSStyleRuleImpl : public nsICSSStyleRule,
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "nsIStyleRule.h"
|
||||
#include "nsICSSDeclaration.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsIURL.h"
|
||||
|
||||
nsDOMCSSDeclaration::nsDOMCSSDeclaration()
|
||||
{
|
||||
|
@ -214,7 +215,10 @@ nsDOMCSSDeclaration::SetProperty(const nsString& aPropertyName,
|
|||
result = NS_NewCSSParser(&css);
|
||||
if (NS_OK == result) {
|
||||
PRInt32 hint;
|
||||
result = css->ParseAndAppendDeclaration(declString, nsnull, decl, &hint);
|
||||
nsIURL* baseURL = nsnull;
|
||||
GetBaseURL(&baseURL);
|
||||
result = css->ParseAndAppendDeclaration(declString, baseURL, decl, &hint);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
if (NS_OK == result) {
|
||||
result = StylePropertyChanged(aPropertyName, hint);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIScriptObjectOwner.h"
|
||||
|
||||
class nsICSSDeclaration;
|
||||
class nsIURL;
|
||||
|
||||
class nsDOMCSSDeclaration : public nsIDOMCSS2Properties,
|
||||
public nsIScriptObjectOwner
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
virtual nsresult StylePropertyChanged(const nsString& aPropertyName,
|
||||
PRInt32 aHint) = 0;
|
||||
virtual nsresult GetParent(nsISupports **aParent) = 0;
|
||||
virtual nsresult GetBaseURL(nsIURL** aURL) = 0; // get URL that style URLs are realtive to
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMCSSDeclaration();
|
||||
|
|
Загрузка…
Ссылка в новой задаче