Bug 756383 - make nsHTMLAnchorElement::IsHTMLFocusable faster, r=bz
authorAlexander Surkov <surkov.alexander@gmail.com>
Wed, 23 May 2012 12:03:32 +0900
changeset 94656 41d7c9506e270d49b6e30c39f71aef885fe704a2
parent 94655 384f2d1f7b49ff4df1963e58f1c8e617e982229b
child 94657 9d89bbb93a2cbce54085c516250119d9016f9ac2
push id9726
push usersurkov.alexander@gmail.com
push dateWed, 23 May 2012 03:01:26 +0000
treeherdermozilla-inbound@41d7c9506e27 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs756383
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 756383 - make nsHTMLAnchorElement::IsHTMLFocusable faster, r=bz
content/base/src/Link.h
content/html/content/src/nsHTMLAnchorElement.cpp
--- a/content/base/src/Link.h
+++ b/content/base/src/Link.h
@@ -99,16 +99,28 @@ public:
   virtual bool HasDeferredDNSPrefetchRequest() { return true; }
 
   virtual size_t
     SizeOfExcludingThis(nsMallocSizeOfFun aMallocSizeOf) const;
 
 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:
   /**
    * Unregisters from History so this node no longer gets notifications about
    * changes to visitedness.
    */
   void UnregisterFromHistory();
--- a/content/html/content/src/nsHTMLAnchorElement.cpp
+++ b/content/html/content/src/nsHTMLAnchorElement.cpp
@@ -282,18 +282,17 @@ nsHTMLAnchorElement::IsHTMLFocusable(boo
 
     *aIsFocusable = false;
 
     return true;
   }
 
   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) {
         *aTabIndex = -1;
       }
 
       *aIsFocusable = false;