Bug 1438193 - part11-7: TakeFocus r=surkov
authorTokio Kajitsuka <kajitsuka-tokio@g.ecc.u-tokyo.ac.jp>
Wed, 16 May 2018 02:19:54 +0900
changeset 472829 289b4c6fe61feee2537c0bc027781663516fa52c
parent 472828 4e8ac5d56aab8fa261b0aa15c8072d82e8f0883d
child 472830 835d704af69f0dd13db43d8b5de85bd70c58c468
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1438193
milestone62.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 1438193 - part11-7: TakeFocus r=surkov turn TakeFocus & AnchorURIAt into const functions
accessible/generic/Accessible.cpp
accessible/generic/Accessible.h
accessible/generic/BaseAccessibles.cpp
accessible/generic/BaseAccessibles.h
accessible/generic/DocAccessible.cpp
accessible/generic/DocAccessible.h
accessible/html/HTMLImageMapAccessible.cpp
accessible/html/HTMLImageMapAccessible.h
accessible/html/HTMLLinkAccessible.cpp
accessible/html/HTMLLinkAccessible.h
accessible/xul/XULElementAccessibles.cpp
accessible/xul/XULElementAccessibles.h
accessible/xul/XULTreeAccessible.cpp
accessible/xul/XULTreeAccessible.h
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -742,17 +742,17 @@ Accessible::TakeSelection()
   if (select) {
     if (select->State() & states::MULTISELECTABLE)
       select->UnselectAll();
     SetSelected(true);
   }
 }
 
 void
-Accessible::TakeFocus()
+Accessible::TakeFocus() const
 {
   nsIFrame* frame = GetFrame();
   if (!frame)
     return;
 
   nsIContent* focusContent = mContent;
 
   // If the accessible focus is managed by container widget then focus the
@@ -2391,17 +2391,17 @@ Accessible::AnchorCount()
 Accessible*
 Accessible::AnchorAt(uint32_t aAnchorIndex)
 {
   MOZ_ASSERT(IsLink(), "GetAnchor is called on not hyper link!");
   return aAnchorIndex == 0 ? this : nullptr;
 }
 
 already_AddRefed<nsIURI>
-Accessible::AnchorURIAt(uint32_t aAnchorIndex)
+Accessible::AnchorURIAt(uint32_t aAnchorIndex) const
 {
   MOZ_ASSERT(IsLink(), "AnchorURIAt is called on not hyper link!");
   return nullptr;
 }
 
 void
 Accessible::ToTextPoint(HyperTextAccessible** aContainer, int32_t* aOffset,
                         bool aIsBefore) const
--- a/accessible/generic/Accessible.h
+++ b/accessible/generic/Accessible.h
@@ -537,17 +537,17 @@ public:
   /**
    * Select the accessible within its container.
    */
   void TakeSelection();
 
   /**
    * Focus the accessible.
    */
-  virtual void TakeFocus();
+  virtual void TakeFocus() const;
 
   /**
    * Scroll the accessible into view.
    */
   void ScrollTo(uint32_t aHow) const;
 
   /**
    * Scroll the accessible to the given point.
@@ -760,17 +760,17 @@ public:
   /**
    * Returns an anchor accessible at the given index.
    */
   virtual Accessible* AnchorAt(uint32_t aAnchorIndex);
 
   /**
    * Returns an anchor URI at the given index.
    */
-  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex);
+  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) const;
 
   /**
    * Returns a text point for the accessible element.
    */
   void ToTextPoint(HyperTextAccessible** aContainer, int32_t* aOffset,
                    bool aIsBefore = true) const;
 
   //////////////////////////////////////////////////////////////////////////////
--- a/accessible/generic/BaseAccessibles.cpp
+++ b/accessible/generic/BaseAccessibles.cpp
@@ -63,31 +63,30 @@ LeafAccessible::IsAcceptableChild(nsICon
 ////////////////////////////////////////////////////////////////////////////////
 // LinkableAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 ////////////////////////////////////////////////////////////////////////////////
 // LinkableAccessible. nsIAccessible
 
 void
-LinkableAccessible::TakeFocus()
+LinkableAccessible::TakeFocus() const
 {
-  if (Accessible* actionAcc = ActionWalk()) {
+  if (const Accessible* actionAcc = ActionWalk()) {
     actionAcc->TakeFocus();
   } else {
     AccessibleWrap::TakeFocus();
   }
 }
 
 uint64_t
 LinkableAccessible::NativeLinkState() const
 {
   bool isLink;
-  Accessible* actionAcc =
-    const_cast<LinkableAccessible*>(this)->ActionWalk(&isLink);
+  const Accessible* actionAcc = ActionWalk(&isLink);
   if (isLink) {
     return states::LINKED | (actionAcc->LinkState() & states::TRAVERSED);
   }
 
   return 0;
 }
 
 void
@@ -184,17 +183,17 @@ LinkableAccessible::ActionNameAt(uint8_t
 
 bool
 LinkableAccessible::DoAction(uint8_t aIndex)
 {
   if (aIndex != eAction_Jump) {
     return false;
   }
 
-  if (Accessible* actionAcc = ActionWalk()) {
+  if (const Accessible* actionAcc = ActionWalk()) {
     return actionAcc->DoAction(aIndex);
   }
 
   return AccessibleWrap::DoAction(aIndex);
 }
 
 KeyBinding
 LinkableAccessible::AccessKey() const
@@ -206,20 +205,20 @@ LinkableAccessible::AccessKey() const
 
   return Accessible::AccessKey();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // LinkableAccessible: HyperLinkAccessible
 
 already_AddRefed<nsIURI>
-LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex)
+LinkableAccessible::AnchorURIAt(uint32_t aAnchorIndex) const
 {
   bool isLink;
-  Accessible* actionAcc = ActionWalk(&isLink);
+  const Accessible* actionAcc = ActionWalk(&isLink);
   if (isLink) {
     NS_ASSERTION(actionAcc->IsLink(), "HyperLink isn't implemented.");
 
     if (actionAcc->IsLink()) {
       return actionAcc->AnchorURIAt(aAnchorIndex);
     }
   }
 
--- a/accessible/generic/BaseAccessibles.h
+++ b/accessible/generic/BaseAccessibles.h
@@ -60,30 +60,30 @@ public:
   {
   }
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(LinkableAccessible, AccessibleWrap)
 
   // Accessible
   virtual void Value(nsString& aValue) const override;
   virtual uint64_t NativeLinkState() const override;
-  virtual void TakeFocus() override;
+  virtual void TakeFocus() const override;
 
   // ActionAccessible
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t index) override;
   virtual KeyBinding AccessKey() const override;
 
   // ActionAccessible helpers
   const Accessible* ActionWalk(bool* aIsLink = nullptr,
                                bool* aIsOnclick = nullptr,
                                bool* aIsLabelWithControl = nullptr) const;
   // HyperLinkAccessible
-  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
+  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) const override;
 
 protected:
   virtual ~LinkableAccessible() {}
 
 };
 
 /**
  * A simple accessible that gets its enumerated role.
--- a/accessible/generic/DocAccessible.cpp
+++ b/accessible/generic/DocAccessible.cpp
@@ -315,17 +315,17 @@ Accessible*
 DocAccessible::FocusedChild()
 {
   // Return an accessible for the current global focus, which does not have to
   // be contained within the current document.
   return FocusMgr()->FocusedAccessible();
 }
 
 void
-DocAccessible::TakeFocus()
+DocAccessible::TakeFocus() const
 {
   // Focus the document.
   nsFocusManager* fm = nsFocusManager::GetFocusManager();
   RefPtr<dom::Element> newFocus;
   AutoHandlingUserInputStatePusher inputStatePusher(true, nullptr, mDocumentNode);
   fm->MoveFocus(mDocumentNode->GetWindow(), nullptr,
                 nsFocusManager::MOVEFOCUS_ROOT, 0, getter_AddRefs(newFocus));
 }
--- a/accessible/generic/DocAccessible.h
+++ b/accessible/generic/DocAccessible.h
@@ -74,17 +74,17 @@ public:
   virtual Accessible* FocusedChild() override;
   virtual mozilla::a11y::role NativeRole() const override;
   virtual uint64_t NativeState() override;
   virtual uint64_t NativeInteractiveState() const override;
   virtual bool NativelyUnavailable() const override;
   virtual void ApplyARIAState(uint64_t* aState) const override;
   virtual already_AddRefed<nsIPersistentProperties> Attributes() override;
 
-  virtual void TakeFocus() override;
+  virtual void TakeFocus() const override;
 
 #ifdef A11Y_LOG
   virtual nsresult HandleAccEvent(AccEvent* aEvent) override;
 #endif
 
   virtual nsRect RelativeBounds(nsIFrame** aRelativeFrame) const override;
 
   // HyperTextAccessible
--- a/accessible/html/HTMLImageMapAccessible.cpp
+++ b/accessible/html/HTMLImageMapAccessible.cpp
@@ -52,17 +52,17 @@ HTMLImageMapAccessible::AnchorCount()
 
 Accessible*
 HTMLImageMapAccessible::AnchorAt(uint32_t aAnchorIndex)
 {
   return GetChildAt(aAnchorIndex);
 }
 
 already_AddRefed<nsIURI>
-HTMLImageMapAccessible::AnchorURIAt(uint32_t aAnchorIndex)
+HTMLImageMapAccessible::AnchorURIAt(uint32_t aAnchorIndex) const
 {
   Accessible* area = GetChildAt(aAnchorIndex);
   if (!area)
     return nullptr;
 
   nsIContent* linkContent = area->GetContent();
   return linkContent ? linkContent->GetHrefURI() : nullptr;
 }
--- a/accessible/html/HTMLImageMapAccessible.h
+++ b/accessible/html/HTMLImageMapAccessible.h
@@ -25,17 +25,17 @@ public:
                                        ImageAccessibleWrap)
 
   // Accessible
   virtual a11y::role NativeRole() const override;
 
   // HyperLinkAccessible
   virtual uint32_t AnchorCount() override;
   virtual Accessible* AnchorAt(uint32_t aAnchorIndex) override;
-  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
+  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) const override;
 
   /**
    * Update area children of the image map.
    */
   void UpdateChildAreas(bool aDoFireEvents = true);
 
   /**
    * Return accessible of child node.
--- a/accessible/html/HTMLLinkAccessible.cpp
+++ b/accessible/html/HTMLLinkAccessible.cpp
@@ -123,17 +123,17 @@ HTMLLinkAccessible::DoAction(uint8_t aIn
 bool
 HTMLLinkAccessible::IsLink() const
 {
   // Expose HyperLinkAccessible unconditionally.
   return true;
 }
 
 already_AddRefed<nsIURI>
-HTMLLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
+HTMLLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex) const
 {
   return aAnchorIndex == 0 ? mContent->GetHrefURI() : nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Protected members
 
 bool
--- a/accessible/html/HTMLLinkAccessible.h
+++ b/accessible/html/HTMLLinkAccessible.h
@@ -28,17 +28,17 @@ public:
 
   // ActionAccessible
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t aIndex) override;
 
   // HyperLinkAccessible
   virtual bool IsLink() const override;
-  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
+  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) const override;
 
 protected:
   virtual ~HTMLLinkAccessible() {}
 
   enum { eAction_Jump = 0 };
 
   /**
    * Returns true if the link has href attribute.
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -263,17 +263,17 @@ uint32_t
 XULLinkAccessible::EndOffset()
 {
   if (Accessible::IsLink())
     return Accessible::EndOffset();
   return IndexInParent() + 1;
 }
 
 already_AddRefed<nsIURI>
-XULLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex)
+XULLinkAccessible::AnchorURIAt(uint32_t aAnchorIndex) const
 {
   if (aAnchorIndex != 0)
     return nullptr;
 
   nsAutoString href;
   mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
 
   nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
--- a/accessible/xul/XULElementAccessibles.h
+++ b/accessible/xul/XULElementAccessibles.h
@@ -93,17 +93,17 @@ public:
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t aIndex) override;
 
   // HyperLinkAccessible
   virtual bool IsLink() const override;
   virtual uint32_t StartOffset() override;
   virtual uint32_t EndOffset() override;
-  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) override;
+  virtual already_AddRefed<nsIURI> AnchorURIAt(uint32_t aAnchorIndex) const override;
 
 protected:
   virtual ~XULLinkAccessible();
 
   // Accessible
   virtual ENameValueFlag NativeName(nsString& aName) const override;
 
   enum { eAction_Jump = 0 };
--- a/accessible/xul/XULTreeAccessible.cpp
+++ b/accessible/xul/XULTreeAccessible.cpp
@@ -773,17 +773,17 @@ XULTreeItemAccessibleBase::SetSelected(b
     bool isSelected = false;
     selection->IsSelected(mRow, &isSelected);
     if (isSelected != aSelect)
       selection->ToggleSelect(mRow);
   }
 }
 
 void
-XULTreeItemAccessibleBase::TakeFocus()
+XULTreeItemAccessibleBase::TakeFocus() const
 {
   nsCOMPtr<nsITreeSelection> selection;
   mTreeView->GetSelection(getter_AddRefs(selection));
   if (selection)
     selection->SetCurrentIndex(mRow);
 
   // focus event will be fired here
   Accessible::TakeFocus();
--- a/accessible/xul/XULTreeAccessible.h
+++ b/accessible/xul/XULTreeAccessible.h
@@ -150,17 +150,17 @@ public:
   virtual nsIntRect BoundsInCSSPixels() const override;
   virtual GroupPos GroupPosition() override;
   virtual uint64_t NativeState() override;
   virtual uint64_t NativeInteractiveState() const override;
   virtual int32_t IndexInParent() const override;
   virtual Relation RelationByType(RelationType aType) const override;
   virtual Accessible* FocusedChild() override;
   virtual void SetSelected(bool aSelect) override;
-  virtual void TakeFocus() override;
+  virtual void TakeFocus() const override;
 
   // ActionAccessible
   virtual uint8_t ActionCount() override;
   virtual void ActionNameAt(uint8_t aIndex, nsAString& aName) override;
   virtual bool DoAction(uint8_t aIndex) override;
 
   // Widgets
   virtual Accessible* ContainerWidget() const override;