Merge "[Release] Webkit2-efl-123997_0.11.75" into tizen_2.2
[framework/web/webkit-efl.git] / Source / WebKit2 / WebProcess / WebPage / WebFrame.h
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 #ifndef WebFrame_h
27 #define WebFrame_h
28
29 #include "APIObject.h"
30 #include "ImmutableArray.h"
31 #include "WKBase.h"
32 #include "WebFrameLoaderClient.h"
33 #include <JavaScriptCore/JSBase.h>
34 #include <WebCore/FrameLoaderClient.h>
35 #include <WebCore/FrameLoaderTypes.h>
36 #include <WebCore/PolicyChecker.h>
37 #include <wtf/Forward.h>
38 #include <wtf/PassRefPtr.h>
39 #include <wtf/RefPtr.h>
40 #include <wtf/RetainPtr.h>
41
42 namespace WebCore {
43     class Frame;
44     class HTMLFrameOwnerElement;
45     class KURL;
46 }
47
48 namespace WebKit {
49
50 class InjectedBundleNodeHandle;
51 class InjectedBundleRangeHandle;
52 class InjectedBundleScriptWorld;
53 class WebPage;
54
55 #if ENABLE(WEB_INTENTS)
56 struct IntentData;
57 #endif
58
59 class WebFrame : public APIObject {
60 public:
61     static const Type APIType = TypeBundleFrame;
62
63     static PassRefPtr<WebFrame> createMainFrame(WebPage*);
64     static PassRefPtr<WebFrame> createSubframe(WebPage*, const String& frameName, WebCore::HTMLFrameOwnerElement*);
65     ~WebFrame();
66
67     // Called when the FrameLoaderClient (and therefore the WebCore::Frame) is being torn down.
68     void invalidate();
69
70     WebPage* page() const;
71     WebCore::Frame* coreFrame() const { return m_coreFrame; }
72
73     uint64_t frameID() const { return m_frameID; }
74
75     uint64_t setUpPolicyListener(WebCore::FramePolicyFunction);
76     void invalidatePolicyListener();
77     void didReceivePolicyDecision(uint64_t listenerID, WebCore::PolicyAction, uint64_t downloadID);
78 #if ENABLE(TIZEN_DOWNLOAD_ATTRIBUTE)
79     void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
80 #else
81     void startDownload(const WebCore::ResourceRequest&);
82 #endif
83     void convertHandleToDownload(WebCore::ResourceHandle*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
84
85 #if ENABLE(WEB_INTENTS)
86     void deliverIntent(const IntentData&);
87 #endif
88
89     String source() const;
90     String contentsAsString() const;
91     String selectionAsString() const;
92
93     WebCore::IntSize size() const;
94
95     // WKBundleFrame API and SPI functions
96     bool isMainFrame() const;
97     String name() const;
98     String url() const;
99     String innerText() const;
100     bool isFrameSet() const;
101     WebFrame* parentFrame() const;
102     PassRefPtr<ImmutableArray> childFrames();
103     JSValueRef computedStyleIncludingVisitedInfo(JSObjectRef element);
104     JSGlobalContextRef jsContext();
105     JSGlobalContextRef jsContextForWorld(InjectedBundleScriptWorld*);
106     WebCore::IntRect contentBounds() const;
107     WebCore::IntRect visibleContentBounds() const;
108     WebCore::IntRect visibleContentBoundsExcludingScrollbars() const;
109     WebCore::IntSize scrollOffset() const;
110     bool hasHorizontalScrollbar() const;
111     bool hasVerticalScrollbar() const;
112     bool getDocumentBackgroundColor(double* red, double* green, double* blue, double* alpha);
113     bool containsAnyFormElements() const;
114
115     static WebFrame* frameForContext(JSContextRef);
116
117     JSValueRef jsWrapperForWorld(InjectedBundleNodeHandle*, InjectedBundleScriptWorld*);
118     JSValueRef jsWrapperForWorld(InjectedBundleRangeHandle*, InjectedBundleScriptWorld*);
119
120     static String counterValue(JSObjectRef element);
121     static String markerText(JSObjectRef element);
122
123     unsigned numberOfActiveAnimations() const;
124     bool pauseAnimationOnElementWithId(const String& animationName, const String& elementID, double time);
125     bool pauseTransitionOnElementWithId(const String& propertyName, const String& elementID, double time);
126     void suspendAnimations();
127     void resumeAnimations();
128     String layerTreeAsText() const;
129     
130     unsigned pendingUnloadCount() const;
131     
132     bool allowsFollowingLink(const WebCore::KURL&) const;
133
134     String provisionalURL() const;
135     String suggestedFilenameForResourceWithURL(const WebCore::KURL&) const;
136     String mimeTypeForResourceWithURL(const WebCore::KURL&) const;
137
138     void setTextDirection(const String&);
139
140     // Simple listener class used by plug-ins to know when frames finish or fail loading.
141     class LoadListener {
142     public:
143         virtual ~LoadListener() { }
144
145         virtual void didFinishLoad(WebFrame*) = 0;
146         virtual void didFailLoad(WebFrame*, bool wasCancelled) = 0;
147     };
148     void setLoadListener(LoadListener* loadListener) { m_loadListener = loadListener; }
149     LoadListener* loadListener() const { return m_loadListener; }
150     
151 #if PLATFORM(MAC) || PLATFORM(WIN)
152     typedef bool (*FrameFilterFunction)(WKBundleFrameRef, WKBundleFrameRef subframe, void* context);
153     RetainPtr<CFDataRef> webArchiveData(FrameFilterFunction, void* context);
154 #endif
155
156 private:
157     static PassRefPtr<WebFrame> create();
158     WebFrame();
159
160     void init(WebPage*, const String& frameName, WebCore::HTMLFrameOwnerElement*);
161
162     virtual Type type() const { return APIType; }
163
164     WebCore::Frame* m_coreFrame;
165
166     uint64_t m_policyListenerID;
167     WebCore::FramePolicyFunction m_policyFunction;
168     uint64_t m_policyDownloadID;
169
170     WebFrameLoaderClient m_frameLoaderClient;
171     LoadListener* m_loadListener;
172     
173     uint64_t m_frameID;
174 };
175
176 } // namespace WebKit
177
178 #endif // WebFrame_h