MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / getStartAndEnd

Function getStartAndEnd

player/NymphCastPlayer/container_qpainter.cpp:97–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97static std::pair<Selection::Element, Selection::Element> getStartAndEnd(const Selection::Element &a,
98 const Selection::Element &b)
99{
100 if (a.element == b.element) {
101 if (a.index <= b.index)
102 return {a, b};
103 return {b, a};
104 }
105 const litehtml::elements_vector aPath = path(a.element);
106 const litehtml::elements_vector bPath = path(b.element);
107 litehtml::element::ptr commonParent;
108 size_t firstDifferentIndex;
109 std::tie(commonParent, firstDifferentIndex) = getCommonParent(aPath, bPath);
110 if (!commonParent) {
111 qWarning() << "internal error: litehtml elements do not have common parent";
112 return {a, b};
113 }
114 if (commonParent == a.element)
115 return {a, a}; // 'a' already contains 'b'
116 if (commonParent == b.element)
117 return {b, b};
118 // find out if a or b is first in the child sub-trees of commonParent
119 const litehtml::element::ptr aBranch = aPath.at(firstDifferentIndex);
120 const litehtml::element::ptr bBranch = bPath.at(firstDifferentIndex);
121 for (int i = 0; i < int(commonParent->get_children_count()); ++i) {
122 const litehtml::element::ptr child = commonParent->get_child(i);
123 if (child == aBranch)
124 return {a, b};
125 if (child == bBranch)
126 return {b, a};
127 }
128 qWarning() << "internal error: failed to find out order of litehtml elements";
129 return {a, b};
130}
131
132static int findChild(const litehtml::element::ptr &child, const litehtml::element::ptr &parent)
133{

Callers 2

updateMethod · 0.85
findTextMethod · 0.85

Calls 4

pathFunction · 0.85
getCommonParentFunction · 0.85
get_children_countMethod · 0.80
get_childMethod · 0.80

Tested by

no test coverage detected