Skip to content

Commit 5753dce

Browse files
committed
Sync Lexbor
1 parent 3571310 commit 5753dce

File tree

4 files changed

+40
-23
lines changed

4 files changed

+40
-23
lines changed

ext/dom/lexbor/lexbor/css/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extern "C" {
1818

1919

2020
#define LXB_CSS_VERSION_MAJOR 1
21-
#define LXB_CSS_VERSION_MINOR 1
21+
#define LXB_CSS_VERSION_MINOR 2
2222
#define LXB_CSS_VERSION_PATCH 0
2323

2424
#define LXB_CSS_VERSION_STRING \

ext/dom/lexbor/lexbor/css/selectors/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616

1717

1818
#define LXB_CSS_SELECTORS_VERSION_MAJOR 1
19-
#define LXB_CSS_SELECTORS_VERSION_MINOR 0
19+
#define LXB_CSS_SELECTORS_VERSION_MINOR 1
2020
#define LXB_CSS_SELECTORS_VERSION_PATCH 0
2121

2222
#define LXB_CSS_SELECTORS_VERSION_STRING \

ext/dom/lexbor/lexbor/css/selectors/state.c

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,14 @@ lxb_css_selectors_state_compound_handler(lxb_css_parser_t *parser,
742742
goto unexpected;
743743
}
744744

745+
if (status == LXB_STATUS_OK) {
746+
return true;
747+
}
748+
745749
if (status == LXB_STATUS_ERROR_MEMORY_ALLOCATION) {
746750
return lxb_css_parser_memory_fail(parser);
747751
}
748752

749-
return true;
750-
751753
unexpected:
752754

753755
(void) lxb_css_parser_states_to_root(parser);
@@ -827,11 +829,15 @@ lxb_css_selectors_state_compound_sub(lxb_css_parser_t *parser,
827829
return lxb_css_parser_states_set_back(parser);
828830
}
829831

832+
if (status == LXB_STATUS_OK) {
833+
return true;
834+
}
835+
830836
if (status == LXB_STATUS_ERROR_MEMORY_ALLOCATION) {
831837
return lxb_css_parser_memory_fail(parser);
832838
}
833839

834-
return true;
840+
return lxb_css_parser_unexpected(parser);
835841
}
836842

837843
static bool
@@ -874,11 +880,15 @@ lxb_css_selectors_state_compound_pseudo(lxb_css_parser_t *parser,
874880
lxb_css_selectors_state_compound_pseudo);
875881
}
876882

883+
if (status == LXB_STATUS_OK) {
884+
return true;
885+
}
886+
877887
if (status == LXB_STATUS_ERROR_MEMORY_ALLOCATION) {
878888
return lxb_css_parser_memory_fail(parser);
879889
}
880890

881-
return true;
891+
return lxb_css_parser_unexpected(parser);
882892
}
883893

884894
/*
@@ -1015,12 +1025,14 @@ lxb_css_selectors_state_simple_handler(lxb_css_parser_t *parser,
10151025
goto unexpected;
10161026
}
10171027

1028+
if (status == LXB_STATUS_OK) {
1029+
return true;
1030+
}
1031+
10181032
if (status == LXB_STATUS_ERROR_MEMORY_ALLOCATION) {
10191033
return lxb_css_parser_memory_fail(parser);
10201034
}
10211035

1022-
return true;
1023-
10241036
unexpected:
10251037

10261038
(void) lxb_css_parser_states_set_back(parser);
@@ -1224,7 +1236,10 @@ lxb_css_selectors_state_attribute(lxb_css_parser_t *parser)
12241236
lxb_css_parser_token_status_m(parser, token);
12251237

12261238
if (token->type != LXB_CSS_SYNTAX_TOKEN_IDENT) {
1227-
goto failed;
1239+
attribute = &selector->u.attribute;
1240+
attribute->match = LXB_CSS_SELECTOR_MATCH_DASH;
1241+
1242+
goto assignment;
12281243
}
12291244

12301245
selector->ns = selector->name;
@@ -1282,20 +1297,23 @@ lxb_css_selectors_state_attribute(lxb_css_parser_t *parser)
12821297
lxb_css_syntax_parser_consume(parser);
12831298
lxb_css_parser_token_status_m(parser, token);
12841299

1285-
if (token->type != LXB_CSS_SYNTAX_TOKEN_DELIM
1286-
|| lxb_css_syntax_token_delim_char(token) != '=')
1287-
{
1288-
goto failed;
1289-
}
1290-
1291-
lxb_css_syntax_parser_consume(parser);
1292-
lxb_css_parser_token_status_wo_ws_m(parser, token);
12931300
break;
12941301

12951302
default:
12961303
goto failed;
12971304
}
12981305

1306+
assignment:
1307+
1308+
if (token->type != LXB_CSS_SYNTAX_TOKEN_DELIM
1309+
|| lxb_css_syntax_token_delim_char(token) != '=')
1310+
{
1311+
goto failed;
1312+
}
1313+
1314+
lxb_css_syntax_parser_consume(parser);
1315+
lxb_css_parser_token_status_wo_ws_m(parser, token);
1316+
12991317
string_or_ident:
13001318

13011319
if (token->type != LXB_CSS_SYNTAX_TOKEN_STRING
@@ -1861,18 +1879,17 @@ lxb_css_selectors_state_list_end(lxb_css_parser_t *parser,
18611879
lxb_css_parser_state_t *states;
18621880
lxb_css_selectors_t *selectors = parser->selectors;
18631881

1864-
if (token->type == LXB_CSS_SYNTAX_TOKEN_WHITESPACE) {
1865-
lxb_css_syntax_parser_consume(parser);
1866-
lxb_css_parser_token_status_m(parser, token);
1867-
}
1868-
18691882
if (lxb_css_parser_is_failed(parser)) {
18701883
token = lxb_css_selectors_state_function_error(parser, token);
18711884
if (token == NULL) {
18721885
return lxb_css_parser_fail(parser,
18731886
LXB_STATUS_ERROR_MEMORY_ALLOCATION);
18741887
}
18751888
}
1889+
else if (token->type == LXB_CSS_SYNTAX_TOKEN_WHITESPACE) {
1890+
lxb_css_syntax_parser_consume(parser);
1891+
lxb_css_parser_token_status_m(parser, token);
1892+
}
18761893

18771894
if (selectors->parent != NULL && selectors->list_last &&
18781895
selectors->list_last->prev != NULL)

ext/dom/lexbor/lexbor/selectors-adapted/selectors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Author: Alexander Borisov <[email protected]>
55
* Adapted for PHP + libxml2 by: Niels Dossche <[email protected]>
6-
* Based on https://github.com/lexbor/lexbor/blob/795126188f8df25ed1f5fc8ed368bdd5110a8045/source/lexbor/selectors/selectors.c Lexbor 2.4.0
6+
* Based on https://github.com/lexbor/lexbor/blob/80e0bd7a6e08b856e436e1f4fbc986945e73c8be/source/lexbor/selectors/selectors.c Lexbor 2.4.0
77
*/
88

99
#include "lexbor/selectors-adapted/selectors.h"

0 commit comments

Comments
 (0)