Bug 756383 - make nsHTMLAnchorElement::IsHTMLFocusable faster, r=bz

This commit is contained in:
Alexander Surkov 2012-05-23 12:03:32 +09:00
parent 62fe25331c
commit 1ea076a4d7
2 changed files with 13 additions and 2 deletions

View File

@ -104,6 +104,18 @@ public:
protected:
virtual ~Link();
/**
* Return true if the link has associated URI.
*/
bool HasURI() const
{
if (mCachedURI)
return true;
nsCOMPtr<nsIURI> uri(GetURI());
return !!uri;
}
bool HasCachedURI() const { return !!mCachedURI; }
private:

View File

@ -287,8 +287,7 @@ nsHTMLAnchorElement::IsHTMLFocusable(bool aWithMouse,
if (!HasAttr(kNameSpaceID_None, nsGkAtoms::tabindex)) {
// check whether we're actually a link
nsCOMPtr<nsIURI> absURI;
if (!IsLink(getter_AddRefs(absURI))) {
if (!Link::HasURI()) {
// Not tabbable or focusable without href (bug 17605), unless
// forced to be via presence of nonnegative tabindex attribute
if (aTabIndex) {