@@ -290,8 +290,8 @@ bool element::is_block_formatting_context() const
290
290
291
291
litehtml::string litehtml::element::get_counter_value (const string& counter_name)
292
292
{
293
- std::map<string , int >::iterator i;
294
- if (find_counter (counter_name, i))
293
+ std::map<string_id , int >::iterator i;
294
+ if (find_counter (_id ( counter_name) , i))
295
295
{
296
296
return std::to_string (i->second );
297
297
}
@@ -302,7 +302,7 @@ string litehtml::element::get_counters_value(const string_vector& parameters)
302
302
{
303
303
string result = " " ;
304
304
if (parameters.size () >= 2 ) {
305
- const string& counter_name = parameters[0 ];
305
+ const string_id counter_name_id = _id ( parameters[0 ]) ;
306
306
string delims = parameters[1 ];
307
307
litehtml::trim (delims, " \" '" );
308
308
@@ -311,15 +311,15 @@ string litehtml::element::get_counters_value(const string_vector& parameters)
311
311
element::ptr current = shared_from_this ();
312
312
while (current != nullptr )
313
313
{
314
- auto map_iterator = current->m_counter_values .find (counter_name );
314
+ auto map_iterator = current->m_counter_values .find (counter_name_id );
315
315
if (map_iterator != current->m_counter_values .end ()) {
316
316
values.push_back (std::to_string (map_iterator->second ));
317
317
}
318
318
current = current->parent ();
319
319
}
320
320
if (values.empty ()) {
321
- // if no counter is found, instancieate one with value '0'
322
- shared_from_this ()->m_counter_values [counter_name ] = 0 ;
321
+ // if no counter is found, instanciate one with value '0'
322
+ shared_from_this ()->m_counter_values [counter_name_id ] = 0 ;
323
323
result = " 0" ;
324
324
}
325
325
else {
@@ -331,13 +331,13 @@ string litehtml::element::get_counters_value(const string_vector& parameters)
331
331
}
332
332
333
333
334
- bool litehtml::element::find_counter (const string& counter_name , std::map<string , int >::iterator& map_iterator) {
334
+ bool litehtml::element::find_counter (const string_id& counter_name_id , std::map<string_id , int >::iterator& map_iterator) {
335
335
element::ptr current = shared_from_this ();
336
336
337
337
// search upwards
338
338
while (current != nullptr )
339
339
{
340
- map_iterator = current->m_counter_values .find (counter_name );
340
+ map_iterator = current->m_counter_values .find (counter_name_id );
341
341
if (map_iterator != current->m_counter_values .end ()) {
342
342
return true ;
343
343
}
@@ -346,7 +346,7 @@ bool litehtml::element::find_counter(const string& counter_name, std::map<string
346
346
std::vector<element::ptr> siblings = current->get_siblings_before ();
347
347
std::reverse (siblings.begin (), siblings.end ());
348
348
for (const element::ptr& sibling : siblings) {
349
- map_iterator = sibling->m_counter_values .find (counter_name );
349
+ map_iterator = sibling->m_counter_values .find (counter_name_id );
350
350
if (map_iterator != sibling->m_counter_values .end ()) {
351
351
return true ;
352
352
}
@@ -372,7 +372,7 @@ std::vector<element::ptr> litehtml::element::get_siblings_before() const
372
372
}
373
373
374
374
375
- void litehtml::element::parse_counter_tokens (const string_vector& tokens, const int default_value, std::function<void (const string &, const int )> handler) const {
375
+ void litehtml::element::parse_counter_tokens (const string_vector& tokens, const int default_value, std::function<void (const string_id &, const int )> handler) const {
376
376
int pos = 0 ;
377
377
while (pos < tokens.size ()) {
378
378
string name = tokens[pos];
@@ -384,25 +384,25 @@ void litehtml::element::parse_counter_tokens(const string_vector& tokens, const
384
384
else {
385
385
pos += 1 ;
386
386
}
387
- handler (name, value);
387
+ handler (_id ( name) , value);
388
388
}
389
389
}
390
390
391
- void litehtml::element::increment_counter (const string& counter_name , const int increment)
391
+ void litehtml::element::increment_counter (const string_id& counter_name_id , const int increment)
392
392
{
393
- std::map<string , int >::iterator i;
394
- if (find_counter (counter_name , i)) {
393
+ std::map<string_id , int >::iterator i;
394
+ if (find_counter (counter_name_id , i)) {
395
395
i->second = i->second + increment;
396
396
}
397
397
else {
398
398
// if counter is not found, initialize one on this element
399
- m_counter_values[counter_name ] = increment;
399
+ m_counter_values[counter_name_id ] = increment;
400
400
}
401
401
}
402
402
403
- void litehtml::element::reset_counter (const string& counter_name , const int value)
403
+ void litehtml::element::reset_counter (const string_id& counter_name_id , const int value)
404
404
{
405
- m_counter_values[counter_name ] = value;
405
+ m_counter_values[counter_name_id ] = value;
406
406
}
407
407
408
408
const background* element::get_background (bool own_only) LITEHTML_RETURN_FUNC(nullptr )
0 commit comments