Commit 4484b814 authored by weinig's avatar weinig

Reviewed by Geoff.

        Patch for http://bugs.webkit.org/show_bug.cgi?id=14226
        Move the History object out of the JS bindings

        - Autogenerate JSHistory.

        * DerivedSources.make:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * bindings/js/kjs_window.cpp:
        (KJS::WindowPrivate::WindowPrivate):
        (KJS::Window::mark):
        (KJS::Window::getValueProperty):
        (KJS::Window::clearHelperObjectProperties):
        (KJS::Window::disconnectFrame):
        * bindings/js/kjs_window.h:
        (KJS::Window::):
        * bridge/GlobalHistory.h: Copied from WebCore/bridge/History.h.
        * bridge/History.h: Removed.
        * bridge/mac/GlobalHistoryMac.mm: Copied from WebCore/bridge/mac/HistoryMac.mm.
        * bridge/mac/HistoryMac.mm: Removed.
        * bridge/win/GlobalHistoryWin.cpp: Copied from WebCore/bridge/win/HistoryWin.cpp.
        * bridge/win/HistoryWin.cpp: Removed.
        * css/cssstyleselector.cpp:
        * page/DOMWindow.cpp:
        (WebCore::DOMWindow::disconnectFrame):
        (WebCore::DOMWindow::history):
        * page/DOMWindow.h:
        * page/DOMWindow.idl:
        * page/History.cpp: Added.
        (WebCore::History::History):
        (WebCore::History::frame):
        (WebCore::History::disconnectFrame):
        (WebCore::History::length):
        (WebCore::History::back):
        (WebCore::History::forward):
        (WebCore::History::go):
        * page/History.h: Added.
        * page/History.idl: Added.
        * platform/gdk/TemporaryLinkStubs.cpp:
        * platform/qt/TemporaryLinkStubs.cpp:
        * platform/wx/TemporaryLinkStubs.cpp:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@23584 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4bd12d78
2007-06-19 Sam Weinig <sam@webkit.org>
Reviewed by Geoff.
Patch for http://bugs.webkit.org/show_bug.cgi?id=14226
Move the History object out of the JS bindings
- Autogenerate JSHistory.
* DerivedSources.make:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/kjs_window.cpp:
(KJS::WindowPrivate::WindowPrivate):
(KJS::Window::mark):
(KJS::Window::getValueProperty):
(KJS::Window::clearHelperObjectProperties):
(KJS::Window::disconnectFrame):
* bindings/js/kjs_window.h:
(KJS::Window::):
* bridge/GlobalHistory.h: Copied from WebCore/bridge/History.h.
* bridge/History.h: Removed.
* bridge/mac/GlobalHistoryMac.mm: Copied from WebCore/bridge/mac/HistoryMac.mm.
* bridge/mac/HistoryMac.mm: Removed.
* bridge/win/GlobalHistoryWin.cpp: Copied from WebCore/bridge/win/HistoryWin.cpp.
* bridge/win/HistoryWin.cpp: Removed.
* css/cssstyleselector.cpp:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::disconnectFrame):
(WebCore::DOMWindow::history):
* page/DOMWindow.h:
* page/DOMWindow.idl:
* page/History.cpp: Added.
(WebCore::History::History):
(WebCore::History::frame):
(WebCore::History::disconnectFrame):
(WebCore::History::length):
(WebCore::History::back):
(WebCore::History::forward):
(WebCore::History::go):
* page/History.h: Added.
* page/History.idl: Added.
* platform/gdk/TemporaryLinkStubs.cpp:
* platform/qt/TemporaryLinkStubs.cpp:
* platform/wx/TemporaryLinkStubs.cpp:
2007-06-18 Sam Weinig <sam@webkit.org>
Qt build fix.
......@@ -393,6 +393,7 @@ all : \
JSHTMLTextAreaElement.h \
JSHTMLTitleElement.h \
JSHTMLUListElement.h \
JSHistory.h \
JSKeyboardEvent.h \
JSMediaList.h \
JSMouseEvent.h \
......
......@@ -258,6 +258,7 @@ IDL_BINDINGS += \
html/HTMLUListElement.idl \
page/BarInfo.idl \
page/DOMWindow.idl \
page/History.idl \
page/Screen.idl \
xml/DOMParser.idl \
xml/XMLSerializer.idl
......@@ -569,6 +570,7 @@ SOURCES += \
page/Frame.cpp \
page/FrameTree.cpp \
page/FrameView.cpp \
page/History.cpp \
page/MouseEventWithHitTestResults.cpp \
page/Page.cpp \
page/Screen.cpp \
......
......@@ -602,6 +602,14 @@
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSEventTargetNode.lut.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSHistory.cpp"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSHistory.h"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\$(ProjectName)\DerivedSources\JSHTMLAnchorElement.cpp"
>
......@@ -2469,6 +2477,14 @@
RelativePath="..\page\FrameView.h"
>
</File>
<File
RelativePath="..\page\History.cpp"
>
</File>
<File
RelativePath="..\page\History.h"
>
</File>
<File
RelativePath="..\page\MouseEventWithHitTestResults.cpp"
>
......@@ -5848,7 +5864,7 @@
>
</File>
<File
RelativePath="..\bridge\History.h"
RelativePath="..\bridge\GlobalHistory.h"
>
</File>
<File
......@@ -5875,7 +5891,7 @@
>
</File>
<File
RelativePath="..\bridge\win\HistoryWin.cpp"
RelativePath="..\bridge\win\GlobalHistoryWin.cpp"
>
</File>
<File
......
This diff is collapsed.
......@@ -82,8 +82,7 @@ const double cMinimumTimerInterval = 0.010;
struct WindowPrivate {
WindowPrivate()
: history(0)
, loc(0)
: loc(0)
, m_selection(0)
, m_evt(0)
, m_returnValueSlot(0)
......@@ -94,7 +93,6 @@ struct WindowPrivate {
Window::ListenersMap jsHTMLEventListeners;
Window::UnprotectedListenersMap jsUnprotectedEventListeners;
Window::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
mutable History* history;
mutable Location* loc;
mutable Selection* m_selection;
WebCore::Event *m_evt;
......@@ -139,27 +137,7 @@ public:
ScheduledAction *action;
};
////////////////////// History Object ////////////////////////
class History : public DOMObject {
friend class HistoryFunc;
public:
History(ExecState *exec, Frame *f)
: m_frame(f)
{
setPrototype(exec->lexicalInterpreter()->builtinObjectPrototype());
}
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
JSValue *getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { Back, Forward, Go, Length };
void disconnectFrame() { m_frame = 0; }
private:
Frame* m_frame;
};
}
} // namespace KJS
#include "kjs_window.lut.h"
......@@ -180,7 +158,6 @@ const ClassInfo Window::info = { "Window", 0, &WindowTable, 0 };
status Window::Status DontDelete
DOMException Window::DOMException DontDelete
frames Window::Frames DontDelete|ReadOnly
history Window::History_ DontDelete|ReadOnly
event Window::Event_ DontDelete
innerHeight Window::InnerHeight DontDelete|ReadOnly
innerWidth Window::InnerWidth DontDelete|ReadOnly
......@@ -356,8 +333,6 @@ bool Window::find(const String& string, bool caseSensitive, bool backwards, bool
void Window::mark()
{
JSObject::mark();
if (d->history && !d->history->marked())
d->history->mark();
if (d->loc && !d->loc->marked())
d->loc->mark();
if (d->m_selection && !d->m_selection->marked())
......@@ -587,10 +562,6 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
return jsString(UString(m_frame->jsStatusBarText()));
case Frames:
return retrieve(m_frame);
case History_:
if (!d->history)
d->history = new History(exec, m_frame);
return d->history;
case Event_:
if (!d->m_evt)
return jsUndefined();
......@@ -1222,7 +1193,6 @@ JSUnprotectedEventListener *Window::findOrCreateJSUnprotectedEventListener(JSVal
void Window::clearHelperObjectProperties()
{
d->history = 0;
d->loc = 0;
d->m_selection = 0;
d->m_evt = 0;
......@@ -1859,8 +1829,6 @@ void Window::disconnectFrame()
d->loc->m_frame = 0;
if (d->m_selection)
d->m_selection->m_frame = 0;
if (d->history)
d->history->disconnectFrame();
}
Window::ListenersMap& Window::jsEventListeners()
......@@ -2218,56 +2186,6 @@ JSValue *SelectionFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const
return jsUndefined();
}
////////////////////// History Object ////////////////////////
const ClassInfo History::info = { "History", 0, &HistoryTable, 0 };
/*
@begin HistoryTable 4
length History::Length DontDelete|ReadOnly
back History::Back DontDelete|Function 0
forward History::Forward DontDelete|Function 0
go History::Go DontDelete|Function 1
@end
*/
KJS_IMPLEMENT_PROTOTYPE_FUNCTION(HistoryFunc)
bool History::getOwnPropertySlot(ExecState *exec, const Identifier& propertyName, PropertySlot& slot)
{
return getStaticPropertySlot<HistoryFunc, History, JSObject>(exec, &HistoryTable, this, propertyName, slot);
}
JSValue *History::getValueProperty(ExecState *, int token) const
{
ASSERT(token == Length);
return m_frame ? jsNumber(m_frame->loader()->getHistoryLength()) : jsNumber(0);
}
JSValue *HistoryFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const List &args)
{
if (!thisObj->inherits(&History::info))
return throwError(exec, TypeError);
History *history = static_cast<History *>(thisObj);
int steps;
switch (id) {
case History::Back:
steps = -1;
break;
case History::Forward:
steps = 1;
break;
case History::Go:
steps = args[0]->toInt32(exec);
break;
default:
return jsUndefined();
}
if (Frame* frame = history->m_frame)
frame->loader()->scheduleHistoryNavigation(steps);
return jsUndefined();
}
/////////////////////////////////////////////////////////////////////////////
PausedTimeouts::~PausedTimeouts()
......
......@@ -36,8 +36,6 @@ namespace WebCore {
namespace KJS {
class BarInfo;
class History;
class JSEventListener;
class JSLazyEventListener;
class JSUnprotectedEventListener;
......@@ -150,7 +148,7 @@ namespace KJS {
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
enum { AToB, BToA, Closed, Crypto, DefaultStatus, Status, DOMException, Frames, History_, Event_, InnerHeight,
enum { AToB, BToA, Closed, Crypto, DefaultStatus, Status, DOMException, Frames, Event_, InnerHeight,
InnerWidth, Length, Location_, Name, Navigator_, ClientInformation,
OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, PageYOffset,
Parent, ScreenX, ScreenY, Scroll, ScrollBy,
......
......@@ -23,8 +23,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef History_h
#define History_h
#ifndef GlobalHistory_h
#define GlobalHistory_h
namespace WebCore {
......@@ -32,6 +32,6 @@ namespace WebCore {
bool historyContains(const DeprecatedString&);
}
} // namespace WebCore
#endif
#endif // GlobalHistory_h
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
......@@ -24,7 +24,7 @@
*/
#import "config.h"
#import "History.h"
#import "GlobalHistory.h"
#import "DeprecatedString.h"
#import "WebCoreHistory.h"
......@@ -39,4 +39,4 @@ bool historyContains(const DeprecatedString& s)
return [[WebCoreHistory historyProvider] containsItemForURLUnicode:(UniChar *)s.unicode() length:s.length()];
}
}
} // namespace WebCore
......@@ -24,7 +24,7 @@
*/
#include "config.h"
#include "History.h"
#include "GlobalHistory.h"
#include "DeprecatedString.h"
#include "WebCoreHistory.h"
......@@ -42,4 +42,4 @@ bool historyContains(const DeprecatedString& s)
return WebCoreHistory::historyProvider()->containsItemForURLUnicode((UChar*)s.unicode(), s.length());
}
}
\ No newline at end of file
} // namespace WebCore
......@@ -38,28 +38,28 @@
#include "CSSStyleSheet.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
#include "Counter.h"
#include "CachedImage.h"
#include "Counter.h"
#include "DashboardRegion.h"
#include "FontFamilyValue.h"
#include "FontValue.h"
#include "Frame.h"
#include "FrameView.h"
#include "GlobalHistory.h"
#include "HTMLDocument.h"
#include "HTMLElement.h"
#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "History.h"
#include "Settings.h"
#include "MediaList.h"
#include "MediaQueryEvaluator.h"
#include "Pair.h"
#include "Rect.h"
#include "RenderTheme.h"
#include "Settings.h"
#include "ShadowValue.h"
#include "StyleSheetList.h"
#include "UserAgentStyleSheets.h"
#include "loader.h"
#include "ShadowValue.h"
#if ENABLE(SVG)
#include "XLinkNames.h"
......
......@@ -34,6 +34,7 @@
#include "Element.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "History.h"
#include "Page.h"
#include "PlatformScreen.h"
#include "Screen.h"
......@@ -60,6 +61,8 @@ void DOMWindow::disconnectFrame()
m_frame = 0;
if (m_screen)
m_screen->disconnectFrame();
if (m_history)
m_history->disconnectFrame();
if (m_locationbar)
m_locationbar->disconnectFrame();
if (m_menubar)
......@@ -81,6 +84,13 @@ Screen* DOMWindow::screen() const
return m_screen.get();
}
History* DOMWindow::history() const
{
if (!m_history)
m_history = new History(m_frame);
return m_history.get();
}
BarInfo* DOMWindow::locationbar() const
{
if (!m_locationbar)
......
......@@ -38,6 +38,7 @@ namespace WebCore {
class Document;
class Element;
class Frame;
class History;
class Screen;
class String;
......@@ -51,6 +52,7 @@ namespace WebCore {
// DOM Level 0
Screen* screen() const;
History* history() const;
BarInfo* locationbar() const;
BarInfo* menubar() const;
BarInfo* personalbar() const;
......@@ -71,6 +73,7 @@ namespace WebCore {
private:
Frame* m_frame;
mutable RefPtr<Screen> m_screen;
mutable RefPtr<History> m_history;
mutable RefPtr<BarInfo> m_locationbar;
mutable RefPtr<BarInfo> m_menubar;
mutable RefPtr<BarInfo> m_personalbar;
......
......@@ -30,6 +30,7 @@ module window {
interface [LegacyParent=KJS::Window, DoNotCache, GenerateNativeConverter, CustomGetOwnPropertySlot] DOMWindow {
// DOM Level 0
readonly attribute Screen screen;
readonly attribute History history;
readonly attribute BarInfo locationbar;
readonly attribute BarInfo menubar;
readonly attribute BarInfo personalbar;
......
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "History.h"
#include "Frame.h"
#include "FrameLoader.h"
namespace WebCore {
History::History(Frame* frame)
: m_frame(frame)
{
}
Frame* History::frame() const
{
return m_frame;
}
void History::disconnectFrame()
{
m_frame = 0;
}
unsigned History::length() const
{
if (!m_frame)
return 0;
return m_frame->loader()->getHistoryLength();
}
void History::back()
{
if (!m_frame)
return;
m_frame->loader()->scheduleHistoryNavigation(-1);
}
void History::forward()
{
if (!m_frame)
return;
m_frame->loader()->scheduleHistoryNavigation(1);
}
void History::go(int distance)
{
if (!m_frame)
return;
m_frame->loader()->scheduleHistoryNavigation(distance);
}
} // namespace WebCore
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef History_h
#define History_h
#include "Shared.h"
namespace WebCore {
class Frame;
class History : public Shared<History> {
public:
History(Frame*);
Frame* frame() const;
void disconnectFrame();
unsigned length() const;
void back();
void forward();
void go(int distance);
private:
Frame* m_frame;
};
} // namespace WebCore
#endif // History_h
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
module window {
interface History {
readonly attribute unsigned long length;
void back();
void forward();
void go(in long distance);
};
}
......@@ -48,9 +48,9 @@
#include "FrameLoader.h"
#include "FrameLoaderClientGdk.h"
#include "FrameView.h"
#include "GlobalHistory.h"
#include "GraphicsContext.h"
#include "HTMLFrameOwnerElement.h"
#include "History.h"
#include "Icon.h"
#include "IconDatabase.h"
#include "IconLoader.h"
......
......@@ -40,7 +40,7 @@
#include "FrameLoader.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "History.h"
#include "GlobalHistory.h"
#include "IconLoader.h"
#include "IntPoint.h"
#include "KURL.h"
......
......@@ -39,7 +39,7 @@
#include "PlatformMouseEvent.h"
#include "CookieJar.h"
#include "Screen.h"
#include "History.h"
#include "GlobalHistory.h"
#include "Language.h"
#include "LocalizedStrings.h"
#include "PlugInInfoStore.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment