зеркало из https://github.com/mozilla/pjs.git
making the world safe for null linkHandlers
This commit is contained in:
Родитель
4532d338b1
Коммит
a49b921177
|
@ -286,10 +286,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler* handler;
|
||||
nsresult rv = aPresContext.GetLinkHandler(&handler);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
NS_RELEASE(handler);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
|
|
@ -1497,6 +1497,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no link handler? then all links are unvisited
|
||||
linkState = eLinkState_Unvisited;
|
||||
}
|
||||
}
|
||||
if (nsCSSAtoms::linkPseudo == pseudoClass->mAtom) {
|
||||
result = PRBool(eLinkState_Unvisited == linkState);
|
||||
|
|
|
@ -568,8 +568,7 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
// test link state
|
||||
nsILinkHandler* linkHandler;
|
||||
|
||||
if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) &&
|
||||
(nsnull != linkHandler)) {
|
||||
if (NS_OK == aPresContext->GetLinkHandler(&linkHandler)) {
|
||||
nsAutoString base, href;
|
||||
nsresult attrState = styledContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, href);
|
||||
|
||||
|
@ -602,7 +601,12 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
NS_IF_RELEASE(docURL);
|
||||
|
||||
nsLinkState state;
|
||||
if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
if (!linkHandler) {
|
||||
// if there is no link handler then just use eLinkState_Unvisited rule
|
||||
aResults->AppendElement(mLinkRule);
|
||||
matchCount++;
|
||||
}
|
||||
else if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
switch (state) {
|
||||
case eLinkState_Unvisited:
|
||||
if (nsnull != mLinkRule) {
|
||||
|
|
|
@ -286,10 +286,16 @@ nsHTMLAnchorElement::HandleDOMEvent(nsIPresContext& aPresContext,
|
|||
switch (aEvent->message) {
|
||||
case NS_MOUSE_LEFT_BUTTON_DOWN:
|
||||
{
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
// don't make the link grab the focus if there is no link handler
|
||||
nsILinkHandler* handler;
|
||||
nsresult rv = aPresContext.GetLinkHandler(&handler);
|
||||
if (NS_SUCCEEDED(rv) && (nsnull != handler)) {
|
||||
nsIEventStateManager *stateManager;
|
||||
if (NS_OK == aPresContext.GetEventStateManager(&stateManager)) {
|
||||
stateManager->SetContentState(this, NS_EVENT_STATE_ACTIVE | NS_EVENT_STATE_FOCUS);
|
||||
NS_RELEASE(stateManager);
|
||||
}
|
||||
NS_RELEASE(handler);
|
||||
}
|
||||
aEventStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
|
|
|
@ -541,7 +541,8 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
|||
|
||||
/* The postBuffer is now owned by the IPostData instance */
|
||||
}
|
||||
handler->OnLinkClick(mContent, eLinkVerb_Replace, absURLSpec.GetUnicode(), target.GetUnicode(), postData);
|
||||
if (handler)
|
||||
handler->OnLinkClick(mContent, eLinkVerb_Replace, absURLSpec.GetUnicode(), target.GetUnicode(), postData);
|
||||
NS_IF_RELEASE(postData);
|
||||
NS_RELEASE(handler);
|
||||
|
||||
|
|
|
@ -1497,6 +1497,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no link handler? then all links are unvisited
|
||||
linkState = eLinkState_Unvisited;
|
||||
}
|
||||
}
|
||||
if (nsCSSAtoms::linkPseudo == pseudoClass->mAtom) {
|
||||
result = PRBool(eLinkState_Unvisited == linkState);
|
||||
|
|
|
@ -568,8 +568,7 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
// test link state
|
||||
nsILinkHandler* linkHandler;
|
||||
|
||||
if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) &&
|
||||
(nsnull != linkHandler)) {
|
||||
if (NS_OK == aPresContext->GetLinkHandler(&linkHandler)) {
|
||||
nsAutoString base, href;
|
||||
nsresult attrState = styledContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, href);
|
||||
|
||||
|
@ -602,7 +601,12 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
NS_IF_RELEASE(docURL);
|
||||
|
||||
nsLinkState state;
|
||||
if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
if (!linkHandler) {
|
||||
// if there is no link handler then just use eLinkState_Unvisited rule
|
||||
aResults->AppendElement(mLinkRule);
|
||||
matchCount++;
|
||||
}
|
||||
else if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
switch (state) {
|
||||
case eLinkState_Unvisited:
|
||||
if (nsnull != mLinkRule) {
|
||||
|
|
|
@ -1497,6 +1497,10 @@ static PRBool SelectorMatches(nsIPresContext* aPresContext,
|
|||
linkHandler->GetLinkState(absURLSpec.GetUnicode(), linkState);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no link handler? then all links are unvisited
|
||||
linkState = eLinkState_Unvisited;
|
||||
}
|
||||
}
|
||||
if (nsCSSAtoms::linkPseudo == pseudoClass->mAtom) {
|
||||
result = PRBool(eLinkState_Unvisited == linkState);
|
||||
|
|
|
@ -568,8 +568,7 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
// test link state
|
||||
nsILinkHandler* linkHandler;
|
||||
|
||||
if ((NS_OK == aPresContext->GetLinkHandler(&linkHandler)) &&
|
||||
(nsnull != linkHandler)) {
|
||||
if (NS_OK == aPresContext->GetLinkHandler(&linkHandler)) {
|
||||
nsAutoString base, href;
|
||||
nsresult attrState = styledContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::href, href);
|
||||
|
||||
|
@ -602,7 +601,12 @@ PRInt32 HTMLStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,
|
|||
NS_IF_RELEASE(docURL);
|
||||
|
||||
nsLinkState state;
|
||||
if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
if (!linkHandler) {
|
||||
// if there is no link handler then just use eLinkState_Unvisited rule
|
||||
aResults->AppendElement(mLinkRule);
|
||||
matchCount++;
|
||||
}
|
||||
else if (NS_OK == linkHandler->GetLinkState(absURLSpec.GetUnicode(), state)) {
|
||||
switch (state) {
|
||||
case eLinkState_Unvisited:
|
||||
if (nsnull != mLinkRule) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче