028c5dc
From 1b13c952f50aab2b907dab13395ab23d0955c238 Mon Sep 17 00:00:00 2001
028c5dc
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
028c5dc
Date: Fri, 15 Feb 2013 17:12:00 +0000
028c5dc
Subject: [PATCH] Resolves: rhbz#895196 sc filter float a11y parent of itself
028c5dc
 loop/recurse
028c5dc
028c5dc
Change-Id: I3679e7cfcd32a78b40c6a7b803c92ff0abe6f32c
028c5dc
---
028c5dc
 accessibility/source/helper/acc_factory.cxx |  8 +++++---
028c5dc
 vcl/inc/vcl/popupmenuwindow.hxx             |  3 +++
028c5dc
 vcl/source/window/popupmenuwindow.cxx       |  6 ++++++
028c5dc
 vcl/source/window/window.cxx                | 12 +++++++++---
028c5dc
 4 files changed, 23 insertions(+), 6 deletions(-)
028c5dc
028c5dc
diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx
028c5dc
index dc16fe6..93f6bf5 100644
028c5dc
--- a/accessibility/source/helper/acc_factory.cxx
028c5dc
+++ b/accessibility/source/helper/acc_factory.cxx
028c5dc
@@ -382,9 +382,11 @@ inline bool hasFloatingChild(Window *pWindow)
028c5dc
             }
028c5dc
             else if ( nType == WINDOW_BORDERWINDOW && hasFloatingChild( pWindow ) )
028c5dc
             {
028c5dc
-                PopupMenuFloatingWindow* pChild = dynamic_cast<PopupMenuFloatingWindow*>(
028c5dc
-                    pWindow->GetAccessibleChildWindow(0));
028c5dc
-                if ( pChild && pChild->IsPopupMenu() )
028c5dc
+                // The logic here has to match that of Window::GetAccessibleParentWindow in
028c5dc
+                // vcl/source/window/window.cxx to avoid PopupMenuFloatingWindow
028c5dc
+                // becoming a11y parents of themselves
028c5dc
+                Window* pChild = pWindow->GetAccessibleChildWindow(0);
028c5dc
+                if (PopupMenuFloatingWindow::isPopupMenu(pChild))
028c5dc
                 {
028c5dc
                     // Get the accessible context from the child window.
028c5dc
                     Reference<XAccessible> xAccessible = pChild->CreateAccessible();
028c5dc
diff --git a/vcl/inc/vcl/popupmenuwindow.hxx b/vcl/inc/vcl/popupmenuwindow.hxx
028c5dc
index 57b7747..a5856dc 100644
028c5dc
--- a/vcl/inc/vcl/popupmenuwindow.hxx
028c5dc
+++ b/vcl/inc/vcl/popupmenuwindow.hxx
028c5dc
@@ -34,6 +34,9 @@ public:
028c5dc
     sal_uInt16      GetMenuStackLevel() const;
028c5dc
     void            SetMenuStackLevel( sal_uInt16 nLevel );
028c5dc
     bool            IsPopupMenu() const;
028c5dc
+
028c5dc
+    //determine if a given window is an activated PopupMenuFloatingWindow
028c5dc
+    static bool isPopupMenu(const Window *pWindow);
028c5dc
 };
028c5dc
 
028c5dc
 #endif
028c5dc
diff --git a/vcl/source/window/popupmenuwindow.cxx b/vcl/source/window/popupmenuwindow.cxx
028c5dc
index e5e773a..7a03794 100644
028c5dc
--- a/vcl/source/window/popupmenuwindow.cxx
028c5dc
+++ b/vcl/source/window/popupmenuwindow.cxx
028c5dc
@@ -67,4 +67,10 @@ bool PopupMenuFloatingWindow::IsPopupMenu() const
028c5dc
     return mpImplData->mnMenuStackLevel != ::std::numeric_limits<sal_uInt16>::max();
028c5dc
 }
028c5dc
 
028c5dc
+bool PopupMenuFloatingWindow::isPopupMenu(const Window *pWindow)
028c5dc
+{
028c5dc
+    const PopupMenuFloatingWindow* pChild = dynamic_cast<const PopupMenuFloatingWindow*>(pWindow);
028c5dc
+    return pChild && pChild->IsPopupMenu();
028c5dc
+}
028c5dc
+
028c5dc
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
028c5dc
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
028c5dc
index 6767fde..7ddb6b1 100644
028c5dc
--- a/vcl/source/window/window.cxx
028c5dc
+++ b/vcl/source/window/window.cxx
028c5dc
@@ -48,6 +48,7 @@
028c5dc
 #include "vcl/unowrap.hxx"
028c5dc
 #include "vcl/gdimtf.hxx"
028c5dc
 #include "vcl/pdfextoutdevdata.hxx"
028c5dc
+#include "vcl/popupmenuwindow.hxx"
028c5dc
 #include "vcl/lazydelete.hxx"
028c5dc
 #include "vcl/virdev.hxx"
028c5dc
 
028c5dc
@@ -8601,10 +8602,15 @@ Window* Window::GetAccessibleParentWindow() const
028c5dc
             pWorkWin = pWorkWin->mpWindowImpl->mpNext;
028c5dc
         pParent = pWorkWin;
028c5dc
     }
028c5dc
-    // If this a floating window which has a native boarder window, this one should be reported as
028c5dc
-    // accessible parent
028c5dc
+    // If this is a floating window which has a native border window, then that border should be reported as
028c5dc
+    // the accessible parent, unless the floating window is a PopupMenuFloatingWindow
028c5dc
+    //
028c5dc
+    // The logic here has to match that of AccessibleFactory::createAccessibleContext in
028c5dc
+    // accessibility/source/helper/acc_factory.cxx to avoid PopupMenuFloatingWindow
028c5dc
+    // becoming a11y parents of themselves
028c5dc
     else if( GetType() == WINDOW_FLOATINGWINDOW &&
028c5dc
-        mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame)
028c5dc
+        mpWindowImpl->mpBorderWindow && mpWindowImpl->mpBorderWindow->mpWindowImpl->mbFrame &&
028c5dc
+        !PopupMenuFloatingWindow::isPopupMenu(this))
028c5dc
     {
028c5dc
         pParent = mpWindowImpl->mpBorderWindow;
028c5dc
     }
028c5dc
-- 
028c5dc
1.8.1.2
028c5dc