mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
dom: html_collection: rename Match into Matcher
This commit is contained in:
@@ -11,11 +11,11 @@ const utils = @import("utils.z");
|
|||||||
const Element = @import("element.zig").Element;
|
const Element = @import("element.zig").Element;
|
||||||
const Union = @import("element.zig").Union;
|
const Union = @import("element.zig").Union;
|
||||||
|
|
||||||
const Match = union(enum) {
|
const Matcher = union(enum) {
|
||||||
matchByTagName: MatchByTagName,
|
matchByTagName: MatchByTagName,
|
||||||
matchByClassName: MatchByClassName,
|
matchByClassName: MatchByClassName,
|
||||||
|
|
||||||
pub fn match(self: Match, node: *parser.Node) bool {
|
pub fn match(self: Matcher, node: *parser.Node) bool {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
inline else => |case| return case.match(node),
|
inline else => |case| return case.match(node),
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ pub const MatchByTagName = struct {
|
|||||||
pub fn HTMLCollectionByTagName(root: *parser.Node, tag_name: []const u8) HTMLCollection {
|
pub fn HTMLCollectionByTagName(root: *parser.Node, tag_name: []const u8) HTMLCollection {
|
||||||
return HTMLCollection{
|
return HTMLCollection{
|
||||||
.root = root,
|
.root = root,
|
||||||
.match = Match{
|
.matcher = Matcher{
|
||||||
.matchByTagName = MatchByTagName.init(tag_name),
|
.matchByTagName = MatchByTagName.init(tag_name),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -74,7 +74,7 @@ pub const MatchByClassName = struct {
|
|||||||
pub fn HTMLCollectionByClassName(root: *parser.Node, classNames: []const u8) HTMLCollection {
|
pub fn HTMLCollectionByClassName(root: *parser.Node, classNames: []const u8) HTMLCollection {
|
||||||
return HTMLCollection{
|
return HTMLCollection{
|
||||||
.root = root,
|
.root = root,
|
||||||
.match = Match{
|
.matcher = Matcher{
|
||||||
.matchByClassName = MatchByClassName.init(classNames),
|
.matchByClassName = MatchByClassName.init(classNames),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -87,7 +87,7 @@ pub fn HTMLCollectionByClassName(root: *parser.Node, classNames: []const u8) HTM
|
|||||||
pub const HTMLCollection = struct {
|
pub const HTMLCollection = struct {
|
||||||
pub const mem_guarantied = true;
|
pub const mem_guarantied = true;
|
||||||
|
|
||||||
match: Match,
|
matcher: Matcher,
|
||||||
|
|
||||||
root: *parser.Node,
|
root: *parser.Node,
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ pub const HTMLCollection = struct {
|
|||||||
while (true) {
|
while (true) {
|
||||||
ntype = parser.nodeType(node);
|
ntype = parser.nodeType(node);
|
||||||
if (ntype == .element) {
|
if (ntype == .element) {
|
||||||
if (self.match.match(node)) {
|
if (self.matcher.match(node)) {
|
||||||
len += 1;
|
len += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,7 +178,7 @@ pub const HTMLCollection = struct {
|
|||||||
while (true) {
|
while (true) {
|
||||||
ntype = parser.nodeType(node);
|
ntype = parser.nodeType(node);
|
||||||
if (ntype == .element) {
|
if (ntype == .element) {
|
||||||
if (self.match.match(node)) {
|
if (self.matcher.match(node)) {
|
||||||
// check if we found the searched element.
|
// check if we found the searched element.
|
||||||
if (i == index) {
|
if (i == index) {
|
||||||
// save the current state
|
// save the current state
|
||||||
@@ -210,7 +210,7 @@ pub const HTMLCollection = struct {
|
|||||||
while (true) {
|
while (true) {
|
||||||
ntype = parser.nodeType(node);
|
ntype = parser.nodeType(node);
|
||||||
if (ntype == .element) {
|
if (ntype == .element) {
|
||||||
if (self.match.match(node)) {
|
if (self.matcher.match(node)) {
|
||||||
const elem = @as(*parser.Element, @ptrCast(node));
|
const elem = @as(*parser.Element, @ptrCast(node));
|
||||||
|
|
||||||
var attr = parser.elementGetAttribute(elem, "id");
|
var attr = parser.elementGetAttribute(elem, "id");
|
||||||
|
|||||||
Reference in New Issue
Block a user