Coverage Report

Created: 2025-12-14 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wt/src/Wt/Render/CssData.C
Line
Count
Source
1
#include "CssData.h"
2
3
4
#include <map>
5
#include "Wt/Render/Block.h"
6
#include "Wt/Render/CssData_p.h"
7
#include "web/WebUtils.h"
8
9
using namespace Wt::Render;
10
11
void Wt::Render::Term::setValue(const std::string& value)
12
26.0k
{
13
26.0k
  value_ = value;
14
26.0k
}
15
16
///////////////////////////////////////////////////////////////////////////////
17
///// isMatch                                                             /////
18
///////////////////////////////////////////////////////////////////////////////
19
20
bool Wt::Render::Match::isMatch(const Block* block, const SimpleSelector& s)
21
0
{
22
0
  const DomElementType tag = block->type();
23
0
  const std::string id = block->id();
24
0
  const std::vector<std::string>& classes = block->classes();
25
0
  const std::vector<std::string>& requiredClasses = s.classes();
26
27
  //cout << "isMatch? block:" << tag << " " << id
28
  //               << "; s: " << s.elementName() << " " << s.hashId();
29
30
  // Match tagname?
31
0
  if (!s.elementName().empty() &&
32
0
      s.elementName() != "*" &&
33
0
      tag != s.elementType())
34
0
  {
35
    //cout << "; NO! tag" << endl;
36
0
    return false;
37
0
  }
38
39
  // Match Id?
40
0
  if (s.hashId().size() && id != s.hashId())
41
0
  {
42
    //cout << "; NO! id" << endl;
43
0
    return false;
44
0
  }
45
46
  // Match all classes?
47
0
  for (unsigned int i = 0; i < requiredClasses.size(); ++i)
48
0
  {
49
0
    if (Wt::Utils::indexOf(classes, requiredClasses[i]) == -1)
50
0
    {
51
      //cout << "; NO! classes" << r << endl;
52
0
      return false;
53
0
    }
54
0
  }
55
56
  // Done!
57
  //cout << "; YES!" << endl;
58
0
  return true;
59
0
}
60
61
Specificity Wt::Render::Match::isMatch(const Block* block, const Selector& selector)
62
0
{
63
0
  if(!selector.size())
64
0
    return Specificity(false);
65
66
0
  if(!isMatch(block, selector.at(selector.size()-1)))
67
0
    return Specificity(false);
68
0
  const Block* parent = block->parent();
69
0
  for(int i = selector.size()-2; i >= 0; --i)
70
0
  {
71
0
    bool matchFound = false;
72
0
    while(parent)
73
0
    {
74
0
      matchFound = isMatch(parent, selector.at(i));
75
0
      parent = parent->parent();
76
0
      if(matchFound)
77
0
        break;
78
0
    }
79
80
0
    if(!matchFound && !parent)
81
0
      return Specificity(false);
82
0
  }
83
0
  return selector.specificity();
84
0
}
85
86