[webkit-changes] cvs commit: WebKit/WebView.subproj WebFrame.m
WebUIDelegatePrivate.h WebView.m WebViewPrivate.h
Timothy
thatcher at opensource.apple.com
Fri Nov 18 18:36:14 PST 2005
thatcher 05/11/18 18:36:13
Modified: . Tag: Safari-2-0-branch ChangeLog
khtml/ecma Tag: Safari-2-0-branch kjs_events.cpp
kjs_window.cpp kjs_window.h
khtml/html Tag: Safari-2-0-branch html_baseimpl.cpp
khtml/misc Tag: Safari-2-0-branch htmlattrs.in shared.h
khtml/xml Tag: Safari-2-0-branch dom2_eventsimpl.cpp
dom2_eventsimpl.h
kwq Tag: Safari-2-0-branch KWQKHTMLPart.h
KWQKHTMLPart.mm WebCoreBridge.h WebCoreBridge.mm
. Tag: Safari-2-0-branch ChangeLog
WebCoreSupport.subproj Tag: Safari-2-0-branch WebBridge.m
WebView.subproj Tag: Safari-2-0-branch WebFrame.m
WebUIDelegatePrivate.h WebView.m WebViewPrivate.h
Log:
WebCore:
Merged fix from TOT to Safari-2-0-branch
2005-11-18 Vicki Murley <vicki at apple.com>
Changes by Darin, reviewed by Beth and Vicki.
- fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
* khtml/ecma/kjs_events.cpp:
(KJS::JSAbstractEventListener::handleEvent):
* khtml/ecma/kjs_window.cpp:
(KJS::Window::getValueProperty):
(KJS::Window::put):
* khtml/ecma/kjs_window.h:
(KJS::Window::):
* khtml/html/html_baseimpl.cpp:
(HTMLBodyElementImpl::parseMappedAttribute):
(HTMLFrameElementImpl::parseMappedAttribute):
(HTMLFrameSetElementImpl::parseMappedAttribute):
* khtml/html/htmlnames.h:
* khtml/xml/EventNames.h:
* khtml/xml/dom2_eventsimpl.cpp:
(DOM::EventImpl::storesResultAsString):
(DOM::EventImpl::storeResult):
(DOM::BeforeUnloadEventImpl::BeforeUnloadEventImpl):
(DOM::BeforeUnloadEventImpl::storesResultAsString):
(DOM::BeforeUnloadEventImpl::storeResult):
* khtml/xml/dom2_eventsimpl.h:
(DOM::BeforeUnloadEventImpl::result):
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::shouldClose):
* kwq/WebCoreBridge.h:
* kwq/WebCoreBridge.mm:
(-[WebCoreBridge shouldClose]):
WebKit:
Merged fix from TOT to Safari-2-0-branch
2005-11-18 Vicki Murley <vicki at apple.com>
Changes by Darin, reviewed by Beth and Vicki.
- fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge canRunBeforeUnloadConfirmPanel]):
(-[WebBridge runBeforeUnloadConfirmPanelWithMessage:]):
* WebView.subproj/WebFrame.m:
(-[WebFrame _checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]):
(-[WebFrame _continueLoadRequestAfterNavigationPolicy:formState:]):
* WebView.subproj/WebUIDelegatePrivate.h:
* WebView.subproj/WebView.m:
(-[WebView shouldClose]):
* WebView.subproj/WebViewPrivate.h:
Revision Changes Path
No revision
No revision
1.1.2.75 +38 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.1.2.74
retrieving revision 1.1.2.75
diff -u -r1.1.2.74 -r1.1.2.75
--- ChangeLog 19 Nov 2005 00:11:15 -0000 1.1.2.74
+++ ChangeLog 19 Nov 2005 02:35:20 -0000 1.1.2.75
@@ -2,6 +2,44 @@
Merged fix from TOT to Safari-2-0-branch
+ 2005-11-18 Vicki Murley <vicki at apple.com>
+
+ Changes by Darin, reviewed by Beth and Vicki.
+
+ - fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
+
+ * khtml/ecma/kjs_events.cpp:
+ (KJS::JSAbstractEventListener::handleEvent):
+ * khtml/ecma/kjs_window.cpp:
+ (KJS::Window::getValueProperty):
+ (KJS::Window::put):
+ * khtml/ecma/kjs_window.h:
+ (KJS::Window::):
+ * khtml/html/html_baseimpl.cpp:
+ (HTMLBodyElementImpl::parseMappedAttribute):
+ (HTMLFrameElementImpl::parseMappedAttribute):
+ (HTMLFrameSetElementImpl::parseMappedAttribute):
+ * khtml/html/htmlnames.h:
+ * khtml/xml/EventNames.h:
+ * khtml/xml/dom2_eventsimpl.cpp:
+ (DOM::EventImpl::storesResultAsString):
+ (DOM::EventImpl::storeResult):
+ (DOM::BeforeUnloadEventImpl::BeforeUnloadEventImpl):
+ (DOM::BeforeUnloadEventImpl::storesResultAsString):
+ (DOM::BeforeUnloadEventImpl::storeResult):
+ * khtml/xml/dom2_eventsimpl.h:
+ (DOM::BeforeUnloadEventImpl::result):
+ * kwq/KWQKHTMLPart.h:
+ * kwq/KWQKHTMLPart.mm:
+ (KWQKHTMLPart::shouldClose):
+ * kwq/WebCoreBridge.h:
+ * kwq/WebCoreBridge.mm:
+ (-[WebCoreBridge shouldClose]):
+
+2005-11-18 Timothy Hatcher <timothy at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch
+
2005-11-18 Beth Dakin <bdakin at apple.com>
Reviewed by Darin.
No revision
No revision
1.42.8.9 +8 -4 WebCore/khtml/ecma/kjs_events.cpp
Index: kjs_events.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_events.cpp,v
retrieving revision 1.42.8.8
retrieving revision 1.42.8.9
diff -u -r1.42.8.8 -r1.42.8.9
--- kjs_events.cpp 5 Oct 2005 16:11:29 -0000 1.42.8.8
+++ kjs_events.cpp 19 Nov 2005 02:35:28 -0000 1.42.8.9
@@ -116,10 +116,14 @@
if (Interpreter::shouldPrintExceptions())
printf("(event handler):%s\n", message);
exec->clearException();
- } else if (html) {
- QVariant ret = ValueToVariant(exec, retval);
- if (ret.type() == QVariant::Bool && ret.toBool() == false)
- evt.preventDefault();
+ } else {
+ if (!retval.isA(UndefinedType) && !retval.isA(NullType) && evt.handle()->storesResultAsString())
+ evt.handle()->storeResult(retval.toString(exec).string());
+ if (html) {
+ QVariant ret = ValueToVariant(exec, retval);
+ if (ret.type() == QVariant::Bool && ret.toBool() == false)
+ evt.preventDefault();
+ }
}
DOM::DocumentImpl::updateDocumentsRendering();
1.146.8.13 +7 -0 WebCore/khtml/ecma/kjs_window.cpp
Index: kjs_window.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.cpp,v
retrieving revision 1.146.8.12
retrieving revision 1.146.8.13
diff -u -r1.146.8.12 -r1.146.8.13
--- kjs_window.cpp 10 Nov 2005 20:28:57 -0000 1.146.8.12
+++ kjs_window.cpp 19 Nov 2005 02:35:29 -0000 1.146.8.13
@@ -308,6 +308,7 @@
onselect Window::Onselect DontDelete
onsubmit Window::Onsubmit DontDelete
onunload Window::Onunload DontDelete
+ onbeforeunload Window::Onbeforeunload DontDelete
frameElement Window::FrameElement DontDelete|ReadOnly
showModalDialog Window::ShowModalDialog DontDelete|Function 1
@end
@@ -1067,6 +1068,8 @@
return getListener(exec,DOM::EventImpl::SUBMIT_EVENT);
else
return Undefined();
+ case Onbeforeunload:
+ return getListener(exec, DOM::EventImpl::BEFOREUNLOAD_EVENT);
case Onunload:
if (isSafeScript(exec))
return getListener(exec,DOM::EventImpl::UNLOAD_EVENT);
@@ -1292,6 +1295,10 @@
if (isSafeScript(exec))
setListener(exec,DOM::EventImpl::SUBMIT_EVENT,value);
return;
+ case Onbeforeunload:
+ if (isSafeScript(exec))
+ setListener(exec, DOM::EventImpl::BEFOREUNLOAD_EVENT, value);
+ return;
case Onunload:
if (isSafeScript(exec))
setListener(exec,DOM::EventImpl::UNLOAD_EVENT,value);
1.34.8.8 +1 -1 WebCore/khtml/ecma/kjs_window.h
Index: kjs_window.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/ecma/kjs_window.h,v
retrieving revision 1.34.8.7
retrieving revision 1.34.8.8
diff -u -r1.34.8.7 -r1.34.8.8
--- kjs_window.h 16 Sep 2005 02:34:12 -0000 1.34.8.7
+++ kjs_window.h 19 Nov 2005 02:35:31 -0000 1.34.8.8
@@ -145,7 +145,7 @@
Onabort, Onblur, Onchange, Onclick, Ondblclick, Ondragdrop, Onerror,
Onfocus, Onkeydown, Onkeypress, Onkeyup, Onload, Onmousedown, Onmousemove,
Onmouseout, Onmouseover, Onmouseup, OnWindowMouseWheel, Onmove, Onreset, Onresize, Onscroll, Onsearch,
- Onselect, Onsubmit, Onunload,
+ Onselect, Onsubmit, Onunload, Onbeforeunload,
Statusbar, Toolbar, FrameElement, ShowModalDialog };
protected:
Value getListener(ExecState *exec, int eventId) const;
No revision
No revision
1.68.8.4 +12 -0 WebCore/khtml/html/html_baseimpl.cpp
Index: html_baseimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/html/html_baseimpl.cpp,v
retrieving revision 1.68.8.3
retrieving revision 1.68.8.4
diff -u -r1.68.8.3 -r1.68.8.4
--- html_baseimpl.cpp 12 Nov 2005 01:24:32 -0000 1.68.8.3
+++ html_baseimpl.cpp 19 Nov 2005 02:35:35 -0000 1.68.8.4
@@ -172,6 +172,10 @@
getDocument()->setHTMLWindowEventListener(EventImpl::LOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), NULL));
break;
+ case ATTR_ONBEFOREUNLOAD:
+ getDocument()->setHTMLWindowEventListener(EventImpl::BEFOREUNLOAD_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string(), NULL));
+ break;
case ATTR_ONUNLOAD:
getDocument()->setHTMLWindowEventListener(EventImpl::UNLOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), NULL));
@@ -393,6 +397,10 @@
setHTMLEventListener(EventImpl::LOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
break;
+ case ATTR_ONBEFOREUNLOAD:
+ setHTMLEventListener(EventImpl::BEFOREUNLOAD_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string(), this));
+ break;
case ATTR_ONUNLOAD:
setHTMLEventListener(EventImpl::UNLOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
@@ -610,6 +618,10 @@
setHTMLEventListener(EventImpl::LOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
break;
+ case ATTR_ONBEFOREUNLOAD:
+ setHTMLEventListener(EventImpl::BEFOREUNLOAD_EVENT,
+ getDocument()->createHTMLEventListener(attr->value().string(), this));
+ break;
case ATTR_ONUNLOAD:
setHTMLEventListener(EventImpl::UNLOAD_EVENT,
getDocument()->createHTMLEventListener(attr->value().string(), this));
No revision
No revision
1.16.16.2 +1 -0 WebCore/khtml/misc/Attic/htmlattrs.in
Index: htmlattrs.in
===================================================================
RCS file: /cvs/root/WebCore/khtml/misc/Attic/htmlattrs.in,v
retrieving revision 1.16.16.1
retrieving revision 1.16.16.2
diff -u -r1.16.16.1 -r1.16.16.2
--- htmlattrs.in 27 Apr 2005 00:58:14 -0000 1.16.16.1
+++ htmlattrs.in 19 Nov 2005 02:35:37 -0000 1.16.16.2
@@ -127,6 +127,7 @@
onselectstart
onsubmit
onunload
+onbeforeunload
oversrc
pagex
pagey
1.5.10.2 +24 -9 WebCore/khtml/misc/shared.h
Index: shared.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/misc/shared.h,v
retrieving revision 1.5.10.1
retrieving revision 1.5.10.2
diff -u -r1.5.10.1 -r1.5.10.2
--- shared.h 24 Aug 2005 02:50:46 -0000 1.5.10.1
+++ shared.h 19 Nov 2005 02:35:37 -0000 1.5.10.2
@@ -64,10 +64,12 @@
{
public:
SharedPtr() : m_ptr(0) {}
- explicit SharedPtr(T *ptr) : m_ptr(ptr) { if (m_ptr) m_ptr->ref(); }
+ SharedPtr(T *ptr) : m_ptr(ptr) { if (m_ptr) m_ptr->ref(); }
SharedPtr(const SharedPtr &o) : m_ptr(o.m_ptr) { if (m_ptr) m_ptr->ref(); }
~SharedPtr() { if (m_ptr) m_ptr->deref(); }
-
+
+ template <class U> SharedPtr(const SharedPtr<U> &o) : m_ptr(o.get()) { if (T *ptr = m_ptr) ptr->ref(); }
+
bool isNull() const { return m_ptr == 0; }
bool notNull() const { return m_ptr != 0; }
@@ -79,26 +81,39 @@
T *operator->() const { return m_ptr; }
bool operator!() const { return m_ptr == 0; }
+ operator bool() const { return m_ptr != NULL; }
inline friend bool operator==(const SharedPtr &a, const SharedPtr &b) { return a.m_ptr == b.m_ptr; }
inline friend bool operator==(const SharedPtr &a, const T *b) { return a.m_ptr == b; }
inline friend bool operator==(const T *a, const SharedPtr &b) { return a == b.m_ptr; }
SharedPtr &operator=(const SharedPtr &);
+ SharedPtr &operator=(T *);
private:
T* m_ptr;
+
+ operator int() const; // deliberately not implemented; helps prevent operator bool from converting to int accidentally
};
template <class T> SharedPtr<T> &SharedPtr<T>::operator=(const SharedPtr<T> &o)
{
- if (m_ptr != o.m_ptr) {
- if (m_ptr)
- m_ptr->deref();
- m_ptr = o.m_ptr;
- if (m_ptr)
- m_ptr->ref();
- }
+ T *optr = o.m_ptr;
+ if (optr)
+ optr->ref();
+ if (T *ptr = m_ptr)
+ ptr->deref();
+ m_ptr = optr;
+ return *this;
+}
+
+template <class T> inline SharedPtr<T> &SharedPtr<T>::operator=(T *optr)
+{
+ if (optr)
+ optr->ref();
+ if (T *ptr = m_ptr)
+ ptr->deref();
+ m_ptr = optr;
return *this;
}
No revision
No revision
1.29.10.3 +26 -0 WebCore/khtml/xml/dom2_eventsimpl.cpp
Index: dom2_eventsimpl.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom2_eventsimpl.cpp,v
retrieving revision 1.29.10.2
retrieving revision 1.29.10.3
diff -u -r1.29.10.2 -r1.29.10.3
--- dom2_eventsimpl.cpp 27 Apr 2005 21:41:53 -0000 1.29.10.2
+++ dom2_eventsimpl.cpp 19 Nov 2005 02:35:38 -0000 1.29.10.3
@@ -295,6 +295,15 @@
return false;
}
+bool EventImpl::storesResultAsString() const
+{
+ return false;
+}
+
+void EventImpl::storeResult(const DOMString&)
+{
+}
+
// -----------------------------------------------------------------------------
UIEventImpl::UIEventImpl()
@@ -788,3 +797,20 @@
ClipboardImpl::~ClipboardImpl()
{
}
+
+// -----------------------------------------------------------------------------
+
+BeforeUnloadEventImpl::BeforeUnloadEventImpl()
+ : EventImpl(BEFOREUNLOAD_EVENT, false, false)
+{
+}
+
+bool BeforeUnloadEventImpl::storesResultAsString() const
+{
+ return true;
+}
+
+void BeforeUnloadEventImpl::storeResult(const DOMString& s)
+{
+ m_result = s.implementation();
+}
1.24.10.4 +18 -0 WebCore/khtml/xml/dom2_eventsimpl.h
Index: dom2_eventsimpl.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/xml/dom2_eventsimpl.h,v
retrieving revision 1.24.10.3
retrieving revision 1.24.10.4
diff -u -r1.24.10.3 -r1.24.10.4
--- dom2_eventsimpl.h 22 Jul 2005 03:09:50 -0000 1.24.10.3
+++ dom2_eventsimpl.h 19 Nov 2005 02:35:38 -0000 1.24.10.4
@@ -87,6 +87,7 @@
DOMCHARACTERDATAMODIFIED_EVENT,
// HTML events
LOAD_EVENT,
+ BEFOREUNLOAD_EVENT,
UNLOAD_EVENT,
ABORT_EVENT,
ERROR_EVENT,
@@ -167,6 +168,9 @@
void setDefaultPrevented(bool defaultPrevented) { m_defaultPrevented = defaultPrevented; }
bool getCancelBubble() const { return m_cancelBubble; }
+ virtual bool storesResultAsString() const;
+ virtual void storeResult(const DOMString&);
+
protected:
DOMStringImpl *m_type;
bool m_canBubble;
@@ -477,6 +481,20 @@
virtual void setDragImageElement(const Node &, const QPoint &) = 0;
};
+class BeforeUnloadEventImpl : public EventImpl
+{
+public:
+ BeforeUnloadEventImpl();
+
+ virtual bool storesResultAsString() const;
+ virtual void storeResult(const DOMString&);
+
+ DOMString result() const { return m_result.get(); }
+
+private:
+ khtml::SharedPtr<DOMStringImpl> m_result;
+};
+
} // namespace
#endif
No revision
No revision
1.216.8.6 +2 -0 WebCore/kwq/KWQKHTMLPart.h
Index: KWQKHTMLPart.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.h,v
retrieving revision 1.216.8.5
retrieving revision 1.216.8.6
diff -u -r1.216.8.5 -r1.216.8.6
--- KWQKHTMLPart.h 18 Nov 2005 22:41:59 -0000 1.216.8.5
+++ KWQKHTMLPart.h 19 Nov 2005 02:35:40 -0000 1.216.8.6
@@ -203,6 +203,8 @@
bool statusbarVisible();
bool toolbarVisible();
+ bool shouldClose();
+
void KWQKHTMLPart::addMessageToConsole(const QString &message, unsigned int lineNumber, const QString &sourceID);
using KHTMLPart::xmlDocImpl;
khtml::RenderObject *renderer() const;
1.628.6.13 +36 -60 WebCore/kwq/KWQKHTMLPart.mm
Index: KWQKHTMLPart.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQKHTMLPart.mm,v
retrieving revision 1.628.6.12
retrieving revision 1.628.6.13
diff -u -r1.628.6.12 -r1.628.6.13
--- KWQKHTMLPart.mm 18 Nov 2005 22:41:59 -0000 1.628.6.12
+++ KWQKHTMLPart.mm 19 Nov 2005 02:35:41 -0000 1.628.6.13
@@ -76,6 +76,7 @@
#import "visible_position.h"
#import "visible_text.h"
#import "visible_units.h"
+#import "misc/shared.h"
#import <JavaScriptCore/identifier.h>
#import <JavaScriptCore/property_map.h>
@@ -90,66 +91,8 @@
#undef _KWQ_TIMING
-using DOM::AtomicString;
-using DOM::ClipboardEventImpl;
-using DOM::DocumentFragmentImpl;
-using DOM::DocumentImpl;
-using DOM::DocumentMarker;
-using DOM::DOMString;
-using DOM::ElementImpl;
-using DOM::EventImpl;
-using DOM::HTMLDocumentImpl;
-using DOM::HTMLElementImpl;
-using DOM::HTMLFormElementImpl;
-using DOM::HTMLFrameElementImpl;
-using DOM::HTMLGenericFormElementImpl;
-using DOM::HTMLTableCellElementImpl;
-using DOM::Node;
-using DOM::NodeImpl;
-using DOM::Position;
-using DOM::Range;
-using DOM::RangeImpl;
-using DOM::TextImpl;
-
-using khtml::Cache;
-using khtml::CharacterIterator;
-using khtml::ChildFrame;
-using khtml::Decoder;
-using khtml::DashboardRegionValue;
-using khtml::EditCommandPtr;
-using khtml::endOfWord;
-using khtml::findPlainText;
-using khtml::InlineTextBox;
-using khtml::LeftWordIfOnBoundary;
-using khtml::MouseDoubleClickEvent;
-using khtml::MouseMoveEvent;
-using khtml::MousePressEvent;
-using khtml::MouseReleaseEvent;
-using khtml::parseURL;
-using khtml::PRE;
-using khtml::RenderCanvas;
-using khtml::RenderImage;
-using khtml::RenderLayer;
-using khtml::RenderListItem;
-using khtml::RenderObject;
-using khtml::RenderPart;
-using khtml::RenderStyle;
-using khtml::RenderTableCell;
-using khtml::RenderText;
-using khtml::RenderWidget;
-using khtml::RightWordIfOnBoundary;
-using khtml::Selection;
-using khtml::setEnd;
-using khtml::setStart;
-using khtml::ShadowData;
-using khtml::startOfWord;
-using khtml::startVisiblePosition;
-using khtml::StyleDashboardRegion;
-using khtml::TextIterator;
-using khtml::DOWNSTREAM;
-using khtml::VISIBLE;
-using khtml::VisiblePosition;
-using khtml::WordAwareIterator;
+using namespace DOM;
+using namespace khtml;
using KIO::Job;
@@ -1900,6 +1843,39 @@
return [_bridge areToolbarsVisible];
}
+bool KWQKHTMLPart::shouldClose()
+{
+ KWQ_BLOCK_EXCEPTIONS;
+
+ if (![_bridge canRunBeforeUnloadConfirmPanel])
+ return true;
+
+ SharedPtr<DocumentImpl> document = xmlDocImpl();
+ if (!document)
+ return true;
+ HTMLElementImpl* body = document->body();
+ if (!body)
+ return true;
+
+ SharedPtr<BeforeUnloadEventImpl> event = new BeforeUnloadEventImpl;
+ event->setTarget(document.get());
+ int exception = 0;
+ body->dispatchGenericEvent(event.get(), exception);
+ if (!event->defaultPrevented() && document)
+ document->defaultEventHandler(event.get());
+ if (event->result().isNull())
+ return true;
+
+ QString text = event->result().string();
+ text.replace(QChar('\\'), backslashAsCurrencySymbol());
+
+ return [_bridge runBeforeUnloadConfirmPanelWithMessage:text.getNSString()];
+
+ KWQ_UNBLOCK_EXCEPTIONS;
+
+ return true;
+}
+
void KWQKHTMLPart::addMessageToConsole(const QString &message, unsigned lineNumber, const QString &sourceURL)
{
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
1.327.8.7 +3 -0 WebCore/kwq/WebCoreBridge.h
Index: WebCoreBridge.h
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.h,v
retrieving revision 1.327.8.6
retrieving revision 1.327.8.7
diff -u -r1.327.8.6 -r1.327.8.7
--- WebCoreBridge.h 16 Sep 2005 19:28:09 -0000 1.327.8.6
+++ WebCoreBridge.h 19 Nov 2005 02:35:43 -0000 1.327.8.7
@@ -363,6 +363,7 @@
- (int)numPendingOrLoadingRequests;
- (BOOL)doneProcessingData;
+- (BOOL)shouldClose;
- (void)setDrawsBackground:(BOOL)drawsBackround;
@@ -515,6 +516,8 @@
- (void)runJavaScriptAlertPanelWithMessage:(NSString *)message;
- (BOOL)runJavaScriptConfirmPanelWithMessage:(NSString *)message;
- (BOOL)runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText returningText:(NSString **)result;
+- (BOOL)canRunBeforeUnloadConfirmPanel;
+- (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message;
- (void)addMessageToConsole:(NSDictionary *)message;
- (id <WebCoreResourceHandle>)startLoadingResource:(id <WebCoreResourceLoader>)loader withURL:(NSURL *)URL customHeaders:(NSDictionary *)customHeaders;
1.382.2.15 +5 -0 WebCore/kwq/WebCoreBridge.mm
Index: WebCoreBridge.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/WebCoreBridge.mm,v
retrieving revision 1.382.2.14
retrieving revision 1.382.2.15
diff -u -r1.382.2.14 -r1.382.2.15
--- WebCoreBridge.mm 16 Nov 2005 01:36:17 -0000 1.382.2.14
+++ WebCoreBridge.mm 19 Nov 2005 02:35:44 -0000 1.382.2.15
@@ -1474,6 +1474,11 @@
return YES;
}
+- (BOOL)shouldClose
+{
+ return _part->shouldClose();
+}
+
- (NSColor *)bodyBackgroundColor
{
return _part->bodyBackgroundColor();
No revision
No revision
1.3118.4.82 +21 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3118.4.81
retrieving revision 1.3118.4.82
diff -u -r1.3118.4.81 -r1.3118.4.82
--- ChangeLog 15 Nov 2005 03:26:37 -0000 1.3118.4.81
+++ ChangeLog 19 Nov 2005 02:35:51 -0000 1.3118.4.82
@@ -1,3 +1,24 @@
+2005-11-18 Timothy Hatcher <timothy at apple.com>
+
+ Merged fix from TOT to Safari-2-0-branch
+
+ 2005-11-18 Vicki Murley <vicki at apple.com>
+
+ Changes by Darin, reviewed by Beth and Vicki.
+
+ - fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge canRunBeforeUnloadConfirmPanel]):
+ (-[WebBridge runBeforeUnloadConfirmPanelWithMessage:]):
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame _checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]):
+ (-[WebFrame _continueLoadRequestAfterNavigationPolicy:formState:]):
+ * WebView.subproj/WebUIDelegatePrivate.h:
+ * WebView.subproj/WebView.m:
+ (-[WebView shouldClose]):
+ * WebView.subproj/WebViewPrivate.h:
+
=== WebKit-417.4 ===
2005-11-12 Timothy Hatcher <timothy at apple.com>
No revision
No revision
1.340.8.14 +16 -0 WebKit/WebCoreSupport.subproj/WebBridge.m
Index: WebBridge.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
retrieving revision 1.340.8.13
retrieving revision 1.340.8.14
diff -u -r1.340.8.13 -r1.340.8.14
--- WebBridge.m 13 Nov 2005 03:22:03 -0000 1.340.8.13
+++ WebBridge.m 19 Nov 2005 02:36:08 -0000 1.340.8.14
@@ -374,6 +374,22 @@
return [[WebDefaultUIDelegate sharedUIDelegate] webView:wv runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:_frame];
}
+- (BOOL)canRunBeforeUnloadConfirmPanel
+{
+ WebView *wv = [_frame webView];
+ id wd = [wv UIDelegate];
+ return [wd respondsToSelector:@selector(webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:)];
+}
+
+- (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message
+{
+ WebView *wv = [_frame webView];
+ id wd = [wv UIDelegate];
+ if ([wd respondsToSelector:@selector(webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:)])
+ return [wd webView:wv runBeforeUnloadConfirmPanelWithMessage:message initiatedByFrame:_frame];
+ return YES;
+}
+
- (BOOL)runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText returningText:(NSString **)result
{
WebView *wv = [_frame webView];
No revision
No revision
1.223.8.11 +8 -1 WebKit/WebView.subproj/WebFrame.m
Index: WebFrame.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrame.m,v
retrieving revision 1.223.8.10
retrieving revision 1.223.8.11
diff -u -r1.223.8.10 -r1.223.8.11
--- WebFrame.m 9 Sep 2005 17:17:02 -0000 1.223.8.10
+++ WebFrame.m 19 Nov 2005 02:36:10 -0000 1.223.8.11
@@ -2310,7 +2310,14 @@
// through this method already, nested; otherwise, _private->policyDataSource should still be set.
ASSERT(_private->policyDataSource || [[self provisionalDataSource] unreachableURL] != nil);
- if (!request) {
+
+ // Two reasons we can't continue:
+ // 1) navigation policy delegate said we can't so request is nil.
+ // 2) before unload event handler caused an alert to come up and the user said cancel.
+ // The "before unload" event handler runs only for the main frame.
+ BOOL canContinue = request && ([[self webView] mainFrame] != self || [_private->bridge shouldClose]);
+
+ if (!canContinue) {
[self _setPolicyDataSource:nil];
return;
}
1.11.8.3 +14 -1 WebKit/WebView.subproj/WebUIDelegatePrivate.h
Index: WebUIDelegatePrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebUIDelegatePrivate.h,v
retrieving revision 1.11.8.2
retrieving revision 1.11.8.3
diff -u -r1.11.8.2 -r1.11.8.3
--- WebUIDelegatePrivate.h 13 Nov 2005 03:22:05 -0000 1.11.8.2
+++ WebUIDelegatePrivate.h 19 Nov 2005 02:36:10 -0000 1.11.8.3
@@ -51,7 +51,7 @@
@param sender The WebView sending the delegate method.
@param message The message to display.
@param frame The WebFrame whose JavaScript initiated this call.
- @result YES if the user hit OK, no if the user chose Cancel.
+ @result YES if the user hit OK, NO if the user chose Cancel.
@discussion Clients should visually indicate that this panel comes
from JavaScript initiated by the specified frame. The panel should have
two buttons, e.g. "OK" and "Cancel".
@@ -72,5 +72,18 @@
*/
- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame;
+/*!
+ @method webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:
+ @abstract Display a confirm panel by an "before unload" event handler.
+ @param sender The WebView sending the delegate method.
+ @param message The message to display.
+ @param frame The WebFrame whose JavaScript initiated this call.
+ @result YES if the user hit OK, NO if the user chose Cancel.
+ @discussion Clients should include a message in addition to the one
+ supplied by the web page that indicates. The panel should have
+ two buttons, e.g. "OK" and "Cancel".
+*/
+// FIXME: Should we indicate a distinction between navigation and close?
+- (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
@end
1.274.8.6 +8 -0 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.274.8.5
retrieving revision 1.274.8.6
diff -u -r1.274.8.5 -r1.274.8.6
--- WebView.m 25 Aug 2005 06:33:58 -0000 1.274.8.5
+++ WebView.m 19 Nov 2005 02:36:11 -0000 1.274.8.6
@@ -2533,6 +2533,14 @@
return _private->scriptDebugDelegate;
}
+- (BOOL)shouldClose
+{
+ WebBridge *bridge = [[self mainFrame] _bridge];
+ if (!bridge)
+ return YES;
+ return [bridge shouldClose];
+}
+
@end
@implementation WebView (WebViewPrintingPrivate)
1.138.8.4 +2 -0 WebKit/WebView.subproj/WebViewPrivate.h
Index: WebViewPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewPrivate.h,v
retrieving revision 1.138.8.3
retrieving revision 1.138.8.4
diff -u -r1.138.8.3 -r1.138.8.4
--- WebViewPrivate.h 25 Aug 2005 06:33:59 -0000 1.138.8.3
+++ WebViewPrivate.h 19 Nov 2005 02:36:11 -0000 1.138.8.4
@@ -72,6 +72,8 @@
*/
- (id)scriptDebugDelegate;
+- (BOOL)shouldClose;
+
@end
@interface WebView (WebPrivate)
More information about the webkit-changes
mailing list