Skip to content

Commit d313317

Browse files
committed
2006-03-03 Eric Seidel <eseidel@apple.com>
Reviewed by mjs. Add WebFrame class (to hold Frame and FrameView). Add Location bar support to Spinneret. * Spinneret/Spinneret/Spinneret.cpp: (resizeSubViews): (_tWinMain): (WndProc): (MyEditProc): * Spinneret/Spinneret/Spinneret.vcproj: * Spinneret/Spinneret/WebFrame.cpp: Added. (WebKit::WebFrame::WebFramePrivate::WebFramePrivate): (WebKit::WebFrame::WebFramePrivate::~WebFramePrivate): (WebKit::WebFrame::WebFrame): (WebKit::WebFrame::loadFilePath): (WebKit::WebFrame::loadHTMLString): (WebKit::WebFrame::paint): (WebKit::WebFrame::impl): (WebKit::WebFrame::viewImpl): * Spinneret/Spinneret/WebFrame.h: Added. * Spinneret/Spinneret/WebView.cpp: (WebKit::WebView::WebViewPrivate::~WebViewPrivate): (WebKit::WebView::WebView): (WebKit::WebView::windowHandle): (WebKit::WebView::mainFrame): (WebKit::WebView::mouseMoved): (WebKit::WebView::mouseDown): (WebKit::WebView::mouseUp): (WebKit::WebView::mouseDoubleClick): (WebKit::WebViewWndProc): * Spinneret/Spinneret/WebView.h: Canonical link: https://commits.webkit.org/11090@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13116 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 3c95402 commit d313317

7 files changed

Lines changed: 303 additions & 80 deletions

File tree

WebKitTools/ChangeLog

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
2006-03-03 Eric Seidel <eseidel@apple.com>
2+
3+
Reviewed by mjs.
4+
5+
Add WebFrame class (to hold Frame and FrameView).
6+
Add Location bar support to Spinneret.
7+
8+
* Spinneret/Spinneret/Spinneret.cpp:
9+
(resizeSubViews):
10+
(_tWinMain):
11+
(WndProc):
12+
(MyEditProc):
13+
* Spinneret/Spinneret/Spinneret.vcproj:
14+
* Spinneret/Spinneret/WebFrame.cpp: Added.
15+
(WebKit::WebFrame::WebFramePrivate::WebFramePrivate):
16+
(WebKit::WebFrame::WebFramePrivate::~WebFramePrivate):
17+
(WebKit::WebFrame::WebFrame):
18+
(WebKit::WebFrame::loadFilePath):
19+
(WebKit::WebFrame::loadHTMLString):
20+
(WebKit::WebFrame::paint):
21+
(WebKit::WebFrame::impl):
22+
(WebKit::WebFrame::viewImpl):
23+
* Spinneret/Spinneret/WebFrame.h: Added.
24+
* Spinneret/Spinneret/WebView.cpp:
25+
(WebKit::WebView::WebViewPrivate::~WebViewPrivate):
26+
(WebKit::WebView::WebView):
27+
(WebKit::WebView::windowHandle):
28+
(WebKit::WebView::mainFrame):
29+
(WebKit::WebView::mouseMoved):
30+
(WebKit::WebView::mouseDown):
31+
(WebKit::WebView::mouseUp):
32+
(WebKit::WebView::mouseDoubleClick):
33+
(WebKit::WebViewWndProc):
34+
* Spinneret/Spinneret/WebView.h:
35+
136
2006-03-02 Eric Seidel <eseidel@apple.com>
237

338
Reviewed by ggaren.

WebKitTools/Spinneret/Spinneret/Spinneret.cpp

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@
2626
#include "stdafx.h"
2727
#include "Spinneret.h"
2828
#include "WebView.h"
29+
#include "WebFrame.h"
30+
31+
#include <commctrl.h>
2932

3033
#define MAX_LOADSTRING 100
34+
#define URLBAR_HEIGHT 24
3135

3236
using namespace WebKit;
3337

3438
// Global Variables:
3539
HINSTANCE hInst; // current instance
3640
HWND hMainWnd;
41+
HWND hURLBarWnd;
42+
long DefEditProc;
3743
WebView* gWebView = 0;
3844
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
3945
TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
@@ -43,6 +49,15 @@ ATOM MyRegisterClass(HINSTANCE hInstance);
4349
BOOL InitInstance(HINSTANCE, int);
4450
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
4551
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
52+
LRESULT CALLBACK MyEditProc(HWND, UINT, WPARAM, LPARAM);
53+
54+
static void resizeSubViews()
55+
{
56+
RECT rcClient;
57+
GetClientRect(hMainWnd, &rcClient);
58+
MoveWindow(hURLBarWnd, 0, 0, rcClient.right, URLBAR_HEIGHT, TRUE);
59+
MoveWindow(gWebView->windowHandle(), 0, URLBAR_HEIGHT, rcClient.right, rcClient.bottom - URLBAR_HEIGHT, TRUE);
60+
}
4661

4762
int APIENTRY _tWinMain(HINSTANCE hInstance,
4863
HINSTANCE hPrevInstance,
@@ -56,6 +71,12 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
5671
MSG msg;
5772
HACCEL hAccelTable;
5873

74+
INITCOMMONCONTROLSEX InitCtrlEx;
75+
76+
InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
77+
InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
78+
InitCommonControlsEx(&InitCtrlEx);
79+
5980
// Initialize global strings
6081
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
6182
LoadString(hInstance, IDC_SPINNERET, szWindowClass, MAX_LOADSTRING);
@@ -65,12 +86,18 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
6586
if (!InitInstance (hInstance, nCmdShow))
6687
return FALSE;
6788

89+
hURLBarWnd = CreateWindow(L"EDIT", 0,
90+
WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOVSCROLL,
91+
0, 0, 0, 0,
92+
hMainWnd,
93+
0,
94+
hInstance, 0);
95+
96+
DefEditProc = GetWindowLong(hURLBarWnd, GWL_WNDPROC);
97+
SetWindowLong(hURLBarWnd, GWL_WNDPROC,(long)MyEditProc);
98+
6899
gWebView = WebView::createWebView(hInstance, hMainWnd);
69-
RECT rcClient;
70-
GetClientRect(hMainWnd, &rcClient);
71-
MoveWindow(gWebView->windowHandle(),
72-
0, 0, rcClient.right, rcClient.bottom,
73-
TRUE);
100+
resizeSubViews();
74101
ShowWindow(gWebView->windowHandle(), nCmdShow);
75102
UpdateWindow(gWebView->windowHandle());
76103

@@ -89,21 +116,6 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
89116
return (int) msg.wParam;
90117
}
91118

92-
93-
94-
//
95-
// FUNCTION: MyRegisterClass()
96-
//
97-
// PURPOSE: Registers the window class.
98-
//
99-
// COMMENTS:
100-
//
101-
// This function and its usage are only necessary if you want this code
102-
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
103-
// function that was added to Windows 95. It is important to call this function
104-
// so that the application will get 'well formed' small icons associated
105-
// with it.
106-
//
107119
ATOM MyRegisterClass(HINSTANCE hInstance)
108120
{
109121
WNDCLASSEX wcex;
@@ -176,23 +188,48 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
176188
case WM_SIZE:
177189
if (!gWebView)
178190
break;
179-
// Get the dimensions of the main window's client
180-
// area, and enumerate the child windows. Pass the
181-
// dimensions to the child windows during enumeration.
182-
183-
RECT rcClient;
184-
GetClientRect(hWnd, &rcClient);
185-
MoveWindow(gWebView->windowHandle(),
186-
0, 0, rcClient.right, rcClient.bottom,
187-
TRUE);
188-
ShowWindow(gWebView->windowHandle(), SW_SHOW);
191+
resizeSubViews();
189192
break;
190193
default:
191194
return DefWindowProc(hWnd, message, wParam, lParam);
192195
}
193196
return 0;
194197
}
195198

199+
200+
#define MAX_URL_LENGTH 1024
201+
202+
LRESULT CALLBACK MyEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
203+
{
204+
switch (message) {
205+
case WM_CHAR:
206+
if( wParam == 13 ) { // Enter Key
207+
wchar_t strPtr[MAX_URL_LENGTH];
208+
char cstrPtr[MAX_URL_LENGTH];
209+
*((LPWORD)strPtr) = MAX_URL_LENGTH;
210+
int strLen = SendMessage(hDlg, EM_GETLINE, 0, (LPARAM)strPtr);
211+
212+
MessageBox(hMainWnd, strPtr, L"Foo", MB_OK);
213+
214+
int x;
215+
for(x = 0; x < strLen; x++)
216+
cstrPtr[x] = strPtr[x];
217+
cstrPtr[x] = 0;
218+
219+
gWebView->mainFrame()->loadFilePath(cstrPtr);
220+
221+
return 0;
222+
} else
223+
return (LRESULT)CallWindowProc((WNDPROC)DefEditProc,hDlg,message,wParam,lParam);
224+
break;
225+
default:
226+
return (LRESULT)CallWindowProc((WNDPROC)DefEditProc,hDlg,message,wParam,lParam);
227+
break;
228+
}
229+
return 0;
230+
}
231+
232+
196233
// Message handler for about box.
197234
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
198235
{

WebKitTools/Spinneret/Spinneret/Spinneret.vcproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
RuntimeLibrary="3"
4848
UsePrecompiledHeader="2"
4949
WarningLevel="1"
50-
Detect64BitPortabilityProblems="true"
50+
Detect64BitPortabilityProblems="false"
5151
DebugInformationFormat="4"
5252
/>
5353
<Tool
@@ -61,7 +61,7 @@
6161
/>
6262
<Tool
6363
Name="VCLinkerTool"
64-
AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;"
64+
AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;&#x0D;&#x0A;comctl32.lib"
6565
LinkIncremental="2"
6666
GenerateDebugInformation="true"
6767
SubSystem="2"
@@ -122,7 +122,7 @@
122122
RuntimeLibrary="2"
123123
UsePrecompiledHeader="2"
124124
WarningLevel="1"
125-
Detect64BitPortabilityProblems="true"
125+
Detect64BitPortabilityProblems="false"
126126
DebugInformationFormat="3"
127127
/>
128128
<Tool
@@ -136,7 +136,7 @@
136136
/>
137137
<Tool
138138
Name="VCLinkerTool"
139-
AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;"
139+
AdditionalOptions="&quot;$(WebKitOutputDir)\WebCore.intermediate\$(ConfigurationName)\WebCore.intermediate\WebCore.lib&quot;&#x0D;&#x0A;&quot;$(WebKitOutputDir)\JavaScriptCore.intermediate\$(ConfigurationName)\JavaScriptCore.intermediate\JavaScriptCore.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\iconv\lib\iconv.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxml\lib\libxml2.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\libxslt\lib\libxslt.lib&quot;&#x0D;&#x0A;&quot;$(SolutionDir)\..\..\icu\lib\icuuc.lib&quot;&#x0D;&#x0A;comctl32.lib"
140140
LinkIncremental="1"
141141
GenerateDebugInformation="true"
142142
SubSystem="2"
@@ -202,6 +202,10 @@
202202
/>
203203
</FileConfiguration>
204204
</File>
205+
<File
206+
RelativePath=".\WebFrame.cpp"
207+
>
208+
</File>
205209
<File
206210
RelativePath=".\WebView.cpp"
207211
>
@@ -224,6 +228,10 @@
224228
RelativePath=".\stdafx.h"
225229
>
226230
</File>
231+
<File
232+
RelativePath=".\WebFrame.h"
233+
>
234+
</File>
227235
<File
228236
RelativePath=".\WebView.h"
229237
>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright (C) 2006 Apple Computer, 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 COMPUTER, INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "stdafx.h"
27+
#include "config.h"
28+
29+
#include "WebFrame.h"
30+
#include "WebView.h"
31+
32+
#include "FrameView.h"
33+
#include "FrameWin.h"
34+
#include "GraphicsContext.h"
35+
#include "Page.h"
36+
#include "render_frames.h"
37+
38+
#include <io.h>
39+
#include <fcntl.h>
40+
#include <direct.h>
41+
42+
using namespace WebCore;
43+
44+
namespace WebKit {
45+
46+
class WebFrame::WebFramePrivate {
47+
public:
48+
WebFramePrivate() { }
49+
~WebFramePrivate() { }
50+
51+
Frame* frame;
52+
FrameView* frameView;
53+
WebView* webView;
54+
};
55+
56+
WebFrame::WebFrame(char* name, WebView* view)
57+
: d(new WebFrame::WebFramePrivate)
58+
{
59+
d->webView = view;
60+
Page *page = new Page();
61+
d->frame = new FrameWin(page, 0);
62+
d->frameView = new FrameView(d->frame);
63+
d->frame->setView(d->frameView);
64+
d->frameView->setWindowHandle(view->windowHandle());
65+
}
66+
67+
void WebFrame::loadFilePath(char *path)
68+
{
69+
FILE* file = fopen(path, "rb");
70+
if (!file) {
71+
printf("Failed to open file: %s\n", path);
72+
printf("Current path: %s\n", _getcwd(0,0));
73+
return;
74+
}
75+
76+
d->frame->begin();
77+
78+
char buffer[4000];
79+
int newBytes = 0;
80+
while ((newBytes = fread(buffer, 1, 4000, file)) > 0) {
81+
d->frame->write(buffer, newBytes);
82+
}
83+
fclose(file);
84+
85+
d->frame->end();
86+
}
87+
88+
void WebFrame::loadHTMLString(char *html, char *baseURL)
89+
{
90+
d->frame->begin();
91+
d->frame->write(html);
92+
d->frame->end();
93+
}
94+
95+
void WebFrame::paint()
96+
{
97+
PAINTSTRUCT ps;
98+
HDC hdc = BeginPaint(d->webView->windowHandle(), &ps);
99+
GraphicsContext context(ps.hdc);
100+
d->frame->paint(&context, ps.rcPaint);
101+
EndPaint(d->webView->windowHandle(), &ps);
102+
}
103+
104+
WebCore::Frame* WebFrame::impl()
105+
{
106+
return d->frame;
107+
}
108+
109+
WebCore::FrameView* WebFrame::viewImpl()
110+
{
111+
return d->frameView;
112+
}
113+
114+
}
115+

0 commit comments

Comments
 (0)