~mmach/netext73/webkit2gtk

« back to all changes in this revision

Viewing changes to Source/WebInspectorUI/UserInterface/Views/AnimationCollectionContentView.js

  • Committer: mmach
  • Date: 2023-06-16 17:21:37 UTC
  • Revision ID: netbit73@gmail.com-20230616172137-2rqx6yr96ga9g3kp
1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2020 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
WI.AnimationCollectionContentView = class AnimationCollectionContentView extends WI.CollectionContentView
 
27
{
 
28
    constructor(representedObject)
 
29
    {
 
30
        console.assert(representedObject instanceof WI.AnimationCollection);
 
31
 
 
32
        let contentPlaceholder = document.createElement("div");
 
33
 
 
34
        let descriptionElement = contentPlaceholder.appendChild(document.createElement("div"));
 
35
        descriptionElement.className = "description";
 
36
 
 
37
        switch (representedObject.animationType) {
 
38
        case WI.Animation.Type.WebAnimation:
 
39
            descriptionElement.textContent = WI.UIString("Waiting for animations created by JavaScript.");
 
40
            break;
 
41
 
 
42
        case WI.Animation.Type.CSSAnimation:
 
43
            descriptionElement.textContent = WI.UIString("Waiting for animations created by CSS.");
 
44
            break;
 
45
 
 
46
        case WI.Animation.Type.CSSTransition:
 
47
            descriptionElement.textContent = WI.UIString("Waiting for transitions created by CSS.");
 
48
            break;
 
49
        }
 
50
        console.assert(descriptionElement.textContent);
 
51
 
 
52
        super(representedObject, WI.AnimationContentView, contentPlaceholder);
 
53
 
 
54
        this.selectionEnabled = true;
 
55
 
 
56
        this.element.classList.add("animation-collection");
 
57
    }
 
58
 
 
59
    // Public
 
60
 
 
61
    handleRefreshButtonClicked()
 
62
    {
 
63
        for (let subview of this.subviews) {
 
64
            if (subview instanceof WI.AnimationContentView)
 
65
                subview.handleRefreshButtonClicked();
 
66
        }
 
67
    }
 
68
 
 
69
    // Protected
 
70
 
 
71
    contentViewAdded(contentView)
 
72
    {
 
73
        contentView.element.addEventListener("mouseenter", this._handleContentViewMouseEnter);
 
74
        contentView.element.addEventListener("mouseleave", this._handleContentViewMouseLeave);
 
75
    }
 
76
 
 
77
    contentViewRemoved(contentView)
 
78
    {
 
79
        contentView.element.removeEventListener("mouseenter", this._handleContentViewMouseEnter);
 
80
        contentView.element.removeEventListener("mouseleave", this._handleContentViewMouseLeave);
 
81
    }
 
82
 
 
83
    detached()
 
84
    {
 
85
        WI.domManager.hideDOMNodeHighlight();
 
86
 
 
87
        super.detached();
 
88
    }
 
89
 
 
90
    // Private
 
91
 
 
92
    _handleContentViewMouseEnter(event)
 
93
    {
 
94
        let contentView = WI.View.fromElement(event.target);
 
95
        if (!(contentView instanceof WI.AnimationContentView))
 
96
            return;
 
97
 
 
98
        let animation = contentView.representedObject;
 
99
        animation.requestEffectTarget((node) => {
 
100
            if (!node || !node.ownerDocument)
 
101
                return;
 
102
            node.highlight();
 
103
        });
 
104
    }
 
105
 
 
106
    _handleContentViewMouseLeave(event)
 
107
    {
 
108
        WI.domManager.hideDOMNodeHighlight();
 
109
    }
 
110
};