1/*
2 * Copyright (C) 2010 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#pragma once
27
28#include "APIObject.h"
29#include "ImageOptions.h"
30#include <JavaScriptCore/JSBase.h>
31#include <wtf/Forward.h>
32#include <wtf/Optional.h>
33#include <wtf/RefPtr.h>
34
35namespace WebCore {
36class IntRect;
37class Node;
38enum class AutoFillButtonType : uint8_t;
39}
40
41namespace WebKit {
42
43class InjectedBundleRangeHandle;
44class InjectedBundleScriptWorld;
45class WebFrame;
46class WebImage;
47
48class InjectedBundleNodeHandle : public API::ObjectImpl<API::Object::Type::BundleNodeHandle> {
49public:
50 static RefPtr<InjectedBundleNodeHandle> getOrCreate(JSContextRef, JSObjectRef);
51 static RefPtr<InjectedBundleNodeHandle> getOrCreate(WebCore::Node*);
52 static Ref<InjectedBundleNodeHandle> getOrCreate(WebCore::Node&);
53
54 virtual ~InjectedBundleNodeHandle();
55
56 WebCore::Node* coreNode();
57
58 // Convenience DOM Operations
59 Ref<InjectedBundleNodeHandle> document();
60
61 // Additional DOM Operations
62 // Note: These should only be operations that are not exposed to JavaScript.
63 WebCore::IntRect elementBounds();
64 WebCore::IntRect renderRect(bool*);
65 RefPtr<WebImage> renderedImage(SnapshotOptions, bool shouldExcludeOverflow, const Optional<float>& bitmapWidth = WTF::nullopt);
66 RefPtr<InjectedBundleRangeHandle> visibleRange();
67 void setHTMLInputElementValueForUser(const String&);
68 void setHTMLInputElementSpellcheckEnabled(bool);
69 bool isHTMLInputElementAutoFilled() const;
70 void setHTMLInputElementAutoFilled(bool);
71 bool isHTMLInputElementAutoFillButtonEnabled() const;
72 void setHTMLInputElementAutoFillButtonEnabled(WebCore::AutoFillButtonType);
73 WebCore::AutoFillButtonType htmlInputElementAutoFillButtonType() const;
74 WebCore::AutoFillButtonType htmlInputElementLastAutoFillButtonType() const;
75 bool isAutoFillAvailable() const;
76 void setAutoFillAvailable(bool);
77 WebCore::IntRect htmlInputElementAutoFillButtonBounds();
78 bool htmlInputElementLastChangeWasUserEdit();
79 bool htmlTextAreaElementLastChangeWasUserEdit();
80 bool isTextField() const;
81 bool isSelectElement() const;
82
83 RefPtr<InjectedBundleNodeHandle> htmlTableCellElementCellAbove();
84
85 RefPtr<WebFrame> documentFrame();
86 RefPtr<WebFrame> htmlFrameElementContentFrame();
87 RefPtr<WebFrame> htmlIFrameElementContentFrame();
88
89private:
90 static Ref<InjectedBundleNodeHandle> create(WebCore::Node&);
91 InjectedBundleNodeHandle(WebCore::Node&);
92
93 Ref<WebCore::Node> m_node;
94};
95
96} // namespace WebKit
97