-
darin@apple.com authored
2009-06-02 Darin Adler <darin@apple.com> Reviewed by David Hyatt. Bug 26112: viewless WebKit -- make events work https://bugs.webkit.org/show_bug.cgi?id=26112 The main fix here is to make mouse and wheel event coordinates in the coordinate system of the top level NSView rather than the NSWindow when in the viewless mode. This is the design Hyatt chose, but the event part of it wasn't done yet. Also fix FrameView to do normal reference counting instead of a strange model with an explicit deref near creation time. * WebCore.base.exp: Updated. * page/EventHandler.cpp: (WebCore::EventHandler::eventLoopHandleMouseUp): Moved this function into the file to reduce conditionals in the header. (WebCore::EventHandler::eventLoopHandleMouseDragged): Ditto. * page/EventHandler.h: Reduced includes. Fixed formatting of Objective-C types. Made currentNSEvent a static member function. Added sendContextMenuEvent and eventMayStartDrag functions that takes NSEvent * so the conversion to PlatformMouseEvent can be done here rather than in WebKit. Reduced #if by making eventLoopHandleMouseUp and eventLoopHandleMouseDragged unconditional. * page/Frame.cpp: (WebCore::Frame::setView): Made this take a PassRefPtr since it takes ownership. (WebCore::Frame::createView): Changed to use RefPtr and FrameView::create and remove the explicit deref. * page/Frame.h: Changed setView to take a PassRefPtr. * page/FrameTree.cpp: Added newly-needed include. * page/FrameView.cpp: (WebCore::FrameView::FrameView): Got rid of one of the two constructors, and removed the initialization of m_refCount and call to show from the reamining one. (WebCore::FrameView::create): Added two create functions that do what the two constructors did before, except that they return a PassRefPtr to make sure the reference counting is handled correctly. (WebCore::FrameView::~FrameView): Removed assertion from when FrameView implemented its own reference counting. * page/FrameView.h: Inherit from RefCounted for reference counting. Made the constructor private and added create functions. Got rid of the hand-implemented reference counting in this class. * page/mac/EventHandlerMac.mm: (WebCore::currentNSEventSlot): Renamed currentEvent to currentNSEventSlot to make it more clear how it relates to currentNSEvent. (WebCore::EventHandler::currentNSEvent): Updated. (WebCore::CurrentEventScope::CurrentEventScope): Added. Use to set/reset the current event in a foolproof way. (WebCore::CurrentEventScope::~CurrentEventScope): Ditto. (WebCore::EventHandler::wheelEvent): Use CurrentEventScope. Pass the platform window in when constructing the PlatformWheelEvent. (WebCore::EventHandler::keyEvent): Use CurrentEventScope. (WebCore::lastEventIsMouseUp): Use currentNSEvent. (WebCore::EventHandler::passMouseDownEventToWidget): Ditto. (WebCore::EventHandler::eventLoopHandleMouseDragged): Ditto. (WebCore::EventHandler::eventLoopHandleMouseUp): Ditto. (WebCore::EventHandler::passSubframeEventToSubframe): Use currentPlatformMouseEvent to get a mouse event that has the appropriate platform window passed to create it. (WebCore::EventHandler::passWheelEventToWidget): Ditto. (WebCore::EventHandler::mouseDown): Ditto. (WebCore::EventHandler::mouseDragged): Ditto. (WebCore::EventHandler::mouseUp): Ditto. (WebCore::EventHandler::mouseMoved): Ditto. (WebCore::EventHandler::currentPlatformMouseEvent): Added. Passes the platform window that's now needed to create a PlatformMouseEvent. (WebCore::EventHandler::sendContextMenuEvent): Added. (WebCore::EventHandler::eventMayStartDrag): Added. * platform/HostWindow.h: Removed unneeded includes and constructor definition. * platform/PlatformMouseEvent.h: Sorted things in alphabetical order. Changed Mac constructor to take a windowView as well as the event. This is needed in viewless mode, since the "window" is actually an NSView, so the event has to know which view to compute the coordinates with. Made the same change to pointForEvent. * platform/PlatformWheelEvent.h: Ditto. * platform/mac/PlatformMouseEventMac.mm: (WebCore::pointForEvent): Convert point from window coordinates to view coordinates if a windowView is passed in. This is used in viewless mode. (WebCore::PlatformMouseEvent::PlatformMouseEvent): Ditto. * platform/mac/WheelEventMac.mm: (WebCore::PlatformWheelEvent::PlatformWheelEvent): Ditto. * platform/mac/WidgetMac.mm: (WebCore::Widget::convertFromContainingWindow): Fixed case where there is no platform widget and no parent. Before it would yield unpredictable results because of dispatching to a nil object and returning a structure. Now it returns the point without changing coordinates at all, which is what we need for this case in viewless mode. * rendering/RenderApplet.cpp: Removed unneeded includes. (WebCore::RenderApplet::intrinsicSize): Use widget function. (WebCore::RenderApplet::createWidgetIfNecessary): Ditto. * rendering/RenderApplet.h: Make more things private. Get rid of unneeded explicit destructor. * rendering/RenderFrame.cpp: Removed unneeded includes. (WebCore::RenderFrame::edgeInfo): Updated to use node function so header doesn't have to define element function. (WebCore::RenderFrame::viewCleared): Ditto. Also changed to use widget function. * rendering/RenderFrame.h: Removed unneeded includes. Made some things private. Got rid of element function. * rendering/RenderPart.cpp: Removed unneeded includes. (WebCore::RenderPart::~RenderPart): Changed to use clearWidget function. (WebCore::RenderPart::setWidget): Changed to use widget function. (WebCore::RenderPart::deleteWidget): Changed to use passed-in widget. This is now only called by the clearWidget function. * rendering/RenderPart.h: Removed unneeded forward declarations. Made more functions private. Updated deleteWidget to take widget argument. * rendering/RenderPartObject.cpp: (WebCore::RenderPartObject::~RenderPartObject): use frameView function instead of getting at m_view directly. (WebCore::RenderPartObject::updateWidget): Ditto. (WebCore::RenderPartObject::layout): Ditto. Same for widget and m_widget. (WebCore::RenderPartObject::viewCleared): Ditto. * rendering/RenderPartObject.h: Made some functions private. * rendering/RenderWidget.cpp: (WebCore::RenderWidget::RenderWidget): Initialize m_frameView with construction syntax instead of assignment. (WebCore::RenderWidget::destroy): Updated for name change of m_view to m_frameView. (WebCore::RenderWidget::~RenderWidget): Use clearWidget to delete the widget. (WebCore::RenderWidget::setWidget): Use clearWidget. (WebCore::RenderWidget::paint): Updated for name change of m_view to m_frameView. (WebCore::RenderWidget::deleteWidget): Changed to use passed-in widget. * rendering/RenderWidget.h: Made many functions protected, others private and made all data members private. * svg/animation/SMILTime.h: Removed unhelpful max and min functions. These just do what std::max and std::min will already do automatically for this type, so they are not helpful. * svg/graphics/SVGImage.cpp: (WebCore::SVGImage::SVGImage): Removed unneeded initial values for types that initialize to zero without anything explicit. (WebCore::SVGImage::~SVGImage): Update since m_frame and m_frameView are no longer stored. (WebCore::SVGImage::setContainerSize): Ditto. (WebCore::SVGImage::usesContainerSize): Ditto. (WebCore::SVGImage::size): Ditto. (WebCore::SVGImage::hasRelativeWidth): Ditto. (WebCore::SVGImage::hasRelativeHeight): Ditto. (WebCore::SVGImage::draw): Ditto. (WebCore::SVGImage::nativeImageForCurrentFrame): Ditto. (WebCore::SVGImage::dataChanged): Ditto. * svg/graphics/SVGImage.h: Removed unneeded includes and unneeded data members m_document, m_frame, m_frameView, and m_minSize. WebKit/mac: 2009-06-02 Darin Adler <darin@apple.com> Reviewed by David Hyatt. Bug 26112: viewless WebKit -- make events work https://bugs.webkit.org/show_bug.cgi?id=26112 One change here is to make the -[WebFrame frameView] function assert if ever called in viewless mode, and fix many callers that would trip that assertion. A major change is to put some methods and data in WebView that are currently in WebHTMLView, used only in viewless mode. A next step will be to use the WebView methods whenever possible, even when not in the viewless mode. Also fix FrameView to do normal reference counting instead of a strange model with an explicit deref near creation time. * WebCoreSupport/WebChromeClient.mm: (WebChromeClient::scrollRectIntoView): Add code to start in the appropriate place when dealing with viewless mode. This gets triggered when visiting the Google home page. (WebChromeClient::setToolTip): Changed to call WebView instead of WebHTMLView. (WebChromeClient::print): Changed to use a new selector that doesn't require a WebFrameView if present. Also don't even try to use the old selector in viewless mode. * WebCoreSupport/WebEditorClient.mm: (WebEditorClient::respondToChangedSelection): Changed to call WebView instead of WebHTMLView. * WebCoreSupport/WebFrameLoaderClient.mm: (WebFrameLoaderClient::transitionToCommittedForNewPage): Added more code paths for viewless mode to skip things we can't do in that mode, with appropriate FIXME. Use Frame::create and RefPtr and eliminate the strange reference counting of FrameView. * WebView/WebDataSource.mm: (-[WebDataSource _receivedData:]): Added a _usesDocumentViews guard around code that's specific to document views. * WebView/WebFrame.mm: (-[WebFrame _updateBackgroundAndUpdatesWhileOffscreen]): Added a _usesDocumentViews guard around code that's specific to document views. (-[WebFrame _hasSelection]): Added an implementation for viewless mode. (-[WebFrame _clearSelection]): Assert we're not in viewless mode; it doesn't really make sense to clear the selection in only one frame in viewless mode. Later we can decide what to do. (-[WebFrame _dragSourceMovedTo:]): Assert we're not in viewless mode; the dragging code for viewless mode shouldn't have to involve the WebFrame object at all. (-[WebFrame _dragSourceEndedAt:operation:]): Ditto. (-[WebFrame frameView]): Assert we're not in viewless mode. This assertion fires often, but it's a great pointer to code that needs to be changed. * WebView/WebHTMLView.mm: (-[WebHTMLView hitTest:]): Tweaked a comment. (-[WebHTMLView _updateMouseoverWithEvent:]): Fixed a bug where the fake event for moving the mouse out of the old view ended up overwriting the event for moving the mouse within the new view. (-[WebHTMLView mouseDown:]): Got rid of explicit conversion of event to PlatformMouseEvent in call to sendContextMenuEvent; that's no longer possible without passing another argument, and it's now handled in EventHandler. * WebView/WebTextCompletionController.h: Copied from WebKit/mac/WebView/WebHTMLView.mm. Removed everything except for the WebTextCompletionController class. * WebView/WebTextCompletionController.mm: Copied from WebKit/mac/WebView/WebHTMLView.mm. Ditto. * WebView/WebUIDelegatePrivate.h: Added webView:printFrame: method. * WebView/WebView.mm: Moved includes and fields in from WebHTMLView. (-[WebView _usesDocumentViews]): Updated for name change from useDocumentViews to usesDocumentViews. (-[WebView _commonInitializationWithFrameName:groupName:usesDocumentViews:]): Ditto. (-[WebView drawSingleRect:]): Ditto. (-[WebView isFlipped]): Ditto. (-[WebView setFrameSize:]): Ditto. Also changed to use _mainCoreFrame method. (-[WebView _viewWillDrawInternal]): Ditto. (-[WebView viewWillDraw]): Ditto. (-[WebView drawRect:]): Ditto. (-[WebView _close]): Added code to nil out the lastMouseoverView global. (-[WebView _dashboardRegions]): Use _mainCoreFrame. (-[WebView setProhibitsMainFrameScrolling:]): Ditto. (-[WebView _setInViewSourceMode:]): Ditto. (-[WebView _inViewSourceMode]): Ditto. (-[WebView _attachScriptDebuggerToAllFrames]): Ditto. (-[WebView _detachScriptDebuggerFromAllFrames]): Ditto. (-[WebView textIteratorForRect:]): Ditto. (-[WebView _executeCoreCommandByName:value:]): Ditto. (-[WebView addWindowObserversForWindow:]): Ditto. (-[WebView removeWindowObservers]): Ditto. (-[WebView _updateFocusedAndActiveState]): Ditto. (-[WebView _updateFocusedAndActiveStateForFrame:]): Turned into a class method. Added code to handle the viewless case without calling frameView. (-[WebView _windowDidBecomeKey:]): Updated for name change from useDocumentViews to usesDocumentViews. (-[WebView _windowDidResignKey:]): Ditto. (-[WebView _windowWillOrderOnScreen:]): Ditto. (-[WebView mainFrame]): Tweaked. (-[WebView selectedFrame]): Added a conditional to avoid trying to get at the frame view in viewless case. (-[WebView _setZoomMultiplier:isTextOnly:]): Use _mainCoreFrame. (-[WebView setCustomTextEncodingName:]): Ditto. (-[WebView windowScriptObject]): Ditto. (-[WebView setHostWindow:]): Ditto. Also put some code that's needed only for document views inside _private->usesDocumentViews. (-[WebView _hitTest:dragTypes:]): Tweaked. (-[WebView acceptsFirstResponder]): Added case for viewless mode along with a FIXME, since it's not complete. (-[WebView becomeFirstResponder]): Ditto. (-[WebView _webcore_effectiveFirstResponder]): Put the body of this inside a usesDocumentView check, because we don't need the first responder forwarding in viewless mode. (-[WebView setNextKeyView:]): Ditto. (-[WebView mouseDown:]): Added. Copied from WebHTMLView. FIXME in here suggests that we make WebHTMLView share this one soon, which I think is practical. (-[WebView mouseUp:]): Ditto. (-[WebView setHoverFeedbackSuspended:]): Added a code path for viewless mode. (-[WebView shouldClose]): Use _mainCoreFrame. (-[WebView aeDescByEvaluatingJavaScriptFromString:]): Ditto. (-[WebView setEditable:]): Ditto. (-[WebView _frameViewAtWindowPoint:]): Added an assertion that we're not in viewless mode since this method makes no sense in that mode. (-[WebView _setMouseDownEvent:]): Added. Copied from WebHTMLView. I plan to eliminate the one in WebHTMLView soon. (-[WebView _cancelUpdateMouseoverTimer]): Ditto. (-[WebView _stopAutoscrollTimer]): Ditto. (+[WebView _updateMouseoverWithEvent:]): Ditto. (-[WebView _updateMouseoverWithFakeEvent]): Ditto. (-[WebView _setToolTip:]): Added. Calls through to the WebHTMLView version. (-[WebView _selectionChanged]): Ditto. (-[WebView _mainCoreFrame]): Added. (-[WebView _needsOneShotDrawingSynchronization]): Moved into the WebInternal category. (-[WebView _setNeedsOneShotDrawingSynchronization:]): Ditto. (-[WebView _startedAcceleratedCompositingForFrame:]): Ditto. (-[WebView _stoppedAcceleratedCompositingForFrame:]): Ditto. (viewUpdateRunLoopObserverCallBack): Ditto. (-[WebView _scheduleViewUpdate]): Ditto. * WebView/WebViewInternal.h: Made most of the file not compile at all when included from non-C++ source files, elminating some excess declarations and typedefs. Moved more methods into the real internal category. Added new methods _setMouseDownEvent, _cancelUpdateMouseoverTimer, _stopAutoscrollTimer, _updateMouseoverWithFakeEvent, _selectionChanged, and _setToolTip:. WebKit/wx: 2009-06-02 Darin Adler <darin@apple.com> Reviewed by David Hyatt. * WebKitSupport/FrameLoaderClientWx.cpp: (WebCore::FrameLoaderClientWx::transitionToCommittedForNewPage): Use FrameView::create and RefPtr instead of the old "crazy" reference counting. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@44379 268f45cc-cd09-0410-ab3c-d52691b4dbfc
bd433bc4