Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcampbell committed Oct 29, 2024
1 parent fc5adaf commit b05c5bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions consumer/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,13 +492,23 @@ impl<'a> Node<'a> {
}
}

pub fn label_comes_from_value(&self) -> bool {
self.role() == Role::Label
}

pub fn label(&self) -> Option<String> {
if let Some(label) = &self.data().label() {
Some(label.to_string())
} else {
let labels = self
.labelled_by()
.filter_map(|node| node.value())
.filter_map(|node| {
if node.label_comes_from_value() {
node.value()
} else {
node.label()
}
})
.collect::<Vec<String>>();
(!labels.is_empty()).then(move || labels.join(" "))
}
Expand Down Expand Up @@ -1034,7 +1044,7 @@ mod tests {
}),
(DEFAULT_BUTTON_LABEL_ID, {
let mut builder = NodeBuilder::new(Role::Image);
builder.set_value(DEFAULT_BUTTON_LABEL);
builder.set_label(DEFAULT_BUTTON_LABEL);
builder.build()
}),
(LINK_ID, {
Expand Down
2 changes: 1 addition & 1 deletion platforms/atspi-common/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(crate) struct NodeWrapper<'a>(pub(crate) &'a Node<'a>);

impl<'a> NodeWrapper<'a> {
pub(crate) fn name(&self) -> Option<String> {
if matches!(self.0.role(), Role::Label | Role::Image) {
if self.0.label_comes_from_value() {
self.0.value()
} else {
self.0.label()
Expand Down
4 changes: 2 additions & 2 deletions platforms/windows/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl<'a> NodeWrapper<'a> {
}

pub(crate) fn name(&self) -> Option<String> {
if matches!(self.0.role(), Role::Label | Role::Image) {
if self.0.label_comes_from_value() {
self.0.value()
} else {
self.0.label()
Expand Down Expand Up @@ -332,7 +332,7 @@ impl<'a> NodeWrapper<'a> {
}

fn is_value_pattern_supported(&self) -> bool {
self.0.has_value() && !matches!(self.0.role(), Role::Label | Role::Image)
self.0.has_value() && !self.0.label_comes_from_value()
}

fn is_range_value_pattern_supported(&self) -> bool {
Expand Down

0 comments on commit b05c5bb

Please sign in to comment.