Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,15 @@ public ListViewSkin(final ListView<T> control) {
}
return null;
}
case VISIBLE_ITEM_RANGE: {
ListCell<T> firstVisibleCell = flow.getFirstVisibleCellWithinViewport();
ListCell<T> lastVisibleCell = flow.getLastVisibleCellWithinViewport();
if (firstVisibleCell == null || lastVisibleCell == null) {
return new int[] { 0, 0 };
}
int firstIndex = firstVisibleCell.getIndex();
return new int[] { firstIndex, lastVisibleCell.getIndex() - firstIndex + 1 };
}
case SELECTED_ITEMS: {
MultipleSelectionModel<T> sm = getSkinnable().getSelectionModel();
if (sm == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ public void dispose() {
/** {@inheritDoc} */
@Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) {
switch (attribute) {
case ROW_AT_INDEX: {
final int rowIndex = (Integer)parameters[0];
return rowIndex < 0 ? null : flow.getPrivateCell(rowIndex);
}
case SELECTED_ITEMS: {
List<Node> selection = new ArrayList<>();
TableViewSelectionModel<T> sm = getSkinnable().getSelectionModel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,15 @@ private boolean isCellFocused(int row) {
* look for column headers */
return getTableHeaderRow();
}
case VISIBLE_ITEM_RANGE: {
I firstVisibleCell = flow.getFirstVisibleCellWithinViewport();
I lastVisibleCell = flow.getLastVisibleCellWithinViewport();
if (firstVisibleCell == null || lastVisibleCell == null) {
return new int[] { 0, 0 };
}
int firstIndex = firstVisibleCell.getIndex();
return new int[] { firstIndex, lastVisibleCell.getIndex() - firstIndex + 1 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is not being hit when scrolling with the mouse.

should the change in the viewport origin result in VISIBLE_ITEM_RANGE being updated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is not being hit when scrolling with the mouse.

should the change in the viewport origin result in VISIBLE_ITEM_RANGE being updated?

Not until the VO requests the data. Which happens when it detects change in the selected row or when we enter/exit the table or list with VO selection shortcuts.

}
case VERTICAL_SCROLLBAR: return flow.getVbar();
case HORIZONTAL_SCROLLBAR: return flow.getHbar();
default: return super.queryAccessibleAttribute(attribute, parameters);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -27,7 +27,9 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
Expand Down Expand Up @@ -119,6 +121,7 @@ private static enum MacAttribute {
AXMenuItemCmdGlyph(ACCELERATOR, MacVariant::createNSNumberForInt),
AXMenuItemCmdModifiers(ACCELERATOR, MacVariant::createNSNumberForInt),
AXMenuItemMarkChar(SELECTED, MacVariant::createNSString),
AXVisibleItemRange(VISIBLE_ITEM_RANGE, MacVariant::createNSValueForRange),
AXDateTimeComponents(null, MacVariant::createNSNumberForInt),

// NSAccessibilityMenuRole
Expand Down Expand Up @@ -1300,6 +1303,31 @@ private MacVariant accessibilityAttributeValue(long attribute) {
return null;
}
Object result = getAttribute(jfxAttr);
if (attr == MacAttribute.NSAccessibilitySelectedRowsAttribute
&& role == AccessibleRole.TABLE_VIEW) {
@SuppressWarnings("unchecked")
ObservableList<Node> selectedCells = (ObservableList<Node>)result;
Set<Node> selectedRows = new LinkedHashSet<>();
if (selectedCells != null) {
for (Node cell : selectedCells) {
Accessible cellAccessible = getAccessible(cell);
if (cellAccessible == null) {
continue;
}

Integer rowIndex = (Integer)cellAccessible.getAttribute(ROW_INDEX);
if (rowIndex == null) {
continue;
}

Node row = (Node)getAttribute(ROW_AT_INDEX, rowIndex);
if (row != null) {
selectedRows.add(row);
}
}
}
result = FXCollections.observableArrayList(selectedRows);
}
if (result == null) {
switch (attr) {
case NSAccessibilityParentAttribute: break;
Expand Down Expand Up @@ -1696,12 +1724,15 @@ private void accessibilitySetValue(long value, long attribute) {
if (variant != null && variant.longArray != null && variant.longArray.length > 0) {
long[] ids = variant.longArray;
ObservableList<Node> items = FXCollections.observableArrayList();
AccessibleRole controlRole = (AccessibleRole)getAttribute(ROLE);
for (long id : ids) {
MacAccessible acc = GlassAccessibleToMacAccessible(id);
if (acc != null) {
Integer index = (Integer)acc.getAttribute(INDEX);
if (index != null) {
Node cell = (Node)getAttribute(ROW_AT_INDEX, index);
AccessibleAttribute itemAttribute = controlRole == AccessibleRole.LIST_VIEW
? ITEM_AT_INDEX : ROW_AT_INDEX;
Node cell = (Node)getAttribute(itemAttribute, index);
if (cell != null) {
items.add(cell);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,20 @@ public enum AccessibleAttribute {
*/
VERTICAL_SCROLLBAR(Node.class),

/**
* Returns the range of visible items in an indexed control.
* <ul>
* <li>Used by: ListView and TableView </li>
* <li>Needs notify: no </li>
* <li>Return Type: {@code int[]} containing the first item index and the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please specify how it encodes a no-range case.

it looks like the code returns [0,0], but is this right?
should it return an empty array or null instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The {0, 0} is the valid range, we should not return empty array or null in any case.

* number of visible items </li>
* <li>Parameters: </li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters: should describe the structure (see BOUNDS_FOR_RANGE for example)

* </ul>
*
* @since 28
*/
VISIBLE_ITEM_RANGE(int[].class),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. this is a new attribute, so this PR needs as CSR, correct?
  2. would it make more sense to use a more descriptive record instead of int[]?

minor: the values in this enum are not sorted alphabetically - should they? do we care?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. this is a new attribute, so this PR needs as CSR, correct?

I have no idea. If that would be a change in the public API i would definitely say yes, for the attribute - since we add it and not changing the meaning of the existing attribute - may be? Gray area for me honestly. @kevinrushforth Any comments?

  1. would it make more sense to use a more descriptive record instead of int[]?

That would require more processing on the native side so i would just leave it as is. It is a technical attribute that is required to pass information from the skin level to the native a11y helper - it is not supposed to be available for any other purposes.

minor: the values in this enum are not sorted alphabetically - should they? do we care?

Not really. Changing the existing code just to sort the enum - i would hate to do so, i prefer to keep the history cleaner, it's an old code, technical binding of the parameters to the native bound variables, nobody really looks at it except the compiler.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccessibleAttribute is public API. The new attribute also needs @since 28.
CSR is needed.

(it's fine to keep it an int[])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AccessibleAttribute is public API. The new attribute also needs @since 28. CSR is needed.

Oh well. Time to learn how to create CSR for JavaFX. Yaaaaay.... [/sarcasm off]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. this is a new attribute, so this PR needs as CSR, correct?

I have no idea. If that would be a change in the public API i would definitely say yes, for the attribute - since we add it and not changing the meaning of the existing attribute - may be? Gray area for me honestly. @kevinrushforth Any comments?

It's new API, so yes, a CSR is in order.

minor: the values in this enum are not sorted alphabetically - should they? do we care?

Not really. Changing the existing code just to sort the enum - i would hate to do so, i prefer to keep the history cleaner, it's an old code, technical binding of the parameters to the native bound variables, nobody really looks at it except the compiler.

Yeah, let's not do this. In addition to creating diff churn for no good reason, this would techincally be an incompatible change, since it would change the result of the "ordinal()" method. In practice I can't imagine that wouldn't matter, but ...

AccessibleAttribute is public API. The new attribute also needs @since 28. CSR is needed.

Oh well. Time to learn how to create CSR for JavaFX. Yaaaaay.... [/sarcasm off]

Same way as you would for the JDK. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's not do this. In addition to creating diff churn for no good reason, this would techincally be an incompatible change, since it would change the result of the "ordinal()" method. In practice I can't imagine that wouldn't matter, but ...

Although, I see that we've inserted enums in the middle before, and this does too, so nm about the compatibility point.

Still, let's not have the churn.


/**
* Returns true if node is visible, otherwise false.
* <ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ id jRole;
- (id)requestNodeAttribute:(NSString *)attribute;
- (id)requestNodeAttribute:(NSString *)attribute forParameter:(id)parameter;
- (BOOL)isNodeAttributeSettable:(NSString *)attribute;
- (NSInteger)requestNodeArrayAttributeCount:(NSString *)attribute;
- (NSArray *)requestNodeArrayAttribute:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
- (void)setNodeAttribute:(id)value forAttribute:(NSString *)attribute;
- (NSString *)accessibilityPlaceholderValue;
- (NSRect)accessibilityFrame;
- (id)accessibilityParent;
- (id)accessibilityFocusedUIElement;
- (BOOL)isAccessibilityElement;
- (BOOL)performAccessibleAction:(NSString*)actionId;
+ (void) initializeRolesMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import "com_sun_glass_ui_mac_MacAccessible.h"
#import "com_sun_glass_ui_mac_MacVariant.h"
#import "common.h"
#include <stdlib.h>

static NSMutableDictionary * rolesMap;

Expand All @@ -50,6 +51,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXImageAccessibility" forKey:@"IMAGE"];
[rolesMap setObject:@"JFXImageAccessibility" forKey:@"IMAGE_VIEW"];
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"INCREMENT_BUTTON"];
[rolesMap setObject:@"JFXListAccessibility" forKey:@"LIST_VIEW"];
[rolesMap setObject:@"JFXMenuItemAccessibility" forKey:@"MENU"];
[rolesMap setObject:@"JFXMenuBarAccessibility" forKey:@"MENU_BAR"];
[rolesMap setObject:@"JFXMenuItemAccessibility" forKey:@"MENU_ITEM"];
Expand All @@ -63,6 +65,7 @@ + (void) initializeRolesMap {
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"SPLIT_MENU_BUTTON"];
[rolesMap setObject:@"JFXRadiobuttonAccessibility" forKey:@"TAB_ITEM"];
[rolesMap setObject:@"JFXTabGroupAccessibility" forKey:@"TAB_PANE"];
[rolesMap setObject:@"JFXTableAccessibility" forKey:@"TABLE_VIEW"];
[rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"];
[rolesMap setObject:@"JFXNavigableTextAccessibility" forKey:@"TEXT_AREA"];
[rolesMap setObject:@"JFXNavigableTextAccessibility" forKey:@"TEXT_FIELD"];
Expand Down Expand Up @@ -151,6 +154,34 @@ - (id)requestNodeAttribute:(NSString *)attribute forParameter:(id)parameter
return variantToID(env, jresult);
}

- (NSInteger)requestNodeArrayAttributeCount:(NSString *)attribute
{
GET_MAIN_JENV;
if (env == NULL) {
return -1;
}
jint jresult = (*env)->CallIntMethod(env, [self getJAccessible],
jAccessibilityArrayAttributeCount,
(jlong)attribute);
GLASS_CHECK_EXCEPTION(env);
return jresult;
}

- (NSArray *)requestNodeArrayAttribute:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount
{
GET_MAIN_JENV;
if (env == NULL) {
return nil;
}
jlongArray jresult = (jlongArray)(*env)->CallObjectMethod(env, [self getJAccessible],
jAccessibilityArrayAttributeValues,
(jlong)attribute,
(jint)index,
(jint)maxCount);
GLASS_CHECK_EXCEPTION(env);
return jArrayToNSArray(env, jresult, jLongToID);
}

/*
* Check whether an accessibility attribute on the JavaFX Node can be set.
*/
Expand Down Expand Up @@ -227,6 +258,16 @@ - (NSArray *)accessibilityChildren
return [self requestNodeAttribute:@"AXChildren"];
}

- (id)accessibilityFocusedUIElement
{
GET_MAIN_JENV;
if (env == NULL) return NULL;
id result = (id)(*env)->CallLongMethod(env, self->jAccessible,
jAccessibilityFocusedUIElement);
GLASS_CHECK_EXCEPTION(env);
return result;
}

- (id)accessibilityRoleDescription
{
return [self requestNodeAttribute:@"AXRoleDescription"];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

#import "AccessibleBase.h"
#import <AppKit/NSAccessibility.h>

@interface JFXListAccessibility : AccessibleBase {
};

- (NSAccessibilityRole)accessibilityRole;
- (NSString *)accessibilityLabel;
- (BOOL)isAccessibilityEnabled;
- (NSArray *)accessibilityChildren;
- (id)accessibilityParent;
- (NSRect)accessibilityFrame;
- (NSInteger)accessibilityColumnCount;
- (NSInteger)accessibilityRowCount;
- (NSArray *)accessibilityRows;
- (NSArray *)accessibilitySelectedRows;
- (void)setAccessibilitySelectedRows:(NSArray *)selectedRows;
@end
Loading