Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed dom identifiers #61

Merged
merged 3 commits into from
Apr 26, 2024
Merged
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
16 changes: 16 additions & 0 deletions Frameworks/Foundation/JSTextLayoutManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ JSClass("JSTextLayoutManager", JSObject, {
this.setNeedsLayout();
},

temporaryAttributesAtIndex: function(index){
return this._temporaryAttributedString.attributesAtIndex(index);
},

temporaryAttributeAtIndex: function(attributeName, index){
return this._temporaryAttributedString.attributeAtIndex(attributeName, index);
},

longestRangeOfTemporaryAttributeAtIndex: function(attributeName, index){
return this._temporaryAttributedString.longestRangeOfAttributeAtIndex(attributeName, index);
},

longestRangeOfTemporaryAttributesAtIndex: function(attributeNames, index){
return this._temporaryAttributedString.longestRangeOfAttributesAtIndex(attributeNames, index);
},

// MARK: - Layout

setNeedsLayout: function(){
Expand Down
5 changes: 4 additions & 1 deletion Frameworks/UIKit/UIAccessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ UIAccessibility.Subrole = {
tooltip: "tooltip",
alert: "alert",
menuItemRadio: "menuItemRadio",
menuItemCheckbox: "menuItemCheckbox"
menuItemCheckbox: "menuItemCheckbox",
navigation: "navigation",
region: "region"
};

UIAccessibility.Orientation = {
Expand Down Expand Up @@ -234,6 +236,7 @@ UIAccessibility.Notification = {
rowCollapsed: "UIAccessibility.Notification.rowCollapsed",
selectedChildrenChanged: "UIAccessibility.Notification.selectedChildrenChanged",
selectedTextChanged: "UIAccessibility.Notification.selectedTextChanged",
identifierChanged: "UIAccessibility.Notification.identifierChanged",
labelChanged: "UIAccessibility.Notification.labelChanged",
titleChanged: "UIAccessibility.Notification.labelChanged",
valueChanged: "UIAccessibility.Notification.valueChanged",
Expand Down
11 changes: 10 additions & 1 deletion Frameworks/UIKit/UIApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ JSClass('UIApplication', UIResponder, {
accessibilitySubrole: null,

// Label
accessibilityIdentifier: null,
accessibilityIdentifier: JSDynamicProperty("_accessibilityIdentifier"),
accessibilityLabel: JSReadOnlyProperty(),
accessibilityHint: null,

Expand All @@ -524,6 +524,15 @@ JSClass('UIApplication', UIResponder, {
accessibilityParent: null,
accessibilityElements: JSReadOnlyProperty(),

getAccessibilityIdentifier: function(){
return this._accessibilityIdentifier;
},

setAccessibilityIdentifier: function(accessibilityIdentifier){
this._accessibilityIdentifier = accessibilityIdentifier;
this.windowServer.postNotificationForAccessibilityElement(UIAccessibility.Notification.identifierChanged, this);
},

getAccessibilityFrame: function(){
return this.windowServer.screen.frame;
},
Expand Down
6 changes: 6 additions & 0 deletions Frameworks/UIKit/UIHTMLDisplayServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,12 @@ JSClass("UIHTMLDisplayServer", UIDisplayServer, {
}
}
},

// MARK: - Accessibility

elementIDForAccessibility: function(accessibility){
return accessibility.accessibilityIdentifier || "accessibility-%d".sprintf(accessibility.objectID);
},

// MARK: - Debugging

Expand Down
14 changes: 12 additions & 2 deletions Frameworks/UIKit/UIHTMLDisplayServerCanvasContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,6 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
}else{
this.element.removeAttribute("aria-roledescription");
}
this.element.id = "accessibility-%d".sprintf(accessibility.objectID);
switch (ariaRole){
case "button":
case "tab":
Expand Down Expand Up @@ -961,6 +960,7 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
this.element.addEventListener("mousedown", this.accessibilityMousedownListener);
break;
}
this.updateAccessibilityIdentifier(accessibility);
this.updateAccessibilityLabel(accessibility);
this.updateAccessibilityValue(accessibility);
this.updateAccessibilitySelected(accessibility);
Expand Down Expand Up @@ -1002,6 +1002,10 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
this.updateAccessibilityColumnCount(accessibility);
},

updateAccessibilityIdentifier: function(accessibility){
this.element.id = this.displayServer.elementIDForAccessibility(accessibility);
},

updateAccessibilityLabel: function(accessibility){
// FIXME: Once browsers support aria-description (slated for ARIA-1.3),
// hint should go there
Expand Down Expand Up @@ -1126,7 +1130,7 @@ JSClass("UIHTMLDisplayServerCanvasContext", UIHTMLDisplayServerContext, {
// if (focusedAccessibility === null || focusedAccessibility === undefined){
// this.element.removeAttribute("aria-activedescendant");
// }else{
// this.element.setAttribute("aria-activedescendant", "accessibility-%d".sprintf(focusedAccessibility.objectID));
// this.element.setAttribute("aria-activedescendant", this.displayServer.elementIDForAccessibility(focusedAccessibility));
// }
},

Expand Down Expand Up @@ -1283,6 +1287,12 @@ var ariaRoleForAccessibility = function(accessibility){
case UIAccessibility.Role.outline:
return "treegrid";
case UIAccessibility.Role.group:
switch (accessibility.accessibilitySubrole){
case UIAccessibility.Subrole.navigation:
return "navigation";
case UIAccessibility.Subrole.region:
return "region";
}
return "group";
case UIAccessibility.Role.window:
switch (accessibility.accessibilitySubrole){
Expand Down
11 changes: 10 additions & 1 deletion Frameworks/UIKit/UIHTMLWindowServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
this.accessibilityObservers = {};
this.accessibilityObservers.elementCreated = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.elementCreated, null, this.handleAccessibilityElementCreated, this);
this.accessibilityObservers.elementChanged = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.elementChanged, null, this.handleAccessibilityElementChanged, this);
this.accessibilityObservers.identifierChanged = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.identifierChanged, null, this.handleAccessibilityIdentifierChanged, this);
this.accessibilityObservers.labelChanged = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.labelChanged, null, this.handleAccessibilityLabelChanged, this);
this.accessibilityObservers.valueChanged = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.valueChanged, null, this.handleAccessibilityValueChanged, this);
this.accessibilityObservers.visibilityChanged = this.accessibilityNotificationCenter.addObserver(UIAccessibility.Notification.visibilityChanged, null, this.handleAccessibilityVisibilityChanged, this);
Expand Down Expand Up @@ -1082,7 +1083,7 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
if (element.accessibilityRole === UIAccessibility.Role.scrollBar){
var parent = element.accessibilityParent;
if (parent !== null && parent.accessibilityRole === UIAccessibility.Role.scrollArea){
context.element.setAttribute("aria-controls", "accessibility-%d" + parent.objectID);
context.element.setAttribute("aria-controls", this.displayServer.elementIDForAccessibility(parent));
}
}
}
Expand All @@ -1096,6 +1097,14 @@ JSClass("UIHTMLWindowServer", UIWindowServer, {
}
},

handleAccessibilityIdentifierChanged: function(notification){
var element = notification.sender;
var context = this.contextForAccessibilityElement(element);
if (context !== null){
context.updateAccessibilityIdentifier(element);
}
},

handleAccessibilityLabelChanged: function(notification){
var element = notification.sender;
var context = this.contextForAccessibilityElement(element);
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/UIKit/UIListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ JSClass("UIListView", UIScrollView, {
}
this._listHeaderView = listHeaderView;
if (this._listHeaderView){
this.contentView.addSubview(this._listHeaderView);
this.contentView.insertSubviewAtIndex(this._listHeaderView, 0);
}
this.setNeedsLayout();
},
Expand Down Expand Up @@ -2713,7 +2713,7 @@ JSClass("UIListView", UIScrollView, {
showsFocusRing: false,

getFocusRingPath: function(){
if (this.showsFocusRing){
if (this.showsFocusRing || this.fullKeyboardAccessEnabled){
return UIListView.$super.getFocusRingPath.call(this);
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/UIKit/UIListViewCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ JSClass("UIListViewCell", UIView, {

_createTitleLabel: function(){
var label = UILabel.init();
label.accessibilityHidden = false;
// label.accessibilityHidden = false;
this.contentView.addSubview(label);
return label;
},
Expand Down
4 changes: 2 additions & 2 deletions Frameworks/UIKit/UINavigationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {

createTitleLabel: function(){
var label = UILabel.init();
label.accessibilityHidden = false;
label.accessibilityRole = UIAccessibility.Role.header;
// label.accessibilityHidden = false;
// label.accessibilityRole = UIAccessibility.Role.header;
label.font = this.titleFont;
label.textColor = this.titleColor;
return label;
Expand Down
38 changes: 35 additions & 3 deletions Frameworks/UIKit/UIView.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,26 @@ JSClass('UIView', UIResponder, {
if (spec.containsKey("transform")){
this.transform = spec.valueForKey("transform", JSAffineTransform);
}
if (spec.containsKey("accessibilityRole")){
this.accessibilityRole = spec.valueForKey("accessibilityRole");
this.isAccessibilityElement = this.accessibilityRole !== null;
}
if (spec.containsKey("accessibilitySubrole")){
this.accessibilitySubrole = spec.valueForKey("accessibilitySubrole");
this.isAccessibilityElement = this.accessibilitySubrole !== null;
}
if (spec.containsKey("accessibilityIdentifier")){
this.accessibilityIdentifier = spec.valueForKey("accessibilityIdentifier");
this._accessibilityIdentifier = spec.valueForKey("accessibilityIdentifier");
}
if (spec.containsKey("accessibilityLabel")){
this._accessibilityLabel = spec.valueForKey("accessibilityLabel");
}
if (spec.containsKey("accessibilityHint")){
this.accessibilityHint = spec.valueForKey("accessibilityHint");
}
if (spec.containsKey("accessibilityHidden")){
this.accessibilityHidden = spec.valueForKey("accessibilityHidden");
}
if (spec.containsKey("tag")){
this.tag = spec.valueForKey("tag");
}
Expand Down Expand Up @@ -1104,7 +1115,7 @@ JSClass('UIView', UIResponder, {
accessibilityResponder: JSReadOnlyProperty(),

// Label
accessibilityIdentifier: null,
accessibilityIdentifier: JSDynamicProperty("_accessibilityIdentifier", null),
accessibilityLabel: JSDynamicProperty("_accessibilityLabel", null),
accessibilityHint: null,

Expand All @@ -1128,7 +1139,7 @@ JSClass('UIView', UIResponder, {
accessibilityMultiline: null,

// Children
accessibilityParent: null,
accessibilityParent: JSReadOnlyProperty(),
accessibilityElements: JSReadOnlyProperty(),

getAccessibilityParent: function(){
Expand All @@ -1155,16 +1166,34 @@ JSClass('UIView', UIResponder, {
return this;
},

getAccessibilityIdentifier: function(){
return this._accessibilityIdentifier;
},

setAccessibilityIdentifier: function(accessibilityIdentifier){
if (accessibilityIdentifier === this._accessibilityIdentifier){
return;
}
this._accessibilityIdentifier = accessibilityIdentifier;
this.postAccessibilityNotification(UIAccessibility.Notification.identifierChanged);
},

getAccessibilityLabel: function(){
return this._accessibilityLabel;
},

setAccessibilityLabel: function(accessibilityLabel){
if (accessibilityLabel === this._accessibilityLabel){
return;
}
this._accessibilityLabel = accessibilityLabel;
this.postAccessibilityNotification(UIAccessibility.Notification.labelChanged);
},

setAccessibilityHidden: function(accessibilityHidden){
if (accessibilityHidden === this._accessibilityHidden){
return;
}
this._accessibilityHidden = accessibilityHidden;
this.postAccessibilityNotification(UIAccessibility.Notification.visibilityChanged);
},
Expand All @@ -1177,6 +1206,9 @@ JSClass('UIView', UIResponder, {
if (this._windowServer === null){
return;
}
if (!this.isAccessibilityElement){
return;
}
this._windowServer.postNotificationForAccessibilityElement(notificationName, this);
},

Expand Down
Loading
Loading