mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
fix String copy/reference
This commit is contained in:
@@ -270,7 +270,7 @@ pub fn getTextContent(self: *Node, writer: *std.Io.Writer) error{WriteFailed}!vo
|
||||
try child.getTextContent(writer);
|
||||
}
|
||||
},
|
||||
.cdata => |c| try writer.writeAll(c.getData().str()),
|
||||
.cdata => |c| try writer.writeAll(c._data.str()),
|
||||
.document => {},
|
||||
.document_type => {},
|
||||
.attribute => |attr| try writer.writeAll(attr._value.str()),
|
||||
@@ -1028,7 +1028,7 @@ pub const JsApi = struct {
|
||||
try self.getTextContent(&buf.writer);
|
||||
return buf.written();
|
||||
},
|
||||
.cdata => |cdata| return cdata.getData().str(),
|
||||
.cdata => |cdata| return cdata._data.str(),
|
||||
.attribute => |attr| return attr._value.str(),
|
||||
.document => return null,
|
||||
.document_type => return null,
|
||||
|
||||
@@ -388,8 +388,8 @@ pub fn deleteContents(self: *Range, page: *Page) !void {
|
||||
|
||||
// Complex case: different containers
|
||||
// Handle start container - if it's a text node, truncate it
|
||||
if (self._proto._start_container.is(Node.CData)) |_| {
|
||||
const text_data = self._proto._start_container.getData().str();
|
||||
if (self._proto._start_container.is(Node.CData)) |cdata| {
|
||||
const text_data = cdata._data.str();
|
||||
if (self._proto._start_offset < text_data.len) {
|
||||
// Keep only the part before start_offset
|
||||
const new_text = text_data[0..self._proto._start_offset];
|
||||
@@ -398,8 +398,8 @@ pub fn deleteContents(self: *Range, page: *Page) !void {
|
||||
}
|
||||
|
||||
// Handle end container - if it's a text node, truncate it
|
||||
if (self._proto._end_container.is(Node.CData)) |_| {
|
||||
const text_data = self._proto._end_container.getData().str();
|
||||
if (self._proto._end_container.is(Node.CData)) |cdata| {
|
||||
const text_data = cdata._data.str();
|
||||
if (self._proto._end_offset < text_data.len) {
|
||||
// Keep only the part from end_offset onwards
|
||||
const new_text = text_data[self._proto._end_offset..];
|
||||
|
||||
Reference in New Issue
Block a user