1 | /* |
2 | * Copyright (C) 2013 Google Inc. All rights reserved. |
3 | * Copyright (C) 2013-2016 Apple Inc. All rights reserved. |
4 | * Copyright (C) 2014 University of Washington. All rights reserved. |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions |
8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
14 | * |
15 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
17 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
19 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | * THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | // DO NOT EDIT THIS FILE. It is automatically generated from Automation.json |
29 | // by the script: Source/JavaScriptCore/inspector/scripts/generate-inspector-protocol-bindings.py |
30 | |
31 | #pragma once |
32 | |
33 | #include <JavaScriptCore/InspectorProtocolTypes.h> |
34 | #include <wtf/Assertions.h> |
35 | |
36 | namespace Inspector { |
37 | |
38 | |
39 | |
40 | namespace Protocol { |
41 | |
42 | |
43 | |
44 | // Forward declarations. |
45 | namespace Automation { |
46 | class Point; |
47 | class Size; |
48 | class Rect; |
49 | class BrowsingContext; |
50 | class KeyboardInteraction; |
51 | class Cookie; |
52 | class SessionPermissionData; |
53 | class InputSource; |
54 | class InteractionStep; |
55 | class InputSourceState; |
56 | enum class CoordinateSystem; |
57 | enum class BrowsingContextPresentation; |
58 | enum class ErrorMessage; |
59 | enum class PageLoadStrategy; |
60 | enum class MouseInteraction; |
61 | enum class MouseButton; |
62 | enum class KeyModifier; |
63 | enum class VirtualKey; |
64 | enum class KeyboardInteractionType; |
65 | enum class SessionPermission; |
66 | enum class InputSourceType; |
67 | enum class MouseMoveOrigin; |
68 | } // Automation |
69 | // End of forward declarations. |
70 | |
71 | |
72 | // Typedefs. |
73 | namespace Automation { |
74 | /* An opaque identifier for a browsing context. */ |
75 | typedef String BrowsingContextHandle; |
76 | /* An opaque identifier for a frame in a page. */ |
77 | typedef String FrameHandle; |
78 | /* An opaque identifier for a node in a page. */ |
79 | typedef String NodeHandle; |
80 | } // Automation |
81 | // End of typedefs. |
82 | |
83 | namespace AutomationHelpers { |
84 | |
85 | String getEnumConstantValue(int code); |
86 | |
87 | template<typename T> String getEnumConstantValue(T enumValue) |
88 | { |
89 | return getEnumConstantValue(static_cast<int>(enumValue)); |
90 | } |
91 | |
92 | } // namespace AutomationHelpers |
93 | |
94 | namespace Automation { |
95 | class Point : public JSON::ObjectBase { |
96 | public: |
97 | enum { |
98 | NoFieldsSet = 0, |
99 | XSet = 1 << 0, |
100 | YSet = 1 << 1, |
101 | AllFieldsSet = (XSet | YSet) |
102 | }; |
103 | |
104 | template<int STATE> |
105 | class Builder { |
106 | private: |
107 | RefPtr<JSON::Object> m_result; |
108 | |
109 | template<int STEP> Builder<STATE | STEP>& castState() |
110 | { |
111 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
112 | } |
113 | |
114 | Builder(Ref</*Point*/JSON::Object>&& object) |
115 | : m_result(WTFMove(object)) |
116 | { |
117 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
118 | } |
119 | friend class Point; |
120 | public: |
121 | |
122 | Builder<STATE | XSet>& setX(double value) |
123 | { |
124 | COMPILE_ASSERT(!(STATE & XSet), property_x_already_set); |
125 | m_result->setDouble("x"_s , value); |
126 | return castState<XSet>(); |
127 | } |
128 | |
129 | Builder<STATE | YSet>& setY(double value) |
130 | { |
131 | COMPILE_ASSERT(!(STATE & YSet), property_y_already_set); |
132 | m_result->setDouble("y"_s , value); |
133 | return castState<YSet>(); |
134 | } |
135 | |
136 | Ref<Point> release() |
137 | { |
138 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
139 | COMPILE_ASSERT(sizeof(Point) == sizeof(JSON::Object), cannot_cast); |
140 | |
141 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
142 | auto result = WTFMove(*reinterpret_cast<Ref<Point>*>(&jsonResult)); |
143 | return result; |
144 | } |
145 | }; |
146 | |
147 | /* |
148 | * Synthetic constructor: |
149 | * Ref<Point> result = Point::create() |
150 | * .setX(...) |
151 | * .setY(...) |
152 | * .release(); |
153 | */ |
154 | static Builder<NoFieldsSet> create() |
155 | { |
156 | return Builder<NoFieldsSet>(JSON::Object::create()); |
157 | } |
158 | }; |
159 | |
160 | class Size : public JSON::ObjectBase { |
161 | public: |
162 | enum { |
163 | NoFieldsSet = 0, |
164 | WidthSet = 1 << 0, |
165 | HeightSet = 1 << 1, |
166 | AllFieldsSet = (WidthSet | HeightSet) |
167 | }; |
168 | |
169 | template<int STATE> |
170 | class Builder { |
171 | private: |
172 | RefPtr<JSON::Object> m_result; |
173 | |
174 | template<int STEP> Builder<STATE | STEP>& castState() |
175 | { |
176 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
177 | } |
178 | |
179 | Builder(Ref</*Size*/JSON::Object>&& object) |
180 | : m_result(WTFMove(object)) |
181 | { |
182 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
183 | } |
184 | friend class Size; |
185 | public: |
186 | |
187 | Builder<STATE | WidthSet>& setWidth(double value) |
188 | { |
189 | COMPILE_ASSERT(!(STATE & WidthSet), property_width_already_set); |
190 | m_result->setDouble("width"_s , value); |
191 | return castState<WidthSet>(); |
192 | } |
193 | |
194 | Builder<STATE | HeightSet>& setHeight(double value) |
195 | { |
196 | COMPILE_ASSERT(!(STATE & HeightSet), property_height_already_set); |
197 | m_result->setDouble("height"_s , value); |
198 | return castState<HeightSet>(); |
199 | } |
200 | |
201 | Ref<Size> release() |
202 | { |
203 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
204 | COMPILE_ASSERT(sizeof(Size) == sizeof(JSON::Object), cannot_cast); |
205 | |
206 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
207 | auto result = WTFMove(*reinterpret_cast<Ref<Size>*>(&jsonResult)); |
208 | return result; |
209 | } |
210 | }; |
211 | |
212 | /* |
213 | * Synthetic constructor: |
214 | * Ref<Size> result = Size::create() |
215 | * .setWidth(...) |
216 | * .setHeight(...) |
217 | * .release(); |
218 | */ |
219 | static Builder<NoFieldsSet> create() |
220 | { |
221 | return Builder<NoFieldsSet>(JSON::Object::create()); |
222 | } |
223 | }; |
224 | |
225 | class Rect : public JSON::ObjectBase { |
226 | public: |
227 | enum { |
228 | NoFieldsSet = 0, |
229 | OriginSet = 1 << 0, |
230 | SizeSet = 1 << 1, |
231 | AllFieldsSet = (OriginSet | SizeSet) |
232 | }; |
233 | |
234 | template<int STATE> |
235 | class Builder { |
236 | private: |
237 | RefPtr<JSON::Object> m_result; |
238 | |
239 | template<int STEP> Builder<STATE | STEP>& castState() |
240 | { |
241 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
242 | } |
243 | |
244 | Builder(Ref</*Rect*/JSON::Object>&& object) |
245 | : m_result(WTFMove(object)) |
246 | { |
247 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
248 | } |
249 | friend class Rect; |
250 | public: |
251 | |
252 | Builder<STATE | OriginSet>& setOrigin(RefPtr<Inspector::Protocol::Automation::Point> value) |
253 | { |
254 | COMPILE_ASSERT(!(STATE & OriginSet), property_origin_already_set); |
255 | m_result->setObject("origin"_s , value); |
256 | return castState<OriginSet>(); |
257 | } |
258 | |
259 | Builder<STATE | SizeSet>& setSize(RefPtr<Inspector::Protocol::Automation::Size> value) |
260 | { |
261 | COMPILE_ASSERT(!(STATE & SizeSet), property_size_already_set); |
262 | m_result->setObject("size"_s , value); |
263 | return castState<SizeSet>(); |
264 | } |
265 | |
266 | Ref<Rect> release() |
267 | { |
268 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
269 | COMPILE_ASSERT(sizeof(Rect) == sizeof(JSON::Object), cannot_cast); |
270 | |
271 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
272 | auto result = WTFMove(*reinterpret_cast<Ref<Rect>*>(&jsonResult)); |
273 | return result; |
274 | } |
275 | }; |
276 | |
277 | /* |
278 | * Synthetic constructor: |
279 | * Ref<Rect> result = Rect::create() |
280 | * .setOrigin(...) |
281 | * .setSize(...) |
282 | * .release(); |
283 | */ |
284 | static Builder<NoFieldsSet> create() |
285 | { |
286 | return Builder<NoFieldsSet>(JSON::Object::create()); |
287 | } |
288 | }; |
289 | |
290 | /* The coordinate system in which rects, points, and sizes are to be interpreted. */ |
291 | enum class CoordinateSystem { |
292 | Page = 0, |
293 | Viewport = 1, |
294 | }; // enum class CoordinateSystem |
295 | /* How a browsing context is presented by the user agent. A browsing context is considered a tab if it shares an OS-level window with another browsing context. */ |
296 | enum class BrowsingContextPresentation { |
297 | Window = 2, |
298 | Tab = 3, |
299 | }; // enum class BrowsingContextPresentation |
300 | /* This enum contains predefined error messages that can be used to signal a well-defined error condition, such as a missing implementation, unknown window handle, and so forth. The backend signals one of these errors by using it as a prefix of the commands's error message (the errorString argument in generated C++ backend dispatchers). This will be reported to the frontend as a protocol error with a JSON-RPC error code of 'ServerError'. It is up to the frontend whether and how to deal with errors. */ |
301 | enum class ErrorMessage { |
302 | InternalError = 4, |
303 | Timeout = 5, |
304 | JavaScriptError = 6, |
305 | JavaScriptTimeout = 7, |
306 | WindowNotFound = 8, |
307 | FrameNotFound = 9, |
308 | NodeNotFound = 10, |
309 | InvalidElementState = 11, |
310 | NoJavaScriptDialog = 12, |
311 | NotImplemented = 13, |
312 | MissingParameter = 14, |
313 | InvalidParameter = 15, |
314 | InvalidSelector = 16, |
315 | ElementNotInteractable = 17, |
316 | ElementNotSelectable = 18, |
317 | ScreenshotError = 19, |
318 | UnexpectedAlertOpen = 20, |
319 | TargetOutOfBounds = 21, |
320 | }; // enum class ErrorMessage |
321 | /* Enumerates different page load strategies. */ |
322 | enum class PageLoadStrategy { |
323 | None = 22, |
324 | Eager = 23, |
325 | Normal = 24, |
326 | }; // enum class PageLoadStrategy |
327 | /* A handle representing an open window or tab in the automation session. */ |
328 | class BrowsingContext : public JSON::ObjectBase { |
329 | public: |
330 | enum { |
331 | NoFieldsSet = 0, |
332 | HandleSet = 1 << 0, |
333 | ActiveSet = 1 << 1, |
334 | UrlSet = 1 << 2, |
335 | WindowSizeSet = 1 << 3, |
336 | WindowOriginSet = 1 << 4, |
337 | AllFieldsSet = (HandleSet | ActiveSet | UrlSet | WindowSizeSet | WindowOriginSet) |
338 | }; |
339 | |
340 | template<int STATE> |
341 | class Builder { |
342 | private: |
343 | RefPtr<JSON::Object> m_result; |
344 | |
345 | template<int STEP> Builder<STATE | STEP>& castState() |
346 | { |
347 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
348 | } |
349 | |
350 | Builder(Ref</*BrowsingContext*/JSON::Object>&& object) |
351 | : m_result(WTFMove(object)) |
352 | { |
353 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
354 | } |
355 | friend class BrowsingContext; |
356 | public: |
357 | |
358 | Builder<STATE | HandleSet>& setHandle(const String& value) |
359 | { |
360 | COMPILE_ASSERT(!(STATE & HandleSet), property_handle_already_set); |
361 | m_result->setString("handle"_s , value); |
362 | return castState<HandleSet>(); |
363 | } |
364 | |
365 | Builder<STATE | ActiveSet>& setActive(bool value) |
366 | { |
367 | COMPILE_ASSERT(!(STATE & ActiveSet), property_active_already_set); |
368 | m_result->setBoolean("active"_s , value); |
369 | return castState<ActiveSet>(); |
370 | } |
371 | |
372 | Builder<STATE | UrlSet>& setUrl(const String& value) |
373 | { |
374 | COMPILE_ASSERT(!(STATE & UrlSet), property_url_already_set); |
375 | m_result->setString("url"_s , value); |
376 | return castState<UrlSet>(); |
377 | } |
378 | |
379 | Builder<STATE | WindowSizeSet>& setWindowSize(RefPtr<Inspector::Protocol::Automation::Size> value) |
380 | { |
381 | COMPILE_ASSERT(!(STATE & WindowSizeSet), property_windowSize_already_set); |
382 | m_result->setObject("windowSize"_s , value); |
383 | return castState<WindowSizeSet>(); |
384 | } |
385 | |
386 | Builder<STATE | WindowOriginSet>& setWindowOrigin(RefPtr<Inspector::Protocol::Automation::Point> value) |
387 | { |
388 | COMPILE_ASSERT(!(STATE & WindowOriginSet), property_windowOrigin_already_set); |
389 | m_result->setObject("windowOrigin"_s , value); |
390 | return castState<WindowOriginSet>(); |
391 | } |
392 | |
393 | Ref<BrowsingContext> release() |
394 | { |
395 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
396 | COMPILE_ASSERT(sizeof(BrowsingContext) == sizeof(JSON::Object), cannot_cast); |
397 | |
398 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
399 | auto result = WTFMove(*reinterpret_cast<Ref<BrowsingContext>*>(&jsonResult)); |
400 | return result; |
401 | } |
402 | }; |
403 | |
404 | /* |
405 | * Synthetic constructor: |
406 | * Ref<BrowsingContext> result = BrowsingContext::create() |
407 | * .setHandle(...) |
408 | * .setActive(...) |
409 | * .setUrl(...) |
410 | * .setWindowSize(...) |
411 | * .setWindowOrigin(...) |
412 | * .release(); |
413 | */ |
414 | static Builder<NoFieldsSet> create() |
415 | { |
416 | return Builder<NoFieldsSet>(JSON::Object::create()); |
417 | } |
418 | }; |
419 | |
420 | /* Enumerates different ways of interacting with a mouse cursor. */ |
421 | enum class MouseInteraction { |
422 | Move = 25, |
423 | Down = 26, |
424 | Up = 27, |
425 | SingleClick = 28, |
426 | DoubleClick = 29, |
427 | }; // enum class MouseInteraction |
428 | /* Enumerates different mouse buttons that can be used. */ |
429 | enum class MouseButton { |
430 | None = 22, |
431 | Left = 30, |
432 | Middle = 31, |
433 | Right = 32, |
434 | }; // enum class MouseButton |
435 | /* Enumerates different key modifiers that can remain pressed during other mouse/touch interactions. */ |
436 | enum class KeyModifier { |
437 | CapsLock = 33, |
438 | Control = 34, |
439 | Shift = 35, |
440 | Meta = 36, |
441 | Alt = 37, |
442 | }; // enum class KeyModifier |
443 | /* Enumerates different platform-independent virtual keys on a physical keyboard whose input via keyboard may or may not produce characters. */ |
444 | enum class VirtualKey { |
445 | Shift = 35, |
446 | Control = 34, |
447 | Alternate = 38, |
448 | Meta = 36, |
449 | Command = 39, |
450 | Cancel = 40, |
451 | Help = 41, |
452 | Backspace = 42, |
453 | Tab = 3, |
454 | Clear = 43, |
455 | Enter = 44, |
456 | Pause = 45, |
457 | Escape = 46, |
458 | PageUp = 47, |
459 | PageDown = 48, |
460 | End = 49, |
461 | Home = 50, |
462 | LeftArrow = 51, |
463 | UpArrow = 52, |
464 | RightArrow = 53, |
465 | DownArrow = 54, |
466 | Insert = 55, |
467 | Delete = 56, |
468 | Space = 57, |
469 | Semicolon = 58, |
470 | Equals = 59, |
471 | Return = 60, |
472 | NumberPad0 = 61, |
473 | NumberPad1 = 62, |
474 | NumberPad2 = 63, |
475 | NumberPad3 = 64, |
476 | NumberPad4 = 65, |
477 | NumberPad5 = 66, |
478 | NumberPad6 = 67, |
479 | NumberPad7 = 68, |
480 | NumberPad8 = 69, |
481 | NumberPad9 = 70, |
482 | NumberPadMultiply = 71, |
483 | NumberPadAdd = 72, |
484 | NumberPadSeparator = 73, |
485 | NumberPadSubtract = 74, |
486 | NumberPadDecimal = 75, |
487 | NumberPadDivide = 76, |
488 | Function1 = 77, |
489 | Function2 = 78, |
490 | Function3 = 79, |
491 | Function4 = 80, |
492 | Function5 = 81, |
493 | Function6 = 82, |
494 | Function7 = 83, |
495 | Function8 = 84, |
496 | Function9 = 85, |
497 | Function10 = 86, |
498 | Function11 = 87, |
499 | Function12 = 88, |
500 | }; // enum class VirtualKey |
501 | /* Enumerates different ways of interacting with a keyboard device. 'InsertByKey' implies that a separate KeyDown and KeyUp event are produced for each combining character sequence, regardless of the actual keystrokes required to produce the character sequence. */ |
502 | enum class KeyboardInteractionType { |
503 | KeyPress = 89, |
504 | KeyRelease = 90, |
505 | InsertByKey = 91, |
506 | }; // enum class KeyboardInteractionType |
507 | /* A single step in a key sequence. A step can contain a key up/down of a virtual key, or a sequence of Unicode code points that are delivered to the page at grapheme cluster boundaries. Either a 'key' or 'text' property must be specified. */ |
508 | class KeyboardInteraction : public JSON::ObjectBase { |
509 | public: |
510 | enum { |
511 | NoFieldsSet = 0, |
512 | TypeSet = 1 << 0, |
513 | AllFieldsSet = (TypeSet) |
514 | }; |
515 | |
516 | template<int STATE> |
517 | class Builder { |
518 | private: |
519 | RefPtr<JSON::Object> m_result; |
520 | |
521 | template<int STEP> Builder<STATE | STEP>& castState() |
522 | { |
523 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
524 | } |
525 | |
526 | Builder(Ref</*KeyboardInteraction*/JSON::Object>&& object) |
527 | : m_result(WTFMove(object)) |
528 | { |
529 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
530 | } |
531 | friend class KeyboardInteraction; |
532 | public: |
533 | |
534 | Builder<STATE | TypeSet>& setType(Inspector::Protocol::Automation::KeyboardInteractionType value) |
535 | { |
536 | COMPILE_ASSERT(!(STATE & TypeSet), property_type_already_set); |
537 | m_result->setString("type"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
538 | return castState<TypeSet>(); |
539 | } |
540 | |
541 | Ref<KeyboardInteraction> release() |
542 | { |
543 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
544 | COMPILE_ASSERT(sizeof(KeyboardInteraction) == sizeof(JSON::Object), cannot_cast); |
545 | |
546 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
547 | auto result = WTFMove(*reinterpret_cast<Ref<KeyboardInteraction>*>(&jsonResult)); |
548 | return result; |
549 | } |
550 | }; |
551 | |
552 | /* |
553 | * Synthetic constructor: |
554 | * Ref<KeyboardInteraction> result = KeyboardInteraction::create() |
555 | * .setType(...) |
556 | * .release(); |
557 | */ |
558 | static Builder<NoFieldsSet> create() |
559 | { |
560 | return Builder<NoFieldsSet>(JSON::Object::create()); |
561 | } |
562 | |
563 | void setKey(Inspector::Protocol::Automation::VirtualKey value) |
564 | { |
565 | JSON::ObjectBase::setString("key"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
566 | } |
567 | |
568 | void setText(const String& value) |
569 | { |
570 | JSON::ObjectBase::setString("text"_s , value); |
571 | } |
572 | }; |
573 | |
574 | class Cookie : public JSON::ObjectBase { |
575 | public: |
576 | enum { |
577 | NoFieldsSet = 0, |
578 | NameSet = 1 << 0, |
579 | ValueSet = 1 << 1, |
580 | DomainSet = 1 << 2, |
581 | PathSet = 1 << 3, |
582 | ExpiresSet = 1 << 4, |
583 | SizeSet = 1 << 5, |
584 | HttpOnlySet = 1 << 6, |
585 | SecureSet = 1 << 7, |
586 | SessionSet = 1 << 8, |
587 | AllFieldsSet = (NameSet | ValueSet | DomainSet | PathSet | ExpiresSet | SizeSet | HttpOnlySet | SecureSet | SessionSet) |
588 | }; |
589 | |
590 | template<int STATE> |
591 | class Builder { |
592 | private: |
593 | RefPtr<JSON::Object> m_result; |
594 | |
595 | template<int STEP> Builder<STATE | STEP>& castState() |
596 | { |
597 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
598 | } |
599 | |
600 | Builder(Ref</*Cookie*/JSON::Object>&& object) |
601 | : m_result(WTFMove(object)) |
602 | { |
603 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
604 | } |
605 | friend class Cookie; |
606 | public: |
607 | |
608 | Builder<STATE | NameSet>& setName(const String& value) |
609 | { |
610 | COMPILE_ASSERT(!(STATE & NameSet), property_name_already_set); |
611 | m_result->setString("name"_s , value); |
612 | return castState<NameSet>(); |
613 | } |
614 | |
615 | Builder<STATE | ValueSet>& setValue(const String& value) |
616 | { |
617 | COMPILE_ASSERT(!(STATE & ValueSet), property_value_already_set); |
618 | m_result->setString("value"_s , value); |
619 | return castState<ValueSet>(); |
620 | } |
621 | |
622 | Builder<STATE | DomainSet>& setDomain(const String& value) |
623 | { |
624 | COMPILE_ASSERT(!(STATE & DomainSet), property_domain_already_set); |
625 | m_result->setString("domain"_s , value); |
626 | return castState<DomainSet>(); |
627 | } |
628 | |
629 | Builder<STATE | PathSet>& setPath(const String& value) |
630 | { |
631 | COMPILE_ASSERT(!(STATE & PathSet), property_path_already_set); |
632 | m_result->setString("path"_s , value); |
633 | return castState<PathSet>(); |
634 | } |
635 | |
636 | Builder<STATE | ExpiresSet>& setExpires(double value) |
637 | { |
638 | COMPILE_ASSERT(!(STATE & ExpiresSet), property_expires_already_set); |
639 | m_result->setDouble("expires"_s , value); |
640 | return castState<ExpiresSet>(); |
641 | } |
642 | |
643 | Builder<STATE | SizeSet>& setSize(int value) |
644 | { |
645 | COMPILE_ASSERT(!(STATE & SizeSet), property_size_already_set); |
646 | m_result->setInteger("size"_s , value); |
647 | return castState<SizeSet>(); |
648 | } |
649 | |
650 | Builder<STATE | HttpOnlySet>& setHttpOnly(bool value) |
651 | { |
652 | COMPILE_ASSERT(!(STATE & HttpOnlySet), property_httpOnly_already_set); |
653 | m_result->setBoolean("httpOnly"_s , value); |
654 | return castState<HttpOnlySet>(); |
655 | } |
656 | |
657 | Builder<STATE | SecureSet>& setSecure(bool value) |
658 | { |
659 | COMPILE_ASSERT(!(STATE & SecureSet), property_secure_already_set); |
660 | m_result->setBoolean("secure"_s , value); |
661 | return castState<SecureSet>(); |
662 | } |
663 | |
664 | Builder<STATE | SessionSet>& setSession(bool value) |
665 | { |
666 | COMPILE_ASSERT(!(STATE & SessionSet), property_session_already_set); |
667 | m_result->setBoolean("session"_s , value); |
668 | return castState<SessionSet>(); |
669 | } |
670 | |
671 | Ref<Cookie> release() |
672 | { |
673 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
674 | COMPILE_ASSERT(sizeof(Cookie) == sizeof(JSON::Object), cannot_cast); |
675 | |
676 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
677 | auto result = WTFMove(*reinterpret_cast<Ref<Cookie>*>(&jsonResult)); |
678 | return result; |
679 | } |
680 | }; |
681 | |
682 | /* |
683 | * Synthetic constructor: |
684 | * Ref<Cookie> result = Cookie::create() |
685 | * .setName(...) |
686 | * .setValue(...) |
687 | * .setDomain(...) |
688 | * .setPath(...) |
689 | * .setExpires(...) |
690 | * .setSize(...) |
691 | * .setHttpOnly(...) |
692 | * .setSecure(...) |
693 | * .setSession(...) |
694 | * .release(); |
695 | */ |
696 | static Builder<NoFieldsSet> create() |
697 | { |
698 | return Builder<NoFieldsSet>(JSON::Object::create()); |
699 | } |
700 | }; |
701 | |
702 | /* Enumerates different permissions that must be obtained in order to use privileged APIs. */ |
703 | enum class SessionPermission { |
704 | GetUserMedia = 92, |
705 | }; // enum class SessionPermission |
706 | class SessionPermissionData : public JSON::ObjectBase { |
707 | public: |
708 | enum { |
709 | NoFieldsSet = 0, |
710 | PermissionSet = 1 << 0, |
711 | ValueSet = 1 << 1, |
712 | AllFieldsSet = (PermissionSet | ValueSet) |
713 | }; |
714 | |
715 | template<int STATE> |
716 | class Builder { |
717 | private: |
718 | RefPtr<JSON::Object> m_result; |
719 | |
720 | template<int STEP> Builder<STATE | STEP>& castState() |
721 | { |
722 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
723 | } |
724 | |
725 | Builder(Ref</*SessionPermissionData*/JSON::Object>&& object) |
726 | : m_result(WTFMove(object)) |
727 | { |
728 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
729 | } |
730 | friend class SessionPermissionData; |
731 | public: |
732 | |
733 | Builder<STATE | PermissionSet>& setPermission(Inspector::Protocol::Automation::SessionPermission value) |
734 | { |
735 | COMPILE_ASSERT(!(STATE & PermissionSet), property_permission_already_set); |
736 | m_result->setString("permission"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
737 | return castState<PermissionSet>(); |
738 | } |
739 | |
740 | Builder<STATE | ValueSet>& setValue(bool value) |
741 | { |
742 | COMPILE_ASSERT(!(STATE & ValueSet), property_value_already_set); |
743 | m_result->setBoolean("value"_s , value); |
744 | return castState<ValueSet>(); |
745 | } |
746 | |
747 | Ref<SessionPermissionData> release() |
748 | { |
749 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
750 | COMPILE_ASSERT(sizeof(SessionPermissionData) == sizeof(JSON::Object), cannot_cast); |
751 | |
752 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
753 | auto result = WTFMove(*reinterpret_cast<Ref<SessionPermissionData>*>(&jsonResult)); |
754 | return result; |
755 | } |
756 | }; |
757 | |
758 | /* |
759 | * Synthetic constructor: |
760 | * Ref<SessionPermissionData> result = SessionPermissionData::create() |
761 | * .setPermission(...) |
762 | * .setValue(...) |
763 | * .release(); |
764 | */ |
765 | static Builder<NoFieldsSet> create() |
766 | { |
767 | return Builder<NoFieldsSet>(JSON::Object::create()); |
768 | } |
769 | }; |
770 | |
771 | /* The type of an input source. This determines which state properties are applicable to the input source. The 'Null' input source type has no properties, only a duration. This can extend the effective wait for a tick. */ |
772 | enum class InputSourceType { |
773 | Null = 93, |
774 | Mouse = 94, |
775 | Keyboard = 95, |
776 | Touch = 96, |
777 | }; // enum class InputSourceType |
778 | class InputSource : public JSON::ObjectBase { |
779 | public: |
780 | enum { |
781 | NoFieldsSet = 0, |
782 | SourceIdSet = 1 << 0, |
783 | SourceTypeSet = 1 << 1, |
784 | AllFieldsSet = (SourceIdSet | SourceTypeSet) |
785 | }; |
786 | |
787 | template<int STATE> |
788 | class Builder { |
789 | private: |
790 | RefPtr<JSON::Object> m_result; |
791 | |
792 | template<int STEP> Builder<STATE | STEP>& castState() |
793 | { |
794 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
795 | } |
796 | |
797 | Builder(Ref</*InputSource*/JSON::Object>&& object) |
798 | : m_result(WTFMove(object)) |
799 | { |
800 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
801 | } |
802 | friend class InputSource; |
803 | public: |
804 | |
805 | Builder<STATE | SourceIdSet>& setSourceId(const String& value) |
806 | { |
807 | COMPILE_ASSERT(!(STATE & SourceIdSet), property_sourceId_already_set); |
808 | m_result->setString("sourceId"_s , value); |
809 | return castState<SourceIdSet>(); |
810 | } |
811 | |
812 | Builder<STATE | SourceTypeSet>& setSourceType(Inspector::Protocol::Automation::InputSourceType value) |
813 | { |
814 | COMPILE_ASSERT(!(STATE & SourceTypeSet), property_sourceType_already_set); |
815 | m_result->setString("sourceType"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
816 | return castState<SourceTypeSet>(); |
817 | } |
818 | |
819 | Ref<InputSource> release() |
820 | { |
821 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
822 | COMPILE_ASSERT(sizeof(InputSource) == sizeof(JSON::Object), cannot_cast); |
823 | |
824 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
825 | auto result = WTFMove(*reinterpret_cast<Ref<InputSource>*>(&jsonResult)); |
826 | return result; |
827 | } |
828 | }; |
829 | |
830 | /* |
831 | * Synthetic constructor: |
832 | * Ref<InputSource> result = InputSource::create() |
833 | * .setSourceId(...) |
834 | * .setSourceType(...) |
835 | * .release(); |
836 | */ |
837 | static Builder<NoFieldsSet> create() |
838 | { |
839 | return Builder<NoFieldsSet>(JSON::Object::create()); |
840 | } |
841 | }; |
842 | |
843 | /* A set of input source states to which all applicable input sources must transition before further steps may be processed. If an input source does not have a corresponding state in a step, its state assumed to be 'released' for that step. */ |
844 | class InteractionStep : public JSON::ObjectBase { |
845 | public: |
846 | enum { |
847 | NoFieldsSet = 0, |
848 | AllFieldsSet = 0 |
849 | }; |
850 | |
851 | template<int STATE> |
852 | class Builder { |
853 | private: |
854 | RefPtr<JSON::Object> m_result; |
855 | |
856 | template<int STEP> Builder<STATE | STEP>& castState() |
857 | { |
858 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
859 | } |
860 | |
861 | Builder(Ref</*InteractionStep*/JSON::Object>&& object) |
862 | : m_result(WTFMove(object)) |
863 | { |
864 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
865 | } |
866 | friend class InteractionStep; |
867 | public: |
868 | |
869 | Ref<InteractionStep> release() |
870 | { |
871 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
872 | COMPILE_ASSERT(sizeof(InteractionStep) == sizeof(JSON::Object), cannot_cast); |
873 | |
874 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
875 | auto result = WTFMove(*reinterpret_cast<Ref<InteractionStep>*>(&jsonResult)); |
876 | return result; |
877 | } |
878 | }; |
879 | |
880 | /* |
881 | * Synthetic constructor: |
882 | * Ref<InteractionStep> result = InteractionStep::create() |
883 | * .release(); |
884 | */ |
885 | static Builder<NoFieldsSet> create() |
886 | { |
887 | return Builder<NoFieldsSet>(JSON::Object::create()); |
888 | } |
889 | |
890 | void setStates(RefPtr<JSON::ArrayOf<Inspector::Protocol::Automation::InputSourceState>> value) |
891 | { |
892 | JSON::ObjectBase::setArray("states"_s , WTFMove(value)); |
893 | } |
894 | }; |
895 | |
896 | /* Enumerates different origin types that can be used in mouse move interactions. */ |
897 | enum class MouseMoveOrigin { |
898 | Viewport = 1, |
899 | Pointer = 97, |
900 | Element = 98, |
901 | }; // enum class MouseMoveOrigin |
902 | /* A new state for a specific input source. All state-related fields are optional and must be applicable to the InputSource referenced by 'sourceId'. If no state-related fields are specified, the state is assumed to remain the same as in the previous step (i.e., 'sustained'). */ |
903 | class InputSourceState : public JSON::ObjectBase { |
904 | public: |
905 | enum { |
906 | NoFieldsSet = 0, |
907 | SourceIdSet = 1 << 0, |
908 | AllFieldsSet = (SourceIdSet) |
909 | }; |
910 | |
911 | template<int STATE> |
912 | class Builder { |
913 | private: |
914 | RefPtr<JSON::Object> m_result; |
915 | |
916 | template<int STEP> Builder<STATE | STEP>& castState() |
917 | { |
918 | return *reinterpret_cast<Builder<STATE | STEP>*>(this); |
919 | } |
920 | |
921 | Builder(Ref</*InputSourceState*/JSON::Object>&& object) |
922 | : m_result(WTFMove(object)) |
923 | { |
924 | COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state); |
925 | } |
926 | friend class InputSourceState; |
927 | public: |
928 | |
929 | Builder<STATE | SourceIdSet>& setSourceId(const String& value) |
930 | { |
931 | COMPILE_ASSERT(!(STATE & SourceIdSet), property_sourceId_already_set); |
932 | m_result->setString("sourceId"_s , value); |
933 | return castState<SourceIdSet>(); |
934 | } |
935 | |
936 | Ref<InputSourceState> release() |
937 | { |
938 | COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready); |
939 | COMPILE_ASSERT(sizeof(InputSourceState) == sizeof(JSON::Object), cannot_cast); |
940 | |
941 | Ref<JSON::Object> jsonResult = m_result.releaseNonNull(); |
942 | auto result = WTFMove(*reinterpret_cast<Ref<InputSourceState>*>(&jsonResult)); |
943 | return result; |
944 | } |
945 | }; |
946 | |
947 | /* |
948 | * Synthetic constructor: |
949 | * Ref<InputSourceState> result = InputSourceState::create() |
950 | * .setSourceId(...) |
951 | * .release(); |
952 | */ |
953 | static Builder<NoFieldsSet> create() |
954 | { |
955 | return Builder<NoFieldsSet>(JSON::Object::create()); |
956 | } |
957 | |
958 | void setPressedCharKey(const String& value) |
959 | { |
960 | JSON::ObjectBase::setString("pressedCharKey"_s , value); |
961 | } |
962 | |
963 | void setPressedVirtualKeys(RefPtr<JSON::ArrayOf<Inspector::Protocol::Automation::VirtualKey>> value) |
964 | { |
965 | JSON::ObjectBase::setArray("pressedVirtualKeys"_s , WTFMove(value)); |
966 | } |
967 | |
968 | void setPressedButton(Inspector::Protocol::Automation::MouseButton value) |
969 | { |
970 | JSON::ObjectBase::setString("pressedButton"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
971 | } |
972 | |
973 | void setOrigin(Inspector::Protocol::Automation::MouseMoveOrigin value) |
974 | { |
975 | JSON::ObjectBase::setString("origin"_s , Inspector::Protocol::AutomationHelpers::getEnumConstantValue(value)); |
976 | } |
977 | |
978 | void setNodeHandle(const String& value) |
979 | { |
980 | JSON::ObjectBase::setString("nodeHandle"_s , value); |
981 | } |
982 | |
983 | void setLocation(RefPtr<Inspector::Protocol::Automation::Point> value) |
984 | { |
985 | JSON::ObjectBase::setObject("location"_s , WTFMove(value)); |
986 | } |
987 | |
988 | void setDuration(int value) |
989 | { |
990 | JSON::ObjectBase::setInteger("duration"_s , value); |
991 | } |
992 | }; |
993 | |
994 | } // Automation |
995 | |
996 | |
997 | |
998 | namespace AutomationHelpers { |
999 | |
1000 | template<typename ProtocolEnumType> |
1001 | Optional<ProtocolEnumType> parseEnumValueFromString(const String&); |
1002 | |
1003 | // Enums in the 'Automation' Domain |
1004 | template<> |
1005 | Optional<Inspector::Protocol::Automation::CoordinateSystem> parseEnumValueFromString<Inspector::Protocol::Automation::CoordinateSystem>(const String&); |
1006 | template<> |
1007 | Optional<Inspector::Protocol::Automation::BrowsingContextPresentation> parseEnumValueFromString<Inspector::Protocol::Automation::BrowsingContextPresentation>(const String&); |
1008 | template<> |
1009 | Optional<Inspector::Protocol::Automation::ErrorMessage> parseEnumValueFromString<Inspector::Protocol::Automation::ErrorMessage>(const String&); |
1010 | template<> |
1011 | Optional<Inspector::Protocol::Automation::PageLoadStrategy> parseEnumValueFromString<Inspector::Protocol::Automation::PageLoadStrategy>(const String&); |
1012 | template<> |
1013 | Optional<Inspector::Protocol::Automation::MouseInteraction> parseEnumValueFromString<Inspector::Protocol::Automation::MouseInteraction>(const String&); |
1014 | template<> |
1015 | Optional<Inspector::Protocol::Automation::MouseButton> parseEnumValueFromString<Inspector::Protocol::Automation::MouseButton>(const String&); |
1016 | template<> |
1017 | Optional<Inspector::Protocol::Automation::KeyModifier> parseEnumValueFromString<Inspector::Protocol::Automation::KeyModifier>(const String&); |
1018 | template<> |
1019 | Optional<Inspector::Protocol::Automation::VirtualKey> parseEnumValueFromString<Inspector::Protocol::Automation::VirtualKey>(const String&); |
1020 | template<> |
1021 | Optional<Inspector::Protocol::Automation::KeyboardInteractionType> parseEnumValueFromString<Inspector::Protocol::Automation::KeyboardInteractionType>(const String&); |
1022 | template<> |
1023 | Optional<Inspector::Protocol::Automation::SessionPermission> parseEnumValueFromString<Inspector::Protocol::Automation::SessionPermission>(const String&); |
1024 | template<> |
1025 | Optional<Inspector::Protocol::Automation::InputSourceType> parseEnumValueFromString<Inspector::Protocol::Automation::InputSourceType>(const String&); |
1026 | template<> |
1027 | Optional<Inspector::Protocol::Automation::MouseMoveOrigin> parseEnumValueFromString<Inspector::Protocol::Automation::MouseMoveOrigin>(const String&); |
1028 | |
1029 | } // namespace AutomationHelpers |
1030 | |
1031 | } // namespace Protocol |
1032 | |
1033 | } // namespace Inspector |
1034 | |
1035 | namespace WTF { |
1036 | |
1037 | template<typename T> struct DefaultHash; |
1038 | |
1039 | // Hash declarations in the 'Automation' Domain |
1040 | template<> |
1041 | struct DefaultHash<Inspector::Protocol::Automation::CoordinateSystem> { |
1042 | typedef IntHash<Inspector::Protocol::Automation::CoordinateSystem> Hash; |
1043 | }; |
1044 | template<> |
1045 | struct DefaultHash<Inspector::Protocol::Automation::BrowsingContextPresentation> { |
1046 | typedef IntHash<Inspector::Protocol::Automation::BrowsingContextPresentation> Hash; |
1047 | }; |
1048 | template<> |
1049 | struct DefaultHash<Inspector::Protocol::Automation::ErrorMessage> { |
1050 | typedef IntHash<Inspector::Protocol::Automation::ErrorMessage> Hash; |
1051 | }; |
1052 | template<> |
1053 | struct DefaultHash<Inspector::Protocol::Automation::PageLoadStrategy> { |
1054 | typedef IntHash<Inspector::Protocol::Automation::PageLoadStrategy> Hash; |
1055 | }; |
1056 | template<> |
1057 | struct DefaultHash<Inspector::Protocol::Automation::MouseInteraction> { |
1058 | typedef IntHash<Inspector::Protocol::Automation::MouseInteraction> Hash; |
1059 | }; |
1060 | template<> |
1061 | struct DefaultHash<Inspector::Protocol::Automation::MouseButton> { |
1062 | typedef IntHash<Inspector::Protocol::Automation::MouseButton> Hash; |
1063 | }; |
1064 | template<> |
1065 | struct DefaultHash<Inspector::Protocol::Automation::KeyModifier> { |
1066 | typedef IntHash<Inspector::Protocol::Automation::KeyModifier> Hash; |
1067 | }; |
1068 | template<> |
1069 | struct DefaultHash<Inspector::Protocol::Automation::VirtualKey> { |
1070 | typedef IntHash<Inspector::Protocol::Automation::VirtualKey> Hash; |
1071 | }; |
1072 | template<> |
1073 | struct DefaultHash<Inspector::Protocol::Automation::KeyboardInteractionType> { |
1074 | typedef IntHash<Inspector::Protocol::Automation::KeyboardInteractionType> Hash; |
1075 | }; |
1076 | template<> |
1077 | struct DefaultHash<Inspector::Protocol::Automation::SessionPermission> { |
1078 | typedef IntHash<Inspector::Protocol::Automation::SessionPermission> Hash; |
1079 | }; |
1080 | template<> |
1081 | struct DefaultHash<Inspector::Protocol::Automation::InputSourceType> { |
1082 | typedef IntHash<Inspector::Protocol::Automation::InputSourceType> Hash; |
1083 | }; |
1084 | template<> |
1085 | struct DefaultHash<Inspector::Protocol::Automation::MouseMoveOrigin> { |
1086 | typedef IntHash<Inspector::Protocol::Automation::MouseMoveOrigin> Hash; |
1087 | }; |
1088 | |
1089 | } // namespace WTF |
1090 | |