LocationQuery: fix bugs and omissions

This commit is contained in:
Fischlurch 2017-10-28 02:06:05 +02:00
parent 800407637a
commit f0a32c986a

View file

@ -144,11 +144,11 @@ namespace interact {
{ {
size_t depth = 0; size_t depth = 0;
Rec const& node = drillDown (tree_, path, pos, depth); Rec const& node = drillDown (tree_, path, pos, depth);
if (pos != depth-1) if (depth != pos)
throw error::State(_Fmt{"unable to drill down to depth %d: " throw error::State(_Fmt{"unable to drill down to depth %d: "
"element %s at pos %d in path %s is in " "element %s at pos %d in path %s is in "
"contradiction to actual UI structure"} "contradiction to actual UI structure"}
% pos % (pos+1)
% (depth<path.size()? path[depth] : Symbol::BOTTOM) % (depth<path.size()? path[depth] : Symbol::BOTTOM)
% depth % depth
% path % path
@ -168,6 +168,14 @@ namespace interact {
return Symbol{lib::pull_last (tree_.keys())}; //////////////////////////////////////////////TICKET #1113 : warning use of Symbol table becomes obsolete when EntryID relies on Literal return Symbol{lib::pull_last (tree_.keys())}; //////////////////////////////////////////////TICKET #1113 : warning use of Symbol table becomes obsolete when EntryID relies on Literal
} }
Literal
resolveElm (UICoord const& path, size_t depth)
{
REQUIRE (path.isPresent(depth));
return depth==UIC_WINDOW? GenNodeLocationQuery::determineAnchor(path)
: path[depth];
}
static ChildIter static ChildIter
childSequence (Rec const& node) childSequence (Rec const& node)
{ {
@ -180,16 +188,16 @@ namespace interact {
} }
static Rec const& Rec const&
drillDown (Rec const& tree, UICoord const& path, size_t maxDepth, size_t& depth) drillDown (Rec const& tree, UICoord const& path, size_t maxDepth, size_t& depth)
{ {
if (depth<maxDepth and path.isPresent(depth)) if (depth<maxDepth and path.isPresent(depth))
{ {
const char* pathElm = path[depth]; const char* pathElm = resolveElm (path, depth);
if (hasNode(tree, pathElm, depth)) if (hasNode (tree, pathElm, depth))
{ {
++depth; ++depth;
return drillDown (descendInto(tree,pathElm,depth), path, maxDepth, depth); return drillDown (descendInto(tree,pathElm,depth-1), path, maxDepth, depth);
} }
} }
return tree; return tree;
@ -197,9 +205,9 @@ namespace interact {
/** does the guiding tree contain the element as requested by the UICoord path? /** does the guiding tree contain the element as requested by the UICoord path?
* @remark this function abstracts a special asymmetry of the tree representation: * @remark this function abstracts a special asymmetry of the tree representation:
* at `level==UIC_PERSP` (level 2), the perspective info is packed into the type * at `level==UIC_PERSP` (the second level), the perspective info is packed into
* meta attribute. This was done on purpose, to verify our design is able to * the type meta attribute. This was done on purpose, to verify our design is able
* handle such implementation intricacies, which we expect to encounter * to handle such implementation intricacies, which we expect to encounter
* when navigating the widgets of a real-world UI toolkit set * when navigating the widgets of a real-world UI toolkit set
*/ */
static bool static bool