Fix some IsFocusable methods to do the right thing. Bug 261707, r=aaronl, sr=jst

This commit is contained in:
bzbarsky%mit.edu 2004-10-07 01:15:40 +00:00
Родитель fe17731ee5
Коммит a4d8e15629
3 изменённых файлов: 34 добавлений и 11 удалений

Просмотреть файл

@ -219,8 +219,9 @@ nsHTMLAnchorElement::SetFocus(nsPresContext* aPresContext)
NS_EVENT_STATE_FOCUS);
// Make sure the presentation is up-to-date
if (IsInDoc()) {
GetOwnerDoc()->FlushPendingNotifications(Flush_Layout);
nsIDocument* doc = GetCurrentDoc();
if (doc) {
doc->FlushPendingNotifications(Flush_Layout);
}
nsIPresShell *presShell = aPresContext->GetPresShell();
@ -244,15 +245,17 @@ nsHTMLAnchorElement::IsFocusable(PRInt32 *aTabIndex)
}
PRBool isFocusable = PR_FALSE;
nsAutoString href;
GetAttribute(NS_LITERAL_STRING("href"), href);
if (href.IsEmpty() && !HasAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex)) {
// Not tabbable or focusable without href (bug 17605), unless
// forced to be via presence of nonnegative tabindex attribute
if (aTabIndex) {
*aTabIndex = -1;
if (!HasAttr(kNameSpaceID_None, nsHTMLAtoms::tabindex)) {
// check whether we're actually a link
nsCOMPtr<nsIURI> linkURI = nsContentUtils::GetLinkURI(this);
if (!linkURI) {
// Not tabbable or focusable without href (bug 17605), unless
// forced to be via presence of nonnegative tabindex attribute
if (aTabIndex) {
*aTabIndex = -1;
}
return PR_FALSE;
}
return PR_FALSE;
}
if (aTabIndex && (sTabFocusModel & eTabFocus_linksMask) == 0) {

Просмотреть файл

@ -258,7 +258,7 @@ nsXMLElement::MaybeTriggerAutoLink(nsIDocShell *aShell)
nsCOMPtr<nsIURI> uri;
rv = nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri),
value,
GetCurrentDoc(),
GetOwnerDoc(),
base);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsPresContext> pc;
@ -416,6 +416,25 @@ nsXMLElement::HandleDOMEvent(nsPresContext* aPresContext,
return ret;
}
PRBool
nsXMLElement::IsFocusable(PRInt32 *aTabIndex)
{
nsCOMPtr<nsIURI> linkURI = nsContentUtils::GetLinkURI(this);
if (linkURI) {
if (aTabIndex) {
*aTabIndex = ((sTabFocusModel & eTabFocus_linksMask) == 0 ? -1 : 0);
}
return PR_TRUE;
}
if (aTabIndex) {
*aTabIndex = -1;
}
return PR_FALSE;
}
NS_IMETHODIMP
nsXMLElement::CloneNode(PRBool aDeep, nsIDOMNode** aReturn)
{

Просмотреть файл

@ -85,6 +85,7 @@ public:
nsEvent* aEvent, nsIDOMEvent** aDOMEvent,
PRUint32 aFlags,
nsEventStatus* aEventStatus);
virtual PRBool IsFocusable(PRInt32 *aTabIndex = nsnull);
protected:
PRBool mIsLink;