summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/timing/performance_element_timing.h
blob: 682165c2441f3c2e3b79e4195d3f255166afd622 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_ELEMENT_TIMING_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_ELEMENT_TIMING_H_

#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/dom_high_res_time_stamp.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/geometry/dom_rect_read_only.h"
#include "third_party/blink/renderer/core/timing/performance_entry.h"

namespace blink {

// The PerformanceElementTiming object exposes the time in which an element is
// first rendered on the screen and its intersection with the viewport at the
// time it is painted. Currently this is only done for <img> elements but other
// element types should be supported in the future.
class CORE_EXPORT PerformanceElementTiming final : public PerformanceEntry {
  DEFINE_WRAPPERTYPEINFO();

 public:
  static PerformanceElementTiming* Create(const AtomicString& name,
                                          const String& url,
                                          const FloatRect& intersection_rect,
                                          DOMHighResTimeStamp render_time,
                                          DOMHighResTimeStamp load_time,
                                          const AtomicString& identifier,
                                          int naturalWidth,
                                          int naturalHeight,
                                          const AtomicString& id,
                                          Element*);
  PerformanceElementTiming(const AtomicString& name,
                           DOMHighResTimeStamp start_time,
                           const String& url,
                           const FloatRect& intersection_rect,
                           DOMHighResTimeStamp render_time,
                           DOMHighResTimeStamp load_time,
                           const AtomicString& identifier,
                           int naturalWidth,
                           int naturalHeight,
                           const AtomicString& id,
                           Element*);

  ~PerformanceElementTiming() override;

  AtomicString entryType() const override;
  PerformanceEntryType EntryTypeEnum() const override;

  DOMRectReadOnly* intersectionRect() const { return intersection_rect_; }
  DOMHighResTimeStamp renderTime() const { return render_time_; }
  DOMHighResTimeStamp loadTime() const { return load_time_; }
  AtomicString identifier() const { return identifier_; }
  unsigned naturalWidth() const { return naturalWidth_; }
  unsigned naturalHeight() const { return naturalHeight_; }
  AtomicString id() const { return id_; }
  String url() const { return url_; }
  Element* element() const;

  void Trace(Visitor*) override;

 private:
  void BuildJSONValue(V8ObjectBuilder&) const override;

  WeakMember<Element> element_;
  Member<DOMRectReadOnly> intersection_rect_;
  DOMHighResTimeStamp render_time_;
  DOMHighResTimeStamp load_time_;
  AtomicString identifier_;
  unsigned naturalWidth_;
  unsigned naturalHeight_;
  AtomicString id_;
  String url_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PERFORMANCE_ELEMENT_TIMING_H_