mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
89d38b5d7a
- Bug 1173364 - support ARIA table and cell roles, r=marcoz (c6f9fc891e) - Bug 1205318 - make aria-owns loop alg more sophisticated, r=yzen (d287b1e41c) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), r=smaug (bf920abdd3) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList(), part3, r=davidb (675c3a0ee2) - Bug 1205476 - crash in mozilla::a11y::DocAccessible::ProcessInvalidationList, part2, r=davidb (a7cd835169) - Bug 1186786 - Replace nsBaseHashtable::EnumerateRead() calls in accessible/ with iterators. r=tbsaunde. (172fcbe18f) - Bug 1219299 - rework aria-owns implementation, r=yzen (c297a84b41) - Bug 1219744 - no child_of/parent_of relations for aria-owns, r=yzen (38ea8be268) - Bug 1205341 - get rid of aria-owns provided relations, part1: remove ARIA combobox special support (bug 819273 backout), r=yzen (0ca03a27bd) - Bug 1219743 - remove special ARIA owns support for ARIA menus, r=yzen (64468fdfd1) - Bug 1200595 - Introduce TextureData and implement it for X11. r=mattwoodrow, Bas, sotaro (2e6bc3f02c) - Bug 1200595 - Buffer TextureData implementation. r=mattwoodrow (1cb3ffd937) - Bug 1227415 - Fix copy buffer size r=jolin (344130daec) - Bug 1200595 - Gralloc TextureData implementation. r=sotaro (a0726233ca) - Bug 1205725 - Add basic SidebandStream handling to HwcComposer2D r=mwu,nical (42bea59a5f) - namespace (ab69730d53) - Bug 1194775 - Paper over a crash in ContentClient. r=Bas (998051cee4) - minor (c24c0b069d) - Bug 1197315 - remove PR_snprintf calls in gfx/; r=froydnj (f153fed9c8) - Bug 1157664 - Initialize mozilla::layers::FPSCOUNTER::mIteratorIndex. r=nical (cf5d2203ee) - Bug 1157663 - Init mMap in the constructor to avoid half initialized structures. r=nical (d972306493) - Bug 1167370: Check for Map() call failing. r=bas (707eda52ff) - Bug 1221276 - Don't crash if we don't have a surface. r=nical (c53141ea3d) - Bug 1219230 - Use the valid region for determining buffer size instead of the visible region. r=mstange (f2d4783eef) - Pass the correct moz2d backend in CanvasClients. (bug 1212499, r=mattwoodrow) (c16688afbb) - Bug 1179987 - Simplify unlocking of tiled texture hosts. r=nical (781200f702) - Bug 1170189 - Fix tiling crash on Linux. r=jrmuizel (879bbfb506) - Bug 1170189 - fix a comment in the tiling code. r=BenWa (62b47f1bbd) - Bug 1179987 - Make tiled TextureSource recycling based on pointer comparisons rather than trying to do it geometrically. r=nical (7bde534929) - Bug 1189710 - Use correct offset for LayerRenderState in TiledContentHost. r=jrmuizel (cb93c2f98a) - Bug 1215050 - Make layerscope support TiledPaintedLayer when using HWC. r=mattwoodrow, r=cjku (6bffac30f8) - Bug 1186208 - Fix crash when tiling is enabled on linux. r=mattwoodrow (b2f2c85734) - Bug 1197713 - Add missing gfxPrefs.h include to TiledContentHost.cpp. r=nical (22bce4e071) - Bug 1143575. Async image invalidation does not necessarily need to invalidate the layer; LayerTreeInvalidation will do that for us. r=mattwoodrow (a6144b7127) - Bug 1219529 - Don't attempt to deallocate shmems after the ipdl protocol is shut down. r=sotaro (3bb89ef36e) - Bug 1143575. Add assertion for diagnostic purposes. r=nical (e4944dd72f) - Bug 1202175 - Guard GLX-specific call in SurfaceDescriptorX11. r=jgilbert (167a4aa49b) - Bug 1132528 - Handle non existent key r=nical (6c12df1446) - Bug 1137151: Marked destructor of |GrallocReporter| as protected, r=jmuizelaar (57605c4472) - Bug 1145389 - Add gralloc allocation requet size check r=nical (47c6065148) - Bug 1181197 - Fix null dereference in SharedPlanarYCbCrImage destructor. r=jgilbert (3f8c390a6f) - Bug 1195110 - Check if GLContext is destroyed before freeing resources in CompositingRenderTargetOGL. r=jrmuizel (8eac603d84) - bug 1178956 - Specify precision in OGLShaderProgram.cpp to fix compositor on iOS. r=kip (daa6d9db20) - Bug 1186725 - InitTextures should check if LockRect() returns an error, r=mattwoodrow (bc87f908a7) - Bug 1170143 - Add some error checks around the creation of dxgi ycbcrvideo frames. r=Bas (c96e4d9e79) - Bug 1170143 - Build fix. r=me (a9d0064bc3) - Bug 1202700 - Use d3d9 device to upload YCbCr surfaces on the client side if possible. r=Bas (3ccd0c68f5) - Bug 1199361 - Add texture memory reporters for YCbCr TextureClients. r=jrmuizel (723e9d4b10) - bug 1183967 - fixup correct case of mfidl.h (e9abd04709) - Bug 1133007 - followup - make CreateServerSocketRunnable's constructor explicit; r=bustage (5de0ec7900) - Bug 1195653 - Part1.1: Dump SecondaryEffects (EffectTypes::MASK) on Layerscope viewer. r=dglastonbury (v2, carry r+) (a6736ad381) - Bug 1195653 - Part1.2: Use sSentTextureIds instead of sTextureIdList and move HasTextureIdBeenSent into SendTextureSource. r=dglastonbury (v3, carry r+) (7e0b14bca6) - Bug 1195653 - Part1.3: Add isMask attribute field to LayerScopePacket.proto. r=dglastonbury (v2, carry r+) (510e50e09a) - Bug 1195653 - Part1.4: Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (v1, carry r+) (f1824afcb3) - Bug 1195653 - Part1.5: Send isMask info to LayerScope viewer by TexturePacket. r=dglastonbury (v3) (1722e5e6fe) - Bug 1205521 - Part1: (v3) Add texture/mask attribute fields in LayerScopePacket.proto. r=dglastonbury (0cca15f8f5) - Bug 1205521 - Part2: (v3) Generated file diffs from patched LayerScopePacket.proto. r=dglastonbury (6253724bcf) - Bug 1205521 - Part3: (v3) Dump texture/mask attributes on layerscope viewer. r=dglastonbury (31d346bad1) - Bug 1205521 - Part4: (v2) Align LayerScopePacket to fit changes in Bug 1211324. r=dglastonbury (712da0fe9c) - Bug 1177023 - Log the IsRootContent flag when dumping framemetrics. r=botond (9bea51f318) - Bug 1153724 - Only assert if the size was reasonable to start. r=mchang (c3d61bbee1) - namespace (edcce0a0b3) - Bug 1195857: Make nsPresContext::HasAuthorSpecifiedRules()'s arg 'const', to remove need for const_cast in callers. r=jwatt (274fe66dca) - Bug 1182414, part 1 - Fix printing crash with range input controls. r=dholbert (352a408a83) - Bug 1182414, part 2 - Add printing crash test. r=dholbert (0fc9bd4529) - Bug 1099103 - Prevent numbers input using a grouping separator from being mis-processed as if the separator was a decimal separator. r=dholbert (90276c2f6b) - Bug 1157142 - Support logical (inline/block) in addition to physical orientation for the <input type=range> element; make inline the default behavior so that range sliders respect writing mode. r=jwatt (2ec37cbba8)
405 lines
12 KiB
C++
405 lines
12 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "FocusManager.h"
|
|
|
|
#include "Accessible-inl.h"
|
|
#include "AccIterator.h"
|
|
#include "DocAccessible-inl.h"
|
|
#include "nsAccessibilityService.h"
|
|
#include "nsAccUtils.h"
|
|
#include "nsEventShell.h"
|
|
#include "Role.h"
|
|
|
|
#include "nsFocusManager.h"
|
|
#include "mozilla/EventStateManager.h"
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
namespace mozilla {
|
|
namespace a11y {
|
|
|
|
FocusManager::FocusManager()
|
|
{
|
|
}
|
|
|
|
FocusManager::~FocusManager()
|
|
{
|
|
}
|
|
|
|
Accessible*
|
|
FocusManager::FocusedAccessible() const
|
|
{
|
|
if (mActiveItem)
|
|
return mActiveItem;
|
|
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
if (focusedNode) {
|
|
DocAccessible* doc =
|
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
|
return doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
bool
|
|
FocusManager::IsFocused(const Accessible* aAccessible) const
|
|
{
|
|
if (mActiveItem)
|
|
return mActiveItem == aAccessible;
|
|
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
if (focusedNode) {
|
|
// XXX: Before getting an accessible for node having a DOM focus make sure
|
|
// they belong to the same document because it can trigger unwanted document
|
|
// accessible creation for temporary about:blank document. Without this
|
|
// peculiarity we would end up with plain implementation based on
|
|
// FocusedAccessible() method call. Make sure this issue is fixed in
|
|
// bug 638465.
|
|
if (focusedNode->OwnerDoc() == aAccessible->GetNode()->OwnerDoc()) {
|
|
DocAccessible* doc =
|
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
|
return aAccessible ==
|
|
(doc ? doc->GetAccessibleEvenIfNotInMapOrContainer(focusedNode) : nullptr);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool
|
|
FocusManager::IsFocusWithin(const Accessible* aContainer) const
|
|
{
|
|
Accessible* child = FocusedAccessible();
|
|
while (child) {
|
|
if (child == aContainer)
|
|
return true;
|
|
|
|
child = child->Parent();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
FocusManager::FocusDisposition
|
|
FocusManager::IsInOrContainsFocus(const Accessible* aAccessible) const
|
|
{
|
|
Accessible* focus = FocusedAccessible();
|
|
if (!focus)
|
|
return eNone;
|
|
|
|
// If focused.
|
|
if (focus == aAccessible)
|
|
return eFocused;
|
|
|
|
// If contains the focus.
|
|
Accessible* child = focus->Parent();
|
|
while (child) {
|
|
if (child == aAccessible)
|
|
return eContainsFocus;
|
|
|
|
child = child->Parent();
|
|
}
|
|
|
|
// If contained by focus.
|
|
child = aAccessible->Parent();
|
|
while (child) {
|
|
if (child == focus)
|
|
return eContainedByFocus;
|
|
|
|
child = child->Parent();
|
|
}
|
|
|
|
return eNone;
|
|
}
|
|
|
|
void
|
|
FocusManager::NotifyOfDOMFocus(nsISupports* aTarget)
|
|
{
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusNotificationTarget("DOM focus", "Target", aTarget);
|
|
#endif
|
|
|
|
mActiveItem = nullptr;
|
|
|
|
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
|
if (targetNode) {
|
|
DocAccessible* document =
|
|
GetAccService()->GetDocAccessible(targetNode->OwnerDoc());
|
|
if (document) {
|
|
// Set selection listener for focused element.
|
|
if (targetNode->IsElement())
|
|
SelectionMgr()->SetControlSelectionListener(targetNode->AsElement());
|
|
|
|
document->HandleNotification<FocusManager, nsINode>
|
|
(this, &FocusManager::ProcessDOMFocus, targetNode);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
FocusManager::NotifyOfDOMBlur(nsISupports* aTarget)
|
|
{
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusNotificationTarget("DOM blur", "Target", aTarget);
|
|
#endif
|
|
|
|
mActiveItem = nullptr;
|
|
|
|
// If DOM document stays focused then fire accessible focus event to process
|
|
// the case when no element within this DOM document will be focused.
|
|
nsCOMPtr<nsINode> targetNode(do_QueryInterface(aTarget));
|
|
if (targetNode && targetNode->OwnerDoc() == FocusedDOMDocument()) {
|
|
nsIDocument* DOMDoc = targetNode->OwnerDoc();
|
|
DocAccessible* document =
|
|
GetAccService()->GetDocAccessible(DOMDoc);
|
|
if (document) {
|
|
// Clear selection listener for previously focused element.
|
|
if (targetNode->IsElement())
|
|
SelectionMgr()->ClearControlSelectionListener();
|
|
|
|
document->HandleNotification<FocusManager, nsINode>
|
|
(this, &FocusManager::ProcessDOMFocus, DOMDoc);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
FocusManager::ActiveItemChanged(Accessible* aItem, bool aCheckIfActive)
|
|
{
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusNotificationTarget("active item changed", "Item", aItem);
|
|
#endif
|
|
|
|
// Nothing changed, happens for XUL trees and HTML selects.
|
|
if (aItem && aItem == mActiveItem)
|
|
return;
|
|
|
|
mActiveItem = nullptr;
|
|
|
|
if (aItem && aCheckIfActive) {
|
|
Accessible* widget = aItem->ContainerWidget();
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::ActiveWidget(widget);
|
|
#endif
|
|
if (!widget || !widget->IsActiveWidget() || !widget->AreItemsOperable())
|
|
return;
|
|
}
|
|
mActiveItem = aItem;
|
|
|
|
// If active item is changed then fire accessible focus event on it, otherwise
|
|
// if there's no an active item then fire focus event to accessible having
|
|
// DOM focus.
|
|
Accessible* target = FocusedAccessible();
|
|
if (target)
|
|
DispatchFocusEvent(target->Document(), target);
|
|
}
|
|
|
|
void
|
|
FocusManager::ForceFocusEvent()
|
|
{
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
if (focusedNode) {
|
|
DocAccessible* document =
|
|
GetAccService()->GetDocAccessible(focusedNode->OwnerDoc());
|
|
if (document) {
|
|
document->HandleNotification<FocusManager, nsINode>
|
|
(this, &FocusManager::ProcessDOMFocus, focusedNode);
|
|
}
|
|
}
|
|
}
|
|
|
|
void
|
|
FocusManager::DispatchFocusEvent(DocAccessible* aDocument,
|
|
Accessible* aTarget)
|
|
{
|
|
NS_PRECONDITION(aDocument, "No document for focused accessible!");
|
|
if (aDocument) {
|
|
RefPtr<AccEvent> event =
|
|
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, aTarget,
|
|
eAutoDetect, AccEvent::eCoalesceOfSameType);
|
|
aDocument->FireDelayedEvent(event);
|
|
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusDispatched(aTarget);
|
|
#endif
|
|
}
|
|
}
|
|
|
|
void
|
|
FocusManager::ProcessDOMFocus(nsINode* aTarget)
|
|
{
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusNotificationTarget("process DOM focus", "Target", aTarget);
|
|
#endif
|
|
|
|
DocAccessible* document =
|
|
GetAccService()->GetDocAccessible(aTarget->OwnerDoc());
|
|
if (!document)
|
|
return;
|
|
|
|
Accessible* target = document->GetAccessibleEvenIfNotInMapOrContainer(aTarget);
|
|
if (target) {
|
|
// Check if still focused. Otherwise we can end up with storing the active
|
|
// item for control that isn't focused anymore.
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
if (!focusedNode)
|
|
return;
|
|
|
|
Accessible* DOMFocus =
|
|
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
|
if (target != DOMFocus)
|
|
return;
|
|
|
|
Accessible* activeItem = target->CurrentItem();
|
|
if (activeItem) {
|
|
mActiveItem = activeItem;
|
|
target = activeItem;
|
|
}
|
|
|
|
DispatchFocusEvent(document, target);
|
|
}
|
|
}
|
|
|
|
void
|
|
FocusManager::ProcessFocusEvent(AccEvent* aEvent)
|
|
{
|
|
NS_PRECONDITION(aEvent->GetEventType() == nsIAccessibleEvent::EVENT_FOCUS,
|
|
"Focus event is expected!");
|
|
|
|
// Emit focus event if event target is the active item. Otherwise then check
|
|
// if it's still focused and then update active item and emit focus event.
|
|
Accessible* target = aEvent->GetAccessible();
|
|
if (target != mActiveItem) {
|
|
|
|
// Check if still focused. Otherwise we can end up with storing the active
|
|
// item for control that isn't focused anymore.
|
|
DocAccessible* document = aEvent->GetDocAccessible();
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
if (!focusedNode)
|
|
return;
|
|
|
|
Accessible* DOMFocus =
|
|
document->GetAccessibleEvenIfNotInMapOrContainer(focusedNode);
|
|
if (target != DOMFocus)
|
|
return;
|
|
|
|
Accessible* activeItem = target->CurrentItem();
|
|
if (activeItem) {
|
|
mActiveItem = activeItem;
|
|
target = activeItem;
|
|
}
|
|
}
|
|
|
|
// Fire menu start/end events for ARIA menus.
|
|
if (target->IsARIARole(nsGkAtoms::menuitem)) {
|
|
// The focus was moved into menu.
|
|
Accessible* ARIAMenubar = nullptr;
|
|
for (Accessible* parent = target->Parent(); parent; parent = parent->Parent()) {
|
|
if (parent->IsARIARole(nsGkAtoms::menubar)) {
|
|
ARIAMenubar = parent;
|
|
break;
|
|
}
|
|
|
|
// Go up in the parent chain of the menu hierarchy.
|
|
if (!parent->IsARIARole(nsGkAtoms::menuitem) &&
|
|
!parent->IsARIARole(nsGkAtoms::menu)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (ARIAMenubar != mActiveARIAMenubar) {
|
|
// Leaving ARIA menu. Fire menu_end event on current menubar.
|
|
if (mActiveARIAMenubar) {
|
|
RefPtr<AccEvent> menuEndEvent =
|
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
|
aEvent->FromUserInput());
|
|
nsEventShell::FireEvent(menuEndEvent);
|
|
}
|
|
|
|
mActiveARIAMenubar = ARIAMenubar;
|
|
|
|
// Entering ARIA menu. Fire menu_start event.
|
|
if (mActiveARIAMenubar) {
|
|
RefPtr<AccEvent> menuStartEvent =
|
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_START,
|
|
mActiveARIAMenubar, aEvent->FromUserInput());
|
|
nsEventShell::FireEvent(menuStartEvent);
|
|
}
|
|
}
|
|
} else if (mActiveARIAMenubar) {
|
|
// Focus left a menu. Fire menu_end event.
|
|
RefPtr<AccEvent> menuEndEvent =
|
|
new AccEvent(nsIAccessibleEvent::EVENT_MENU_END, mActiveARIAMenubar,
|
|
aEvent->FromUserInput());
|
|
nsEventShell::FireEvent(menuEndEvent);
|
|
|
|
mActiveARIAMenubar = nullptr;
|
|
}
|
|
|
|
#ifdef A11Y_LOG
|
|
if (logging::IsEnabled(logging::eFocus))
|
|
logging::FocusNotificationTarget("fire focus event", "Target", target);
|
|
#endif
|
|
|
|
// Reset cached caret value. The cache will be updated upon processing the
|
|
// next caret move event. This ensures that we will return the correct caret
|
|
// offset before the caret move event is handled.
|
|
SelectionMgr()->ResetCaretOffset();
|
|
|
|
RefPtr<AccEvent> focusEvent =
|
|
new AccEvent(nsIAccessibleEvent::EVENT_FOCUS, target, aEvent->FromUserInput());
|
|
nsEventShell::FireEvent(focusEvent);
|
|
|
|
// Fire scrolling_start event when the document receives the focus if it has
|
|
// an anchor jump. If an accessible within the document receive the focus
|
|
// then null out the anchor jump because it no longer applies.
|
|
DocAccessible* targetDocument = target->Document();
|
|
Accessible* anchorJump = targetDocument->AnchorJump();
|
|
if (anchorJump) {
|
|
if (target == targetDocument) {
|
|
// XXX: bug 625699, note in some cases the node could go away before we
|
|
// we receive focus event, for example if the node is removed from DOM.
|
|
nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
|
|
anchorJump, aEvent->FromUserInput());
|
|
}
|
|
targetDocument->SetAnchorJump(nullptr);
|
|
}
|
|
}
|
|
|
|
nsINode*
|
|
FocusManager::FocusedDOMNode() const
|
|
{
|
|
nsFocusManager* DOMFocusManager = nsFocusManager::GetFocusManager();
|
|
nsIContent* focusedElm = DOMFocusManager->GetFocusedContent();
|
|
|
|
// No focus on remote target elements like xul:browser having DOM focus and
|
|
// residing in chrome process because it means an element in content process
|
|
// keeps the focus.
|
|
if (focusedElm) {
|
|
if (EventStateManager::IsRemoteTarget(focusedElm)) {
|
|
return nullptr;
|
|
}
|
|
return focusedElm;
|
|
}
|
|
|
|
// Otherwise the focus can be on DOM document.
|
|
nsPIDOMWindow* focusedWnd = DOMFocusManager->GetFocusedWindow();
|
|
return focusedWnd ? focusedWnd->GetExtantDoc() : nullptr;
|
|
}
|
|
|
|
nsIDocument*
|
|
FocusManager::FocusedDOMDocument() const
|
|
{
|
|
nsINode* focusedNode = FocusedDOMNode();
|
|
return focusedNode ? focusedNode->OwnerDoc() : nullptr;
|
|
}
|
|
|
|
} // namespace a11y
|
|
} // namespace mozilla
|