Commit 9c03760c authored by darin's avatar darin
Browse files

WebCore:

        Reviewed by John.

	- fixed 3108912 -- onclick handlers not supported on form elements

	We now pass the events back to the NSView here in WebCore; they pass through all the
	machinery in the DOM before getting sent on.

        * kwq/KWQKHTMLPart.h: Add widgetWillReleaseView and handleMouseDownEventForWidget functions,
	overrides for khtmlMousePressEvent, khtmlMouseDoubleClickEvent, khtmlMouseReleaseEvent, and
	a new _mouseDownView field.

        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::KWQKHTMLPart): Initialize _mouseDownView to nil.
        (KWQKHTMLPart::khtmlMousePressEvent): Call handleMouseDownEventForWidget, but if it returns
	false call through to the base class function.
        (KWQKHTMLPart::khtmlMouseDoubleClickEvent): Ditto.
        (KWQKHTMLPart::handleMouseDownEventForWidget): Do a hit test to find out which view to send
	the mouse down event to, and then send it.
        (KWQKHTMLPart::khtmlMouseReleaseEvent): Send the mouse up event to the view we sent a mouse
	down event to, or call through to the base class otherwise.
        (KWQKHTMLPart::widgetWillReleaseView): Clear out the _mouseDownView field if the view is
	being released by the QWidget that owns it.

        * kwq/KWQWidget.mm:
        (QWidget::~QWidget): Call KWQKHTMLPart::widgetWillReleaseView.
        (QWidget::setView): Call KWQKHTMLPart::widgetWillReleaseView on the old view.

WebKit:

        Reviewed by John.

	- fixed 3108912 -- onclick handlers not supported on form elements

        * WebView.subproj/WebHTMLView.m: (-[WebHTMLView hitTest:]):
	Take over hit testing so that all clicks on subviews are handled by the WebHTMLView.
	WebCore now handles getting the mouse events to the subviews after passing
	the events through the DOM.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 102b38ae
2002-12-10 Darin Adler <darin@apple.com>
Reviewed by John.
- fixed 3108912 -- onclick handlers not supported on form elements
We now pass the events back to the NSView here in WebCore; they pass through all the
machinery in the DOM before getting sent on.
* kwq/KWQKHTMLPart.h: Add widgetWillReleaseView and handleMouseDownEventForWidget functions,
overrides for khtmlMousePressEvent, khtmlMouseDoubleClickEvent, khtmlMouseReleaseEvent, and
a new _mouseDownView field.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::KWQKHTMLPart): Initialize _mouseDownView to nil.
(KWQKHTMLPart::khtmlMousePressEvent): Call handleMouseDownEventForWidget, but if it returns
false call through to the base class function.
(KWQKHTMLPart::khtmlMouseDoubleClickEvent): Ditto.
(KWQKHTMLPart::handleMouseDownEventForWidget): Do a hit test to find out which view to send
the mouse down event to, and then send it.
(KWQKHTMLPart::khtmlMouseReleaseEvent): Send the mouse up event to the view we sent a mouse
down event to, or call through to the base class otherwise.
(KWQKHTMLPart::widgetWillReleaseView): Clear out the _mouseDownView field if the view is
being released by the QWidget that owns it.
* kwq/KWQWidget.mm:
(QWidget::~QWidget): Call KWQKHTMLPart::widgetWillReleaseView.
(QWidget::setView): Call KWQKHTMLPart::widgetWillReleaseView on the old view.
2002-12-09 Darin Adler <darin@apple.com>
Reviewed by Maciej.
......
2002-12-10 Darin Adler <darin@apple.com>
Reviewed by John.
- fixed 3108912 -- onclick handlers not supported on form elements
We now pass the events back to the NSView here in WebCore; they pass through all the
machinery in the DOM before getting sent on.
* kwq/KWQKHTMLPart.h: Add widgetWillReleaseView and handleMouseDownEventForWidget functions,
overrides for khtmlMousePressEvent, khtmlMouseDoubleClickEvent, khtmlMouseReleaseEvent, and
a new _mouseDownView field.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::KWQKHTMLPart): Initialize _mouseDownView to nil.
(KWQKHTMLPart::khtmlMousePressEvent): Call handleMouseDownEventForWidget, but if it returns
false call through to the base class function.
(KWQKHTMLPart::khtmlMouseDoubleClickEvent): Ditto.
(KWQKHTMLPart::handleMouseDownEventForWidget): Do a hit test to find out which view to send
the mouse down event to, and then send it.
(KWQKHTMLPart::khtmlMouseReleaseEvent): Send the mouse up event to the view we sent a mouse
down event to, or call through to the base class otherwise.
(KWQKHTMLPart::widgetWillReleaseView): Clear out the _mouseDownView field if the view is
being released by the QWidget that owns it.
* kwq/KWQWidget.mm:
(QWidget::~QWidget): Call KWQKHTMLPart::widgetWillReleaseView.
(QWidget::setView): Call KWQKHTMLPart::widgetWillReleaseView on the old view.
2002-12-09 Darin Adler <darin@apple.com>
Reviewed by Maciej.
......
......@@ -143,9 +143,17 @@ public:
void addMetaData(const QString &key, const QString &value);
bool keyEvent(NSEvent *event);
bool keyEvent(NSEvent *);
static void widgetWillReleaseView(NSView *);
private:
virtual void khtmlMousePressEvent(khtml::MousePressEvent *);
virtual void khtmlMouseDoubleClickEvent(khtml::MouseDoubleClickEvent *);
virtual void khtmlMouseReleaseEvent(khtml::MouseReleaseEvent *);
bool handleMouseDownEventForWidget(khtml::MouseEvent *);
void setPolicyBaseURL(const DOM::DOMString &);
WebCoreBridge *bridgeForFrameName(const QString &frameName);
......@@ -163,6 +171,8 @@ private:
KWQSignal _completedWithBool;
bool _ownsView;
NSView *_mouseDownView;
static QPtrList<KWQKHTMLPart> &mutableInstances();
......
......@@ -47,9 +47,17 @@
#undef _KWQ_TIMING
using DOM::DocumentImpl;
using DOM::DOMString;
using DOM::EventImpl;
using DOM::Node;
using khtml::Cache;
using khtml::ChildFrame;
using khtml::Decoder;
using khtml::MouseDoubleClickEvent;
using khtml::MousePressEvent;
using khtml::MouseReleaseEvent;
using khtml::RenderObject;
using khtml::RenderPart;
using khtml::RenderText;
......@@ -57,6 +65,9 @@ using khtml::RenderWidget;
using KIO::Job;
using KJS::SavedProperties;
using KJS::Window;
using KParts::ReadOnlyPart;
using KParts::URLArgs;
......@@ -72,7 +83,7 @@ void KHTMLPart::completed(bool arg)
KWQ(this)->_completed.call(arg);
}
void KHTMLPart::nodeActivated(const DOM::Node &aNode)
void KHTMLPart::nodeActivated(const Node &)
{
}
......@@ -107,6 +118,7 @@ KWQKHTMLPart::KWQKHTMLPart()
, _completed(this, SIGNAL(completed()))
, _completedWithBool(this, SIGNAL(completed(bool)))
, _ownsView(false)
, _mouseDownView(nil)
{
Cache::init();
mutableInstances().prepend(this);
......@@ -412,34 +424,34 @@ bool KWQKHTMLPart::canCachePage()
(d->m_frames.count() ||
parentPart() ||
d->m_objects.count() ||
d->m_doc->getWindowEventListener (DOM::EventImpl::UNLOAD_EVENT) ||
(d->m_jscript && KJS::Window::retrieveWindow(this)->hasTimeouts()))){
d->m_doc->getWindowEventListener (EventImpl::UNLOAD_EVENT) ||
(d->m_jscript && Window::retrieveWindow(this)->hasTimeouts()))){
return false;
}
return true;
}
void KWQKHTMLPart::saveWindowProperties(KJS::SavedProperties *windowProperties)
void KWQKHTMLPart::saveWindowProperties(SavedProperties *windowProperties)
{
KJS::Window::retrieveWindow(this)->saveProperties(*windowProperties);
Window::retrieveWindow(this)->saveProperties(*windowProperties);
}
void KWQKHTMLPart::saveLocationProperties(KJS::SavedProperties *locationProperties)
void KWQKHTMLPart::saveLocationProperties(SavedProperties *locationProperties)
{
KJS::Window::retrieveWindow(this)->location()->saveProperties(*locationProperties);
Window::retrieveWindow(this)->location()->saveProperties(*locationProperties);
}
void KWQKHTMLPart::restoreWindowProperties(KJS::SavedProperties *windowProperties)
void KWQKHTMLPart::restoreWindowProperties(SavedProperties *windowProperties)
{
KJS::Window::retrieveWindow(this)->restoreProperties(*windowProperties);
Window::retrieveWindow(this)->restoreProperties(*windowProperties);
}
void KWQKHTMLPart::restoreLocationProperties(KJS::SavedProperties *locationProperties)
void KWQKHTMLPart::restoreLocationProperties(SavedProperties *locationProperties)
{
KJS::Window::retrieveWindow(this)->location()->restoreProperties(*locationProperties);
Window::retrieveWindow(this)->location()->restoreProperties(*locationProperties);
}
void KWQKHTMLPart::openURLFromPageCache(DOM::DocumentImpl *doc, KURL *url, KJS::SavedProperties *windowProperties, KJS::SavedProperties *locationProperties)
void KWQKHTMLPart::openURLFromPageCache(DocumentImpl *doc, KURL *url, SavedProperties *windowProperties, SavedProperties *locationProperties)
{
d->m_redirectionTimer.stop();
......@@ -561,7 +573,7 @@ void KWQKHTMLPart::updatePolicyBaseURL()
}
}
void KWQKHTMLPart::setPolicyBaseURL(const DOM::DOMString &s)
void KWQKHTMLPart::setPolicyBaseURL(const DOMString &s)
{
// XML documents will cause this to return null. docImpl() is
// an HTMLdocument only. -dwh
......@@ -702,6 +714,74 @@ void KWQKHTMLPart::scrollToAnchor(const KURL &URL)
bool KWQKHTMLPart::closeURL()
{
saveDocumentState();
return KHTMLPart::closeURL();
saveDocumentState();
return KHTMLPart::closeURL();
}
void KWQKHTMLPart::khtmlMousePressEvent(MousePressEvent *event)
{
if (!handleMouseDownEventForWidget(event)) {
KHTMLPart::khtmlMousePressEvent(event);
}
}
void KWQKHTMLPart::khtmlMouseDoubleClickEvent(MouseDoubleClickEvent *event)
{
if (!handleMouseDownEventForWidget(event)) {
KHTMLPart::khtmlMouseDoubleClickEvent(event);
}
}
bool KWQKHTMLPart::handleMouseDownEventForWidget(khtml::MouseEvent *event)
{
_mouseDownView = nil;
// Figure out which view to send the event to.
RenderObject *target = event->innerNode().handle()->renderer();
if (!target->isWidget()) {
return false;
}
NSView *outerView = static_cast<RenderWidget *>(target)->widget()->getOuterView();
ASSERT(outerView);
ASSERT([outerView superview]);
NSView *topView = outerView;
NSView *superview;
while ((superview = [topView superview])) {
topView = superview;
}
NSView *view = [outerView hitTest:[[outerView superview] convertPoint:[[NSApp currentEvent] locationInWindow] fromView:topView]];
if (view == nil) {
ERROR("KHTML says we hit a RenderWidget, but AppKit doesn't agree we hit the corresponding NSView");
return false;
}
[view mouseDown:[NSApp currentEvent]];
// Remember which view we sent the event to, so we can direct the release event properly.
_mouseDownView = view;
return true;
}
void KWQKHTMLPart::khtmlMouseReleaseEvent(MouseReleaseEvent *event)
{
if (!_mouseDownView) {
KHTMLPart::khtmlMouseReleaseEvent(event);
return;
}
[_mouseDownView mouseUp:[NSApp currentEvent]];
_mouseDownView = nil;
}
void KWQKHTMLPart::widgetWillReleaseView(NSView *view)
{
if (view == nil) {
return;
}
for (QPtrListIterator<KWQKHTMLPart> it(instances()); it.current(); ++it) {
if ([it.current()->_mouseDownView isDescendantOf:view]) {
it.current()->_mouseDownView = nil;
}
}
}
......@@ -72,6 +72,7 @@ QWidget::QWidget(NSView *view)
QWidget::~QWidget()
{
KWQKHTMLPart::widgetWillReleaseView(getOuterView());
[data->view release];
delete data;
}
......@@ -344,17 +345,20 @@ NSView *QWidget::getView() const
void QWidget::setView(NSView *view)
{
[view retain];
if (view == data->view) {
return;
}
KWQKHTMLPart::widgetWillReleaseView(getOuterView());
[data->view release];
data->view = view;
data->view = [view retain];
}
NSView *QWidget::getOuterView() const
{
// A QScrollView is a widget only used to represent a frame. If
// this widget's view is a WebCoreFrameView the we resize it's containing
// view, an WebView. The scrollview contained by the WebView
// will be autosized.
// A QScrollView is a widget normally used to represent a frame.
// If this widget's view is a WebCoreFrameView the we resize its containing view, a WebView.
// The scroll view contained by the WebView will be autosized.
NSView *view = data->view;
ASSERT(view);
if ([view conformsToProtocol:@protocol(WebCoreFrameView)]) {
......
2002-12-10 Darin Adler <darin@apple.com>
Reviewed by John.
- fixed 3108912 -- onclick handlers not supported on form elements
* WebView.subproj/WebHTMLView.m: (-[WebHTMLView hitTest:]):
Take over hit testing so that all clicks on subviews are handled by the WebHTMLView.
WebCore now handles getting the mouse events to the subviews after passing
the events through the DOM.
2002-12-09 Maciej Stachowiak <mjs@apple.com>
Reviewed by Trey.
......
......@@ -924,14 +924,10 @@ - (void)dataSourceUpdated:(WebDataSource *)dataSource
{
}
#if 0
- (NSView *)hitTest:(NSPoint)point
{
// We handle all clicks. We don't allow subviews to handle them.
// We handle all clicks. They are passed along to subviews by WebCore.
return [super hitTest:point] ? self : nil;
}
#endif
@end
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