2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include "DocumentLoader.h"
34 #include "EventHandler.h"
35 #include "FrameLoader.h"
36 #include "FrameLoaderClientGdk.h"
37 #include "FramePrivate.h"
38 #include "FrameView.h"
39 #include "GraphicsContext.h"
40 #include "HitTestRequest.h"
41 #include "HitTestResult.h"
42 #include "KeyboardCodes.h"
43 #include "NotImplemented.h"
45 #include "PlatformKeyboardEvent.h"
46 #include "PlatformMouseEvent.h"
47 #include "PlatformString.h"
48 #include "PlatformWheelEvent.h"
49 #include "RenderObject.h"
50 #include "RenderTreeAsText.h"
51 #include "ResourceHandle.h"
52 #include "ResourceResponse.h"
53 #include "SelectionController.h"
55 #include "TypingCommand.h"
60 // This function loads resources from WebKit
61 // This does not belong here and I'm not sure where
63 // I don't know what the plans or design is
64 // for none code resources
65 Vector<char> loadResourceIntoArray(const char* resourceName)
67 Vector<char> resource;
68 //if (strcmp(resourceName,"missingImage") == 0) {
75 FrameGdk::FrameGdk(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClientGdk* frameLoader)
76 : Frame(page, ownerElement, frameLoader)
78 m_exitAfterLoading = false;
79 m_dumpRenderTreeAfterLoading = false;
81 Settings* settings = page->settings();
82 settings->setLoadsImagesAutomatically(true);
83 settings->setMinimumFontSize(5);
84 settings->setMinimumLogicalFontSize(5);
85 settings->setShouldPrintBackgrounds(true);
86 settings->setJavaScriptEnabled(true);
88 settings->setDefaultFixedFontSize(14);
89 settings->setDefaultFontSize(14);
90 settings->setSerifFontFamily("Times New Roman");
91 settings->setSansSerifFontFamily("Arial");
92 settings->setFixedFontFamily("Courier");
93 settings->setStandardFontFamily("Arial");
95 frameLoader->setFrame(this);
100 loader()->cancelAndClear();
103 void FrameGdk::onDidFinishLoad()
105 if (dumpRenderTreeAfterLoading())
107 if (exitAfterLoading())
108 gtk_main_quit(); // FIXME: a bit drastic?
111 void FrameGdk::dumpRenderTree() const
113 if (view()->needsLayout())
116 String txt = externalRepresentation(renderer());
117 CString utf8Str = txt.utf8();
118 const char *utf8 = utf8Str.data();
120 printf("%s\n", utf8);
122 printf("FrameGdk::dumpRenderTree() no data\n");
125 bool FrameGdk::keyPress(const PlatformKeyboardEvent& keyEvent)
130 return eventHandler()->keyEvent(keyEvent);
133 void FrameGdk::handleGdkEvent(GdkEvent* event)
135 switch (event->type) {
139 gdk_region_get_clipbox(event->expose.region, &clip);
140 gdk_window_begin_paint_region(event->any.window, event->expose.region);
141 cairo_t* cr = gdk_cairo_create(event->any.window);
142 GraphicsContext ctx(cr);
144 if (view()->needsLayout())
146 IntRect rect(clip.x, clip.y, clip.width, clip.height);
150 gdk_window_end_paint(event->any.window);
154 case GDK_CONFIGURE: {
155 view()->updateGeometry(event->configure.width, event->configure.height);
161 PlatformWheelEvent wheelEvent(event);
162 view()->wheelEvent(wheelEvent);
163 if (wheelEvent.isAccepted())
166 HitTestRequest hitTestRequest(true, true);
167 HitTestResult hitTestResult(wheelEvent.pos());
168 renderer()->layer()->hitTest(hitTestRequest, hitTestResult);
169 Node* node = hitTestResult.innerNode();
173 * FIXME: Does this belong here?
174 * Default to scrolling the page
175 * not sure why its null
176 * broke anyway when its not null
177 * doScroll(renderer(), wheelEvent.deltaX(), wheelEvent.deltaY());
183 case GDK_DRAG_MOTION:
184 case GDK_DRAG_STATUS:
186 case GDK_DROP_FINISHED: {
187 //bool updateDragAndDrop(const PlatformMouseEvent&, Clipboard*);
188 //void cancelDragAndDrop(const PlatformMouseEvent&, Clipboard*);
189 //bool performDragAndDrop(const PlatformMouseEvent&, Clipboard*);
192 case GDK_MOTION_NOTIFY:
193 eventHandler()->handleMouseMoveEvent(PlatformMouseEvent(event));
195 case GDK_BUTTON_PRESS:
196 case GDK_2BUTTON_PRESS:
197 case GDK_3BUTTON_PRESS:
198 eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
200 case GDK_BUTTON_RELEASE:
201 eventHandler()->handleMouseReleaseEvent(PlatformMouseEvent(event));
204 case GDK_KEY_RELEASE: {
205 PlatformKeyboardEvent keyEvent(event);
218 void Frame::issueTransposeCommand()
223 void Frame::cleanupPlatformScriptObjects()
228 DragImageRef Frame::dragImageForSelection()
234 void Frame::dashboardRegionsChanged()