Commit Graph

5 Commits

Author SHA1 Message Date
Kevin Wern
9a846abe86 Bug 1227224 - Further improvements to generic tree traversal algorithms. r=botond
- Introduce a more general version of ForEachNode that takes two actions
  (pre-action and post-action).
- Express the one-action version of ForEachNode in terms of the two-action
  version.
- Add TraversalFlag::Abort, which stops traversal immediately.
- Express DepthFirstSearch in terms of ForEachNode.
- Add ForEachNodePostOrder and DepthFirstSearchPostOrder.
- The new functions are all recursive, and traverse children in the order
  provided by the node accessors. Adjust tests to reflect this.
- Refactor two APZCTreeManager functions, FindTargetNode and GetAPZCAtPoint,
  to use the algorithms.

MozReview-Commit-ID: 83Y7psjkUWG

--HG--
extra : commitid : JSMoSuDetUL
extra : rebase_source : 6ef99b1d6dac841eb94d99feb605ca235d9086c9
extra : amend_source : 518a636ee5a5162bca83dde6b90cb1a3b5304a3b
2016-01-25 04:04:13 -08:00
Kevin Wern
6b43e66943 Bug 1226920 - Allow calling ForEachNode() with an action returning void r=botond
--HG--
extra : rebase_source : e2d16580f20bd5dc154760803ec562fe0ed485c4
extra : source : 8e743b5913982ccd18d51544a5a93213fb700e5c
2015-11-23 13:06:01 -05:00
Kevin Wern
02d8d69dc7 Bug 1199798 - Create tests for TreeTraversal.h r=botond
Move queue and stack includes outside of mozilla namespace.

Test the following for searches:
- Null root returns null.
- Needle is root returns root.
- No needle results in full traversal.
- Needle node in middle returns that needle, and stops traversing.

Test the following for ForEachNode:
- Null root still runs correctly.
- No skips results in traversal of entire tree.
- Root skip results in only changing the root.
- First skips are still included (whether leaf or parent).

--HG--
extra : source : 6d2572c274363c7544c4f96f0016fead098b157e
2015-11-16 13:54:12 -05:00
Kevin Wern
6a1cf14315 Bug 1199798 - Use more generic tree traversal algorithms in APZCTreeManager. r=botond
Extend the tree traversal algorithms in TreeTraversal.h, and use them
instead of manual loops in APZCTreeManager.

- Create function ForEachNode(), which calls a function on each node
  of a tree. The function must return a TraversalFlag to indicate
  whether the node's children should be visited or skipped.
- Modify DepthFirstSearch() and BreadthFirstSearch() to operate on
  pointers that are not (necessarily) const. This makes them more
  general.
- Refactor functions in APZCTreeManager: Collect, FlushRepaints,
  FlushRepaintsRecursively, FlushPendingRepaint,
  FlushPendingRepaintRecursively, UpdateZoomConstraints,
  UpdateZoomConstraintsRecursively, ClearTree, FindScrollNode.

--HG--
extra : rebase_source : e7a740a9833ba49b1d41849bb43ce9077d42bc07
extra : source : ef6f195f2259e103f0c1979a5f4ebb5a8601b15d
2015-11-06 12:31:36 -05:00
Tim Stullich
78588ac104 Bug 1171312 - Add generic tree search algorithms for layers-related data structures. r=botond
--HG--
extra : source : a377fceec2fbab853eb2e847d98789250501aa96
extra : amend_source : 2e18afc459d4a2116a008e2482084d84c7c63e9c
2015-07-21 16:36:08 -07:00