blockly 7.20211209.4 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/blockly.d.ts +18963 -18432
  2. package/blockly.min.js +852 -844
  3. package/blockly_compressed.js +669 -664
  4. package/blockly_compressed.js.map +1 -1
  5. package/blocks/blocks.js +47 -0
  6. package/blocks/colour.js +13 -3
  7. package/blocks/lists.js +22 -13
  8. package/blocks/logic.js +13 -3
  9. package/blocks/loops.js +24 -11
  10. package/blocks/math.js +12 -3
  11. package/blocks/procedures.js +41 -27
  12. package/blocks/text.js +22 -13
  13. package/blocks/variables.js +14 -3
  14. package/blocks/variables_dynamic.js +13 -3
  15. package/blocks_compressed.js +146 -141
  16. package/blocks_compressed.js.map +1 -1
  17. package/core/block.js +1869 -1814
  18. package/core/block_drag_surface.js +201 -200
  19. package/core/block_dragger.js +377 -373
  20. package/core/block_svg.js +1593 -1479
  21. package/core/blockly.js +8 -22
  22. package/core/blocks.js +9 -2
  23. package/core/browser_events.js +22 -5
  24. package/core/bubble.js +841 -797
  25. package/core/bubble_dragger.js +213 -206
  26. package/core/bump_objects.js +2 -2
  27. package/core/clipboard.js +9 -9
  28. package/core/comment.js +353 -332
  29. package/core/common.js +46 -17
  30. package/core/component_manager.js +181 -174
  31. package/core/config.js +87 -0
  32. package/core/connection.js +595 -584
  33. package/core/connection_checker.js +242 -244
  34. package/core/connection_db.js +235 -230
  35. package/core/contextmenu.js +9 -6
  36. package/core/contextmenu_items.js +1 -2
  37. package/core/contextmenu_registry.js +93 -89
  38. package/core/css.js +474 -474
  39. package/core/delete_area.js +45 -42
  40. package/core/drag_target.js +57 -56
  41. package/core/dropdowndiv.js +153 -163
  42. package/core/events/events.js +2 -2
  43. package/core/events/events_abstract.js +89 -77
  44. package/core/events/events_block_base.js +37 -36
  45. package/core/events/events_block_change.js +130 -124
  46. package/core/events/events_block_create.js +73 -71
  47. package/core/events/events_block_delete.js +84 -82
  48. package/core/events/events_block_drag.js +50 -49
  49. package/core/events/events_block_move.js +147 -140
  50. package/core/events/events_bubble_open.js +51 -50
  51. package/core/events/events_click.js +48 -44
  52. package/core/events/events_comment_base.js +72 -69
  53. package/core/events/events_comment_change.js +63 -61
  54. package/core/events/events_comment_create.js +44 -42
  55. package/core/events/events_comment_delete.js +42 -40
  56. package/core/events/events_comment_move.js +106 -104
  57. package/core/events/events_marker_move.js +65 -64
  58. package/core/events/events_selected.js +46 -45
  59. package/core/events/events_theme_change.js +36 -35
  60. package/core/events/events_toolbox_item_select.js +46 -45
  61. package/core/events/events_trashcan_open.js +37 -36
  62. package/core/events/events_ui.js +47 -46
  63. package/core/events/events_ui_base.js +30 -29
  64. package/core/events/events_var_base.js +37 -36
  65. package/core/events/events_var_create.js +50 -48
  66. package/core/events/events_var_delete.js +50 -48
  67. package/core/events/events_var_rename.js +51 -49
  68. package/core/events/events_viewport.js +66 -65
  69. package/core/events/utils.js +29 -14
  70. package/core/events/workspace_events.js +49 -55
  71. package/core/extensions.js +4 -3
  72. package/core/field.js +1061 -997
  73. package/core/field_angle.js +462 -442
  74. package/core/field_checkbox.js +194 -182
  75. package/core/field_colour.js +519 -505
  76. package/core/field_dropdown.js +617 -598
  77. package/core/field_image.js +229 -220
  78. package/core/field_label.js +102 -91
  79. package/core/field_label_serializable.js +42 -41
  80. package/core/field_multilineinput.js +372 -358
  81. package/core/field_number.js +272 -253
  82. package/core/field_textinput.js +499 -467
  83. package/core/field_variable.js +458 -420
  84. package/core/flyout_base.js +1005 -952
  85. package/core/flyout_button.js +277 -260
  86. package/core/flyout_horizontal.js +304 -302
  87. package/core/flyout_metrics_manager.js +64 -64
  88. package/core/flyout_vertical.js +306 -300
  89. package/core/generator.js +459 -446
  90. package/core/gesture.js +829 -813
  91. package/core/grid.js +166 -163
  92. package/core/icon.js +168 -159
  93. package/core/inject.js +7 -5
  94. package/core/input.js +257 -248
  95. package/core/insertion_marker_manager.js +655 -624
  96. package/core/internal_constants.js +0 -129
  97. package/core/keyboard_nav/ast_node.js +605 -596
  98. package/core/keyboard_nav/basic_cursor.js +166 -165
  99. package/core/keyboard_nav/cursor.js +99 -97
  100. package/core/keyboard_nav/marker.js +83 -79
  101. package/core/keyboard_nav/tab_navigate_cursor.js +18 -23
  102. package/core/marker_manager.js +153 -141
  103. package/core/menu.js +377 -372
  104. package/core/menuitem.js +223 -217
  105. package/core/metrics_manager.js +403 -390
  106. package/core/mutator.js +468 -437
  107. package/core/names.js +229 -188
  108. package/core/options.js +290 -284
  109. package/core/procedures.js +29 -17
  110. package/core/registry.js +19 -16
  111. package/core/rendered_connection.js +482 -463
  112. package/core/renderers/common/block_rendering.js +9 -3
  113. package/core/renderers/common/constants.js +1119 -1112
  114. package/core/renderers/common/debug.js +14 -0
  115. package/core/renderers/common/debugger.js +338 -316
  116. package/core/renderers/common/drawer.js +380 -370
  117. package/core/renderers/common/i_path_object.js +2 -2
  118. package/core/renderers/common/info.js +626 -618
  119. package/core/renderers/common/marker_svg.js +579 -541
  120. package/core/renderers/common/path_object.js +203 -200
  121. package/core/renderers/common/renderer.js +220 -218
  122. package/core/renderers/geras/constants.js +36 -36
  123. package/core/renderers/geras/drawer.js +155 -147
  124. package/core/renderers/geras/highlight_constants.js +244 -238
  125. package/core/renderers/geras/highlighter.js +231 -179
  126. package/core/renderers/geras/info.js +392 -369
  127. package/core/renderers/geras/measurables/inline_input.js +25 -19
  128. package/core/renderers/geras/measurables/statement_input.js +23 -17
  129. package/core/renderers/geras/path_object.js +106 -121
  130. package/core/renderers/geras/renderer.js +96 -98
  131. package/core/renderers/measurables/base.js +30 -18
  132. package/core/renderers/measurables/bottom_row.js +83 -80
  133. package/core/renderers/measurables/connection.js +22 -15
  134. package/core/renderers/measurables/external_value_input.js +35 -22
  135. package/core/renderers/measurables/field.js +35 -20
  136. package/core/renderers/measurables/hat.js +18 -13
  137. package/core/renderers/measurables/icon.js +24 -17
  138. package/core/renderers/measurables/in_row_spacer.js +15 -13
  139. package/core/renderers/measurables/inline_input.js +43 -33
  140. package/core/renderers/measurables/input_connection.js +41 -28
  141. package/core/renderers/measurables/input_row.js +50 -44
  142. package/core/renderers/measurables/jagged_edge.js +14 -12
  143. package/core/renderers/measurables/next_connection.js +16 -14
  144. package/core/renderers/measurables/output_connection.js +26 -20
  145. package/core/renderers/measurables/previous_connection.js +16 -15
  146. package/core/renderers/measurables/round_corner.js +20 -18
  147. package/core/renderers/measurables/row.js +184 -168
  148. package/core/renderers/measurables/spacer_row.js +38 -23
  149. package/core/renderers/measurables/square_corner.js +18 -16
  150. package/core/renderers/measurables/statement_input.js +23 -20
  151. package/core/renderers/measurables/top_row.js +88 -85
  152. package/core/renderers/minimalist/constants.js +8 -7
  153. package/core/renderers/minimalist/drawer.js +11 -10
  154. package/core/renderers/minimalist/info.js +18 -18
  155. package/core/renderers/minimalist/renderer.js +40 -39
  156. package/core/renderers/thrasos/info.js +258 -248
  157. package/core/renderers/thrasos/renderer.js +20 -20
  158. package/core/renderers/zelos/constants.js +898 -873
  159. package/core/renderers/zelos/drawer.js +186 -169
  160. package/core/renderers/zelos/info.js +502 -479
  161. package/core/renderers/zelos/marker_svg.js +129 -115
  162. package/core/renderers/zelos/measurables/bottom_row.js +31 -30
  163. package/core/renderers/zelos/measurables/inputs.js +22 -21
  164. package/core/renderers/zelos/measurables/row_elements.js +14 -13
  165. package/core/renderers/zelos/measurables/top_row.js +34 -33
  166. package/core/renderers/zelos/path_object.js +181 -180
  167. package/core/renderers/zelos/renderer.js +91 -92
  168. package/core/scrollbar.js +759 -713
  169. package/core/scrollbar_pair.js +250 -245
  170. package/core/serialization/blocks.js +19 -9
  171. package/core/serialization/workspaces.js +3 -2
  172. package/core/shortcut_registry.js +286 -277
  173. package/core/sprites.js +31 -0
  174. package/core/theme.js +135 -141
  175. package/core/theme_manager.js +147 -143
  176. package/core/toolbox/category.js +602 -576
  177. package/core/toolbox/collapsible_category.js +226 -227
  178. package/core/toolbox/separator.js +70 -61
  179. package/core/toolbox/toolbox.js +934 -927
  180. package/core/toolbox/toolbox_item.js +115 -99
  181. package/core/tooltip.js +108 -35
  182. package/core/touch.js +8 -3
  183. package/core/touch_gesture.js +254 -251
  184. package/core/trashcan.js +606 -595
  185. package/core/utils/coordinate.js +97 -95
  186. package/core/utils/dom.js +2 -2
  187. package/core/utils/global.js +2 -0
  188. package/core/utils/rect.js +41 -37
  189. package/core/utils/sentinel.js +25 -0
  190. package/core/utils/size.js +30 -27
  191. package/core/utils/svg.js +18 -16
  192. package/core/variable_map.js +325 -341
  193. package/core/variable_model.js +55 -54
  194. package/core/variables.js +9 -2
  195. package/core/variables_dynamic.js +3 -1
  196. package/core/warning.js +126 -120
  197. package/core/widgetdiv.js +4 -4
  198. package/core/workspace.js +685 -664
  199. package/core/workspace_audio.js +124 -118
  200. package/core/workspace_comment.js +308 -298
  201. package/core/workspace_comment_svg.js +1029 -951
  202. package/core/workspace_drag_surface_svg.js +147 -140
  203. package/core/workspace_dragger.js +70 -71
  204. package/core/workspace_svg.js +2322 -2297
  205. package/core/xml.js +30 -20
  206. package/core/zoom_controls.js +431 -439
  207. package/dart_compressed.js +40 -43
  208. package/dart_compressed.js.map +1 -1
  209. package/generators/dart/colour.js +56 -64
  210. package/generators/dart/lists.js +61 -50
  211. package/generators/dart/math.js +160 -148
  212. package/generators/dart/text.js +83 -61
  213. package/generators/javascript/colour.js +37 -34
  214. package/generators/javascript/lists.js +50 -43
  215. package/generators/javascript/math.js +123 -139
  216. package/generators/javascript/text.js +67 -81
  217. package/generators/lua/colour.js +25 -23
  218. package/generators/lua/lists.js +97 -69
  219. package/generators/lua/logic.js +1 -2
  220. package/generators/lua/math.js +182 -144
  221. package/generators/lua/text.js +116 -99
  222. package/generators/php/colour.js +38 -32
  223. package/generators/php/lists.js +109 -89
  224. package/generators/php/math.js +90 -81
  225. package/generators/php/text.js +63 -61
  226. package/generators/python/colour.js +18 -18
  227. package/generators/python/lists.js +38 -30
  228. package/generators/python/loops.js +12 -8
  229. package/generators/python/math.js +104 -106
  230. package/generators/python/text.js +34 -30
  231. package/javascript_compressed.js +37 -39
  232. package/javascript_compressed.js.map +1 -1
  233. package/lua_compressed.js +39 -42
  234. package/lua_compressed.js.map +1 -1
  235. package/msg/az.js +2 -2
  236. package/msg/be.js +4 -4
  237. package/msg/cs.js +15 -15
  238. package/msg/de.js +1 -1
  239. package/msg/diq.js +1 -1
  240. package/msg/eo.js +1 -1
  241. package/msg/es.js +1 -1
  242. package/msg/fa.js +1 -1
  243. package/msg/fr.js +4 -4
  244. package/msg/he.js +1 -1
  245. package/msg/hr.js +2 -2
  246. package/msg/hy.js +2 -2
  247. package/msg/id.js +12 -12
  248. package/msg/inh.js +14 -14
  249. package/msg/ja.js +7 -7
  250. package/msg/lv.js +29 -29
  251. package/msg/pa.js +3 -3
  252. package/msg/smn.js +436 -0
  253. package/msg/te.js +1 -1
  254. package/msg/yue.js +1 -1
  255. package/msg/zh-hans.js +3 -3
  256. package/msg/zh-hant.js +3 -3
  257. package/package.json +7 -6
  258. package/php_compressed.js +38 -42
  259. package/php_compressed.js.map +1 -1
  260. package/python_compressed.js +26 -25
  261. package/python_compressed.js.map +1 -1
  262. package/blocks/all.js +0 -23
@@ -32,20 +32,409 @@ const {WorkspaceSvg} = goog.requireType('Blockly.WorkspaceSvg');
32
32
 
33
33
  /**
34
34
  * The manager for all workspace metrics calculations.
35
- * @param {!WorkspaceSvg} workspace The workspace to calculate metrics
36
- * for.
37
35
  * @implements {IMetricsManager}
38
- * @constructor
39
36
  * @alias Blockly.MetricsManager
40
37
  */
41
- const MetricsManager = function(workspace) {
38
+ class MetricsManager {
42
39
  /**
43
- * The workspace to calculate metrics for.
44
- * @type {!WorkspaceSvg}
40
+ * @param {!WorkspaceSvg} workspace The workspace to calculate metrics
41
+ * for.
42
+ */
43
+ constructor(workspace) {
44
+ /**
45
+ * The workspace to calculate metrics for.
46
+ * @type {!WorkspaceSvg}
47
+ * @protected
48
+ */
49
+ this.workspace_ = workspace;
50
+ }
51
+
52
+ /**
53
+ * Gets the dimensions of the given workspace component, in pixel coordinates.
54
+ * @param {?IToolbox|?IFlyout} elem The element to get the
55
+ * dimensions of, or null. It should be a toolbox or flyout, and should
56
+ * implement getWidth() and getHeight().
57
+ * @return {!Size} An object containing width and height
58
+ * attributes, which will both be zero if elem did not exist.
59
+ * @protected
60
+ */
61
+ getDimensionsPx_(elem) {
62
+ let width = 0;
63
+ let height = 0;
64
+ if (elem) {
65
+ width = elem.getWidth();
66
+ height = elem.getHeight();
67
+ }
68
+ return new Size(width, height);
69
+ }
70
+
71
+ /**
72
+ * Gets the width and the height of the flyout on the workspace in pixel
73
+ * coordinates. Returns 0 for the width and height if the workspace has a
74
+ * category toolbox instead of a simple toolbox.
75
+ * @param {boolean=} opt_own Whether to only return the workspace's own
76
+ * flyout.
77
+ * @return {!MetricsManager.ToolboxMetrics} The width and height of the
78
+ * flyout.
79
+ * @public
80
+ */
81
+ getFlyoutMetrics(opt_own) {
82
+ const flyoutDimensions =
83
+ this.getDimensionsPx_(this.workspace_.getFlyout(opt_own));
84
+ return {
85
+ width: flyoutDimensions.width,
86
+ height: flyoutDimensions.height,
87
+ position: this.workspace_.toolboxPosition,
88
+ };
89
+ }
90
+
91
+ /**
92
+ * Gets the width, height and position of the toolbox on the workspace in
93
+ * pixel coordinates. Returns 0 for the width and height if the workspace has
94
+ * a simple toolbox instead of a category toolbox. To get the width and height
95
+ * of a
96
+ * simple toolbox @see {@link getFlyoutMetrics}.
97
+ * @return {!MetricsManager.ToolboxMetrics} The object with the width,
98
+ * height and position of the toolbox.
99
+ * @public
100
+ */
101
+ getToolboxMetrics() {
102
+ const toolboxDimensions =
103
+ this.getDimensionsPx_(this.workspace_.getToolbox());
104
+
105
+ return {
106
+ width: toolboxDimensions.width,
107
+ height: toolboxDimensions.height,
108
+ position: this.workspace_.toolboxPosition,
109
+ };
110
+ }
111
+
112
+ /**
113
+ * Gets the width and height of the workspace's parent SVG element in pixel
114
+ * coordinates. This area includes the toolbox and the visible workspace area.
115
+ * @return {!Size} The width and height of the workspace's parent
116
+ * SVG element.
117
+ * @public
118
+ */
119
+ getSvgMetrics() {
120
+ return this.workspace_.getCachedParentSvgSize();
121
+ }
122
+
123
+ /**
124
+ * Gets the absolute left and absolute top in pixel coordinates.
125
+ * This is where the visible workspace starts in relation to the SVG
126
+ * container.
127
+ * @return {!MetricsManager.AbsoluteMetrics} The absolute metrics for
128
+ * the workspace.
129
+ * @public
130
+ */
131
+ getAbsoluteMetrics() {
132
+ let absoluteLeft = 0;
133
+ const toolboxMetrics = this.getToolboxMetrics();
134
+ const flyoutMetrics = this.getFlyoutMetrics(true);
135
+ const doesToolboxExist = !!this.workspace_.getToolbox();
136
+ const doesFlyoutExist = !!this.workspace_.getFlyout(true);
137
+ const toolboxPosition =
138
+ doesToolboxExist ? toolboxMetrics.position : flyoutMetrics.position;
139
+
140
+ const atLeft = toolboxPosition === toolboxUtils.Position.LEFT;
141
+ const atTop = toolboxPosition === toolboxUtils.Position.TOP;
142
+ if (doesToolboxExist && atLeft) {
143
+ absoluteLeft = toolboxMetrics.width;
144
+ } else if (doesFlyoutExist && atLeft) {
145
+ absoluteLeft = flyoutMetrics.width;
146
+ }
147
+ let absoluteTop = 0;
148
+ if (doesToolboxExist && atTop) {
149
+ absoluteTop = toolboxMetrics.height;
150
+ } else if (doesFlyoutExist && atTop) {
151
+ absoluteTop = flyoutMetrics.height;
152
+ }
153
+
154
+ return {
155
+ top: absoluteTop,
156
+ left: absoluteLeft,
157
+ };
158
+ }
159
+
160
+ /**
161
+ * Gets the metrics for the visible workspace in either pixel or workspace
162
+ * coordinates. The visible workspace does not include the toolbox or flyout.
163
+ * @param {boolean=} opt_getWorkspaceCoordinates True to get the view metrics
164
+ * in workspace coordinates, false to get them in pixel coordinates.
165
+ * @return {!MetricsManager.ContainerRegion} The width, height, top and
166
+ * left of the viewport in either workspace coordinates or pixel
167
+ * coordinates.
168
+ * @public
169
+ */
170
+ getViewMetrics(opt_getWorkspaceCoordinates) {
171
+ const scale = opt_getWorkspaceCoordinates ? this.workspace_.scale : 1;
172
+ const svgMetrics = this.getSvgMetrics();
173
+ const toolboxMetrics = this.getToolboxMetrics();
174
+ const flyoutMetrics = this.getFlyoutMetrics(true);
175
+ const doesToolboxExist = !!this.workspace_.getToolbox();
176
+ const toolboxPosition =
177
+ doesToolboxExist ? toolboxMetrics.position : flyoutMetrics.position;
178
+
179
+ if (this.workspace_.getToolbox()) {
180
+ if (toolboxPosition === toolboxUtils.Position.TOP ||
181
+ toolboxPosition === toolboxUtils.Position.BOTTOM) {
182
+ svgMetrics.height -= toolboxMetrics.height;
183
+ } else if (
184
+ toolboxPosition === toolboxUtils.Position.LEFT ||
185
+ toolboxPosition === toolboxUtils.Position.RIGHT) {
186
+ svgMetrics.width -= toolboxMetrics.width;
187
+ }
188
+ } else if (this.workspace_.getFlyout(true)) {
189
+ if (toolboxPosition === toolboxUtils.Position.TOP ||
190
+ toolboxPosition === toolboxUtils.Position.BOTTOM) {
191
+ svgMetrics.height -= flyoutMetrics.height;
192
+ } else if (
193
+ toolboxPosition === toolboxUtils.Position.LEFT ||
194
+ toolboxPosition === toolboxUtils.Position.RIGHT) {
195
+ svgMetrics.width -= flyoutMetrics.width;
196
+ }
197
+ }
198
+ return {
199
+ height: svgMetrics.height / scale,
200
+ width: svgMetrics.width / scale,
201
+ top: -this.workspace_.scrollY / scale,
202
+ left: -this.workspace_.scrollX / scale,
203
+ };
204
+ }
205
+
206
+ /**
207
+ * Gets content metrics in either pixel or workspace coordinates.
208
+ * The content area is a rectangle around all the top bounded elements on the
209
+ * workspace (workspace comments and blocks).
210
+ * @param {boolean=} opt_getWorkspaceCoordinates True to get the content
211
+ * metrics in workspace coordinates, false to get them in pixel
212
+ * coordinates.
213
+ * @return {!MetricsManager.ContainerRegion} The
214
+ * metrics for the content container.
215
+ * @public
216
+ */
217
+ getContentMetrics(opt_getWorkspaceCoordinates) {
218
+ const scale = opt_getWorkspaceCoordinates ? 1 : this.workspace_.scale;
219
+
220
+ // Block bounding box is in workspace coordinates.
221
+ const blockBox = this.workspace_.getBlocksBoundingBox();
222
+
223
+ return {
224
+ height: (blockBox.bottom - blockBox.top) * scale,
225
+ width: (blockBox.right - blockBox.left) * scale,
226
+ top: blockBox.top * scale,
227
+ left: blockBox.left * scale,
228
+ };
229
+ }
230
+
231
+ /**
232
+ * Returns whether the scroll area has fixed edges.
233
+ * @return {boolean} Whether the scroll area has fixed edges.
234
+ * @package
235
+ */
236
+ hasFixedEdges() {
237
+ // This exists for optimization of bump logic.
238
+ return !this.workspace_.isMovableHorizontally() ||
239
+ !this.workspace_.isMovableVertically();
240
+ }
241
+
242
+ /**
243
+ * Computes the fixed edges of the scroll area.
244
+ * @param {!MetricsManager.ContainerRegion=} opt_viewMetrics The view
245
+ * metrics if they have been previously computed. Passing in null may
246
+ * cause the view metrics to be computed again, if it is needed.
247
+ * @return {!MetricsManager.FixedEdges} The fixed edges of the scroll
248
+ * area.
45
249
  * @protected
46
250
  */
47
- this.workspace_ = workspace;
48
- };
251
+ getComputedFixedEdges_(opt_viewMetrics) {
252
+ if (!this.hasFixedEdges()) {
253
+ // Return early if there are no edges.
254
+ return {};
255
+ }
256
+
257
+ const hScrollEnabled = this.workspace_.isMovableHorizontally();
258
+ const vScrollEnabled = this.workspace_.isMovableVertically();
259
+
260
+ const viewMetrics = opt_viewMetrics || this.getViewMetrics(false);
261
+
262
+ const edges = {};
263
+ if (!vScrollEnabled) {
264
+ edges.top = viewMetrics.top;
265
+ edges.bottom = viewMetrics.top + viewMetrics.height;
266
+ }
267
+ if (!hScrollEnabled) {
268
+ edges.left = viewMetrics.left;
269
+ edges.right = viewMetrics.left + viewMetrics.width;
270
+ }
271
+ return edges;
272
+ }
273
+
274
+ /**
275
+ * Returns the content area with added padding.
276
+ * @param {!MetricsManager.ContainerRegion} viewMetrics The view
277
+ * metrics.
278
+ * @param {!MetricsManager.ContainerRegion} contentMetrics The content
279
+ * metrics.
280
+ * @return {{top: number, bottom: number, left: number, right: number}} The
281
+ * padded content area.
282
+ * @protected
283
+ */
284
+ getPaddedContent_(viewMetrics, contentMetrics) {
285
+ const contentBottom = contentMetrics.top + contentMetrics.height;
286
+ const contentRight = contentMetrics.left + contentMetrics.width;
287
+
288
+ const viewWidth = viewMetrics.width;
289
+ const viewHeight = viewMetrics.height;
290
+ const halfWidth = viewWidth / 2;
291
+ const halfHeight = viewHeight / 2;
292
+
293
+ // Add a padding around the content that is at least half a screen wide.
294
+ // Ensure padding is wide enough that blocks can scroll over entire screen.
295
+ const top =
296
+ Math.min(contentMetrics.top - halfHeight, contentBottom - viewHeight);
297
+ const left =
298
+ Math.min(contentMetrics.left - halfWidth, contentRight - viewWidth);
299
+ const bottom =
300
+ Math.max(contentBottom + halfHeight, contentMetrics.top + viewHeight);
301
+ const right =
302
+ Math.max(contentRight + halfWidth, contentMetrics.left + viewWidth);
303
+
304
+ return {top: top, bottom: bottom, left: left, right: right};
305
+ }
306
+
307
+ /**
308
+ * Returns the metrics for the scroll area of the workspace.
309
+ * @param {boolean=} opt_getWorkspaceCoordinates True to get the scroll
310
+ * metrics in workspace coordinates, false to get them in pixel
311
+ * coordinates.
312
+ * @param {!MetricsManager.ContainerRegion=} opt_viewMetrics The view
313
+ * metrics if they have been previously computed. Passing in null may
314
+ * cause the view metrics to be computed again, if it is needed.
315
+ * @param {!MetricsManager.ContainerRegion=} opt_contentMetrics The
316
+ * content metrics if they have been previously computed. Passing in null
317
+ * may cause the content metrics to be computed again, if it is needed.
318
+ * @return {!MetricsManager.ContainerRegion} The metrics for the scroll
319
+ * container.
320
+ */
321
+ getScrollMetrics(
322
+ opt_getWorkspaceCoordinates, opt_viewMetrics, opt_contentMetrics) {
323
+ const scale = opt_getWorkspaceCoordinates ? this.workspace_.scale : 1;
324
+ const viewMetrics = opt_viewMetrics || this.getViewMetrics(false);
325
+ const contentMetrics = opt_contentMetrics || this.getContentMetrics();
326
+ const fixedEdges = this.getComputedFixedEdges_(viewMetrics);
327
+
328
+ // Add padding around content.
329
+ const paddedContent = this.getPaddedContent_(viewMetrics, contentMetrics);
330
+
331
+ // Use combination of fixed bounds and padded content to make scroll area.
332
+ const top =
333
+ fixedEdges.top !== undefined ? fixedEdges.top : paddedContent.top;
334
+ const left =
335
+ fixedEdges.left !== undefined ? fixedEdges.left : paddedContent.left;
336
+ const bottom = fixedEdges.bottom !== undefined ? fixedEdges.bottom :
337
+ paddedContent.bottom;
338
+ const right =
339
+ fixedEdges.right !== undefined ? fixedEdges.right : paddedContent.right;
340
+
341
+ return {
342
+ top: top / scale,
343
+ left: left / scale,
344
+ width: (right - left) / scale,
345
+ height: (bottom - top) / scale,
346
+ };
347
+ }
348
+
349
+ /**
350
+ * Returns common metrics used by UI elements.
351
+ * @return {!MetricsManager.UiMetrics} The UI metrics.
352
+ */
353
+ getUiMetrics() {
354
+ return {
355
+ viewMetrics: this.getViewMetrics(),
356
+ absoluteMetrics: this.getAbsoluteMetrics(),
357
+ toolboxMetrics: this.getToolboxMetrics(),
358
+ };
359
+ }
360
+
361
+ /**
362
+ * Returns an object with all the metrics required to size scrollbars for a
363
+ * top level workspace. The following properties are computed:
364
+ * Coordinate system: pixel coordinates, -left, -up, +right, +down
365
+ * .viewHeight: Height of the visible portion of the workspace.
366
+ * .viewWidth: Width of the visible portion of the workspace.
367
+ * .contentHeight: Height of the content.
368
+ * .contentWidth: Width of the content.
369
+ * .scrollHeight: Height of the scroll area.
370
+ * .scrollWidth: Width of the scroll area.
371
+ * .svgHeight: Height of the Blockly div (the view + the toolbox,
372
+ * simple or otherwise),
373
+ * .svgWidth: Width of the Blockly div (the view + the toolbox,
374
+ * simple or otherwise),
375
+ * .viewTop: Top-edge of the visible portion of the workspace, relative to
376
+ * the workspace origin.
377
+ * .viewLeft: Left-edge of the visible portion of the workspace, relative to
378
+ * the workspace origin.
379
+ * .contentTop: Top-edge of the content, relative to the workspace origin.
380
+ * .contentLeft: Left-edge of the content relative to the workspace origin.
381
+ * .scrollTop: Top-edge of the scroll area, relative to the workspace origin.
382
+ * .scrollLeft: Left-edge of the scroll area relative to the workspace origin.
383
+ * .absoluteTop: Top-edge of the visible portion of the workspace, relative
384
+ * to the blocklyDiv.
385
+ * .absoluteLeft: Left-edge of the visible portion of the workspace, relative
386
+ * to the blocklyDiv.
387
+ * .toolboxWidth: Width of the toolbox, if it exists. Otherwise zero.
388
+ * .toolboxHeight: Height of the toolbox, if it exists. Otherwise zero.
389
+ * .flyoutWidth: Width of the flyout if it is always open. Otherwise zero.
390
+ * .flyoutHeight: Height of the flyout if it is always open. Otherwise zero.
391
+ * .toolboxPosition: Top, bottom, left or right. Use TOOLBOX_AT constants to
392
+ * compare.
393
+ * @return {!Metrics} Contains size and position metrics of a top
394
+ * level workspace.
395
+ * @public
396
+ */
397
+ getMetrics() {
398
+ const toolboxMetrics = this.getToolboxMetrics();
399
+ const flyoutMetrics = this.getFlyoutMetrics(true);
400
+ const svgMetrics = this.getSvgMetrics();
401
+ const absoluteMetrics = this.getAbsoluteMetrics();
402
+ const viewMetrics = this.getViewMetrics();
403
+ const contentMetrics = this.getContentMetrics();
404
+ const scrollMetrics =
405
+ this.getScrollMetrics(false, viewMetrics, contentMetrics);
406
+
407
+ return {
408
+ contentHeight: contentMetrics.height,
409
+ contentWidth: contentMetrics.width,
410
+ contentTop: contentMetrics.top,
411
+ contentLeft: contentMetrics.left,
412
+
413
+ scrollHeight: scrollMetrics.height,
414
+ scrollWidth: scrollMetrics.width,
415
+ scrollTop: scrollMetrics.top,
416
+ scrollLeft: scrollMetrics.left,
417
+
418
+ viewHeight: viewMetrics.height,
419
+ viewWidth: viewMetrics.width,
420
+ viewTop: viewMetrics.top,
421
+ viewLeft: viewMetrics.left,
422
+
423
+ absoluteTop: absoluteMetrics.top,
424
+ absoluteLeft: absoluteMetrics.left,
425
+
426
+ svgHeight: svgMetrics.height,
427
+ svgWidth: svgMetrics.width,
428
+
429
+ toolboxWidth: toolboxMetrics.width,
430
+ toolboxHeight: toolboxMetrics.height,
431
+ toolboxPosition: toolboxMetrics.position,
432
+
433
+ flyoutWidth: flyoutMetrics.width,
434
+ flyoutHeight: flyoutMetrics.height,
435
+ };
436
+ }
437
+ }
49
438
 
50
439
  /**
51
440
  * Describes the width, height and location of the toolbox on the main
@@ -57,6 +446,7 @@ const MetricsManager = function(workspace) {
57
446
  * }}
58
447
  */
59
448
  MetricsManager.ToolboxMetrics;
449
+
60
450
  /**
61
451
  * Describes where the viewport starts in relation to the workspace SVG.
62
452
  * @typedef {{
@@ -65,8 +455,10 @@ MetricsManager.ToolboxMetrics;
65
455
  * }}
66
456
  */
67
457
  MetricsManager.AbsoluteMetrics;
458
+
68
459
  /**
69
- * All the measurements needed to describe the size and location of a container.
460
+ * All the measurements needed to describe the size and location of a
461
+ * container.
70
462
  * @typedef {{
71
463
  * height: number,
72
464
  * width: number,
@@ -75,6 +467,7 @@ MetricsManager.AbsoluteMetrics;
75
467
  * }}
76
468
  */
77
469
  MetricsManager.ContainerRegion;
470
+
78
471
  /**
79
472
  * Describes fixed edges of the workspace.
80
473
  * @typedef {{
@@ -85,6 +478,7 @@ MetricsManager.ContainerRegion;
85
478
  * }}
86
479
  */
87
480
  MetricsManager.FixedEdges;
481
+
88
482
  /**
89
483
  * Common metrics used for UI elements.
90
484
  * @typedef {{
@@ -94,387 +488,6 @@ MetricsManager.FixedEdges;
94
488
  * }}
95
489
  */
96
490
  MetricsManager.UiMetrics;
97
- /**
98
- * Gets the dimensions of the given workspace component, in pixel coordinates.
99
- * @param {?IToolbox|?IFlyout} elem The element to get the
100
- * dimensions of, or null. It should be a toolbox or flyout, and should
101
- * implement getWidth() and getHeight().
102
- * @return {!Size} An object containing width and height
103
- * attributes, which will both be zero if elem did not exist.
104
- * @protected
105
- */
106
- MetricsManager.prototype.getDimensionsPx_ = function(elem) {
107
- let width = 0;
108
- let height = 0;
109
- if (elem) {
110
- width = elem.getWidth();
111
- height = elem.getHeight();
112
- }
113
- return new Size(width, height);
114
- };
115
-
116
- /**
117
- * Gets the width and the height of the flyout on the workspace in pixel
118
- * coordinates. Returns 0 for the width and height if the workspace has a
119
- * category toolbox instead of a simple toolbox.
120
- * @param {boolean=} opt_own Whether to only return the workspace's own flyout.
121
- * @return {!MetricsManager.ToolboxMetrics} The width and height of the
122
- * flyout.
123
- * @public
124
- */
125
- MetricsManager.prototype.getFlyoutMetrics = function(opt_own) {
126
- const flyoutDimensions =
127
- this.getDimensionsPx_(this.workspace_.getFlyout(opt_own));
128
- return {
129
- width: flyoutDimensions.width,
130
- height: flyoutDimensions.height,
131
- position: this.workspace_.toolboxPosition,
132
- };
133
- };
134
-
135
- /**
136
- * Gets the width, height and position of the toolbox on the workspace in pixel
137
- * coordinates. Returns 0 for the width and height if the workspace has a simple
138
- * toolbox instead of a category toolbox. To get the width and height of a
139
- * simple toolbox @see {@link getFlyoutMetrics}.
140
- * @return {!MetricsManager.ToolboxMetrics} The object with the width,
141
- * height and position of the toolbox.
142
- * @public
143
- */
144
- MetricsManager.prototype.getToolboxMetrics = function() {
145
- const toolboxDimensions = this.getDimensionsPx_(this.workspace_.getToolbox());
146
-
147
- return {
148
- width: toolboxDimensions.width,
149
- height: toolboxDimensions.height,
150
- position: this.workspace_.toolboxPosition,
151
- };
152
- };
153
-
154
- /**
155
- * Gets the width and height of the workspace's parent SVG element in pixel
156
- * coordinates. This area includes the toolbox and the visible workspace area.
157
- * @return {!Size} The width and height of the workspace's parent
158
- * SVG element.
159
- * @public
160
- */
161
- MetricsManager.prototype.getSvgMetrics = function() {
162
- return this.workspace_.getCachedParentSvgSize();
163
- };
164
-
165
- /**
166
- * Gets the absolute left and absolute top in pixel coordinates.
167
- * This is where the visible workspace starts in relation to the SVG container.
168
- * @return {!MetricsManager.AbsoluteMetrics} The absolute metrics for
169
- * the workspace.
170
- * @public
171
- */
172
- MetricsManager.prototype.getAbsoluteMetrics = function() {
173
- let absoluteLeft = 0;
174
- const toolboxMetrics = this.getToolboxMetrics();
175
- const flyoutMetrics = this.getFlyoutMetrics(true);
176
- const doesToolboxExist = !!this.workspace_.getToolbox();
177
- const doesFlyoutExist = !!this.workspace_.getFlyout(true);
178
- const toolboxPosition =
179
- doesToolboxExist ? toolboxMetrics.position : flyoutMetrics.position;
180
-
181
- const atLeft = toolboxPosition === toolboxUtils.Position.LEFT;
182
- const atTop = toolboxPosition === toolboxUtils.Position.TOP;
183
- if (doesToolboxExist && atLeft) {
184
- absoluteLeft = toolboxMetrics.width;
185
- } else if (doesFlyoutExist && atLeft) {
186
- absoluteLeft = flyoutMetrics.width;
187
- }
188
- let absoluteTop = 0;
189
- if (doesToolboxExist && atTop) {
190
- absoluteTop = toolboxMetrics.height;
191
- } else if (doesFlyoutExist && atTop) {
192
- absoluteTop = flyoutMetrics.height;
193
- }
194
-
195
- return {
196
- top: absoluteTop,
197
- left: absoluteLeft,
198
- };
199
- };
200
-
201
- /**
202
- * Gets the metrics for the visible workspace in either pixel or workspace
203
- * coordinates. The visible workspace does not include the toolbox or flyout.
204
- * @param {boolean=} opt_getWorkspaceCoordinates True to get the view metrics in
205
- * workspace coordinates, false to get them in pixel coordinates.
206
- * @return {!MetricsManager.ContainerRegion} The width, height, top and
207
- * left of the viewport in either workspace coordinates or pixel
208
- * coordinates.
209
- * @public
210
- */
211
- MetricsManager.prototype.getViewMetrics = function(
212
- opt_getWorkspaceCoordinates) {
213
- const scale = opt_getWorkspaceCoordinates ? this.workspace_.scale : 1;
214
- const svgMetrics = this.getSvgMetrics();
215
- const toolboxMetrics = this.getToolboxMetrics();
216
- const flyoutMetrics = this.getFlyoutMetrics(true);
217
- const doesToolboxExist = !!this.workspace_.getToolbox();
218
- const toolboxPosition =
219
- doesToolboxExist ? toolboxMetrics.position : flyoutMetrics.position;
220
-
221
- if (this.workspace_.getToolbox()) {
222
- if (toolboxPosition === toolboxUtils.Position.TOP ||
223
- toolboxPosition === toolboxUtils.Position.BOTTOM) {
224
- svgMetrics.height -= toolboxMetrics.height;
225
- } else if (
226
- toolboxPosition === toolboxUtils.Position.LEFT ||
227
- toolboxPosition === toolboxUtils.Position.RIGHT) {
228
- svgMetrics.width -= toolboxMetrics.width;
229
- }
230
- } else if (this.workspace_.getFlyout(true)) {
231
- if (toolboxPosition === toolboxUtils.Position.TOP ||
232
- toolboxPosition === toolboxUtils.Position.BOTTOM) {
233
- svgMetrics.height -= flyoutMetrics.height;
234
- } else if (
235
- toolboxPosition === toolboxUtils.Position.LEFT ||
236
- toolboxPosition === toolboxUtils.Position.RIGHT) {
237
- svgMetrics.width -= flyoutMetrics.width;
238
- }
239
- }
240
- return {
241
- height: svgMetrics.height / scale,
242
- width: svgMetrics.width / scale,
243
- top: -this.workspace_.scrollY / scale,
244
- left: -this.workspace_.scrollX / scale,
245
- };
246
- };
247
-
248
- /**
249
- * Gets content metrics in either pixel or workspace coordinates.
250
- * The content area is a rectangle around all the top bounded elements on the
251
- * workspace (workspace comments and blocks).
252
- * @param {boolean=} opt_getWorkspaceCoordinates True to get the content metrics
253
- * in workspace coordinates, false to get them in pixel coordinates.
254
- * @return {!MetricsManager.ContainerRegion} The
255
- * metrics for the content container.
256
- * @public
257
- */
258
- MetricsManager.prototype.getContentMetrics = function(
259
- opt_getWorkspaceCoordinates) {
260
- const scale = opt_getWorkspaceCoordinates ? 1 : this.workspace_.scale;
261
-
262
- // Block bounding box is in workspace coordinates.
263
- const blockBox = this.workspace_.getBlocksBoundingBox();
264
-
265
- return {
266
- height: (blockBox.bottom - blockBox.top) * scale,
267
- width: (blockBox.right - blockBox.left) * scale,
268
- top: blockBox.top * scale,
269
- left: blockBox.left * scale,
270
- };
271
- };
272
-
273
- /**
274
- * Returns whether the scroll area has fixed edges.
275
- * @return {boolean} Whether the scroll area has fixed edges.
276
- * @package
277
- */
278
- MetricsManager.prototype.hasFixedEdges = function() {
279
- // This exists for optimization of bump logic.
280
- return !this.workspace_.isMovableHorizontally() ||
281
- !this.workspace_.isMovableVertically();
282
- };
283
-
284
- /**
285
- * Computes the fixed edges of the scroll area.
286
- * @param {!MetricsManager.ContainerRegion=} opt_viewMetrics The view
287
- * metrics if they have been previously computed. Passing in null may cause
288
- * the view metrics to be computed again, if it is needed.
289
- * @return {!MetricsManager.FixedEdges} The fixed edges of the scroll
290
- * area.
291
- * @protected
292
- */
293
- MetricsManager.prototype.getComputedFixedEdges_ = function(opt_viewMetrics) {
294
- if (!this.hasFixedEdges()) {
295
- // Return early if there are no edges.
296
- return {};
297
- }
298
-
299
- const hScrollEnabled = this.workspace_.isMovableHorizontally();
300
- const vScrollEnabled = this.workspace_.isMovableVertically();
301
-
302
- const viewMetrics = opt_viewMetrics || this.getViewMetrics(false);
303
-
304
- const edges = {};
305
- if (!vScrollEnabled) {
306
- edges.top = viewMetrics.top;
307
- edges.bottom = viewMetrics.top + viewMetrics.height;
308
- }
309
- if (!hScrollEnabled) {
310
- edges.left = viewMetrics.left;
311
- edges.right = viewMetrics.left + viewMetrics.width;
312
- }
313
- return edges;
314
- };
315
-
316
- /**
317
- * Returns the content area with added padding.
318
- * @param {!MetricsManager.ContainerRegion} viewMetrics The view
319
- * metrics.
320
- * @param {!MetricsManager.ContainerRegion} contentMetrics The content
321
- * metrics.
322
- * @return {{top: number, bottom: number, left: number, right: number}} The
323
- * padded content area.
324
- * @protected
325
- */
326
- MetricsManager.prototype.getPaddedContent_ = function(
327
- viewMetrics, contentMetrics) {
328
- const contentBottom = contentMetrics.top + contentMetrics.height;
329
- const contentRight = contentMetrics.left + contentMetrics.width;
330
-
331
- const viewWidth = viewMetrics.width;
332
- const viewHeight = viewMetrics.height;
333
- const halfWidth = viewWidth / 2;
334
- const halfHeight = viewHeight / 2;
335
-
336
- // Add a padding around the content that is at least half a screen wide.
337
- // Ensure padding is wide enough that blocks can scroll over entire screen.
338
- const top =
339
- Math.min(contentMetrics.top - halfHeight, contentBottom - viewHeight);
340
- const left =
341
- Math.min(contentMetrics.left - halfWidth, contentRight - viewWidth);
342
- const bottom =
343
- Math.max(contentBottom + halfHeight, contentMetrics.top + viewHeight);
344
- const right =
345
- Math.max(contentRight + halfWidth, contentMetrics.left + viewWidth);
346
-
347
- return {top: top, bottom: bottom, left: left, right: right};
348
- };
349
-
350
- /**
351
- * Returns the metrics for the scroll area of the workspace.
352
- * @param {boolean=} opt_getWorkspaceCoordinates True to get the scroll metrics
353
- * in workspace coordinates, false to get them in pixel coordinates.
354
- * @param {!MetricsManager.ContainerRegion=} opt_viewMetrics The view
355
- * metrics if they have been previously computed. Passing in null may cause
356
- * the view metrics to be computed again, if it is needed.
357
- * @param {!MetricsManager.ContainerRegion=} opt_contentMetrics The
358
- * content metrics if they have been previously computed. Passing in null
359
- * may cause the content metrics to be computed again, if it is needed.
360
- * @return {!MetricsManager.ContainerRegion} The metrics for the scroll
361
- * container.
362
- */
363
- MetricsManager.prototype.getScrollMetrics = function(
364
- opt_getWorkspaceCoordinates, opt_viewMetrics, opt_contentMetrics) {
365
- const scale = opt_getWorkspaceCoordinates ? this.workspace_.scale : 1;
366
- const viewMetrics = opt_viewMetrics || this.getViewMetrics(false);
367
- const contentMetrics = opt_contentMetrics || this.getContentMetrics();
368
- const fixedEdges = this.getComputedFixedEdges_(viewMetrics);
369
-
370
- // Add padding around content.
371
- const paddedContent = this.getPaddedContent_(viewMetrics, contentMetrics);
372
-
373
- // Use combination of fixed bounds and padded content to make scroll area.
374
- const top = fixedEdges.top !== undefined ? fixedEdges.top : paddedContent.top;
375
- const left =
376
- fixedEdges.left !== undefined ? fixedEdges.left : paddedContent.left;
377
- const bottom = fixedEdges.bottom !== undefined ? fixedEdges.bottom :
378
- paddedContent.bottom;
379
- const right =
380
- fixedEdges.right !== undefined ? fixedEdges.right : paddedContent.right;
381
-
382
- return {
383
- top: top / scale,
384
- left: left / scale,
385
- width: (right - left) / scale,
386
- height: (bottom - top) / scale,
387
- };
388
- };
389
-
390
- /**
391
- * Returns common metrics used by UI elements.
392
- * @return {!MetricsManager.UiMetrics} The UI metrics.
393
- */
394
- MetricsManager.prototype.getUiMetrics = function() {
395
- return {
396
- viewMetrics: this.getViewMetrics(),
397
- absoluteMetrics: this.getAbsoluteMetrics(),
398
- toolboxMetrics: this.getToolboxMetrics(),
399
- };
400
- };
401
-
402
- /**
403
- * Returns an object with all the metrics required to size scrollbars for a
404
- * top level workspace. The following properties are computed:
405
- * Coordinate system: pixel coordinates, -left, -up, +right, +down
406
- * .viewHeight: Height of the visible portion of the workspace.
407
- * .viewWidth: Width of the visible portion of the workspace.
408
- * .contentHeight: Height of the content.
409
- * .contentWidth: Width of the content.
410
- * .scrollHeight: Height of the scroll area.
411
- * .scrollWidth: Width of the scroll area.
412
- * .svgHeight: Height of the Blockly div (the view + the toolbox,
413
- * simple or otherwise),
414
- * .svgWidth: Width of the Blockly div (the view + the toolbox,
415
- * simple or otherwise),
416
- * .viewTop: Top-edge of the visible portion of the workspace, relative to
417
- * the workspace origin.
418
- * .viewLeft: Left-edge of the visible portion of the workspace, relative to
419
- * the workspace origin.
420
- * .contentTop: Top-edge of the content, relative to the workspace origin.
421
- * .contentLeft: Left-edge of the content relative to the workspace origin.
422
- * .scrollTop: Top-edge of the scroll area, relative to the workspace origin.
423
- * .scrollLeft: Left-edge of the scroll area relative to the workspace origin.
424
- * .absoluteTop: Top-edge of the visible portion of the workspace, relative
425
- * to the blocklyDiv.
426
- * .absoluteLeft: Left-edge of the visible portion of the workspace, relative
427
- * to the blocklyDiv.
428
- * .toolboxWidth: Width of the toolbox, if it exists. Otherwise zero.
429
- * .toolboxHeight: Height of the toolbox, if it exists. Otherwise zero.
430
- * .flyoutWidth: Width of the flyout if it is always open. Otherwise zero.
431
- * .flyoutHeight: Height of the flyout if it is always open. Otherwise zero.
432
- * .toolboxPosition: Top, bottom, left or right. Use TOOLBOX_AT constants to
433
- * compare.
434
- * @return {!Metrics} Contains size and position metrics of a top
435
- * level workspace.
436
- * @public
437
- */
438
- MetricsManager.prototype.getMetrics = function() {
439
- const toolboxMetrics = this.getToolboxMetrics();
440
- const flyoutMetrics = this.getFlyoutMetrics(true);
441
- const svgMetrics = this.getSvgMetrics();
442
- const absoluteMetrics = this.getAbsoluteMetrics();
443
- const viewMetrics = this.getViewMetrics();
444
- const contentMetrics = this.getContentMetrics();
445
- const scrollMetrics =
446
- this.getScrollMetrics(false, viewMetrics, contentMetrics);
447
-
448
- return {
449
- contentHeight: contentMetrics.height,
450
- contentWidth: contentMetrics.width,
451
- contentTop: contentMetrics.top,
452
- contentLeft: contentMetrics.left,
453
-
454
- scrollHeight: scrollMetrics.height,
455
- scrollWidth: scrollMetrics.width,
456
- scrollTop: scrollMetrics.top,
457
- scrollLeft: scrollMetrics.left,
458
-
459
- viewHeight: viewMetrics.height,
460
- viewWidth: viewMetrics.width,
461
- viewTop: viewMetrics.top,
462
- viewLeft: viewMetrics.left,
463
-
464
- absoluteTop: absoluteMetrics.top,
465
- absoluteLeft: absoluteMetrics.left,
466
-
467
- svgHeight: svgMetrics.height,
468
- svgWidth: svgMetrics.width,
469
-
470
- toolboxWidth: toolboxMetrics.width,
471
- toolboxHeight: toolboxMetrics.height,
472
- toolboxPosition: toolboxMetrics.position,
473
-
474
- flyoutWidth: flyoutMetrics.width,
475
- flyoutHeight: flyoutMetrics.height,
476
- };
477
- };
478
491
 
479
492
  registry.register(
480
493
  registry.Type.METRICS_MANAGER, registry.DEFAULT, MetricsManager);