mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
AXNode: add spacing between concatenated text nodes
When calculating accessible names for elements without explicit labels, multiple descendant text nodes were previously concatenated directly together. This adds a space between distinct text node contents to prevent words from sticking together.
This commit is contained in:
@@ -777,7 +777,8 @@ pub fn getName(self: AXNode, page: *Page, allocator: std.mem.Allocator) !?[]cons
|
|||||||
const source = try self.writeName(w, page);
|
const source = try self.writeName(w, page);
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
// Remove literal quotes inserted by writeString.
|
// Remove literal quotes inserted by writeString.
|
||||||
const raw_text = std.mem.trim(u8, aw.written(), "\"");
|
var raw_text = std.mem.trim(u8, aw.written(), "\"");
|
||||||
|
raw_text = std.mem.trim(u8, raw_text, &std.ascii.whitespace);
|
||||||
return try allocator.dupe(u8, raw_text);
|
return try allocator.dupe(u8, raw_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -908,7 +909,13 @@ fn writeAccessibleNameFallback(node: *DOMNode, writer: *std.Io.Writer, page: *Pa
|
|||||||
while (it.next()) |child| {
|
while (it.next()) |child| {
|
||||||
switch (child._type) {
|
switch (child._type) {
|
||||||
.cdata => |cd| switch (cd._type) {
|
.cdata => |cd| switch (cd._type) {
|
||||||
.text => |*text| try writer.writeAll(text.getWholeText()),
|
.text => |*text| {
|
||||||
|
const content = std.mem.trim(u8, text.getWholeText(), &std.ascii.whitespace);
|
||||||
|
if (content.len > 0) {
|
||||||
|
try writer.writeAll(content);
|
||||||
|
try writer.writeByte(' ');
|
||||||
|
}
|
||||||
|
},
|
||||||
else => {},
|
else => {},
|
||||||
},
|
},
|
||||||
.element => |el| {
|
.element => |el| {
|
||||||
|
|||||||
Reference in New Issue
Block a user