diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CSS.cpp | 10 | ||||
| -rw-r--r-- | src/core/CSS.hpp | 11 | 
2 files changed, 17 insertions, 4 deletions
diff --git a/src/core/CSS.cpp b/src/core/CSS.cpp index 8beb075..c3900e8 100644 --- a/src/core/CSS.cpp +++ b/src/core/CSS.cpp @@ -116,16 +116,22 @@ std::vector<Rooted<SelectorNode>> SelectorNode::append(  		if (edge->getTarget()->getEdges().size() == 0) {  			// if there are no more subsequent edges this is a leafe we could  			// not merge, because it is already present in the Tree. -			out.push_back(edge->getTarget()); +			out.push_back(children[0]);  		} else {  			// otherwise we go into recursion.  			for (auto &e : edge->getTarget()->getEdges()) { +				Rooted<SelectorEdge> e2 {e};  				std::vector<Rooted<SelectorNode>> childLeafs = -				    children[0]->append(e); +				    children[0]->append(e2);  				out.insert(out.end(), childLeafs.begin(), childLeafs.end());  			}  		}  	}  	return out;  } + +std::vector<Rooted<SelectorNode>> SelectorNode::append(Rooted<SelectorNode> node){ +	const Rooted<SelectorEdge> e {new SelectorEdge{node->getManager(), node}}; +	return std::move(append(e)); +}  } diff --git a/src/core/CSS.hpp b/src/core/CSS.hpp index 8c87ee7..e730721 100644 --- a/src/core/CSS.hpp +++ b/src/core/CSS.hpp @@ -227,8 +227,9 @@ public:  		const SelectionOperator selectionOperator;  	public: -		SelectorEdge(Manager &mgr, Handle<SelectorNode> target, -		             SelectionOperator selectionOperator) +		SelectorEdge( +		    Manager &mgr, Handle<SelectorNode> target, +		    SelectionOperator selectionOperator = SelectionOperator::DESCENDANT)  		    : Managed(mgr),  		      target(acquire(target)),  		      selectionOperator(selectionOperator) @@ -378,6 +379,12 @@ public:  	 *         because they were already contained.  	 */  	std::vector<Rooted<SelectorNode>> append(Rooted<SelectorEdge> edge); + +	/** +	 * This is just a convenience function which creates a new edge +	 * automatically using the DESCENDANT SelectionOperator. +	 */ +	std::vector<Rooted<SelectorNode>> append(Rooted<SelectorNode> node);  };  }  #endif  | 
