]> git.sesse.net Git - casparcg/blob - dependencies64/cef/include/internal/cef_types_wrappers.h
* Merged html producer and updated to latest CEF version (does not have satisfactory...
[casparcg] / dependencies64 / cef / include / internal / cef_types_wrappers.h
1 // Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
2 //
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
5 // met:
6 //
7 //    * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 //    * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
12 // distribution.
13 //    * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 #ifndef CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
31 #define CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_
32 #pragma once
33
34 #include "include/internal/cef_string.h"
35 #include "include/internal/cef_string_list.h"
36 #include "include/internal/cef_types.h"
37
38 ///
39 // Template class that provides common functionality for CEF structure wrapping.
40 ///
41 template <class traits>
42 class CefStructBase : public traits::struct_type {
43  public:
44   typedef typename traits::struct_type struct_type;
45
46   CefStructBase() : attached_to_(NULL) {
47     Init();
48   }
49   virtual ~CefStructBase() {
50     // Only clear this object's data if it isn't currently attached to a
51     // structure.
52     if (!attached_to_)
53       Clear(this);
54   }
55
56   CefStructBase(const CefStructBase& r) {
57     Init();
58     *this = r;
59   }
60   CefStructBase(const struct_type& r) {  // NOLINT(runtime/explicit)
61     Init();
62     *this = r;
63   }
64
65   ///
66   // Clear this object's values.
67   ///
68   void Reset() {
69     Clear(this);
70     Init();
71   }
72
73   ///
74   // Attach to the source structure's existing values. DetachTo() can be called
75   // to insert the values back into the existing structure.
76   ///
77   void AttachTo(struct_type& source) {
78     // Only clear this object's data if it isn't currently attached to a
79     // structure.
80     if (!attached_to_)
81       Clear(this);
82
83     // This object is now attached to the new structure.
84     attached_to_ = &source;
85
86     // Transfer ownership of the values from the source structure.
87     memcpy(static_cast<struct_type*>(this), &source, sizeof(struct_type));
88   }
89
90   ///
91   // Relinquish ownership of values to the target structure.
92   ///
93   void DetachTo(struct_type& target) {
94     if (attached_to_ != &target) {
95       // Clear the target structure's values only if we are not currently
96       // attached to that structure.
97       Clear(&target);
98     }
99
100     // Transfer ownership of the values to the target structure.
101     memcpy(&target, static_cast<struct_type*>(this), sizeof(struct_type));
102
103     // Remove the references from this object.
104     Init();
105   }
106
107   ///
108   // Set this object's values. If |copy| is true the source structure's values
109   // will be copied instead of referenced.
110   ///
111   void Set(const struct_type& source, bool copy) {
112     traits::set(&source, this, copy);
113   }
114
115   CefStructBase& operator=(const CefStructBase& s) {
116     return operator=(static_cast<const struct_type&>(s));
117   }
118
119   CefStructBase& operator=(const struct_type& s) {
120     Set(s, true);
121     return *this;
122   }
123
124  protected:
125   void Init() {
126     memset(static_cast<struct_type*>(this), 0, sizeof(struct_type));
127     attached_to_ = NULL;
128     traits::init(this);
129   }
130
131   static void Clear(struct_type* s) { traits::clear(s); }
132
133   struct_type* attached_to_;
134 };
135
136
137 struct CefPointTraits {
138   typedef cef_point_t struct_type;
139
140   static inline void init(struct_type* s) {}
141   static inline void clear(struct_type* s) {}
142
143   static inline void set(const struct_type* src, struct_type* target,
144       bool copy) {
145     *target = *src;
146   }
147 };
148
149 ///
150 // Class representing a point.
151 ///
152 class CefPoint : public CefStructBase<CefPointTraits> {
153  public:
154   typedef CefStructBase<CefPointTraits> parent;
155
156   CefPoint() : parent() {}
157   CefPoint(const cef_point_t& r) : parent(r) {}  // NOLINT(runtime/explicit)
158   CefPoint(const CefPoint& r) : parent(r) {}  // NOLINT(runtime/explicit)
159   CefPoint(int x, int y) : parent() {
160     Set(x, y);
161   }
162
163   bool IsEmpty() const { return x <= 0 && y <= 0; }
164   void Set(int x, int y) {
165     this->x = x, this->y = y;
166   }
167 };
168
169 inline bool operator==(const CefPoint& a, const CefPoint& b) {
170   return a.x == b.x && a.y == b.y;
171 }
172
173 inline bool operator!=(const CefPoint& a, const CefPoint& b) {
174   return !(a == b);
175 }
176
177
178 struct CefRectTraits {
179   typedef cef_rect_t struct_type;
180
181   static inline void init(struct_type* s) {}
182   static inline void clear(struct_type* s) {}
183
184   static inline void set(const struct_type* src, struct_type* target,
185       bool copy) {
186     *target = *src;
187   }
188 };
189
190 ///
191 // Class representing a rectangle.
192 ///
193 class CefRect : public CefStructBase<CefRectTraits> {
194  public:
195   typedef CefStructBase<CefRectTraits> parent;
196
197   CefRect() : parent() {}
198   CefRect(const cef_rect_t& r) : parent(r) {}  // NOLINT(runtime/explicit)
199   CefRect(const CefRect& r) : parent(r) {}  // NOLINT(runtime/explicit)
200   CefRect(int x, int y, int width, int height) : parent() {
201     Set(x, y, width, height);
202   }
203
204   bool IsEmpty() const { return width <= 0 || height <= 0; }
205   void Set(int x, int y, int width, int height) {
206     this->x = x, this->y = y, this->width = width, this->height = height;
207   }
208 };
209
210 inline bool operator==(const CefRect& a, const CefRect& b) {
211   return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height;
212 }
213
214 inline bool operator!=(const CefRect& a, const CefRect& b) {
215   return !(a == b);
216 }
217
218
219 struct CefSizeTraits {
220   typedef cef_size_t struct_type;
221
222   static inline void init(struct_type* s) {}
223   static inline void clear(struct_type* s) {}
224
225   static inline void set(const struct_type* src, struct_type* target,
226       bool copy) {
227     *target = *src;
228   }
229 };
230
231 ///
232 // Class representing a size.
233 ///
234 class CefSize : public CefStructBase<CefSizeTraits> {
235  public:
236   typedef CefStructBase<CefSizeTraits> parent;
237
238   CefSize() : parent() {}
239   CefSize(const cef_size_t& r) : parent(r) {}  // NOLINT(runtime/explicit)
240   CefSize(const CefSize& r) : parent(r) {}  // NOLINT(runtime/explicit)
241   CefSize(int width, int height) : parent() {
242     Set(width, height);
243   }
244
245   bool IsEmpty() const { return width <= 0 || height <= 0; }
246   void Set(int width, int height) {
247     this->width = width, this->height = height;
248   }
249 };
250
251 inline bool operator==(const CefSize& a, const CefSize& b) {
252   return a.width == b.width && a.height == b.height;
253 }
254
255 inline bool operator!=(const CefSize& a, const CefSize& b) {
256   return !(a == b);
257 }
258
259
260 struct CefScreenInfoTraits {
261   typedef cef_screen_info_t struct_type;
262
263   static inline void init(struct_type* s) {}
264
265   static inline void clear(struct_type* s) {}
266
267   static inline void set(const struct_type* src, struct_type* target,
268       bool copy) {
269     target->device_scale_factor = src->device_scale_factor;
270     target->depth = src->depth;
271     target->depth_per_component = src->depth_per_component;
272     target->is_monochrome = src->is_monochrome;
273     target->rect = src->rect;
274     target->available_rect = src->available_rect;
275   }
276 };
277
278 ///
279 // Class representing the virtual screen information for use when window
280 // rendering is disabled.
281 ///
282 class CefScreenInfo : public CefStructBase<CefScreenInfoTraits> {
283  public:
284   typedef CefStructBase<CefScreenInfoTraits> parent;
285
286   CefScreenInfo() : parent() {}
287   CefScreenInfo(const cef_screen_info_t& r) : parent(r) {}  // NOLINT(runtime/explicit)
288   CefScreenInfo(const CefScreenInfo& r) : parent(r) {}  // NOLINT(runtime/explicit)
289   CefScreenInfo(float device_scale_factor,
290                 int depth,
291                 int depth_per_component,
292                 bool is_monochrome,
293                 const CefRect& rect,
294                 const CefRect& available_rect) : parent() {
295     Set(device_scale_factor, depth, depth_per_component,
296         is_monochrome, rect, available_rect);
297   }
298
299   void Set(float device_scale_factor,
300            int depth,
301            int depth_per_component,
302            bool is_monochrome,
303            const CefRect& rect,
304            const CefRect& available_rect) {
305     this->device_scale_factor = device_scale_factor;
306     this->depth = depth;
307     this->depth_per_component = depth_per_component;
308     this->is_monochrome = is_monochrome;
309     this->rect = rect;
310     this->available_rect = available_rect;
311   }
312 };
313
314
315 struct CefKeyEventTraits {
316   typedef cef_key_event_t struct_type;
317
318   static inline void init(struct_type* s) {}
319
320   static inline void clear(struct_type* s) {}
321
322   static inline void set(const struct_type* src, struct_type* target,
323       bool copy) {
324     target->type = src->type;
325     target->modifiers = src->modifiers;
326     target->windows_key_code = src->windows_key_code;
327     target->native_key_code = src->native_key_code;
328     target->is_system_key = src->is_system_key;
329     target->character = src->character;
330     target->unmodified_character = src->unmodified_character;
331     target->focus_on_editable_field = src->focus_on_editable_field;
332   }
333 };
334
335 ///
336 // Class representing a a keyboard event.
337 ///
338 typedef CefStructBase<CefKeyEventTraits> CefKeyEvent;
339
340
341 struct CefMouseEventTraits {
342   typedef cef_mouse_event_t struct_type;
343
344   static inline void init(struct_type* s) {}
345
346   static inline void clear(struct_type* s) {}
347
348   static inline void set(const struct_type* src, struct_type* target,
349       bool copy) {
350     target->x = src->x;
351     target->y = src->y;
352     target->modifiers = src->modifiers;
353   }
354 };
355
356 ///
357 // Class representing a mouse event.
358 ///
359 typedef CefStructBase<CefMouseEventTraits> CefMouseEvent;
360
361
362 struct CefPopupFeaturesTraits {
363   typedef cef_popup_features_t struct_type;
364
365   static inline void init(struct_type* s) {
366     s->menuBarVisible = true;
367     s->statusBarVisible = true;
368     s->toolBarVisible = true;
369     s->locationBarVisible = true;
370     s->scrollbarsVisible = true;
371     s->resizable = true;
372   }
373
374   static inline void clear(struct_type* s) {
375     if (s->additionalFeatures)
376       cef_string_list_free(s->additionalFeatures);
377   }
378
379   static inline void set(const struct_type* src, struct_type* target,
380       bool copy) {
381     if (target->additionalFeatures)
382       cef_string_list_free(target->additionalFeatures);
383     target->additionalFeatures = src->additionalFeatures ?
384         cef_string_list_copy(src->additionalFeatures) : NULL;
385
386     target->x = src->x;
387     target->xSet = src->xSet;
388     target->y = src->y;
389     target->ySet = src->ySet;
390     target->width = src->width;
391     target->widthSet = src->widthSet;
392     target->height = src->height;
393     target->heightSet = src->heightSet;
394     target->menuBarVisible = src->menuBarVisible;
395     target->statusBarVisible = src->statusBarVisible;
396     target->toolBarVisible = src->toolBarVisible;
397     target->locationBarVisible = src->locationBarVisible;
398     target->scrollbarsVisible = src->scrollbarsVisible;
399     target->resizable = src->resizable;
400     target->fullscreen = src->fullscreen;
401     target->dialog = src->dialog;
402   }
403 };
404
405 ///
406 // Class representing popup window features.
407 ///
408 typedef CefStructBase<CefPopupFeaturesTraits> CefPopupFeatures;
409
410
411 struct CefSettingsTraits {
412   typedef cef_settings_t struct_type;
413
414   static inline void init(struct_type* s) {
415     s->size = sizeof(struct_type);
416   }
417
418   static inline void clear(struct_type* s) {
419     cef_string_clear(&s->browser_subprocess_path);
420     cef_string_clear(&s->cache_path);
421     cef_string_clear(&s->user_data_path);
422     cef_string_clear(&s->user_agent);
423     cef_string_clear(&s->product_version);
424     cef_string_clear(&s->locale);
425     cef_string_clear(&s->log_file);
426     cef_string_clear(&s->javascript_flags);
427     cef_string_clear(&s->resources_dir_path);
428     cef_string_clear(&s->locales_dir_path);
429     cef_string_clear(&s->accept_language_list);
430   }
431
432   static inline void set(const struct_type* src, struct_type* target,
433       bool copy) {
434     target->single_process = src->single_process;
435     target->no_sandbox = src->no_sandbox;
436     cef_string_set(src->browser_subprocess_path.str,
437         src->browser_subprocess_path.length,
438         &target->browser_subprocess_path, copy);
439     target->multi_threaded_message_loop = src->multi_threaded_message_loop;
440     target->windowless_rendering_enabled = src->windowless_rendering_enabled;
441     target->command_line_args_disabled = src->command_line_args_disabled;
442
443     cef_string_set(src->cache_path.str, src->cache_path.length,
444         &target->cache_path, copy);
445     cef_string_set(src->user_data_path.str, src->user_data_path.length,
446         &target->user_data_path, copy);
447     target->persist_session_cookies = src->persist_session_cookies;
448
449     cef_string_set(src->user_agent.str, src->user_agent.length,
450         &target->user_agent, copy);
451     cef_string_set(src->product_version.str, src->product_version.length,
452         &target->product_version, copy);
453     cef_string_set(src->locale.str, src->locale.length, &target->locale, copy);
454
455     cef_string_set(src->log_file.str, src->log_file.length, &target->log_file,
456         copy);
457     target->log_severity = src->log_severity;
458     cef_string_set(src->javascript_flags.str, src->javascript_flags.length,
459         &target->javascript_flags, copy);
460
461     cef_string_set(src->resources_dir_path.str, src->resources_dir_path.length,
462         &target->resources_dir_path, copy);
463     cef_string_set(src->locales_dir_path.str, src->locales_dir_path.length,
464         &target->locales_dir_path, copy);
465     target->pack_loading_disabled = src->pack_loading_disabled;
466     target->remote_debugging_port = src->remote_debugging_port;
467     target->uncaught_exception_stack_size = src->uncaught_exception_stack_size;
468     target->context_safety_implementation = src->context_safety_implementation;
469     target->ignore_certificate_errors = src->ignore_certificate_errors;
470     target->background_color = src->background_color;
471
472     cef_string_set(src->accept_language_list.str,
473         src->accept_language_list.length, &target->accept_language_list, copy);
474   }
475 };
476
477 ///
478 // Class representing initialization settings.
479 ///
480 typedef CefStructBase<CefSettingsTraits> CefSettings;
481
482
483 struct CefRequestContextSettingsTraits {
484   typedef cef_request_context_settings_t struct_type;
485
486   static inline void init(struct_type* s) {
487     s->size = sizeof(struct_type);
488   }
489
490   static inline void clear(struct_type* s) {
491     cef_string_clear(&s->cache_path);
492     cef_string_clear(&s->accept_language_list);
493   }
494
495   static inline void set(const struct_type* src, struct_type* target,
496       bool copy) {
497     cef_string_set(src->cache_path.str, src->cache_path.length,
498         &target->cache_path, copy);
499     target->persist_session_cookies = src->persist_session_cookies;
500     target->ignore_certificate_errors = src->ignore_certificate_errors;
501     cef_string_set(src->accept_language_list.str,
502         src->accept_language_list.length, &target->accept_language_list, copy);
503   }
504 };
505
506 ///
507 // Class representing request context initialization settings.
508 ///
509 typedef CefStructBase<CefRequestContextSettingsTraits>
510     CefRequestContextSettings;
511
512
513 struct CefBrowserSettingsTraits {
514   typedef cef_browser_settings_t struct_type;
515
516   static inline void init(struct_type* s) {
517     s->size = sizeof(struct_type);
518   }
519
520   static inline void clear(struct_type* s) {
521     cef_string_clear(&s->standard_font_family);
522     cef_string_clear(&s->fixed_font_family);
523     cef_string_clear(&s->serif_font_family);
524     cef_string_clear(&s->sans_serif_font_family);
525     cef_string_clear(&s->cursive_font_family);
526     cef_string_clear(&s->fantasy_font_family);
527     cef_string_clear(&s->default_encoding);
528     cef_string_clear(&s->accept_language_list);
529   }
530
531   static inline void set(const struct_type* src, struct_type* target,
532       bool copy) {
533     target->windowless_frame_rate = src->windowless_frame_rate;
534
535     cef_string_set(src->standard_font_family.str,
536         src->standard_font_family.length, &target->standard_font_family, copy);
537     cef_string_set(src->fixed_font_family.str, src->fixed_font_family.length,
538         &target->fixed_font_family, copy);
539     cef_string_set(src->serif_font_family.str, src->serif_font_family.length,
540         &target->serif_font_family, copy);
541     cef_string_set(src->sans_serif_font_family.str,
542         src->sans_serif_font_family.length, &target->sans_serif_font_family,
543         copy);
544     cef_string_set(src->cursive_font_family.str,
545         src->cursive_font_family.length, &target->cursive_font_family, copy);
546     cef_string_set(src->fantasy_font_family.str,
547         src->fantasy_font_family.length, &target->fantasy_font_family, copy);
548
549     target->default_font_size = src->default_font_size;
550     target->default_fixed_font_size = src->default_fixed_font_size;
551     target->minimum_font_size = src->minimum_font_size;
552     target->minimum_logical_font_size = src->minimum_logical_font_size;
553
554     cef_string_set(src->default_encoding.str, src->default_encoding.length,
555         &target->default_encoding, copy);
556
557     target->remote_fonts = src->remote_fonts;
558     target->javascript = src->javascript;
559     target->javascript_open_windows = src->javascript_open_windows;
560     target->javascript_close_windows = src->javascript_close_windows;
561     target->javascript_access_clipboard = src->javascript_access_clipboard;
562     target->javascript_dom_paste = src->javascript_dom_paste;
563     target->caret_browsing = src->caret_browsing;
564     target->java = src->java;
565     target->plugins = src->plugins;
566     target->universal_access_from_file_urls =
567         src->universal_access_from_file_urls;
568     target->file_access_from_file_urls = src->file_access_from_file_urls;
569     target->web_security = src->web_security;
570     target->image_loading = src->image_loading;
571     target->image_shrink_standalone_to_fit =
572         src->image_shrink_standalone_to_fit;
573     target->text_area_resize = src->text_area_resize;
574     target->tab_to_links = src->tab_to_links;
575     target->local_storage = src->local_storage;
576     target->databases= src->databases;
577     target->application_cache = src->application_cache;
578     target->webgl = src->webgl;
579
580     target->background_color = src->background_color;
581
582     cef_string_set(src->accept_language_list.str,
583         src->accept_language_list.length, &target->accept_language_list, copy);
584   }
585 };
586
587 ///
588 // Class representing browser initialization settings.
589 ///
590 typedef CefStructBase<CefBrowserSettingsTraits> CefBrowserSettings;
591
592
593 struct CefURLPartsTraits {
594   typedef cef_urlparts_t struct_type;
595
596   static inline void init(struct_type* s) {}
597
598   static inline void clear(struct_type* s) {
599     cef_string_clear(&s->spec);
600     cef_string_clear(&s->scheme);
601     cef_string_clear(&s->username);
602     cef_string_clear(&s->password);
603     cef_string_clear(&s->host);
604     cef_string_clear(&s->port);
605     cef_string_clear(&s->origin);
606     cef_string_clear(&s->path);
607     cef_string_clear(&s->query);
608   }
609
610   static inline void set(const struct_type* src, struct_type* target,
611       bool copy) {
612     cef_string_set(src->spec.str, src->spec.length, &target->spec, copy);
613     cef_string_set(src->scheme.str, src->scheme.length, &target->scheme, copy);
614     cef_string_set(src->username.str, src->username.length, &target->username,
615         copy);
616     cef_string_set(src->password.str, src->password.length, &target->password,
617         copy);
618     cef_string_set(src->host.str, src->host.length, &target->host, copy);
619     cef_string_set(src->port.str, src->port.length, &target->port, copy);
620     cef_string_set(src->origin.str, src->origin.length, &target->origin, copy);
621     cef_string_set(src->path.str, src->path.length, &target->path, copy);
622     cef_string_set(src->query.str, src->query.length, &target->query, copy);
623   }
624 };
625
626 ///
627 // Class representing a URL's component parts.
628 ///
629 typedef CefStructBase<CefURLPartsTraits> CefURLParts;
630
631
632 struct CefTimeTraits {
633   typedef cef_time_t struct_type;
634
635   static inline void init(struct_type* s) {}
636
637   static inline void clear(struct_type* s) {}
638
639   static inline void set(const struct_type* src, struct_type* target,
640       bool copy) {
641     *target = *src;
642   }
643 };
644
645 ///
646 // Class representing a time.
647 ///
648 class CefTime : public CefStructBase<CefTimeTraits> {
649  public:
650   typedef CefStructBase<CefTimeTraits> parent;
651
652   CefTime() : parent() {}
653   CefTime(const cef_time_t& r) : parent(r) {}  // NOLINT(runtime/explicit)
654   CefTime(const CefTime& r) : parent(r) {}  // NOLINT(runtime/explicit)
655   explicit CefTime(time_t r) : parent() { SetTimeT(r); }
656   explicit CefTime(double r) : parent() { SetDoubleT(r); }
657
658   // Converts to/from time_t.
659   void SetTimeT(time_t r) {
660     cef_time_from_timet(r, this);
661   }
662   time_t GetTimeT() const {
663     time_t time = 0;
664     cef_time_to_timet(this, &time);
665     return time;
666   }
667
668   // Converts to/from a double which is the number of seconds since epoch
669   // (Jan 1, 1970). Webkit uses this format to represent time. A value of 0
670   // means "not initialized".
671   void SetDoubleT(double r) {
672     cef_time_from_doublet(r, this);
673   }
674   double GetDoubleT() const {
675     double time = 0;
676     cef_time_to_doublet(this, &time);
677     return time;
678   }
679
680   // Set this object to now.
681   void Now() {
682     cef_time_now(this);
683   }
684
685   // Return the delta between this object and |other| in milliseconds.
686   long long Delta(const CefTime& other) {
687     long long delta = 0;
688     cef_time_delta(this, &other, &delta);
689     return delta;
690   }
691 };
692
693
694 struct CefCookieTraits {
695   typedef cef_cookie_t struct_type;
696
697   static inline void init(struct_type* s) {}
698
699   static inline void clear(struct_type* s) {
700     cef_string_clear(&s->name);
701     cef_string_clear(&s->value);
702     cef_string_clear(&s->domain);
703     cef_string_clear(&s->path);
704   }
705
706   static inline void set(const struct_type* src, struct_type* target,
707       bool copy) {
708     cef_string_set(src->name.str, src->name.length, &target->name, copy);
709     cef_string_set(src->value.str, src->value.length, &target->value, copy);
710     cef_string_set(src->domain.str, src->domain.length, &target->domain, copy);
711     cef_string_set(src->path.str, src->path.length, &target->path, copy);
712     target->secure = src->secure;
713     target->httponly = src->httponly;
714     target->creation = src->creation;
715     target->last_access = src->last_access;
716     target->has_expires = src->has_expires;
717     target->expires = src->expires;
718   }
719 };
720
721 ///
722 // Class representing a cookie.
723 ///
724 typedef CefStructBase<CefCookieTraits> CefCookie;
725
726
727 struct CefGeopositionTraits {
728   typedef cef_geoposition_t struct_type;
729
730   static inline void init(struct_type* s) {}
731
732   static inline void clear(struct_type* s) {
733     cef_string_clear(&s->error_message);
734   }
735
736   static inline void set(const struct_type* src, struct_type* target,
737       bool copy) {
738     target->latitude = src->latitude;
739     target->longitude = src->longitude;
740     target->altitude = src->altitude;
741     target->accuracy = src->accuracy;
742     target->altitude_accuracy = src->altitude_accuracy;
743     target->heading = src->heading;
744     target->speed = src->speed;
745     target->timestamp = src->timestamp;
746     target->error_code = src->error_code;
747     cef_string_set(src->error_message.str, src->error_message.length,
748         &target->error_message, copy);
749   }
750 };
751
752 ///
753 // Class representing a geoposition.
754 ///
755 typedef CefStructBase<CefGeopositionTraits> CefGeoposition;
756
757
758 struct CefPageRangeTraits {
759   typedef cef_page_range_t struct_type;
760
761   static inline void init(struct_type* s) {}
762   static inline void clear(struct_type* s) {}
763
764   static inline void set(const struct_type* src, struct_type* target,
765       bool copy) {
766     *target = *src;
767   }
768 };
769
770 ///
771 // Class representing a print job page range.
772 ///
773 class CefPageRange : public CefStructBase<CefPageRangeTraits> {
774  public:
775   typedef CefStructBase<CefPageRangeTraits> parent;
776
777   CefPageRange() : parent() {}
778   CefPageRange(const cef_page_range_t& r)  // NOLINT(runtime/explicit)
779       : parent(r) {}
780   CefPageRange(const CefPageRange& r)  // NOLINT(runtime/explicit)
781       : parent(r) {} 
782   CefPageRange(int from, int to) : parent() {
783     Set(from, to);
784   }
785
786   void Set(int from, int to) {
787     this->from = from, this->to = to;
788   }
789 };
790
791 inline bool operator==(const CefPageRange& a, const CefPageRange& b) {
792   return a.from == b.from && a.to == b.to;
793 }
794
795 inline bool operator!=(const CefPageRange& a, const CefPageRange& b) {
796   return !(a == b);
797 }
798
799
800 struct CefCursorInfoTraits {
801   typedef cef_cursor_info_t struct_type;
802
803   static inline void init(struct_type* s) {}
804
805   static inline void clear(struct_type* s) {}
806
807   static inline void set(const struct_type* src, struct_type* target,
808       bool copy) {
809     target->hotspot = src->hotspot;
810     target->image_scale_factor = src->image_scale_factor;
811     target->buffer = src->buffer;
812     target->size = src->size;
813   }
814 };
815
816 ///
817 // Class representing cursor information.
818 ///
819 typedef CefStructBase<CefCursorInfoTraits> CefCursorInfo;
820
821 #endif  // CEF_INCLUDE_INTERNAL_CEF_TYPES_WRAPPERS_H_