diff options
Diffstat (limited to 'WebKit/mac')
83 files changed, 3502 insertions, 926 deletions
diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index e1d0cc3..e45527f 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,1755 @@ +2010-04-21 Mark Rowe <mrowe@apple.com> + + Tiger build fix. + + * Plugins/WebPluginController.mm: Add an #import that is necessary on Tiger. + +2010-04-21 Mark Rowe <mrowe@apple.com> + + Reviewed by Eric Carlson. + + <rdar://problem/7313430> Many crashes in Safari inside Flip4Mac below -[NSAlert didEndAlert:returnCode:contextInfo:] + + Existing versions of the Flip4Mac WebKit plug-in have an object lifetime bug related to an NSAlert that is + used to notify the user about updates to the plug-in. This bug can result in Safari crashing if the page + containing the plug-in navigates while the alert is displayed (<rdar://problem/7313430>). + + The gist of the bug is thus: Flip4Mac sets an instance of the TSUpdateCheck class as the modal delegate of the + NSAlert instance. This TSUpdateCheck instance itself has a delegate. The delegate is set to the WmvPlugin + instance which is the NSView subclass that is exposed to WebKit as the plug-in view. Since this relationship + is that of delegates the TSUpdateCheck does not retain the WmvPlugin. This leads to a bug if the WmvPlugin + instance is destroyed before the TSUpdateCheck instance as the TSUpdateCheck instance will be left with a + pointer to a stale object. This will happen if a page containing the Flip4Mac plug-in triggers a navigation + while the update sheet is visible as the WmvPlugin instance is removed from the view hierarchy and there are + no other references to keep the object alive. + + We work around this bug by patching the following two messages: + + 1) -[NSAlert beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:] + 2) -[TSUpdateCheck alertDidEnd:returnCode:contextInfo:] + + Our override of 1) detects whether it is Flip4Mac's update sheet triggering the alert by checking whether the + modal delegate is an instance of TSUpdateCheck. If it is, it retains the modal delegate's delegate. + + Our override of 2) then autoreleases the delegate, balancing the retain we added in 1). + + These two overrides have the effect of ensuring that the WmvPlugin instance will always outlive the TSUpdateCheck + instance, preventing the TSUpdateCheck instance from accessing a stale delegate pointer and crashing the application. + + * Plugins/WebPluginController.mm: + (-[WebPluginController addPlugin:]): Check whether the plug-in being instantiated is the Flip4Mac plug-in and + install our workaround if it is. + (isKindOfClass): Helper function that checks whether the given object is an instance of the named class. + (WebKit_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_): Autorelease the delegate. + (WebKit_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_): Retain the modal delegate's + delegate if this NSAlert belongs to the Flip4Mac plug-in. + (installFlip4MacPlugInWorkaroundIfNecessary): Swizzle the necessary methods. We swizzle the TSUpdateCheck methods + first since it is possible that in some versions of Flip4Mac the TSUpdateCheck class may not exist or may not have + the method we're interested in. In that case we want to bail out before patching any methods. + +2010-04-20 Mark Rowe <mrowe@apple.com> + + Reviewed by Maciej Stachowiak. + + <rdar://problem/7856151> REGRESSION: NPP_Destroy is not called when page navigates when plug-in is displaying modal dialog + + An interaction between the plug-in host and WebKit was resulting in WKPCSetModal being called while + NetscapePluginInstanceProxy was waiting on a reply to the GetScriptableNPObject message. This resulted + in calls to stop the plug-in being deferred due to the presence of plug-in code up the stack. This + could lead to crashes as it was possible for the plug-in view to be deallocated during the modal runloop. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: + (WKPCInvalidateRect): + (WKPCSetModal): Defer the handling of setModal until the next runloop iteration if the host proxy + is already processing requests. This ensures that there will be no plug-in code on the stack when + the modal runloop is entered, which allows the plug-in to be stopped when the page is navigated while + a modal dialog is displayed. + +2010-04-20 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + Factor DocumentWriter out of FrameLoader + https://bugs.webkit.org/show_bug.cgi?id=37175 + + Update these callsites because the method moved to DocumentWriter. + + * WebView/WebFrame.mm: + (-[WebFrame _canProvideDocumentSource]): + (-[WebFrame _receivedData:textEncodingName:]): + +2010-04-20 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Change a parameter type of chooseIconForFiles() + https://bugs.webkit.org/show_bug.cgi?id=37504 + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::chooseIconForFiles): + +2010-04-20 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r57892. + http://trac.webkit.org/changeset/57892 + https://bugs.webkit.org/show_bug.cgi?id=37864 + + Caused an assertion in Mac builds (Requested by smfr on + #webkit). + + * WebView/WebFrame.mm: + (-[WebFrame _getVisibleRect:]): + * WebView/WebFrameView.mm: + (-[WebFrameView _install]): + +2010-04-20 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Dan Bernstein. + + Clean up RenderPart/RenderPartObject/RenderFrame/RenderEmbeddedObject + https://bugs.webkit.org/show_bug.cgi?id=37741 + + Make Frame::ownerRenderer() return a RenderFrameBase* rather than a + RenderPart*, and add the necessary toRenderFrameBase() and isRenderFrameBase(). + + * WebView/WebFrame.mm: + (-[WebFrame _getVisibleRect:]): + * WebView/WebFrameView.mm: + (-[WebFrameView _install]): + +2010-04-19 Dan Bernstein <mitz@apple.com> + + Reviewed by Sam Weinig. + + Finish exposing extremal shrink factors WebHTMLView uses when shrinking pages to fit in the + printing width as SPI. + + * WebKit.exp: Export _WebHTMLViewPrintingMinimumShrinkFactor and _WebHTMLViewPrintingMaximumShrinkFactor. + +2010-04-15 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Sam Weinig & Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=37675 + Remove casts/constructors to/from JSC::UString type from WebCore::String + + WebCore's strings should not know about JSC::UString, this should be abstracted + away in the bindings. Add explicit conversion methods rather than relying on + overloaded cast operators / constructors being implicitly called. + + This patch only changes the class String, once this has landed StringImpl, and + hopefully AtomicString too, should follow suit. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: + (identifierFromIdentifierRep): + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::addValueToArray): + (WebKit::NetscapePluginInstanceProxy::moveGlobalExceptionToExecState): + * Plugins/Hosted/ProxyInstance.mm: + (WebKit::ProxyInstance::getPropertyNames): + * WebView/WebFrame.mm: + (-[WebFrame _stringByEvaluatingJavaScriptFromString:forceUserGesture:]): + (-[WebFrame _stringByEvaluatingJavaScriptFromString:withGlobalObject:inScriptWorld:]): + * WebView/WebScriptDebugDelegate.mm: + (-[WebScriptCallFrame evaluateWebScript:]): + * WebView/WebScriptDebugger.mm: + (toNSURL): + * WebView/WebView.mm: + (aeDescFromJSValue): + +2010-04-16 Dan Bernstein <mitz@apple.com> + + Reviewed by John Sullivan. + + Expose the extremal shrink factors WebHTMLView uses when shrinking pages to fit in the + printing width as SPI. + + * WebView/WebHTMLView.mm: + Replaced two macros with constants. + (-[WebHTMLView _beginPrintModeWithPageWidth:shrinkToFit:]): Changed to use the constants. + (-[WebHTMLView _scaleFactorForPrintOperation:]): Ditto. + * WebView/WebHTMLViewPrivate.h: Declared _WebHTMLViewPrintingMinimumShrinkFactor and + _WebHTMLViewPrintingMaximumShrinkFactor. + +2010-04-15 Mark Rowe <mrowe@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7870651> WebDynamicScrollBarsView.h generates compile errors when included in plain Objective-C files. + + * WebView/WebDynamicScrollBarsView.h: + +2010-04-15 Adam Roben <aroben@apple.com> + + Export WebUserContentURLPattern from WebKit + + Rubber-stamped by Mark Rowe. + + * WebKit.exp: + +2010-04-15 Dan Bernstein <mitz@apple.com> + + Reviewed by Simon Fraser. + + Made consecutive calls to -[WebHTMLView _beginPrintModeWithPageWidth:shrinkToFit:] work + without intermediate calls -[WebHTMLView _endPrintMode]. + + * WebView/WebHTMLView.mm: + (-[WebHTMLView _setPrinting:minimumPageWidth:maximumPageWidth:adjustViewSize:]): + +2010-04-15 Adam Roben <aroben@apple.com> + + Expose UserContentURLPattern as WebKit SPI + + Fixes <http://webkit.org/b/37354>. + + Reviewed by Tim Hatcher. + + * Misc/WebUserContentURLPattern.h: Added. + + * Misc/WebUserContentURLPattern.mm: Added. + (-[WebUserContentURLPattern initWithPatternString:]): Initialize + _private and then parse the passed-in string into a + UserContentURLPattern. + (-[WebUserContentURLPattern dealloc]): Release _private. + + (-[WebUserContentURLPattern isValid]): + (-[WebUserContentURLPattern scheme]): + (-[WebUserContentURLPattern host]): + (-[WebUserContentURLPattern matchesSubdomains]): + Call through to UserContentURLPattern. + +2010-04-13 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Oliver Hunt. + + Separated a DOMWrapperWorld's behavior of keeping wrappers alive from + its own lifetime, so a DOMWrapperWorld's controller can throw away + its wrappers even before its refcount reaches 0. + + * WebView/WebScriptWorld.h: + * WebView/WebScriptWorld.mm: + (-[WebScriptWorld unregisterWorld]): Exported this function through WebKit. + +2010-04-12 Timothy Hatcher <timothy@apple.com> + + SecurityOrigin needs a way to remove individual OriginAccessEntries + https://bugs.webkit.org/show_bug.cgi?id=37449 + + Reviewed by Dave Hyatt. + + * WebView/WebView.mm: + (+[WebView _removeOriginAccessWhitelistEntryWithSourceOrigin:destinationProtocol:destinationHost:allowDestinationSubdomains:]): + Call SecurityOrigin::removeOriginAccessWhitelistEntry. + * WebView/WebViewPrivate.h: Added _removeOriginAccessWhitelistEntryWithSourceOrigin. + +2010-04-13 Timothy Hatcher <timothy@apple.com> + + Rename SecurityOrigin::whiteListAccessFromOrigin to addOriginAccessWhitelistEntry. + And SecurityOrigin::resetOriginAccessWhiteLists to resetOriginAccessWhitelists. + + SecurityOrigin needs a way to remove individual OriginAccessEntries + https://bugs.webkit.org/show_bug.cgi?id=37449 + + Reviewed by Dave Hyatt. + + * WebView/WebView.mm: + (+[WebView _addOriginAccessWhitelistEntryWithSourceOrigin:destinationProtocol:destinationHost:allowDestinationSubdomains:]): + (+[WebView _resetOriginAccessWhitelists]): + * WebView/WebViewPrivate.h: + +2010-04-11 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r57468. + http://trac.webkit.org/changeset/57468 + https://bugs.webkit.org/show_bug.cgi?id=37433 + + Broke the world... Must have applied the patch wrong + (Requested by abarth on #webkit). + + * WebView/WebFrame.mm: + (-[WebFrame _canProvideDocumentSource]): + (-[WebFrame _receivedData:textEncodingName:]): + +2010-04-11 Adam Barth <abarth@webkit.org> + + Reviewed by Eric Seidel. + + Factor DocumentWriter out of FrameLoader + https://bugs.webkit.org/show_bug.cgi?id=37175 + + Update these callsites because the method moved to DocumentWriter. + + * WebView/WebFrame.mm: + (-[WebFrame _canProvideDocumentSource]): + (-[WebFrame _receivedData:textEncodingName:]): + +2010-04-10 Mark Rowe <mrowe@apple.com> + + Reviewed by Dan Bernstein. + + <rdar://problem/7845305> Further adoption of formal protocols for delegates. + + Move EmptyProtocolDefinitions.h down in to WebCore, and add the new protocols. Adopt the protocols in the appropriate places. + + * Misc/EmptyProtocolDefinitions.h: Removed. + * Misc/WebDownload.mm: + * WebKitPrefix.h: + +2010-04-09 Jer Noble <jer.noble@apple.com> + + Reviewed by Darin Adler. + + Work around QTMovieView bug (<rdar://problem/7712713>) by using a QTMovieLayer instead. + https://bugs.webkit.org/show_bug.cgi?id=37311 / <rdar://problem/7749993> + + * WebView/WebVideoFullscreenController.mm: + (-[WebVideoFullscreenController windowDidLoad]): + (-[WebVideoFullscreenController setMediaElement:WebCore::]): + +2010-04-09 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Maciej Stachowiak. + + https://bugs.webkit.org/show_bug.cgi?id=24572 + XMLHttpRequest.statusText returns always "OK" on Mac + + * WebCoreSupport/WebSystemInterface.m: (InitWebCoreSystemInterface): + +2010-04-09 Eric Seidel <eric@webkit.org> + + Unreviewed, rolling out r57343. + http://trac.webkit.org/changeset/57343 + https://bugs.webkit.org/show_bug.cgi?id=37311 + + Broke Tiger compile. + + * WebView/WebVideoFullscreenController.mm: + (-[WebVideoFullscreenController windowDidLoad]): + (-[WebVideoFullscreenController setMediaElement:WebCore::]): + +2010-04-09 Dan Bernstein <mitz@apple.com> + + Reviewed by Darin Adler. + + <rdar://problem/7846015> REGRESSION (r57332) - Crash in [WebDynamicScrollBarsView(WebInternal) reflectScrolledClipView:] when opening the Downloads window + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView initWithCoder:]): Added. Calls super and then initializes _private. + +2010-04-09 Jer Noble <jer.noble@apple.com> + + Reviewed by Darin Adler. + + Work around QTMovieView bug (<rdar://problem/7712713>) by using a QTMovieLayer instead. + https://bugs.webkit.org/show_bug.cgi?id=37311 / <rdar://problem/7749993> + + * WebView/WebVideoFullscreenController.mm: + (-[WebVideoFullscreenController windowDidLoad]): + (-[WebVideoFullscreenController setMediaElement:WebCore::]): + +2010-04-08 Mark Rowe <mrowe@apple.com> + + Reviewed by John Sullivan. + + <rdar://problem/7814899> REGRESSION(r56008): iTunes crashes on quit inside -[NSScrollView dealloc] + + In r56008 new instance variables were added to WebDynamicScrollBarsView, increasing its size. + This causes problems for 32-bit applications that derive from WebDynamicScrollBarsView, as the + size and layout of their subclasses is baked in at compile time. This results in instances + being allocated that are smaller than the new code expects, and may result in the new instance + variables sharing the same memory space as any instance variables that the subclass defines. + + We can avoid this problem by having the class contain only a single member that acts as a pointer + to a heap-allocated structure that acts as storage for the real instance variables. This makes + us free to add instance variables in the future without risk of changing the size of the class. + To ensure that 32-bit applications that are built against this new WebDynamicScrollBarsView header + are able to run against older versions of WebKit we pad the class out to its previous size. This + results in any subclasses of WebDynamicScrollBarsView being created with a layout that is compatible + with both versions of the code. + + This change could potentially break a subclass of WebDynamicScrollBarsView that directly accesses + instance variables of its superclass. However, this is a private header and no known subclasses + of WebDynamicScrollBarsView access superclass instance variables in this fashion. + + * WebView/WebDynamicScrollBarsView.h: + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView initWithFrame:]): + (-[WebDynamicScrollBarsView dealloc]): + (-[WebDynamicScrollBarsView finalize]): + (-[WebDynamicScrollBarsView setAllowsHorizontalScrolling:]): + (-[WebDynamicScrollBarsView setAllowsScrollersToOverlapContent:]): + (-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): + (-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): + (-[WebDynamicScrollBarsView horizontalScrollingAllowed]): + (-[WebDynamicScrollBarsView verticalScrollingAllowed]): + (-[WebDynamicScrollBarsView contentViewFrame]): + (-[WebDynamicScrollBarsView tile]): + (-[WebDynamicScrollBarsView setSuppressLayout:]): + (-[WebDynamicScrollBarsView setScrollBarsSuppressed:repaintOnUnsuppress:]): + (-[WebDynamicScrollBarsView updateScrollers]): + (-[WebDynamicScrollBarsView reflectScrolledClipView:]): + (-[WebDynamicScrollBarsView allowsHorizontalScrolling]): + (-[WebDynamicScrollBarsView allowsVerticalScrolling]): + (-[WebDynamicScrollBarsView scrollingModes:WebCore::vertical:WebCore::]): + (-[WebDynamicScrollBarsView horizontalScrollingMode]): + (-[WebDynamicScrollBarsView verticalScrollingMode]): + (-[WebDynamicScrollBarsView setScrollingModes:vertical:andLock:]): + (-[WebDynamicScrollBarsView setHorizontalScrollingModeLocked:]): + (-[WebDynamicScrollBarsView setVerticalScrollingModeLocked:]): + (-[WebDynamicScrollBarsView setScrollingModesLocked:]): + (-[WebDynamicScrollBarsView horizontalScrollingModeLocked]): + (-[WebDynamicScrollBarsView verticalScrollingModeLocked]): + (-[WebDynamicScrollBarsView scrollWheel:]): + +2010-04-07 David Hyatt <hyatt@apple.com> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=24300, don't expose history info via CSS + + Add SPI so that layout tests can access computed style including :visited information. + + * WebView/WebRenderNode.mm: + (copyRenderNode): + * WebView/WebView.mm: + (-[WebView _computedStyleIncludingVisitedInfo:forElement:]): + * WebView/WebViewInternal.h: + * WebView/WebViewPrivate.h: + +2010-04-07 Dan Bernstein <mitz@apple.com> + + Reviewed by Adele Peterson. + + Refactor WebHTMLView printing code and add private methods to enter and exit printing mode. + https://bugs.webkit.org/show_bug.cgi?id=37246 + + * Misc/WebNSPrintOperationExtras.h: Declared -_web_availablePaperWidth and -_web_availablePaperHeight. + * Misc/WebNSPrintOperationExtras.m: + (-[NSPrintOperation _web_availablePaperWidth]): Turned -[WebHTMLView _availablePaperWidthForPrintOperation:] + into this method. + (-[NSPrintOperation _web_availablePaperHeight]): Turned -[WebHTMLView _calculatePrintHeight] into this + method. + * WebView/WebHTMLView.mm: + (-[WebHTMLView _isInPrintMode]): Added this accessor. + (-[WebHTMLView _beginPrintModeWithPageWidth:shrinkToFit:]): Added. Moved the code from -knowsPageRange: that + computes the layout widths and enters printing mode into this private method. + (-[WebHTMLView _endPrintMode]): New private method (the old -_endPrintMode has been renamed). + (-[WebHTMLView _scaleFactorForPrintOperation:]): Use -[NSPrintOperation _web_availablePaperWidth]. + (-[WebHTMLView _endPrintModeAndRestoreWindowAutodisplay]): Renamed -_endPrintMode to this, changed it to call + _endPrintMode. + (-[WebHTMLView _delayedEndPrintMode:]): Updated for rename. + (-[WebHTMLView knowsPageRange:]): Use -_beginPrintModeWithPageWidth:shrintToFit:, + -[NSPrintOperation _web_availablePaperWidth], and -[NSPrintOperation _web_availablePaperHeight]. Updated for + rename. + (-[WebHTMLView beginDocument]): Updated for rename. + (-[WebHTMLView endDocument]): Ditto. + * WebView/WebHTMLViewPrivate.h: Declared new private methods -_isInPrintMode, + -_beginPrintModeWithPageWidth:shrinkToFit: and -_endPrintMode. + +2010-04-07 Andrey Kosyakov <caseq@chromium.org> + + Reviewed by Yury Semikhatsky. + + Removed redundant FrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest() + https://bugs.webkit.org/show_bug.cgi?id=36949 + + * WebCoreSupport/WebFrameLoaderClient.h: + * WebCoreSupport/WebFrameLoaderClient.mm: + +2010-04-06 Dan Bernstein <mitz@apple.com> + + Tiger build fix after r57184. + + * WebView/WebHTMLViewPrivate.h: + +2010-04-06 Dan Bernstein <mitz@apple.com> + + Tiger build fix after r57184. + + * WebView/WebHTMLViewPrivate.h: + +2010-04-06 Adam Barth <abarth@webkit.org> + + Unreviewed. + + Speculative build fix for Tiger. + + * WebView/WebHTMLViewPrivate.h: + +2010-04-06 Dan Bernstein <mitz@apple.com> + + Reviewed by Sam Weinig and Anders Carlsson. + + Expose WebHTMLView’s page breaking logic as SPI. + + * WebView/WebHTMLView.mm: + (-[WebHTMLView _adjustedBottomOfPageWithTop:bottom:limit:]): Factored out of -adjustPageHeightNew:top:bottom:limit: + (-[WebHTMLView adjustPageHeightNew:top:bottom:limit:]): Call -_adjustedBottomOfPageWithTop:bottom:limit: + * WebView/WebHTMLViewPrivate.h: Declared -_adjustedBottomOfPageWithTop:bottom:limit: + +2010-04-06 Mark Rowe <mrowe@apple.com> + + Add an #if in order to make Tiger happy. + + * WebView/WebViewData.mm: + (-[WebViewPrivate init]): + +2010-04-06 Mark Rowe <mrowe@apple.com> + + Build fix. + + * WebView/WebViewData.mm: + (-[WebViewPrivate init]): Use objc_collectingEnabled like we do elsewhere in WebKit. + +2010-04-05 Mark Rowe <mrowe@apple.com> + + Reviewed by Adele Peterson. + + Test case for <http://webkit.org/b/37115> / <rdar://problem/7829331>. + REGRESSION(r56989): Crash in Mail in WebCore::Position::isCandidate when deleting block using block deletion UI + + * WebView/WebHTMLView.mm: + (-[WebHTMLView _updateFontPanel]): Ask the window whether it is the key window rather than doing the comparison + manually. This allows DumpRenderTree's override of isKeyWindow to force this code path to be taken during tests. + +2010-04-05 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=37111 + <rdar://problem/7790327> Draw replacement text when plug-in host crashes + + * Plugins/Hosted/WebHostedNetscapePluginView.h: Removed _pluginDied - it was only used + for drawing replacement icon, and this information is now in WebCore. + * Plugins/Hosted/WebHostedNetscapePluginView.mm: + (-[WebHostedNetscapePluginView pluginHostDied]): Tell RenderEmbeddedObject that the plug-in + has crashed. + (-[WebHostedNetscapePluginView drawRect:]): Removed the case for crashed plug-in host. It is + handled by WebCore now. + + * WebCoreSupport/WebViewFactory.mm: (-[WebViewFactory crashedPluginText]): Added a string + for plug-in failure. + +2010-04-03 yael aharon <yael.aharon@nokia.com> + + Reviewed by Darin Adler. + + Enable HTMLProgressElement for Safari on OSX + https://bugs.webkit.org/show_bug.cgi?id=36961 + + * Configurations/FeatureDefines.xcconfig: + +2010-04-02 Jer Noble <jer.noble@apple.com> + + Reviewed by Eric Carlson. + + https://bugs.webkit.org/show_bug.cgi?id=36624 + Add an INIT macro for the WebKitSystemInterface function wkQTMovieSelectPreferredAlternates. + + * WebCoreSupport/WebSystemInterface.m: + (InitWebCoreSystemInterface): + +2010-04-02 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=37043 + Java regression tests spam stderr about being unable to set status message + + With this change, there is still spam about "Attempt to access JavaScript from destroyed + applet, type 9." I haven't investigated if that indicates a problem or not. + + * Plugins/WebPluginController.mm: (-[WebPluginController webPlugInContainerShowStatus:]): + Removed check for _documentView. We don't seem to care. + +2010-04-01 Kinuko Yasuda <kinuko@chromium.org> + + Reviewed by Dmitry Titov. + + Add FileThread for async file operation support in FileReader and FileWriter + https://bugs.webkit.org/show_bug.cgi?id=36896 + + Add FILE_READER or FILE_WRITER feature defines. + + * Configurations/FeatureDefines.xcconfig: + +2010-04-01 Ada Chan <adachan@apple.com> + + Reviewed by Darin Adler. + + Change WebDatabaseManager::deleteOrigin() to return true if there are no errors in deleting the origin. + Ditto for WebDatabaseManager::deleteDatabase(). + + https://bugs.webkit.org/show_bug.cgi?id=36988 + + * Storage/WebDatabaseManager.mm: + (-[WebDatabaseManager deleteOrigin:]): + (-[WebDatabaseManager deleteDatabase:withOrigin:]): + * Storage/WebDatabaseManagerPrivate.h: + +2010-04-01 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=36976 + <rdar://problem/7817498> + REGRESSION(r54783): Silverlight plug-in causes Safari to crash if JavaScript is disabled + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::get): The HashTable assertions aren't + there to catch potential future attempts to store empty/deleted values before these happen - + it's actually wrong to try to look up these values. Added an early return. + (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::forget): Ditto. + +2010-04-01 Chris Marrin <cmarrin@apple.com> + + Reviewed by Simon Fraser. + + Added layerTreeAsText function to DRT (for Mac) + https://bugs.webkit.org/show_bug.cgi?id=36782 + + This is the WebKit side for Mac. It plumbs the + call from WebCore to DRT. + + * WebView/WebFrame.mm:WebKit (Mac) side of plumbing + (-[WebFrame _layerTreeAsText]): + * WebView/WebFramePrivate.h: + +2010-04-01 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Oliver Hunt. + + https://bugs.webkit.org/show_bug.cgi?id=36976 + <rdar://problem/7817498> + REGRESSION(r54783): Silverlight plug-in causes Safari to crash if JavaScript is disabled + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::get): Use find() instead of get(), + because the latter fails with an assertion when looking up 0 or -1. + (WebKit::NetscapePluginInstanceProxy::LocalObjectMap::forget): Be prepared for unexpected + object IDs coming from plug-in host. + +2010-03-31 Chris Fleizach <cfleizach@apple.com> + + Reviewed by Darin Adler. + + Bug 36845 - AX: need a way to set the label of a AXWebArea through WebKit + https://bugs.webkit.org/show_bug.cgi?id=36845 + + Provide a way through WebKit to set an accessible label that describes the web area. + + * WebView/WebFrame.mm: + (-[WebFrame setAccessibleName:]): + * WebView/WebFramePrivate.h: + +2010-03-31 Marcus Bulach <bulach@chromium.org> + + Reviewed by Jeremy Orlow. + + Adds Geolocation param for cancelGeolocationPermissionRequestForFrame. + https://bugs.webkit.org/show_bug.cgi?id=35031 + + * WebCoreSupport/WebChromeClient.h: + (WebChromeClient::cancelGeolocationPermissionRequestForFrame): + +2010-03-30 Gavin Barraclough <barraclough@apple.com> + + Rubber stamped by Sam Weinig. + + https://bugs.webkit.org/show_bug.cgi?id=36866 + Move CString to WTF + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::getCookies): + (WebKit::NetscapePluginInstanceProxy::getProxy): + (WebKit::NetscapePluginInstanceProxy::getAuthenticationInfo): + (WebKit::NetscapePluginInstanceProxy::resolveURL): + * Plugins/WebBaseNetscapePluginView.h: + * Plugins/WebBaseNetscapePluginView.mm: + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView resolveURL:forTarget:]): + +2010-03-30 John Sullivan <sullivan@apple.com> + + Reviewed by Dan Bernstein. + + https://bugs.webkit.org/show_bug.cgi?id=36848 + <rdar://problem/7362913> + Menu items appropriate only for rich-content editing can appear in plain-text contexts + + * WebView/WebHTMLView.mm: + (-[WebHTMLView validRequestorForSendType:returnType:]): + Don't return self for non-string content if _canEditRichly is false. + +2010-03-29 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=36791 + Add assertions for instance proxy validity + + Add some assertions that the instance proxy hasn't been deleted. We sometimes keep a raw + pointer to one across complicated function calls, relying on the caller to protect the + reference. + + * Plugins/Hosted/NetscapePluginInstanceProxy.h: + (WebKit::NetscapePluginInstanceProxy::renderContextID): + (WebKit::NetscapePluginInstanceProxy::pluginView): + (WebKit::NetscapePluginInstanceProxy::hostProxy): + +2010-03-30 Laszlo Gombos <laszlo.1.gombos@nokia.com> + + Reviewed by David Kilzer. + + Explicit guards for ENABLE_GEOLOCATION + https://bugs.webkit.org/show_bug.cgi?id=25756 + + * WebCoreSupport/WebGeolocationMock.mm: + (-[WebGeolocationMock setError:code:]): Make the body conditional on + ENABLE(GEOLOCATION) + (-[WebGeolocationMock setPosition:]): Ditto. + +2010-03-26 Kenneth Rohde Christiansen <kenneth@webkit.org> + + Reviewed by Antti Koivisto. + + Change method name due to it dealing with both flattening + of frame sets and inner frames. + + * WebView/WebPreferenceKeysPrivate.h: + * WebView/WebPreferences.mm: + (+[WebPreferences initialize]): + (-[WebPreferences isFrameFlatteningEnabled]): + (-[WebPreferences setFrameFlatteningEnabled:]): + * WebView/WebPreferencesPrivate.h: + * WebView/WebView.mm: + (-[WebView _preferencesChangedNotification:]): + +2010-03-27 Darin Adler <darin@apple.com> + + * Misc/WebNSFileManagerExtras.m: + (-[NSFileManager _webkit_pathWithUniqueFilenameForPath:]): + Removed stray "!". How did that get in there? + +2010-03-27 Darin Adler <darin@apple.com> + + Reviewed by Mark Rowe. + + WebKit NSFileManager methods don't handle broken symlinks correctly. + Part of <rdar://problem/7574046>. + + * Misc/WebNSFileManagerExtras.h: Removed unused defines and methods. + * Misc/WebNSFileManagerExtras.m: Removed unused methods. + (fileExists): Added. For use instead of fileExistsAtPath: for cases where we'd like + to treat a broken symlink as a file that does indeed exist. + (-[NSFileManager _webkit_pathWithUniqueFilenameForPath:]): Use fileExists. + +2010-03-25 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Mark Rowe. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: (WKPCRunSyncOpenPanel): Re-fetch host proxy in + a way that works in a function that doesn't have a pluginID argument for some reason. + +2010-03-25 Simon Fraser <simon.fraser@apple.com> + + Build fix: no review. + + Another c_str() -> data(). + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::enumerate): + +2010-03-25 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Mark Rowe. + + Correctness fix after r56493. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: (WKPCRunSyncOpenPanel): We still need to update + our hostProxy reference, even though we didn't use to have instanceProxy. Nothing guarantees + that the host proxy won't go away while the open panel is up. + +2010-03-24 Mark Rowe <mrowe@apple.com> + + Build fix after r56474. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: + (WKPCRunSyncOpenPanel): + +2010-03-24 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Anders Carlsson. + + https://bugs.webkit.org/show_bug.cgi?id=36563 + A plug-in makes Safari crash on http://www.itscodingtime.com/ + + * Plugins/Hosted/NetscapePluginHostProxy.h: + (WebKit::NetscapePluginHostProxy::port): Assert that the object is still alive. This isn't + beautifully systemic, but helped catch a bug, and may help catch more. + (WebKit::NetscapePluginHostProxy::clientPort): Ditto. + (WebKit::NetscapePluginHostProxy::isProcessingRequests): Changed m_processingRequests to a + static. This doesn't change behavior much, but helps avoid writing into deallocated memory. + + * Plugins/Hosted/NetscapePluginHostProxy.mm: + (WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy): Changed m_processingRequests + to a static. + (WebKit::NetscapePluginHostProxy::processRequests): Ditto. Changing m_processingRequests + after destroying the object in pluginHostDied() was wrong, but reasonably harmless, as there + wasn't much time for some other object to be allocated at this address. + (WKPCEvaluate): Refetch host proxy, as it may have been destroyed. + (WKPCInvoke): Ditto. + (WKPCInvokeDefault): Ditto. + (WKPCGetProperty): Ditto. + (WKPCSetProperty): Ditto. + (WKPCRemoveProperty): Ditto. + (WKPCHasProperty): Ditto. + (WKPCHasMethod): Ditto. + (WKPCEnumerate): Ditto. + (WKPCRunSyncOpenPanel): Ditto. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::processRequestsAndWaitForReply): Bail out of the + "event loop" if host proxy went away while processing a request. + +2010-03-24 Hayato Ito <hayato@chromium.org> + + Reviewed by Shinichiro Hamaji. + + Refactor computePageRects so that Mac can make use of it. + https://bugs.webkit.org/show_bug.cgi?id=36159 + + Refactoring only, so no new tests. + + * WebView/WebFrame.mm: + (-[WebFrame _computePageRectsWithPrintWidthScaleFactor:printHeight:]): + +2010-03-24 Kent Tamura <tkent@chromium.org> + + Reviewed by Darin Adler. + + Make Icon::createIconForFiles() optional. + https://bugs.webkit.org/show_bug.cgi?id=35072 + + - Rename iconForFiles() to chooseIconForFiles(). + - Call Icon::createIconForFiles() from chooseIconForFiles(). + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::chooseIconForFiles): + +2010-03-23 Dan Bernstein <mitz@apple.com> + + Reverted accidental change from r56429. + + * WebCoreSupport/WebContextMenuClient.mm: + (WebContextMenuClient::getCustomMenuFromDefaultItems): + +2010-03-23 Dan Bernstein <mitz@apple.com> + + Reviewed by John Sullivan. + + WebKit part of + <rdar://problem/7197736> Plug-in clip rect does not update when overflow + clip changes + https://bugs.webkit.org/show_bug.cgi?id=36479. + + * Plugins/Hosted/WebHostedNetscapePluginView.mm: + (-[WebHostedNetscapePluginView visibleRectDidChange]): Added. Calls + WKSyncSurfaceToView(). + * Plugins/WebBaseNetscapePluginView.h: + * Plugins/WebBaseNetscapePluginView.mm: + (-[WebBaseNetscapePluginView _windowClipRect]): Changed to use Widget::windowClipRect(). + (-[WebBaseNetscapePluginView visibleRectDidChange]): Added. Invokes -renewGState. + +2010-03-22 Kevin Decker <kdecker@apple.com> + + Reviewed by Simon Fraser. + + https://bugs.webkit.org/show_bug.cgi?id=36328 + + This patch entirely WebNullPluginView. + + * Plugins/WebNetscapePluginView.mm: + * Plugins/WebNullPluginView.h: Removed. + * Plugins/WebNullPluginView.mm: Removed. + * Resources/nullplugin.tiff: Removed. + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::createPlugin): Invoke the resource load delegate if the plug-in failed to load. + +2010-03-22 Alexey Proskuryakov <ap@apple.com> + + Reviewed by John Sullivan. + + https://bugs.webkit.org/show_bug.cgi?id=36455 + Make WebKit more resistant against plug-in crashes + + No tests, because crashing on build bots isn't good, even if it's only helper processes + that crash. + + * Plugins/Hosted/NetscapePluginInstanceProxy.h: + (WebKit::NetscapePluginInstanceProxy::waitForReply): Protect "this", because this function + needs it after waiting for reply. Some callers used to do this, but not all, and we really + shouldn't depend on callers here. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::wheelEvent): Don't protect the plug-in instance proxy, + because this function doesn't use it after waiting for reply. + (WebKit::NetscapePluginInstanceProxy::createBindingsInstance): Ditto. + + * Plugins/Hosted/ProxyInstance.mm: (WebKit::ProxyInstance::invoke): Added an m_instanceProxy + null check for another code path. + +2010-03-22 Kevin Decker <kdecker@apple.com> + + Reviewed by John Sullivan. + + https://bugs.webkit.org/show_bug.cgi?id=36328 + + * WebCoreSupport/WebViewFactory.mm: + (-[WebViewFactory missingPluginText]): Added. + +2010-03-18 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=36337 + Log an error when an OOP plug-in sends an unknown object id + + Making these LOG_ERROR and not ASSERTs, because I don't want early returns to look + temporary or redundant. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::evaluate): + (WebKit::NetscapePluginInstanceProxy::invoke): + (WebKit::NetscapePluginInstanceProxy::invokeDefault): + (WebKit::NetscapePluginInstanceProxy::construct): + (WebKit::NetscapePluginInstanceProxy::getProperty): + (WebKit::NetscapePluginInstanceProxy::setProperty): + (WebKit::NetscapePluginInstanceProxy::removeProperty): + (WebKit::NetscapePluginInstanceProxy::hasProperty): + (WebKit::NetscapePluginInstanceProxy::hasMethod): + (WebKit::NetscapePluginInstanceProxy::enumerate): + +2010-03-16 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=36184 + YouTube video resizing doesn't work with OOP plug-ins + + Test: plugins/resize-from-plugin.html + + We were calling _WKPHResizePluginInstance synchronously or asynchronously, depending on + whether the size has changed. But sync and async messages are not necessarily delivered in + order - plug-in host listens only to the former while waiting for a response to a message it + sent (a call to invoke() in this case). + + * Plugins/Hosted/NetscapePluginInstanceProxy.h: + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::resize): + * Plugins/Hosted/WebHostedNetscapePluginView.mm: + (-[WebHostedNetscapePluginView updateAndSetWindow]): + +2010-03-16 Yury Semikhatsky <yurys@chromium.org> + + Reviewed by Pavel Feldman. + + Introduce InspectorFrontendClient that provides InspectorFrontend with an interface to the embedder. InspectorClient now serves as a delegate for InspectorController and does not contain methods for managing inspector frontend window. That allows to create remote InspectorFrontendHost. + + Introduce InspectorFrontendClient that would provide InspectorFrontend with an interface to the embedder + https://bugs.webkit.org/show_bug.cgi?id=35036 + + * WebCoreSupport/WebInspectorClient.h: + * WebCoreSupport/WebInspectorClient.mm: + (WebInspectorClient::WebInspectorClient): + (WebInspectorClient::inspectorDestroyed): + (WebInspectorClient::openInspectorFrontend): + (WebInspectorClient::highlight): + (WebInspectorClient::hideHighlight): + (WebInspectorFrontendClient::WebInspectorFrontendClient): + (WebInspectorFrontendClient::frontendLoaded): + (WebInspectorFrontendClient::localizedStringsURL): + (WebInspectorFrontendClient::hiddenPanels): + (WebInspectorFrontendClient::bringToFront): + (WebInspectorFrontendClient::closeWindow): + (WebInspectorFrontendClient::attachWindow): + (WebInspectorFrontendClient::detachWindow): + (WebInspectorFrontendClient::setAttachedWindowHeight): + (WebInspectorFrontendClient::inspectedURLChanged): + (WebInspectorFrontendClient::updateWindowTitle): + (-[WebInspectorWindowController dealloc]): + (-[WebInspectorWindowController windowShouldClose:]): + (-[WebInspectorWindowController close]): + (-[WebInspectorWindowController showWindow:]): + (-[WebInspectorWindowController attach]): + (-[WebInspectorWindowController detach]): + (-[WebInspectorWindowController attached]): + (-[WebInspectorWindowController setFrontendClient:]): + (-[WebInspectorWindowController destroyInspectorView]): + (-[WebNodeHighlighter initWithInspectedWebView:]): + (-[WebNodeHighlighter dealloc]): + (-[WebNodeHighlighter highlightNode:]): + (-[WebNodeHighlighter hideHighlight]): + (-[WebNodeHighlighter didAttachWebNodeHighlight:]): + (-[WebNodeHighlighter willDetachWebNodeHighlight:]): + * WebInspector/WebInspector.mm: + (-[WebInspector attach:]): + (-[WebInspector detach:]): + +2010-03-15 Andy Estes <aestes@apple.com> + + Reviewed by John Sullivan. + + Updated call to WKGetWheelEventDeltas() to match new method signature. + + https://bugs.webkit.org/show_bug.cgi?id=29601 + <rdar://problem/7453254> + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView scrollWheel:]): + +2010-03-15 John Sullivan <sullivan@apple.com> + + Reviewed by Adam Roben. + + -[WebFrame setAlwaysHideHorizontal/VerticalScroller:] prevents keyboard scrolling + <https://bugs.webkit.org/show_bug.cgi?id=36125> + + * WebView/WebDynamicScrollBarsView.h: + Added instance variables horizontalScrollingAllowedButScrollerHidden and + verticalScrollingAllowedButScrollerHidden. Renamed instance variables + hideHorizontal/VerticalScroller to alwaysHideHorizontal/VerticalScroller for clarity. + Declared methods -horizontalScrollingAllowed and -verticalScrollingAllowed. + Added comments. + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): + Updated for instance variable renaming. + (-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): + Ditto. + (-[WebDynamicScrollBarsView horizontalScrollingAllowed]): + New method, returns YES if the scroller is showing or the only reason that the scroller + is not showing is that setAlwaysHideHorizontalScrolling has been called. + (-[WebDynamicScrollBarsView verticalScrollingAllowed]): + New method, returns YES if the scroller is showing or the only reason that the scroller + is not showing is that setAlwaysHideVerticalScrolling has been called. + (-[WebDynamicScrollBarsView updateScrollers]): + Updated for instance variable renamings. Now updates horizontalScrollingAllowedButScrollerHidden + and verticalScrollingAllowedButScrollerHidden. Now takes the always-hidden state into account + in the early-return code path, to avoid taking it into account twice in the regular code path. + + * WebView/WebFrameView.mm: + (-[WebFrameView _scrollToBeginningOfDocument]): + Use _isScrollable instead of _hasScrollBars. + (-[WebFrameView _scrollToEndOfDocument]): + Ditto. + (-[WebFrameView scrollToBeginningOfDocument:]): + Use _largestScrollableChild instead of _largestChildWithScrollBars. + (-[WebFrameView scrollToEndOfDocument:]): + Ditto. + (-[WebFrameView _pageVertically:]): + Use _isScrollable and _largestScrollableChild instead of _hasScrollBars + and _largestChildWithScrollBars. + (-[WebFrameView _pageHorizontally:]): + Ditto. + (-[WebFrameView _scrollLineVertically:]): + Ditto. + (-[WebFrameView _scrollLineHorizontally:]): + Ditto. + (-[WebFrameView keyDown:]): + Use _largestScrollableChild instead of _largestChildWithScrollBars. + (-[WebFrameView _isScrollable]): + New method, calls -[WebDynamicScrollBarsView horizontalScrollingAllowed] and + -[WebDynamicScrollBarsView verticalScrollingAllowed] + (-[WebFrameView _largestScrollableChild]): + New method, like _largestChildWithScrollBars but uses _isScrollable. + (-[WebFrameView _hasScrollBars]): + Added a comment that this is no longer used by Safari, and can thus probably be + deleted once we no longer want to support it for nightly build compatibility with + old versions of Safari. + (-[WebFrameView _largestChildWithScrollBars]): + Ditto. + + * WebView/WebFrameViewPrivate.h: + Declared -_isScrollable and -_largestScrollableChild. Added comments to + _hasScrollBars and _largestChildWithScrollBars saying that they are no longer + used by Safari, and can thus probably be deleted once we no longer want to + support them for nightly build compatibility with old versions of Safari. + +2010-03-15 John Sullivan <sullivan@apple.com> + + Method name and parameter name mistakes from recent SPI addition + <https://bugs.webkit.org/show_bug.cgi?id=36119> + + Reviewed by Dan Bernstein. + + * WebView/WebDynamicScrollBarsView.h: + Renamed instance variable and method name from "setAllowXXX" to "setAllowsXXX". + + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView setAllowsScrollersToOverlapContent:]): + Updated for renamed instance variable and method. + (-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): + Changed parameter name from shouldBeVisible to shouldBeHidden. + (-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): + Ditto. + (-[WebDynamicScrollBarsView contentViewFrame]): + Updated for renamed instance variable. + (-[WebDynamicScrollBarsView tile]): + Ditto. + (-[WebDynamicScrollBarsView reflectScrolledClipView:]): + Ditto. + + * WebView/WebFrame.mm: + (-[WebFrame setAllowsScrollersToOverlapContent:]): + Renamed method from setAllowXXX, and updated for same change in WebDynamicScrollBarsView. + + * WebView/WebFramePrivate.h: + Renamed method name from "setAllowXXX" to "setAllowsXXX". + +2010-03-14 Darin Adler <darin@apple.com> + + Reviewed by Mark Rowe. + + Remove unneeded dependency on non-string identifier for an NSTableColumn + https://bugs.webkit.org/show_bug.cgi?id=36106 + + * WebView/WebTextCompletionController.mm: + (-[WebTextCompletionController _buildUI]): Use init instead of initWithIdentifier: + because the table has only one column and that column does not need an identifier. + +2010-03-12 Beth Dakin <bdakin@apple.com> + + Reviewed by Simon Fraser. + + Fix for https://bugs.webkit.org/show_bug.cgi?id=34942 Fullscreen + API naming is inconsistent + -and corresponding- + <rdar://problem/7729165> + + This patch changes all occurrences of "fullScreen" to the more + popular "fullscreen." + + * Plugins/Hosted/NetscapePluginHostProxy.h: + (WebKit::NetscapePluginHostProxy::isFullscreenWindowShowing): + * Plugins/Hosted/NetscapePluginHostProxy.mm: + (WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy): + (WebKit::NetscapePluginHostProxy::didEnterFullscreen): + (WebKit::NetscapePluginHostProxy::didExitFullscreen): + (WebKit::NetscapePluginHostProxy::setFullscreenWindowIsShowing): + (WKPCSetFullscreenWindowIsShowing): + * Plugins/Hosted/WebKitPluginClient.defs: + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView _workaroundSilverlightFullscreenBug:]): + (-[WebNetscapePluginView _createPlugin]): + (-[WebNetscapePluginView _destroyPlugin]): + * WebView/WebVideoFullscreenHUDWindowController.mm: + (-[WebVideoFullscreenHUDWindowController windowDidLoad]): + +2010-03-12 Andy Estes <aestes@apple.com> + + Reviewed by Brady Eidson. + + Expose WebPDFView's underlying PDFDocument. + + https://bugs.webkit.org/show_bug.cgi?id=36045 + + * WebView/WebDocumentPrivate.h: Create a new protocol called + WebDocumentPDF. + * WebView/WebPDFView.h: Have WebPDFView implement said protocol. + * WebView/WebPDFView.mm: + (-[WebPDFView PDFDocument]): Expose WebPDFView's underlying + PDFDocument by implementing -(PDFDocument*)PDFDocument from + WebDocumentPDF. + +2010-03-12 Andy Estes <aestes@apple.com> + + Reviewed by Brady Eidson. + + Remove an unused method. + + https://bugs.webkit.org/show_bug.cgi?id=35940 + + * Plugins/WebPluginController.mm: + removed - (void)showURL:(NSURL *) inFrame:(NSString *) + +2010-03-11 Mark Rowe <mrowe@apple.com> + + Reviewed by David Kilzer. + + <rdar://problem/7745082> Make it possible to build WebKit for older Mac OS X versions from the current Mac OS X version + + Default to using the appropriate SDK if the target Mac OS X version is not the current Mac OS X version. + + * Configurations/Base.xcconfig: + +2010-03-11 Mark Rowe <mrowe@apple.com> + + Reviewed by Tim Hatcher. + + <rdar://problem/7745082> Make it possible to build WebKit for older Mac OS X versions from the current Mac OS X version + + Introduce TARGET_MAC_OS_X_VERSION_MAJOR to represent the Mac OS X version that is being targeted. It defaults to the + current Mac OS X version unless otherwise specified. + + Key off TARGET_MAC_OS_X_VERSION_MAJOR where we'd previously been keying off MAC_OS_X_VERSION_MAJOR. + + Explicitly map from the target Mac OS X version to the preferred compiler since Xcode's default compiler choice + may not be usable when targetting a different Mac OS X version. + + Key off TARGET_GCC_VERSION rather than MAC_OS_X_VERSION_MAJOR in locations where we'd previously been keying off + MAC_OS_X_VERSION_MAJOR but the decision is really related to the compiler version being used. + + * Configurations/Base.xcconfig: + * Configurations/DebugRelease.xcconfig: + * Configurations/FeatureDefines.xcconfig: + * Configurations/Version.xcconfig: + +2010-03-11 Anders Carlsson <andersca@apple.com> + + Reviewed by David Hyatt. + + Remove invalidateContents, it isn't used and it never makes sense to only invalidate the contents. + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + +2010-03-11 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Geoff Garen. + + https://bugs.webkit.org/show_bug.cgi?id=35965 + <rdar://problem/7742771> Crash when passing an object returned from plug-in back to the plug-in + + Test: plugins/round-trip-npobject.html + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::retainLocalObject): Corrected the check - there is + now a separate ProxyRuntimeObject class for proxy pbjects. + (WebKit::NetscapePluginInstanceProxy::releaseLocalObject): Ditto. + + * Plugins/Hosted/ProxyInstance.mm: + (WebKit::ProxyInstance::invoke): Check if m_instanceProxy is still non-zero. The plug-in + could have crashed while we were waiting for response. + (WebKit::ProxyInstance::setFieldValue): Ditto. + +2010-03-10 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=35975 + <rdar://problem/7739922> Flash 10.1b crashes when generating snapshots + + Do a version check before sending a drawRect event to a Flash plugin, + since 10.1.d51 has a bug that crashes when called this way. + + * Plugins/Hosted/WebHostedNetscapePluginView.mm: + (-[WebHostedNetscapePluginView drawRect:]): + * Plugins/WebBaseNetscapePluginView.h: + * Plugins/WebBaseNetscapePluginView.mm: + (-[WebBaseNetscapePluginView supportsSnapshotting]): + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView drawRect:]): + +2010-03-10 John Sullivan <sullivan@apple.com> + + Reviewed by Tim Hatcher. + + <rdar://problem/7735387> input type other than text won't work with autofill + <https://bugs.webkit.org/show_bug.cgi?id=35963> + + * WebView/WebHTMLRepresentation.mm: + (-[WebHTMLRepresentation elementDoesAutoComplete:]): + Return true for any text field that's not a password, rather than only + for TEXT type. + +2010-03-09 Brady Eidson <beidson@apple.com> + + Reviewed by Tim Hatcher. + + REGRESSION: WebInspector docking busted on Windows + <rdar://problem/7728433> and https://bugs.webkit.org/show_bug.cgi?id=35953 + + * WebCoreSupport/WebInspectorClient.mm: + (-[WebInspectorWindowController showWindow:]): Use the InspectorController:: copy of the should attach settings key. + (-[WebInspectorWindowController attach]): Ditto. + (-[WebInspectorWindowController detach]): Ditto. + +2010-03-09 Geoffrey Garen <ggaren@apple.com> + + Reviewed by Darin Adler. + + Updated for FastMalloc reporting changes. + + * Misc/WebCoreStatistics.mm: + (+[WebCoreStatistics memoryStatistics]): + +2010-03-08 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Mark Rowe. + + Move the new method to the end of the MIG definitions file, to avoid breaking + compatibility between WebKit and older versions of WebKitPluginHost. + + * Plugins/Hosted/WebKitPluginHost.defs: + +2010-03-08 Simon Fraser <simon.fraser@apple.com> + + Reviewed by Kevin Decker. + + <rdar://problem/7714340> Need to grab image snapshot of Core Animation plugins + + Allow plug-ins using the Core Animation drawing model to be captured when doing a flattening paint, + by sending them a drawRect event as if they were software-painting. + + * Plugins/Hosted/NetscapePluginInstanceProxy.h: + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::snapshot): + New snapshot() method that calls over to the plugin host, and then draws the image that comes back. + + * Plugins/Hosted/WebHostedNetscapePluginView.mm: + (-[WebHostedNetscapePluginView drawRect:]): If we don't have a software renderer, but we're doing + a flattening paint, then call the snapshot method. + + * Plugins/Hosted/WebKitPluginHost.defs: Added snapshot method. + + * Plugins/WebBaseNetscapePluginView.h: + * Plugins/WebBaseNetscapePluginView.mm: + (-[WebBaseNetscapePluginView inFlatteningPaint]): + New utility method that asks the FrameView whether the current paint behavior is + flattening. + + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView drawRect:]): If the plug-in is using CA but this is a flattening + paint, go ahead and send a drawRect event to the plug-in. + +2010-03-08 Darin Adler <darin@apple.com> + + Reviewed by Dan Bernstein. + + Fix crash when you quit inside an unload handler. + rdar://problem/6958347 + + Test: manual-tests/quit-inside-unload.html + + * WebView/WebView.mm: + (-[WebView _closeWithFastTeardown]): Removed code to set + _private->closed since _close now does this earlier, before + calling this method. + (-[WebView _close]): Moved code to set _private->closed to the + top of this method. + (-[WebView setHostWindow:]): Rewrote the code that forbade + setting the host window after closing so that it only forbids + non-nil host windows. That way, the code to clear away the host + window can run safely after setting _private->closed, yet client + code cannot set a new host window after closing. + +2010-03-08 Darin Adler <darin@apple.com> + + Roll out a file I checked in by accident. + + * WebView/WebView.mm: Back to previous version. + +2010-03-08 Chris Marrin <cmarrin@apple.com> + + Reviewed by Darin Adler. + + Turn on HW accel on Leopard even if coreVideoHas7228836Fix() is false, when WebGL is enabled + https://bugs.webkit.org/show_bug.cgi?id=35759 + + This allows WebGL to work on Leopard without the fix. It exposes these users to the crash + that happens because of the CoreVideo bug, but it limits the exposure to those who have + chosen to enable WebGL. + + * WebView/WebView.mm: + (-[WebView _preferencesChangedNotification:]): + +2010-03-02 Adam Treat <atreat@rim.com> + + Reviewed by Dave Hyatt. + + Adapt the mac port to the refactoring of repaint methods. + + https://bugs.webkit.org/show_bug.cgi?id=34214 + + * WebCoreSupport/WebChromeClient.h: + * WebCoreSupport/WebChromeClient.mm: + (WebChromeClient::invalidateContents): + (WebChromeClient::invalidateWindow): + (WebChromeClient::invalidateContentsAndWindow): + (WebChromeClient::invalidateContentsForSlowScroll): + +2010-03-08 Jian Li <jianli@chromium.org> + + Reviewed by Dmitry Titov. + + Blob.slice support. + https://bugs.webkit.org/show_bug.cgi?id=32993 + + Add ENABLE_BLOB_SLICE feature define. + + * Configurations/FeatureDefines.xcconfig: + +2010-03-08 Eric Uhrhane <ericu@chromium.org> + + Reviewed by David Levin. + + Remove the now-redundant Settings fields for the Database + https://bugs.webkit.org/show_bug.cgi?id=35763 + + No new tests; this code isn't called. + + * WebView/WebView.mm: Remove the call into Settings. + (-[WebView _preferencesChangedNotification:]): + +2010-03-07 Mark Rowe <mrowe@apple.com> + + Rubber-stamped by Cameron Zwarich. + + Remove unnecessary includes from header files, adding them to the handful of implementation files that need them. + + * Misc/WebIconDatabase.mm: + +2010-03-07 Mark Rowe <mrowe@apple.com> + + Rubber-stamped by Cameron Zwarich. + + Remove unnecessary includes from header files, adding them to the handful of implementation files that need them. + + * Misc/WebNSPasteboardExtras.mm: + +2010-03-04 Mark Rowe <mrowe@apple.com> + + Reviewed by Sam Weinig. + + <rdar://problem/7717249> DOMSVG.h includes a non-existent DOMSVGFEMorphologyElement.h + + * MigrateHeaders.make: Migrate DOMSVGFEMorphologyElement.h and DOMSVGFEMorphologyElementInternal.h. + +2010-03-04 Mark Rowe <mrowe@apple.com> + + Reviewed by Sam Weinig. + + Use a framework-style include to pull in WebInspector.h for consistency + with other parts of WebKit. + + * WebInspector/WebInspectorPrivate.h: + +2010-03-04 Brady Eidson <beidson@apple.com> + + Reviewed by Geoff Garen. + + REGRESSION (31281): -[WebArchive initWithCoder:] leaks + <rdar://problem/7702420> and https://bugs.webkit.org/show_bug.cgi?id=35534 + + * WebView/WebArchive.mm: + (-[WebArchive initWithCoder:]): Don't retain objects we don't own. + +2010-03-03 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Timothy Hatcher. + + https://bugs.webkit.org/show_bug.cgi?id=35692 + <rdar://problem/7703622> Crash when calling abort() on an XHR while in a windowless WebView + + * Panels/WebAuthenticationPanel.m: (-[WebAuthenticationPanel runAsModalDialogWithChallenge:]): + Retain the challenge, just like it's done for sheet. + +2010-03-02 Eric Uhrhane <ericu@chromium.org> + + Reviewed by David Levin. + + Move database enable bit fully out of settings + This is stage one of a three-stage commit [webkit, then chromium, then + webkit again]. In this change I'm adding calls to + Database::setIsAvailable inside Settings::setDatabaseEnabled and + anywhere else that called it, and switching webkit fully over to using + that flag [added in a previous checkin]. Phase two will remove + Chromium's use of Settings for the Database, and phase three will remove + the Setting for the Database enable entirely, leaving only + Database::isAvailable/setIsAvailable. + + No new tests; tested by existing storage tests. + + https://bugs.webkit.org/show_bug.cgi?id=35310 + + * WebView/WebView.mm: Added a call to Database::setIsAvailable. + (-[WebView _preferencesChangedNotification:]): + +2010-03-02 Adam Roben <aroben@apple.com> + + Add -[WebView _registerURLSchemeAsSecure:] + + Fixes <http://webkit.org/b/35580> <rdar://problem/7706407> Expose + SecurityOrigin::registerURLSchemeAsSecure as WebKit SPI + + Reviewed by Tim Hatcher. + + * WebView/WebView.mm: + (+[WebView _registerURLSchemeAsSecure:]): + * WebView/WebViewPrivate.h: + Added. Calls through to SecurityOrigin::registerURLSchemeAsSecure. + +2010-03-01 Jakob Petsovits <jpetsovits@rim.com> + + Reviewed by Adam Barth. + + Adapt to the new ZoomMode enum. + https://bugs.webkit.org/show_bug.cgi?id=35347 + + * WebView/WebView.mm: + (-[WebView _preferencesChangedNotification:]): + (-[WebView _setZoomMultiplier:isTextOnly:]): + (-[WebView _realZoomMultiplierIsTextOnly]): + +2010-02-27 Jing Jin <jjin@apple.com> + + Reviewed by Timothy Hatcher. + + Move implementation of Bug 35449 into WebFramePrivate. + + * WebView/WebFrame.h: + * WebView/WebFrame.mm: + (-[WebFrame setAllowScrollersToOverlapContent:]): + (-[WebFrame setAlwaysHideHorizontalScroller:]): + (-[WebFrame setAlwaysHideVerticalScroller:]): + * WebView/WebFramePrivate.h: + +2010-02-26 Jing Jin <jjin@apple.com> + + Reviewed by Timothy Hatcher. + + https://bugs.webkit.org/show_bug.cgi?id=35449 + Add ability to hide WebFrame scrollbars and to allow scrollbars to overlap with content. + + * WebView/WebDynamicScrollBarsView.h: + * WebView/WebDynamicScrollBarsView.mm: + (-[WebDynamicScrollBarsView setAllowScrollersToOverlapContent:]): Allows scrollbars to + overlap with the document and re-layouts the document. + (-[WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:]): Hides the horizontal scrollbar. + (-[WebDynamicScrollBarsView setAlwaysHideVerticalScroller:]): Hides the vertical scrollbar. + (-[WebDynamicScrollBarsView contentViewFrame]): Calculates the appropriate frame based + on allowScrollersToOverlapContent. + (-[WebDynamicScrollBarsView tile]): If allowScrollersToOverlapContent is YES, set the + contentView's frame so it overlaps with the scrollbar. + (-[WebDynamicScrollBarsView updateScrollers]): Take into account hideHorizontalScroller + and hideVerticalScroller. + (-[WebDynamicScrollBarsView reflectScrolledClipView:]): set drawsBackground to NO when + scrollbars are overlapping with content, so we don't get trails during scrollbar draw updates. + * WebView/WebDynamicScrollBarsViewInternal.h: + * WebView/WebFrame.h: + * WebView/WebFrame.mm: + (-[WebFrame setAllowScrollersToOverlapContent:]): Hook for [WebDynamicScrollBarsView setAllowScrollersToOverlapContent:] + (-[WebFrame setAlwaysHideHorizontalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideHorizontalScroller:] + (-[WebFrame setAlwaysHideVerticalScroller:]): Hook for [WebDynamicScrollBarsView setAlwaysHideVerticalScroller:] + +2010-02-26 Gavin Barraclough <barraclough@apple.com> + + Reviewed by Alexey Proskuryakov. + + Bug 35401 - Fix handling of errors in handling calls over bridge, + where base object bridge-type does not match method bridge-type. + + The code assumes users will only attempt to invoke a Java method + on a Java base object, etc. + Add language specific subclasses of RuntimeMethod, and pass the + RuntimeMethod into invokeMethod, so we can typecheck before + casting. Throw an exception on type mismatch. + + * Plugins/Hosted/ProxyInstance.h: + * Plugins/Hosted/ProxyInstance.mm: + (WebKit::PluginRuntimeMethod::PluginRuntimeMethod): new class to distinguish this type of RuntimeMethod. + (WebKit::ProxyInstance::getMethod): create an appropriate sublclass of RuntimeMethod. + (WebKit::ProxyInstance::invokeMethod): dynamically check the type of the RuntimeMethod. + +2010-02-25 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Geoffrey Garen. + + https://bugs.webkit.org/show_bug.cgi?id=35394 + <rdar://problem/7685262> Make passing objects between Java and plug-ins work + + Added a ProxyInstance implementation of RuntimeObject. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::addValueToArray): + * Plugins/Hosted/ProxyInstance.h: + * Plugins/Hosted/ProxyInstance.mm: + (WebKit::ProxyInstance::newRuntimeObject): + (WebKit::ProxyInstance::getClass): + * Plugins/Hosted/ProxyRuntimeObject.h: Added. + (WebKit::ProxyRuntimeObject::classInfo): + * Plugins/Hosted/ProxyRuntimeObject.mm: Added. + (WebKit::ProxyRuntimeObject::ProxyRuntimeObject): + (WebKit::ProxyRuntimeObject::~ProxyRuntimeObject): + (WebKit::ProxyRuntimeObject::getInternalProxyInstance): + +2010-02-24 Adam Barth <abarth@webkit.org> + + Reviewed by Darin Fisher. + + [Chromium API] Disambiguate allowJavaScript from didNotAllowScript + https://bugs.webkit.org/show_bug.cgi?id=35205 + + Make these two callsites explicit about not running script immediately. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::getWindowNPObject): + (WebKit::NetscapePluginInstanceProxy::demarshalValueFromArray): + +2010-02-23 Brady Eidson <beidson@apple.com> + + Reviewed by Tim Hatcher and Pavel Feldman. + + Regression (r55107) - WebInspector docking is busted. + https://bugs.webkit.org/show_bug.cgi?id=35274 + + * WebCoreSupport/WebInspectorClient.mm: + (-[WebInspectorWindowController showWindow:]): Swap the order of the "should attach?" check + to get the expected behavior. + +2010-02-23 Dan Bernstein <mitz@apple.com> + + Reviewed by Simon Fraser. + + <rdar://problem/7611158> Incomplete repaint of YouTube timeline thumb while scrolling + https://bugs.webkit.org/show_bug.cgi?id=34381 + + Test: fast/repaint/repaint-during-scroll.html + + NSClipView offsets any rects marked as needing display during scrolling + by the scroll offset. Compensate for this when -setNeedsDisplay: is called + during scrolling. + + * WebView/WebHTMLView.mm: + (-[WebHTMLView _frameOrBoundsChanged]): Set inScrollPositionChanged to YES + around to call to FrameView::scrollPositionChanged(). + (-[WebHTMLView setNeedsDisplayInRect:]): When called beneath + scrollPositionChanged(), adjust the rect by the inverse of the scroll offset. + +2010-02-23 Steve Block <steveblock@google.com> + + Reviewed by Darin Adler. + + Adds ChromeClient::cancelGeolocationPermissionRequestForFrame + https://bugs.webkit.org/show_bug.cgi?id=34962 + + This method is required so that a Geolocation object can cancel an + asynchronous permission request. This allows the chrome client to cancel + any UI it is showing for the permission request. + + * WebCoreSupport/WebChromeClient.h: + (WebChromeClient::cancelGeolocationPermissionRequestForFrame): + +2010-02-22 Alexey Proskuryakov <ap@apple.com> + + Rubber-stamped by Geoff Garen. + + Rename RuntimeObjectImp to RuntimeObject. + + * Plugins/Hosted/NetscapePluginInstanceProxy.mm: + (WebKit::NetscapePluginInstanceProxy::addValueToArray): + (WebKit::NetscapePluginInstanceProxy::retainLocalObject): + (WebKit::NetscapePluginInstanceProxy::releaseLocalObject): + +2010-02-22 Brady Eidson <beidson@apple.com> + + Reviewed by Tim Hatcher. + + Disable WebView docking to views that are too small. + <rdar://problem/7248409> and https://bugs.webkit.org/show_bug.cgi?id=35254 + + * WebCoreSupport/WebInspectorClient.mm: + (-[WebInspectorWindowController showWindow:]): No matter the preference, don't open the inspector + window attached if WebCore says it shouldn't be attached. + +2010-02-22 Simon Fraser <simon.fraser@apple.com> + + Reviewed by John Sullivan. + + <rdar://problem/7285392> + On Leopard, we have to disable hardware acceleration if we detect that the + installed Core Video framework has bug <rdar://problem/7228836>. + + * WebView/WebView.mm: + (coreVideoHas7228836Fix): + (-[WebView _preferencesChangedNotification:]): + +2010-02-21 Dan Bernstein <mitz@apple.com> + + Reviewed by Darin Adler. + + False warnings about needing layout in + -[WebHTMLView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:] + https://bugs.webkit.org/show_bug.cgi?id=35218 + + * WebView/WebHTMLView.mm: + (-[WebHTMLView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]): + Suppress the warning and the forced layout if the view is not being drawn + in this display operation. + +2010-02-21 Kevin Decker <kdecker@apple.com> + + Reviewed by Sam Weinig. + + plugInViewWithArguments: API sends wrong parameter for WebPlugInBaseURLKey + https://bugs.webkit.org/show_bug.cgi?id=35215 + <rdar://problem/7673157> + + The plugInViewWithArguments: API passes a dictionary of plugin arguments. One of the parameters + is WebPlugInBaseURLKey, which is a key that represents the base URL of the document containing + the plug-in's view. Instead of sending the base URL, code in WebFrameLoaderClient::createPlugin + would incorrectly pass the source URL of the plug-in resource. + + * WebCoreSupport/WebFrameLoaderClient.mm: + (WebFrameLoaderClient::createPlugin): When building the plug-in arguments dictionary, pass the + real base URL for the WebPlugInBaseURLKey key. + +2010-02-19 Maciej Stachowiak <mjs@apple.com> + + Reviewed by David Levin. + + Add an ENABLE flag for sandboxed iframes to make it possible to disable it in releases + https://bugs.webkit.org/show_bug.cgi?id=35147 + + * Configurations/FeatureDefines.xcconfig: + +2010-02-19 Alexey Proskuryakov <ap@apple.com> + + Reviewed by Maciej Stachowiak. + + https://bugs.webkit.org/show_bug.cgi?id=35132 + <rdar://problem/7664353> Mouse cursor sometimes flickers over Flash content (35132) + + * Plugins/WebNetscapePluginEventHandlerCarbon.mm: + (WebNetscapePluginEventHandlerCarbon::mouseMoved): Send adjustCursor events on every mouse + move. This matches Firefox, and is actually required for plug-ins to manipulate cursor wihout + resorting to techniques such as fast firing timers. + + * Plugins/WebNetscapePluginView.mm: + (-[WebNetscapePluginView handleMouseEntered:]): Some plug-ins handle mouse cursor internally, + but those that don't just need to get an arrow cursor (matching Firefox). This means that + e.g. a plugin inside <A> won't get a finger mouse pointer. + + * Plugins/WebHostedNetscapePluginView.mm: + (-[WebNetscapePluginView handleMouseEntered:]): + (-[WebNetscapePluginView handleMouseExited:]): + Implement this behavior here, too. Also, out of process code didn't reset mouse pointer on + mouse exit, which it needed to do. + + * WebView/WebHTMLView.mm: + (needsCursorRectsSupportAtPoint): + (setCursor): + (resetCursorRects): + Make sure that the same workaround we have for Web content also applies to Netscape plug-ins, + as AppKit would reset the mouse pointer to arrow if given a chance. + (+[WebHTMLViewPrivate initialize]): Renamed setCursorIMP on Leopard and higher to prevent + confusion - the method we override is completely different. + (-[WebHTMLView hitTest:]): Added a FIXME about a likely bug. + 2010-02-19 Simon Fraser <simon.fraser@apple.com> Reviewed by Dan Bernstein. diff --git a/WebKit/mac/Configurations/Base.xcconfig b/WebKit/mac/Configurations/Base.xcconfig index eb16d36..7914aed 100644 --- a/WebKit/mac/Configurations/Base.xcconfig +++ b/WebKit/mac/Configurations/Base.xcconfig @@ -53,6 +53,8 @@ REAL_PLATFORM_NAME = $(REAL_PLATFORM_NAME_$(PLATFORM_NAME)); REAL_PLATFORM_NAME_ = $(REAL_PLATFORM_NAME_macosx); REAL_PLATFORM_NAME_macosx = macosx; +TARGET_MAC_OS_X_VERSION_MAJOR = $(MAC_OS_X_VERSION_MAJOR); + // DEBUG_DEFINES, GCC_OPTIMIZATION_LEVEL, STRIP_INSTALLED_PRODUCT and DEAD_CODE_STRIPPING vary between the debug and normal variants. // We set up the values for each variant here, and have the Debug configuration in the Xcode project use the _debug variant. @@ -78,6 +80,26 @@ SECTORDER_FLAGS = -sectorder __TEXT __text mac/WebKit.order; // Note that Xcode versions as new as 3.1.2 use XCODE_VERSION_ACTUAL for the minor version // number. Newer versions of Xcode use XCODE_VERSION_MINOR for the minor version, and // XCODE_VERSION_ACTUAL for the full version number. -GCC_VERSION = $(GCC_VERSION_$(XCODE_VERSION_MINOR)); -GCC_VERSION_ = $(GCC_VERSION_$(XCODE_VERSION_ACTUAL)); -GCC_VERSION_0310 = 4.2; +TARGET_GCC_VERSION = $(TARGET_GCC_VERSION_$(TARGET_MAC_OS_X_VERSION_MAJOR)); +TARGET_GCC_VERSION_ = $(TARGET_GCC_VERSION_1040); +TARGET_GCC_VERSION_1040 = GCC_40; +TARGET_GCC_VERSION_1050 = $(TARGET_GCC_VERSION_1050_$(XCODE_VERSION_MINOR)); +TARGET_GCC_VERSION_1050_ = $(TARGET_GCC_VERSION_1050_$(XCODE_VERSION_ACTUAL)); +TARGET_GCC_VERSION_1050_0310 = GCC_42; +TARGET_GCC_VERSION_1050_0320 = GCC_42; +TARGET_GCC_VERSION_1060 = GCC_42; +TARGET_GCC_VERSION_1070 = LLVM_GCC_42; + +GCC_VERSION = $(GCC_VERSION_$(TARGET_GCC_VERSION)); +GCC_VERSION_GCC_40 = 4.0; +GCC_VERSION_GCC_42 = 4.2; +GCC_VERSION_LLVM_GCC_42 = com.apple.compilers.llvmgcc42; + +// If the target Mac OS X version does not match the current Mac OS X version then we'll want to build using the target version's SDK. +SDKROOT = $(SDKROOT_$(MAC_OS_X_VERSION_MAJOR)_$(TARGET_MAC_OS_X_VERSION_MAJOR)); +SDKROOT_1050_1040 = macosx10.4; +SDKROOT_1060_1040 = macosx10.4; +SDKROOT_1060_1050 = macosx10.5; +SDKROOT_1070_1040 = macosx10.4; +SDKROOT_1070_1050 = macosx10.5; +SDKROOT_1070_1060 = macosx10.6; diff --git a/WebKit/mac/Configurations/DebugRelease.xcconfig b/WebKit/mac/Configurations/DebugRelease.xcconfig index 11a94ca..77f7893 100644 --- a/WebKit/mac/Configurations/DebugRelease.xcconfig +++ b/WebKit/mac/Configurations/DebugRelease.xcconfig @@ -23,7 +23,7 @@ #include "Base.xcconfig" -ARCHS = $(ARCHS_$(MAC_OS_X_VERSION_MAJOR)); +ARCHS = $(ARCHS_$(TARGET_MAC_OS_X_VERSION_MAJOR)); ARCHS_ = $(ARCHS_1040); ARCHS_1040 = $(NATIVE_ARCH); ARCHS_1050 = $(NATIVE_ARCH); @@ -32,7 +32,7 @@ ARCHS_1070 = $(ARCHS_STANDARD_32_64_BIT); ONLY_ACTIVE_ARCH = YES; -MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(MAC_OS_X_VERSION_MAJOR)); +MACOSX_DEPLOYMENT_TARGET = $(MACOSX_DEPLOYMENT_TARGET_$(TARGET_MAC_OS_X_VERSION_MAJOR)); MACOSX_DEPLOYMENT_TARGET_ = 10.4; MACOSX_DEPLOYMENT_TARGET_1040 = 10.4; MACOSX_DEPLOYMENT_TARGET_1050 = 10.5; @@ -43,7 +43,7 @@ GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; SECTORDER_FLAGS = ; -WEBKIT_SYSTEM_INTERFACE_LIBRARY = $(WEBKIT_SYSTEM_INTERFACE_LIBRARY_$(MAC_OS_X_VERSION_MAJOR)); +WEBKIT_SYSTEM_INTERFACE_LIBRARY = $(WEBKIT_SYSTEM_INTERFACE_LIBRARY_$(TARGET_MAC_OS_X_VERSION_MAJOR)); WEBKIT_SYSTEM_INTERFACE_LIBRARY_ = WebKitSystemInterfaceTiger; WEBKIT_SYSTEM_INTERFACE_LIBRARY_1040 = WebKitSystemInterfaceTiger; WEBKIT_SYSTEM_INTERFACE_LIBRARY_1050 = WebKitSystemInterfaceLeopard; diff --git a/WebKit/mac/Configurations/FeatureDefines.xcconfig b/WebKit/mac/Configurations/FeatureDefines.xcconfig index 8343ce7..881c788 100644 --- a/WebKit/mac/Configurations/FeatureDefines.xcconfig +++ b/WebKit/mac/Configurations/FeatureDefines.xcconfig @@ -31,16 +31,17 @@ // Set any ENABLE_FEATURE_NAME macro to an empty string to disable that feature. -ENABLE_3D_CANVAS = $(ENABLE_3D_CANVAS_$(MAC_OS_X_VERSION_MAJOR)); +ENABLE_3D_CANVAS = $(ENABLE_3D_CANVAS_$(TARGET_MAC_OS_X_VERSION_MAJOR)); ENABLE_3D_CANVAS_1050 = ENABLE_3D_CANVAS; ENABLE_3D_CANVAS_1060 = ENABLE_3D_CANVAS; ENABLE_3D_CANVAS_1070 = ENABLE_3D_CANVAS; -ENABLE_3D_RENDERING = $(ENABLE_3D_RENDERING_$(MAC_OS_X_VERSION_MAJOR)); +ENABLE_3D_RENDERING = $(ENABLE_3D_RENDERING_$(TARGET_MAC_OS_X_VERSION_MAJOR)); ENABLE_3D_RENDERING_1050 = ENABLE_3D_RENDERING; ENABLE_3D_RENDERING_1060 = ENABLE_3D_RENDERING; ENABLE_3D_RENDERING_1070 = ENABLE_3D_RENDERING; +ENABLE_BLOB_SLICE = ENABLE_BLOB_SLICE; ENABLE_CHANNEL_MESSAGING = ENABLE_CHANNEL_MESSAGING; ENABLE_CLIENT_BASED_GEOLOCATION = ENABLE_CLIENT_BASED_GEOLOCATION; ENABLE_DATABASE = ENABLE_DATABASE; @@ -49,6 +50,8 @@ ENABLE_DATALIST = ENABLE_DATALIST; ENABLE_DOM_STORAGE = ENABLE_DOM_STORAGE; ENABLE_EVENTSOURCE = ENABLE_EVENTSOURCE; ENABLE_FILTERS = ENABLE_FILTERS; +ENABLE_FILE_READER = ; +ENABLE_FILE_WRITER = ; ENABLE_GEOLOCATION = ENABLE_GEOLOCATION; ENABLE_ICONDATABASE = ENABLE_ICONDATABASE; ENABLE_INDEXED_DATABASE = ; @@ -56,7 +59,9 @@ ENABLE_JAVASCRIPT_DEBUGGER = ENABLE_JAVASCRIPT_DEBUGGER; ENABLE_MATHML = ; ENABLE_NOTIFICATIONS = ; ENABLE_OFFLINE_WEB_APPLICATIONS = ENABLE_OFFLINE_WEB_APPLICATIONS; +ENABLE_PROGRESS_TAG = ENABLE_PROGRESS_TAG; ENABLE_RUBY = ENABLE_RUBY; +ENABLE_SANDBOX = ENABLE_SANDBOX; ENABLE_SHARED_WORKERS = ENABLE_SHARED_WORKERS; ENABLE_SVG = ENABLE_SVG; ENABLE_SVG_ANIMATION = ENABLE_SVG_ANIMATION; @@ -73,4 +78,4 @@ ENABLE_XHTMLMP = ; ENABLE_XPATH = ENABLE_XPATH; ENABLE_XSLT = ENABLE_XSLT; -FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_RUBY) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT); +FEATURE_DEFINES = $(ENABLE_3D_CANVAS) $(ENABLE_3D_RENDERING) $(ENABLE_BLOB_SLICE) $(ENABLE_CHANNEL_MESSAGING) $(ENABLE_CLIENT_BASED_GEOLOCATION) $(ENABLE_DATABASE) $(ENABLE_DATAGRID) $(ENABLE_DATALIST) $(ENABLE_DOM_STORAGE) $(ENABLE_EVENTSOURCE) $(ENABLE_FILTERS) $(ENABLE_FILE_READER) $(ENABLE_FILE_WRITER) $(ENABLE_GEOLOCATION) $(ENABLE_ICONDATABASE) $(ENABLE_INDEXED_DATABASE) $(ENABLE_JAVASCRIPT_DEBUGGER) $(ENABLE_MATHML) $(ENABLE_NOTIFICATIONS) $(ENABLE_OFFLINE_WEB_APPLICATIONS) $(ENABLE_PROGRESS_TAG) $(ENABLE_RUBY) $(ENABLE_SANDBOX) $(ENABLE_SHARED_WORKERS) $(ENABLE_SVG) $(ENABLE_SVG_ANIMATION) $(ENABLE_SVG_AS_IMAGE) $(ENABLE_SVG_DOM_OBJC_BINDINGS) $(ENABLE_SVG_FONTS) $(ENABLE_SVG_FOREIGN_OBJECT) $(ENABLE_SVG_USE) $(ENABLE_VIDEO) $(ENABLE_WEB_SOCKETS) $(ENABLE_WML) $(ENABLE_WORKERS) $(ENABLE_XHTMLMP) $(ENABLE_XPATH) $(ENABLE_XSLT); diff --git a/WebKit/mac/Configurations/Version.xcconfig b/WebKit/mac/Configurations/Version.xcconfig index 0e289b1..6aeb263 100644 --- a/WebKit/mac/Configurations/Version.xcconfig +++ b/WebKit/mac/Configurations/Version.xcconfig @@ -22,7 +22,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. MAJOR_VERSION = 533; -MINOR_VERSION = 1; +MINOR_VERSION = 6; TINY_VERSION = 0; FULL_VERSION = $(MAJOR_VERSION).$(MINOR_VERSION); @@ -31,7 +31,7 @@ BUNDLE_VERSION = $(BUNDLE_VERSION_$(CONFIGURATION)); SHORT_VERSION_STRING = $(SHORT_VERSION_STRING_$(CONFIGURATION)) // The system version prefix is based on the current system version. -SYSTEM_VERSION_PREFIX = $(SYSTEM_VERSION_PREFIX_$(MAC_OS_X_VERSION_MAJOR)); +SYSTEM_VERSION_PREFIX = $(SYSTEM_VERSION_PREFIX_$(TARGET_MAC_OS_X_VERSION_MAJOR)); SYSTEM_VERSION_PREFIX_ = 4; // Some Tiger versions of Xcode don't set MAC_OS_X_VERSION_MAJOR. SYSTEM_VERSION_PREFIX_1040 = 4; SYSTEM_VERSION_PREFIX_1050 = 5; diff --git a/WebKit/mac/ForwardingHeaders/runtime/Error.h b/WebKit/mac/ForwardingHeaders/runtime/Error.h new file mode 100644 index 0000000..05d7752 --- /dev/null +++ b/WebKit/mac/ForwardingHeaders/runtime/Error.h @@ -0,0 +1 @@ +#import <JavaScriptCore/Error.h> diff --git a/WebKit/mac/MigrateHeaders.make b/WebKit/mac/MigrateHeaders.make index f4bf744..061169e 100644 --- a/WebKit/mac/MigrateHeaders.make +++ b/WebKit/mac/MigrateHeaders.make @@ -291,6 +291,8 @@ all : \ $(INTERNAL_HEADERS_DIR)/DOMSVGFEMergeElementInternal.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGFEMergeNodeElement.h \ $(INTERNAL_HEADERS_DIR)/DOMSVGFEMergeNodeElementInternal.h \ + $(PRIVATE_HEADERS_DIR)/DOMSVGFEMorphologyElement.h \ + $(INTERNAL_HEADERS_DIR)/DOMSVGFEMorphologyElementInternal.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGFEOffsetElement.h \ $(INTERNAL_HEADERS_DIR)/DOMSVGFEOffsetElementInternal.h \ $(PRIVATE_HEADERS_DIR)/DOMSVGFEPointLightElement.h \ diff --git a/WebKit/mac/Misc/WebCoreStatistics.mm b/WebKit/mac/Misc/WebCoreStatistics.mm index 9e8ae05..1351fe5 100644 --- a/WebKit/mac/Misc/WebCoreStatistics.mm +++ b/WebKit/mac/Misc/WebCoreStatistics.mm @@ -196,10 +196,9 @@ using namespace WebCore; JSLock lock(SilenceAssertionsOnly); Heap::Statistics jsHeapStatistics = JSDOMWindow::commonJSGlobalData()->heap.statistics(); return [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithInt:fastMallocStatistics.heapSize], @"FastMallocHeapSize", - [NSNumber numberWithInt:fastMallocStatistics.freeSizeInHeap], @"FastMallocFreeSizeInHeap", - [NSNumber numberWithInt:fastMallocStatistics.freeSizeInCaches], @"FastMallocFreeSizeInCaches", - [NSNumber numberWithInt:fastMallocStatistics.returnedSize], @"FastMallocReturnedSize", + [NSNumber numberWithInt:fastMallocStatistics.reservedVMBytes], @"FastMallocReservedVMBytes", + [NSNumber numberWithInt:fastMallocStatistics.committedVMBytes], @"FastMallocCommittedVMBytes", + [NSNumber numberWithInt:fastMallocStatistics.freeListBytes], @"FastMallocFreeListBytes", [NSNumber numberWithInt:jsHeapStatistics.size], @"JavaScriptHeapSize", [NSNumber numberWithInt:jsHeapStatistics.free], @"JavaScriptFreeSize", nil]; diff --git a/WebKit/mac/Misc/WebDownload.mm b/WebKit/mac/Misc/WebDownload.mm index 01ed767..82c1259 100644 --- a/WebKit/mac/Misc/WebDownload.mm +++ b/WebKit/mac/Misc/WebDownload.mm @@ -56,7 +56,7 @@ using namespace WebCore; directory:(NSString *)directory; @end -@interface WebDownloadInternal : NSObject +@interface WebDownloadInternal : NSObject <NSURLDownloadDelegate> { @public id realDelegate; diff --git a/WebKit/mac/Misc/WebIconDatabase.mm b/WebKit/mac/Misc/WebIconDatabase.mm index 62c8e2f..0ded0d5 100644 --- a/WebKit/mac/Misc/WebIconDatabase.mm +++ b/WebKit/mac/Misc/WebIconDatabase.mm @@ -40,6 +40,7 @@ #import <WebCore/IconDatabase.h> #import <WebCore/Image.h> #import <WebCore/IntSize.h> +#import <WebCore/SharedBuffer.h> #import <WebCore/ThreadCheck.h> using namespace WebCore; diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.h b/WebKit/mac/Misc/WebNSFileManagerExtras.h index c2287f9..dcf62d0 100644 --- a/WebKit/mac/Misc/WebNSFileManagerExtras.h +++ b/WebKit/mac/Misc/WebNSFileManagerExtras.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2005, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,19 +28,10 @@ #import <Foundation/Foundation.h> -#define WEB_UREAD (00400) /* Read by owner */ -#define WEB_UWRITE (00200) /* Write by owner */ -#define WEB_UEXEC (00100) /* Execute/Search by owner */ - @interface NSFileManager (WebNSFileManagerExtras) - -- (void)_webkit_backgroundRemoveFileAtPath:(NSString *)path; -- (void)_webkit_backgroundRemoveLeftoverFiles:(NSString *)path; -- (BOOL)_webkit_removeFileOnlyAtPath:(NSString *)path; - (void)_webkit_setMetadataURL:(NSString *)URLString referrer:(NSString *)referrer atPath:(NSString *)path; - (NSString *)_webkit_startupVolumeName; - (NSString *)_webkit_pathWithUniqueFilenameForPath:(NSString *)path; - @end diff --git a/WebKit/mac/Misc/WebNSFileManagerExtras.m b/WebKit/mac/Misc/WebNSFileManagerExtras.m index fb1286f..f10781b 100644 --- a/WebKit/mac/Misc/WebNSFileManagerExtras.m +++ b/WebKit/mac/Misc/WebNSFileManagerExtras.m @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,74 +30,13 @@ #import "WebKitNSStringExtras.h" #import "WebNSURLExtras.h" +#import <JavaScriptCore/Assertions.h> #import <WebCore/FoundationExtras.h> #import <WebKitSystemInterface.h> -#import <pthread.h> -#import <sys/mount.h> -#import <JavaScriptCore/Assertions.h> +#import <sys/stat.h> @implementation NSFileManager (WebNSFileManagerExtras) -- (BOOL)_webkit_removeFileOnlyAtPath:(NSString *)path -{ - struct statfs buf; - BOOL result = unlink([path fileSystemRepresentation]) == 0; - - // For mysterious reasons, MNT_DOVOLFS is the flag for "supports resource fork" - if ((statfs([path fileSystemRepresentation], &buf) == 0) && !(buf.f_flags & MNT_DOVOLFS)) { - NSString *lastPathComponent = [path lastPathComponent]; - if ([lastPathComponent length] != 0 && ![lastPathComponent isEqualToString:@"/"]) { - NSString *resourcePath = [[path stringByDeletingLastPathComponent] stringByAppendingString:[@"._" stringByAppendingString:lastPathComponent]]; - if (unlink([resourcePath fileSystemRepresentation]) != 0) { - result = NO; - } - } - } - - return result; -} - -- (void)_webkit_backgroundRemoveFileAtPath:(NSString *)path -{ - NSFileManager *manager; - NSString *moveToSubpath; - NSString *moveToPath; - int i; - - manager = [NSFileManager defaultManager]; - - i = 0; - moveToSubpath = [path stringByDeletingLastPathComponent]; - do { - moveToPath = [NSString stringWithFormat:@"%@/.tmp%d", moveToSubpath, i]; - i++; - } while ([manager fileExistsAtPath:moveToPath]); - - if ([manager moveItemAtPath:path toPath:moveToPath error:NULL]) - [NSThread detachNewThreadSelector:@selector(_performRemoveFileAtPath:) toTarget:self withObject:moveToPath]; -} - -- (void)_webkit_backgroundRemoveLeftoverFiles:(NSString *)path -{ - NSFileManager *manager; - NSString *leftoverSubpath; - NSString *leftoverPath; - int i; - - manager = [NSFileManager defaultManager]; - leftoverSubpath = [path stringByDeletingLastPathComponent]; - - i = 0; - while (1) { - leftoverPath = [NSString stringWithFormat:@"%@/.tmp%d", leftoverSubpath, i]; - if (![manager fileExistsAtPath:leftoverPath]) { - break; - } - [NSThread detachNewThreadSelector:@selector(_performRemoveFileAtPath:) toTarget:self withObject:leftoverPath]; - i++; - } -} - - (NSString *)_webkit_carbonPathForPath:(NSString *)posixPath { OSStatus error; @@ -199,14 +138,22 @@ static void *setMetaData(void* context) return [path substringToIndex:[path length]-1]; } +// -[NSFileManager fileExistsAtPath:] returns NO if there is a broken symlink at the path. +// So we use this function instead, which returns YES if there is anything there, including +// a broken symlink. +static BOOL fileExists(NSString *path) +{ + struct stat statBuffer; + return !lstat([path fileSystemRepresentation], &statBuffer); +} + - (NSString *)_webkit_pathWithUniqueFilenameForPath:(NSString *)path { // "Fix" the filename of the path. NSString *filename = [[path lastPathComponent] _webkit_filenameByFixingIllegalCharacters]; path = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:filename]; - NSFileManager *fileManager = [NSFileManager defaultManager]; - if ([fileManager fileExistsAtPath:path]) { + if (fileExists(path)) { // Don't overwrite existing file by appending "-n", "-n.ext" or "-n.ext.ext" to the filename. NSString *extensions = nil; NSString *pathWithoutExtensions; @@ -221,15 +168,11 @@ static void *setMetaData(void* context) pathWithoutExtensions = [[path stringByDeletingLastPathComponent] stringByAppendingPathComponent:lastPathComponent]; } - NSString *pathWithAppendedNumber; - unsigned i; - - for (i = 1; 1; i++) { - pathWithAppendedNumber = [NSString stringWithFormat:@"%@-%d", pathWithoutExtensions, i]; + for (unsigned i = 1; ; i++) { + NSString *pathWithAppendedNumber = [NSString stringWithFormat:@"%@-%d", pathWithoutExtensions, i]; path = [extensions length] ? [pathWithAppendedNumber stringByAppendingPathExtension:extensions] : pathWithAppendedNumber; - if (![fileManager fileExistsAtPath:path]) { + if (!fileExists(path)) break; - } } } @@ -238,8 +181,8 @@ static void *setMetaData(void* context) @end - #ifdef BUILDING_ON_TIGER + @implementation NSFileManager (WebNSFileManagerTigerForwardCompatibility) - (NSArray *)contentsOfDirectoryAtPath:(NSString *)path error:(NSError **)error @@ -293,4 +236,5 @@ static void *setMetaData(void* context) } @end + #endif diff --git a/WebKit/mac/Misc/WebNSPasteboardExtras.mm b/WebKit/mac/Misc/WebNSPasteboardExtras.mm index 3cc1c7c..8cebeb6 100644 --- a/WebKit/mac/Misc/WebNSPasteboardExtras.mm +++ b/WebKit/mac/Misc/WebNSPasteboardExtras.mm @@ -37,14 +37,15 @@ #import "WebURLsWithTitles.h" #import "WebViewPrivate.h" #import <WebCore/Element.h> +#import <WebCore/Image.h> #import <WebCore/MIMETypeRegistry.h> #import <WebCore/RenderImage.h> #import <WebKit/DOMExtensions.h> #import <WebKit/DOMPrivate.h> +#import <WebKitSystemInterface.h> #import <wtf/Assertions.h> -#import <wtf/StdLibExtras.h> #import <wtf/RetainPtr.h> -#import <WebKitSystemInterface.h> +#import <wtf/StdLibExtras.h> @interface NSFilePromiseDragSource : NSObject - initWithSource:(id)draggingSource; diff --git a/WebKit/mac/Misc/WebNSPrintOperationExtras.h b/WebKit/mac/Misc/WebNSPrintOperationExtras.h index 44eb3df..3535369 100644 --- a/WebKit/mac/Misc/WebNSPrintOperationExtras.h +++ b/WebKit/mac/Misc/WebNSPrintOperationExtras.h @@ -31,5 +31,7 @@ @interface NSPrintOperation (WebKitExtras) - (float)_web_pageSetupScaleFactor; +- (float)_web_availablePaperWidth; +- (float)_web_availablePaperHeight; @end diff --git a/WebKit/mac/Misc/WebNSPrintOperationExtras.m b/WebKit/mac/Misc/WebNSPrintOperationExtras.m index 4c45f17..0982b96 100644 --- a/WebKit/mac/Misc/WebNSPrintOperationExtras.m +++ b/WebKit/mac/Misc/WebNSPrintOperationExtras.m @@ -35,4 +35,16 @@ return [[[[self printInfo] dictionary] objectForKey:NSPrintScalingFactor] floatValue]; } +- (float)_web_availablePaperWidth +{ + NSPrintInfo *printInfo = [self printInfo]; + return [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin]; +} + +- (float)_web_availablePaperHeight +{ + NSPrintInfo *printInfo = [self printInfo]; + return [printInfo paperSize].height - [printInfo topMargin] - [printInfo bottomMargin]; +} + @end diff --git a/WebKit/mac/Misc/WebUserContentURLPattern.h b/WebKit/mac/Misc/WebUserContentURLPattern.h new file mode 100644 index 0000000..6ec4bcf --- /dev/null +++ b/WebKit/mac/Misc/WebUserContentURLPattern.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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. + */ + +@class WebUserContentURLPatternPrivate; + +@interface WebUserContentURLPattern : NSObject { + WebUserContentURLPatternPrivate *_private; +} + +- (id)initWithPatternString:(NSString *)patternString; + +- (BOOL)isValid; +- (NSString *)scheme; +- (NSString *)host; +- (BOOL)matchesSubdomains; + +@end diff --git a/WebKit/mac/Misc/WebUserContentURLPattern.mm b/WebKit/mac/Misc/WebUserContentURLPattern.mm new file mode 100644 index 0000000..5d9f49e --- /dev/null +++ b/WebKit/mac/Misc/WebUserContentURLPattern.mm @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2010 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 INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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. + */ + +#import "WebUserContentURLPattern.h" + +#import <WebCore/UserContentURLPattern.h> + +using namespace WebCore; + +@interface WebUserContentURLPatternPrivate : NSObject +{ +@public + UserContentURLPattern pattern; +} +@end + +@implementation WebUserContentURLPatternPrivate +@end + +@implementation WebUserContentURLPattern + +- (id)initWithPatternString:(NSString *)patternString +{ + self = [super init]; + if (!self) + return nil; + + _private = [[WebUserContentURLPatternPrivate alloc] init]; + _private->pattern = UserContentURLPattern(patternString); + + return self; +} + +- (void)dealloc +{ + [_private release]; + _private = nil; + + [super dealloc]; +} + +- (BOOL)isValid +{ + return _private->pattern.isValid(); +} + +- (NSString *)scheme +{ + return _private->pattern.scheme(); +} + +- (NSString *)host +{ + return _private->pattern.host(); +} + +- (BOOL)matchesSubdomains +{ + return _private->pattern.matchSubdomains(); +} + +@end diff --git a/WebKit/mac/Panels/WebAuthenticationPanel.m b/WebKit/mac/Panels/WebAuthenticationPanel.m index f207d0c..c9442da 100644 --- a/WebKit/mac/Panels/WebAuthenticationPanel.m +++ b/WebKit/mac/Panels/WebAuthenticationPanel.m @@ -218,7 +218,9 @@ - (void)runAsModalDialogWithChallenge:(NSURLAuthenticationChallenge *)chall { [self setUpForChallenge:chall]; + usingSheet = FALSE; + [chall retain]; NSURLCredential *credential = nil; if ([[NSApplication sharedApplication] runModalForWindow:panel] == 0) { @@ -227,6 +229,7 @@ [callback performSelector:selector withObject:chall withObject:credential]; [credential release]; + [chall release]; } - (void)runAsSheetOnWindow:(NSWindow *)window withChallenge:(NSURLAuthenticationChallenge *)chall diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h index cd3729f..d35503f 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.h @@ -43,8 +43,8 @@ class NetscapePluginHostProxy { public: NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods); - mach_port_t port() const { return m_pluginHostPort; } - mach_port_t clientPort() const { return m_clientPort; } + mach_port_t port() const { ASSERT(fastMallocSize(this)); return m_pluginHostPort; } + mach_port_t clientPort() const { ASSERT(fastMallocSize(this)); return m_clientPort; } void addPluginInstance(NetscapePluginInstanceProxy*); void removePluginInstance(NetscapePluginInstanceProxy*); @@ -54,15 +54,15 @@ public: bool isMenuBarVisible() const { return m_menuBarIsVisible; } void setMenuBarVisible(bool); - bool isFullScreenWindowShowing() const { return m_fullScreenWindowIsShowing; } - void setFullScreenWindowIsShowing(bool); + bool isFullscreenWindowShowing() const { return m_fullscreenWindowIsShowing; } + void setFullscreenWindowIsShowing(bool); void setModal(bool); void applicationDidBecomeActive(); bool processRequests(); - bool isProcessingRequests() const { return m_processingRequests; } + static bool isProcessingRequests() { return s_processingRequests; } bool shouldCacheMissingPropertiesAndMethods() const { return m_shouldCacheMissingPropertiesAndMethods; } @@ -73,8 +73,8 @@ private: void beginModal(); void endModal(); - void didEnterFullScreen() const; - void didExitFullScreen() const; + void didEnterFullscreen() const; + void didExitFullscreen() const; static void deadNameNotificationCallback(CFMachPortRef, void *msg, CFIndex size, void *info); @@ -96,10 +96,10 @@ private: RetainPtr<WebPlaceholderModalWindow *> m_placeholderWindow; unsigned m_isModal; bool m_menuBarIsVisible; - bool m_fullScreenWindowIsShowing; + bool m_fullscreenWindowIsShowing; const ProcessSerialNumber m_pluginHostPSN; - unsigned m_processingRequests; + static unsigned s_processingRequests; bool m_shouldCacheMissingPropertiesAndMethods; }; diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm index 836277c..b437012 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginHostProxy.mm @@ -89,15 +89,16 @@ static PluginProxyMap& pluginProxyMap() return pluginProxyMap; } +unsigned NetscapePluginHostProxy::s_processingRequests; + NetscapePluginHostProxy::NetscapePluginHostProxy(mach_port_t clientPort, mach_port_t pluginHostPort, const ProcessSerialNumber& pluginHostPSN, bool shouldCacheMissingPropertiesAndMethods) : m_clientPort(clientPort) , m_portSet(MACH_PORT_NULL) , m_pluginHostPort(pluginHostPort) , m_isModal(false) , m_menuBarIsVisible(true) - , m_fullScreenWindowIsShowing(false) + , m_fullscreenWindowIsShowing(false) , m_pluginHostPSN(pluginHostPSN) - , m_processingRequests(0) , m_shouldCacheMissingPropertiesAndMethods(shouldCacheMissingPropertiesAndMethods) { pluginProxyMap().add(m_clientPort, this); @@ -184,7 +185,9 @@ void NetscapePluginHostProxy::removePluginInstance(NetscapePluginInstanceProxy* NetscapePluginInstanceProxy* NetscapePluginHostProxy::pluginInstance(uint32_t pluginID) { - return m_instances.get(pluginID).get(); + NetscapePluginInstanceProxy* result = m_instances.get(pluginID).get(); + ASSERT(!result || result->hostProxy() == this); + return result; } void NetscapePluginHostProxy::deadNameNotificationCallback(CFMachPortRef port, void *msg, CFIndex size, void *info) @@ -202,12 +205,12 @@ void NetscapePluginHostProxy::setMenuBarVisible(bool visible) [NSMenu setMenuBarVisible:visible]; } -void NetscapePluginHostProxy::didEnterFullScreen() const +void NetscapePluginHostProxy::didEnterFullscreen() const { SetFrontProcess(&m_pluginHostPSN); } -void NetscapePluginHostProxy::didExitFullScreen() const +void NetscapePluginHostProxy::didExitFullscreen() const { // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode. @@ -223,16 +226,16 @@ void NetscapePluginHostProxy::didExitFullScreen() const SetFrontProcess(¤tProcess); } -void NetscapePluginHostProxy::setFullScreenWindowIsShowing(bool isShowing) +void NetscapePluginHostProxy::setFullscreenWindowIsShowing(bool isShowing) { - if (m_fullScreenWindowIsShowing == isShowing) + if (m_fullscreenWindowIsShowing == isShowing) return; - m_fullScreenWindowIsShowing = isShowing; - if (m_fullScreenWindowIsShowing) - didEnterFullScreen(); + m_fullscreenWindowIsShowing = isShowing; + if (m_fullscreenWindowIsShowing) + didEnterFullscreen(); else - didExitFullScreen(); + didExitFullscreen(); } @@ -294,7 +297,7 @@ void NetscapePluginHostProxy::setModal(bool modal) bool NetscapePluginHostProxy::processRequests() { - m_processingRequests++; + s_processingRequests++; if (!m_portSet) { mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_PORT_SET, &m_portSet); @@ -310,7 +313,7 @@ bool NetscapePluginHostProxy::processRequests() if (kr != KERN_SUCCESS) { LOG_ERROR("Could not receive mach message, error %x", kr); - m_processingRequests--; + s_processingRequests--; return false; } @@ -323,24 +326,24 @@ bool NetscapePluginHostProxy::processRequests() if (kr != KERN_SUCCESS) { LOG_ERROR("Could not send mach message, error %x", kr); - m_processingRequests--; + s_processingRequests--; return false; } } - m_processingRequests--; + s_processingRequests--; return true; } if (msg->msgh_local_port == CFMachPortGetPort(m_deadNameNotificationPort.get())) { ASSERT(msg->msgh_id == MACH_NOTIFY_DEAD_NAME); pluginHostDied(); - m_processingRequests--; + s_processingRequests--; return false; } ASSERT_NOT_REACHED(); - m_processingRequests--; + s_processingRequests--; return false; } @@ -437,7 +440,7 @@ kern_return_t WKPCInvalidateRect(mach_port_t clientPort, uint32_t pluginID, doub if (NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID)) instanceProxy->invalidateRect(x, y, width, height); return KERN_SUCCESS; - } + } // Defer the work CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{ @@ -578,7 +581,11 @@ kern_return_t WKPCEvaluate(mach_port_t clientPort, uint32_t pluginID, uint32_t r data_t resultData = 0; mach_msg_type_number_t resultLength = 0; boolean_t returnValue = instanceProxy->evaluate(objectID, script, resultData, resultLength, allowPopups); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength); if (resultData) mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength); @@ -610,7 +617,7 @@ static Identifier identifierFromIdentifierRep(IdentifierRep* identifier) ASSERT(identifier->isString()); const char* str = identifier->string(); - return Identifier(JSDOMWindow::commonJSGlobalData(), String::fromUTF8WithLatin1Fallback(str, strlen(str))); + return Identifier(JSDOMWindow::commonJSGlobalData(), stringToUString(String::fromUTF8WithLatin1Fallback(str, strlen(str)))); } kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t requestID, uint32_t objectID, uint64_t serverIdentifier, @@ -637,7 +644,11 @@ kern_return_t WKPCInvoke(mach_port_t clientPort, uint32_t pluginID, uint32_t req data_t resultData = 0; mach_msg_type_number_t resultLength = 0; boolean_t returnValue = instanceProxy->invoke(objectID, methodNameIdentifier, argumentsData, argumentsLength, resultData, resultLength); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength); if (resultData) mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength); @@ -663,7 +674,11 @@ kern_return_t WKPCInvokeDefault(mach_port_t clientPort, uint32_t pluginID, uint3 data_t resultData = 0; mach_msg_type_number_t resultLength = 0; boolean_t returnValue = instanceProxy->invokeDefault(objectID, argumentsData, argumentsLength, resultData, resultLength); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength); if (resultData) mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength); @@ -701,7 +716,7 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_ NetscapePluginInstanceProxy* instanceProxy = hostProxy->pluginInstance(pluginID); if (!instanceProxy) return KERN_FAILURE; - + IdentifierRep* identifier = reinterpret_cast<IdentifierRep*>(serverIdentifier); if (!IdentifierRep::isValid(identifier)) return KERN_FAILURE; @@ -717,7 +732,11 @@ kern_return_t WKPCGetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_ returnValue = instanceProxy->getProperty(objectID, propertyNameIdentifier, resultData, resultLength); } else returnValue = instanceProxy->setProperty(objectID, identifier->number(), resultData, resultLength); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength); if (resultData) mig_deallocate(reinterpret_cast<vm_address_t>(resultData), resultLength); @@ -750,6 +769,10 @@ kern_return_t WKPCSetProperty(mach_port_t clientPort, uint32_t pluginID, uint32_ } else result = instanceProxy->setProperty(objectID, identifier->number(), valueData, valueLength); + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result); return KERN_SUCCESS; @@ -778,6 +801,10 @@ kern_return_t WKPCRemoveProperty(mach_port_t clientPort, uint32_t pluginID, uint } else result = instanceProxy->removeProperty(objectID, identifier->number()); + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, result); return KERN_SUCCESS; @@ -805,7 +832,11 @@ kern_return_t WKPCHasProperty(mach_port_t clientPort, uint32_t pluginID, uint32_ returnValue = instanceProxy->hasProperty(objectID, propertyNameIdentifier); } else returnValue = instanceProxy->hasProperty(objectID, identifier->number()); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue); return KERN_SUCCESS; @@ -830,6 +861,10 @@ kern_return_t WKPCHasMethod(mach_port_t clientPort, uint32_t pluginID, uint32_t Identifier methodNameIdentifier = identifierFromIdentifierRep(identifier); boolean_t returnValue = instanceProxy->hasMethod(objectID, methodNameIdentifier); + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue); return KERN_SUCCESS; @@ -872,7 +907,11 @@ kern_return_t WKPCEnumerate(mach_port_t clientPort, uint32_t pluginID, uint32_t data_t resultData = 0; mach_msg_type_number_t resultLength = 0; boolean_t returnValue = instanceProxy->enumerate(objectID, resultData, resultLength); - + + hostProxy = instanceProxy->hostProxy(); + if (!hostProxy) + return KERN_FAILURE; + _WKPHBooleanAndDataReply(hostProxy->port(), instanceProxy->pluginID(), requestID, returnValue, resultData, resultLength); if (resultData) @@ -892,13 +931,13 @@ kern_return_t WKPCSetMenuBarVisible(mach_port_t clientPort, boolean_t menuBarVis return KERN_SUCCESS; } -kern_return_t WKPCSetFullScreenWindowIsShowing(mach_port_t clientPort, boolean_t fullScreenWindowIsShowing) +kern_return_t WKPCSetFullscreenWindowIsShowing(mach_port_t clientPort, boolean_t fullscreenWindowIsShowing) { NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort); if (!hostProxy) return KERN_FAILURE; - hostProxy->setFullScreenWindowIsShowing(fullScreenWindowIsShowing); + hostProxy->setFullscreenWindowIsShowing(fullscreenWindowIsShowing); return KERN_SUCCESS; } @@ -908,9 +947,18 @@ kern_return_t WKPCSetModal(mach_port_t clientPort, boolean_t modal) NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort); if (!hostProxy) return KERN_FAILURE; - - hostProxy->setModal(modal); - + + if (!hostProxy->isProcessingRequests()) { + hostProxy->setModal(modal); + return KERN_SUCCESS; + } + + // Defer the work + CFRunLoopPerformBlock(CFRunLoopGetMain(), kCFRunLoopDefaultMode, ^{ + if (NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort)) + hostProxy->setModal(modal); + }); + return KERN_SUCCESS; } @@ -1090,7 +1138,7 @@ kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mac NetscapePluginHostProxy* hostProxy = pluginProxyMap().get(clientPort); if (!hostProxy) return KERN_FAILURE; - + NSOpenPanel *sheet = [NSOpenPanel openPanel]; NSDictionary *panelState = [NSPropertyListSerialization propertyListFromData:[NSData dataWithBytes:panelData length:panelDataLength] mutabilityOption:NSPropertyListImmutable @@ -1114,7 +1162,11 @@ kern_return_t WKPCRunSyncOpenPanel(mach_port_t clientPort, data_t panelData, mac [sheet setRequiredFileType:[panelState objectForKey:@"requiredFileType"]]; [sheet setTitle:[panelState objectForKey:@"title"]]; [sheet runModal]; - + + NetscapePluginHostProxy* newHostProxy = pluginProxyMap().get(clientPort); + if (newHostProxy != hostProxy) + return KERN_FAILURE; + NSDictionary *ret = [NSDictionary dictionaryWithObjectsAndKeys: [sheet filenames], @"filenames", WKNoteOpenPanelFiles([sheet filenames]), @"extensions", diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h index 29a5a2d..593d336 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.h @@ -72,14 +72,14 @@ public: return m_pluginID; } - uint32_t renderContextID() const { return m_renderContextID; } + uint32_t renderContextID() const { ASSERT(fastMallocSize(this)); return m_renderContextID; } void setRenderContextID(uint32_t renderContextID) { m_renderContextID = renderContextID; } bool useSoftwareRenderer() const { return m_useSoftwareRenderer; } void setUseSoftwareRenderer(bool useSoftwareRenderer) { m_useSoftwareRenderer = useSoftwareRenderer; } - WebHostedNetscapePluginView *pluginView() const { return m_pluginView; } - NetscapePluginHostProxy* hostProxy() const { return m_pluginHostProxy; } + WebHostedNetscapePluginView *pluginView() const { ASSERT(fastMallocSize(this)); return m_pluginView; } + NetscapePluginHostProxy* hostProxy() const { ASSERT(fastMallocSize(this)); return m_pluginHostProxy; } bool cancelStreamLoad(uint32_t streamID, NPReason); void disconnectStream(HostedNetscapePluginStream*); @@ -89,7 +89,7 @@ public: void pluginHostDied(); - void resize(NSRect size, NSRect clipRect, bool sync); + void resize(NSRect size, NSRect clipRect); void destroy(); void focusChanged(bool hasFocus); void windowFocusChanged(bool hasFocus); @@ -102,6 +102,7 @@ public: void syntheticKeyDownWithCommandModifier(int keyCode, char character); void flagsChanged(NSEvent *); void print(CGContextRef, unsigned width, unsigned height); + void snapshot(CGContextRef, unsigned width, unsigned height); void startTimers(bool throttleTimers); void stopTimers(); @@ -256,8 +257,9 @@ public: template <typename T> std::auto_ptr<T> waitForReply(uint32_t requestID) { + RefPtr<NetscapePluginInstanceProxy> protect(this); // Plug-in host may crash while we are waiting for reply, releasing all instances to the instance proxy. + willCallPluginFunction(); - m_waitingForReply = true; Reply* reply = processRequestsAndWaitForReply(requestID); diff --git a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm index 515f9f7..f027534 100644 --- a/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm +++ b/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm @@ -30,6 +30,7 @@ #import "HostedNetscapePluginStream.h" #import "NetscapePluginHostProxy.h" #import "ProxyInstance.h" +#import "ProxyRuntimeObject.h" #import "WebDataSourceInternal.h" #import "WebFrameInternal.h" #import "WebHostedNetscapePluginView.h" @@ -43,7 +44,6 @@ #import <JavaScriptCore/Error.h> #import <JavaScriptCore/JSLock.h> #import <JavaScriptCore/PropertyNameArray.h> -#import <WebCore/CString.h> #import <WebCore/CookieJar.h> #import <WebCore/DocumentLoader.h> #import <WebCore/Frame.h> @@ -60,6 +60,7 @@ #import <mach/mach.h> #import <utility> #import <wtf/RefCountedLeakCounter.h> +#import <wtf/text/CString.h> extern "C" { #import "WebKitPluginClientServer.h" @@ -116,6 +117,9 @@ inline bool NetscapePluginInstanceProxy::LocalObjectMap::contains(uint32_t objec inline JSC::JSObject* NetscapePluginInstanceProxy::LocalObjectMap::get(uint32_t objectID) const { + if (objectID == HashTraits<uint32_t>::emptyValue() || HashTraits<uint32_t>::isDeletedValue(objectID)) + return 0; + return m_idToJSObjectMap.get(objectID); } @@ -178,8 +182,16 @@ void NetscapePluginInstanceProxy::LocalObjectMap::clear() bool NetscapePluginInstanceProxy::LocalObjectMap::forget(uint32_t objectID) { + if (objectID == HashTraits<uint32_t>::emptyValue() || HashTraits<uint32_t>::isDeletedValue(objectID)) { + LOG_ERROR("NetscapePluginInstanceProxy::LocalObjectMap::forget: local object id %u is not valid.", objectID); + return true; + } + HashMap<uint32_t, JSC::ProtectedPtr<JSC::JSObject> >::iterator iter = m_idToJSObjectMap.find(objectID); - ASSERT(iter != m_idToJSObjectMap.end()); + if (iter == m_idToJSObjectMap.end()) { + LOG_ERROR("NetscapePluginInstanceProxy::LocalObjectMap::forget: local object %u doesn't exist.", objectID); + return true; + } HashMap<JSC::JSObject*, pair<uint32_t, uint32_t> >::iterator rIter = m_jsObjectToIDMap.find(iter->second.get()); @@ -245,19 +257,17 @@ NetscapePluginInstanceProxy::~NetscapePluginInstanceProxy() #endif } -void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect, bool sync) +void NetscapePluginInstanceProxy::resize(NSRect size, NSRect clipRect) { uint32_t requestID = 0; - if (sync) - requestID = nextRequestID(); + requestID = nextRequestID(); _WKPHResizePluginInstance(m_pluginHostProxy->port(), m_pluginID, requestID, size.origin.x, size.origin.y, size.size.width, size.size.height, clipRect.origin.x, clipRect.origin.y, clipRect.size.width, clipRect.size.height); - if (sync) - waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID); + waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID); } void NetscapePluginInstanceProxy::stopAllStreams() @@ -464,9 +474,6 @@ bool NetscapePluginInstanceProxy::wheelEvent(NSView *pluginView, NSEvent *event) pluginPoint.x, pluginPoint.y, [event buttonNumber], [event deltaX], [event deltaY], [event deltaZ]); - // Protect ourselves in case waiting for the reply causes us to be deleted. - RefPtr<NetscapePluginInstanceProxy> protect(this); - auto_ptr<NetscapePluginInstanceProxy::BooleanReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanReply>(requestID); if (!reply.get() || !reply->m_result) return false; @@ -497,6 +504,22 @@ void NetscapePluginInstanceProxy::print(CGContextRef context, unsigned width, un CGContextRestoreGState(context); } +void NetscapePluginInstanceProxy::snapshot(CGContextRef context, unsigned width, unsigned height) +{ + uint32_t requestID = nextRequestID(); + _WKPHPluginInstanceSnapshot(m_pluginHostProxy->port(), m_pluginID, requestID, width, height); + + auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID); + if (!reply.get() || !reply->m_returnValue) + return; + + RetainPtr<CGDataProvider> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(reply->m_result.get())); + RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB()); + RetainPtr<CGImageRef> image(AdoptCF, CGImageCreate(width, height, 8, 32, width * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host, dataProvider.get(), 0, false, kCGRenderingIntentDefault)); + + CGContextDrawImage(context, CGRectMake(0, 0, width, height), image.get()); +} + void NetscapePluginInstanceProxy::stopTimers() { _WKPHPluginInstanceStopTimers(m_pluginHostProxy->port(), m_pluginID); @@ -765,10 +788,16 @@ NPError NetscapePluginInstanceProxy::loadRequest(NSURLRequest *request, const ch NetscapePluginInstanceProxy::Reply* NetscapePluginInstanceProxy::processRequestsAndWaitForReply(uint32_t requestID) { Reply* reply = 0; - + + ASSERT(m_pluginHostProxy); while (!(reply = m_replies.take(requestID))) { if (!m_pluginHostProxy->processRequests()) return 0; + + // The host proxy can be destroyed while executing a nested processRequests() call, in which case it's normal + // to get a success result, but be unable to keep looping. + if (!m_pluginHostProxy) + return 0; } ASSERT(reply); @@ -782,7 +811,7 @@ bool NetscapePluginInstanceProxy::getWindowNPObject(uint32_t& objectID) if (!frame) return false; - if (!frame->script()->canExecuteScripts()) + if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) objectID = 0; else objectID = m_localObjects.idForObject(frame->script()->windowShell(pluginWorld())->window()); @@ -814,8 +843,10 @@ bool NetscapePluginInstanceProxy::evaluate(uint32_t objectID, const String& scri resultData = 0; resultLength = 0; - if (!m_localObjects.contains(objectID)) + if (!m_localObjects.contains(objectID)) { + LOG_ERROR("NetscapePluginInstanceProxy::evaluate: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -857,8 +888,10 @@ bool NetscapePluginInstanceProxy::invoke(uint32_t objectID, const Identifier& me return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::invoke: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -891,8 +924,10 @@ bool NetscapePluginInstanceProxy::invokeDefault(uint32_t objectID, data_t argume return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::invokeDefault: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -924,8 +959,10 @@ bool NetscapePluginInstanceProxy::construct(uint32_t objectID, data_t argumentsD return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::construct: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -958,8 +995,10 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, const Identifie return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::getProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -977,8 +1016,10 @@ bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, const Identifie bool NetscapePluginInstanceProxy::getProperty(uint32_t objectID, unsigned propertyName, data_t& resultData, mach_msg_type_number_t& resultLength) { JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::getProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -999,8 +1040,10 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, const Identifie return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::setProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1023,8 +1066,10 @@ bool NetscapePluginInstanceProxy::setProperty(uint32_t objectID, unsigned proper return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::setProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1046,8 +1091,10 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, const Identi return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::removeProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1071,8 +1118,10 @@ bool NetscapePluginInstanceProxy::removeProperty(uint32_t objectID, unsigned pro return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::removeProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1096,8 +1145,10 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, const Identifie return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::hasProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1116,8 +1167,10 @@ bool NetscapePluginInstanceProxy::hasProperty(uint32_t objectID, unsigned proper return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::hasProperty: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1136,8 +1189,10 @@ bool NetscapePluginInstanceProxy::hasMethod(uint32_t objectID, const Identifier& return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::hasMethod: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1156,8 +1211,10 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat return false; JSObject* object = m_localObjects.get(objectID); - if (!object) + if (!object) { + LOG_ERROR("NetscapePluginInstanceProxy::enumerate: local object %u doesn't exist.", objectID); return false; + } Frame* frame = core([m_pluginView webFrame]); if (!frame) @@ -1171,7 +1228,7 @@ bool NetscapePluginInstanceProxy::enumerate(uint32_t objectID, data_t& resultDat RetainPtr<NSMutableArray*> array(AdoptNS, [[NSMutableArray alloc] init]); for (unsigned i = 0; i < propertyNames.size(); i++) { - uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().c_str())); + uint64_t methodName = reinterpret_cast<uint64_t>(_NPN_GetStringIdentifier(propertyNames[i].ustring().UTF8String().data())); [array.get() addObject:[NSNumber numberWithLongLong:methodName]]; } @@ -1195,7 +1252,7 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecSta if (value.isString()) { [array addObject:[NSNumber numberWithInt:StringValueType]]; - [array addObject:String(value.toString(exec))]; + [array addObject:ustringToString(value.toString(exec))]; } else if (value.isNumber()) { [array addObject:[NSNumber numberWithInt:DoubleValueType]]; [array addObject:[NSNumber numberWithDouble:value.toNumber(exec)]]; @@ -1206,9 +1263,9 @@ void NetscapePluginInstanceProxy::addValueToArray(NSMutableArray *array, ExecSta [array addObject:[NSNumber numberWithInt:NullValueType]]; else if (value.isObject()) { JSObject* object = asObject(value); - if (object->classInfo() == &RuntimeObjectImp::s_info) { - RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(object); - if (ProxyInstance* instance = static_cast<ProxyInstance*>(imp->getInternalInstance())) { + if (object->classInfo() == &ProxyRuntimeObject::s_info) { + ProxyRuntimeObject* runtimeObject = static_cast<ProxyRuntimeObject*>(object); + if (ProxyInstance* instance = runtimeObject->getInternalProxyInstance()) { [array addObject:[NSNumber numberWithInt:NPObjectValueType]]; [array addObject:[NSNumber numberWithInt:instance->objectID()]]; } @@ -1287,7 +1344,7 @@ bool NetscapePluginInstanceProxy::demarshalValueFromArray(ExecState* exec, NSArr if (!frame) return false; - if (!frame->script()->canExecuteScripts()) + if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript)) return false; RefPtr<RootObject> rootObject = frame->script()->createRootObject(m_pluginView); @@ -1335,26 +1392,18 @@ void NetscapePluginInstanceProxy::demarshalValues(ExecState* exec, data_t values void NetscapePluginInstanceProxy::retainLocalObject(JSC::JSValue value) { - if (!value.isObject()) - return; - - JSObject* object = asObject(value); - if (object->classInfo() == &RuntimeObjectImp::s_info) + if (!value.isObject() || value.inherits(&ProxyRuntimeObject::s_info)) return; - m_localObjects.retain(object); + m_localObjects.retain(asObject(value)); } void NetscapePluginInstanceProxy::releaseLocalObject(JSC::JSValue value) { - if (!value.isObject()) + if (!value.isObject() || value.inherits(&ProxyRuntimeObject::s_info)) return; - JSObject* object = asObject(value); - if (object->classInfo() == &RuntimeObjectImp::s_info) - return; - - m_localObjects.release(object); + m_localObjects.release(asObject(value)); } PassRefPtr<Instance> NetscapePluginInstanceProxy::createBindingsInstance(PassRefPtr<RootObject> rootObject) @@ -1364,10 +1413,6 @@ PassRefPtr<Instance> NetscapePluginInstanceProxy::createBindingsInstance(PassRef if (_WKPHGetScriptableNPObject(m_pluginHostProxy->port(), m_pluginID, requestID) != KERN_SUCCESS) return 0; - // If the plug-in host crashes while we're waiting for a reply, the last reference to the instance proxy - // will go away. Prevent this by protecting it here. - RefPtr<NetscapePluginInstanceProxy> protect(this); - auto_ptr<GetScriptableNPObjectReply> reply = waitForReply<GetScriptableNPObjectReply>(requestID); if (!reply.get()) return 0; @@ -1375,6 +1420,7 @@ PassRefPtr<Instance> NetscapePluginInstanceProxy::createBindingsInstance(PassRef if (!reply->m_objectID) return 0; + // Since the reply was non-null, "this" is still a valid pointer. return ProxyInstance::create(rootObject, this, reply->m_objectID); } @@ -1458,7 +1504,7 @@ bool NetscapePluginInstanceProxy::getCookies(data_t urlData, mach_msg_type_numbe if (Frame* frame = core([m_pluginView webFrame])) { String cookieString = cookies(frame->document(), url); - WebCore::CString cookieStringUTF8 = cookieString.utf8(); + WTF::CString cookieStringUTF8 = cookieString.utf8(); if (cookieStringUTF8.isNull()) return false; @@ -1500,7 +1546,7 @@ bool NetscapePluginInstanceProxy::getProxy(data_t urlData, mach_msg_type_number_ if (!url) return false; - WebCore::CString proxyStringUTF8 = proxiesForURL(url); + WTF::CString proxyStringUTF8 = proxiesForURL(url); proxyLength = proxyStringUTF8.length(); mig_allocate(reinterpret_cast<vm_address_t*>(&proxyData), proxyLength); @@ -1512,8 +1558,8 @@ bool NetscapePluginInstanceProxy::getProxy(data_t urlData, mach_msg_type_number_ bool NetscapePluginInstanceProxy::getAuthenticationInfo(data_t protocolData, data_t hostData, uint32_t port, data_t schemeData, data_t realmData, data_t& usernameData, mach_msg_type_number_t& usernameLength, data_t& passwordData, mach_msg_type_number_t& passwordLength) { - WebCore::CString username; - WebCore::CString password; + WTF::CString username; + WTF::CString password; if (!WebKit::getAuthenticationInfo(protocolData, hostData, port, schemeData, realmData, username, password)) return false; @@ -1583,7 +1629,7 @@ void NetscapePluginInstanceProxy::resolveURL(const char* url, const char* target { ASSERT(m_pluginView); - WebCore::CString resolvedURL = [m_pluginView resolvedURLStringForURL:url target:target]; + WTF::CString resolvedURL = [m_pluginView resolvedURLStringForURL:url target:target]; resolvedURLLength = resolvedURL.length(); mig_allocate(reinterpret_cast<vm_address_t*>(&resolvedURLData), resolvedURLLength); @@ -1613,10 +1659,10 @@ void NetscapePluginInstanceProxy::moveGlobalExceptionToExecState(ExecState* exec { JSLock lock(SilenceAssertionsOnly); - throwError(exec, GeneralError, globalExceptionString()); + throwError(exec, GeneralError, stringToUString(globalExceptionString())); } - globalExceptionString() = UString(); + globalExceptionString() = String(); } } // namespace WebKit diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.h b/WebKit/mac/Plugins/Hosted/ProxyInstance.h index 6e8ac47..c8fb118 100644 --- a/WebKit/mac/Plugins/Hosted/ProxyInstance.h +++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.h @@ -58,10 +58,13 @@ public: private: ProxyInstance(PassRefPtr<JSC::Bindings::RootObject>, NetscapePluginInstanceProxy*, uint32_t objectID); - - virtual JSC::Bindings::Class *getClass() const; - virtual JSC::JSValue invokeMethod(JSC::ExecState*, const JSC::Bindings::MethodList&, const JSC::ArgList& args); + virtual JSC::Bindings::RuntimeObject* newRuntimeObject(JSC::ExecState*); + + virtual JSC::Bindings::Class* getClass() const; + + virtual JSC::JSValue getMethod(JSC::ExecState* exec, const JSC::Identifier& propertyName); + virtual JSC::JSValue invokeMethod(JSC::ExecState*, JSC::RuntimeMethod*, const JSC::ArgList& args); virtual bool supportsInvokeDefaultMethod() const; virtual JSC::JSValue invokeDefaultMethod(JSC::ExecState*, const JSC::ArgList&); diff --git a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm index c7a0ebe..9a976f9 100644 --- a/WebKit/mac/Plugins/Hosted/ProxyInstance.mm +++ b/WebKit/mac/Plugins/Hosted/ProxyInstance.mm @@ -28,9 +28,12 @@ #import "ProxyInstance.h" #import "NetscapePluginHostProxy.h" +#import "ProxyRuntimeObject.h" #import <WebCore/IdentifierRep.h> #import <WebCore/JSDOMWindow.h> #import <WebCore/npruntime_impl.h> +#import <WebCore/runtime_method.h> +#import <runtime/Error.h> #import <runtime/PropertyNameArray.h> extern "C" { @@ -128,7 +131,12 @@ ProxyInstance::~ProxyInstance() invalidate(); } -JSC::Bindings::Class *ProxyInstance::getClass() const +RuntimeObject* ProxyInstance::newRuntimeObject(ExecState* exec) +{ + return new (exec) ProxyRuntimeObject(exec, this); +} + +JSC::Bindings::Class* ProxyInstance::getClass() const { return proxyClass(); } @@ -147,16 +155,20 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id if (_WKPHNPObjectInvoke(m_instanceProxy->hostProxy()->port(), m_instanceProxy->pluginID(), requestID, m_objectID, type, identifier, (char*)[arguments.get() bytes], [arguments.get() length]) != KERN_SUCCESS) { - for (unsigned i = 0; i < args.size(); i++) - m_instanceProxy->releaseLocalObject(args.at(i)); + if (m_instanceProxy) { + for (unsigned i = 0; i < args.size(); i++) + m_instanceProxy->releaseLocalObject(args.at(i)); + } return jsUndefined(); } auto_ptr<NetscapePluginInstanceProxy::BooleanAndDataReply> reply = waitForReply<NetscapePluginInstanceProxy::BooleanAndDataReply>(requestID); NetscapePluginInstanceProxy::moveGlobalExceptionToExecState(exec); - for (unsigned i = 0; i < args.size(); i++) - m_instanceProxy->releaseLocalObject(args.at(i)); + if (m_instanceProxy) { + for (unsigned i = 0; i < args.size(); i++) + m_instanceProxy->releaseLocalObject(args.at(i)); + } if (!reply.get() || !reply->m_returnValue) return jsUndefined(); @@ -164,8 +176,33 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id return m_instanceProxy->demarshalValue(exec, (char*)CFDataGetBytePtr(reply->m_result.get()), CFDataGetLength(reply->m_result.get())); } -JSValue ProxyInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args) +class ProxyRuntimeMethod : public RuntimeMethod { +public: + ProxyRuntimeMethod(ExecState* exec, const Identifier& name, Bindings::MethodList& list) + : RuntimeMethod(exec, name, list) + { + } + + virtual const ClassInfo* classInfo() const { return &s_info; } + + static const ClassInfo s_info; +}; + +const ClassInfo ProxyRuntimeMethod::s_info = { "ProxyRuntimeMethod", &RuntimeMethod::s_info, 0, 0 }; + +JSValue ProxyInstance::getMethod(JSC::ExecState* exec, const JSC::Identifier& propertyName) +{ + MethodList methodList = getClass()->methodsNamed(propertyName, this); + return new (exec) ProxyRuntimeMethod(exec, propertyName, methodList); +} + +JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtimeMethod, const ArgList& args) { + if (!asObject(runtimeMethod)->inherits(&ProxyRuntimeMethod::s_info)) + return throwError(exec, TypeError, "Attempt to invoke non-plug-in method on plug-in object."); + + const MethodList& methodList = *runtimeMethod->methods(); + ASSERT(methodList.size() == 1); ProxyMethod* method = static_cast<ProxyMethod*>(methodList[0]); @@ -280,7 +317,7 @@ void ProxyInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArr if (identifier->isString()) { const char* str = identifier->string(); - nameArray.add(Identifier(JSDOMWindow::commonJSGlobalData(), String::fromUTF8WithLatin1Fallback(str, strlen(str)))); + nameArray.add(Identifier(JSDOMWindow::commonJSGlobalData(), stringToUString(String::fromUTF8WithLatin1Fallback(str, strlen(str))))); } else nameArray.add(Identifier::from(exec, identifier->number())); } @@ -396,7 +433,8 @@ void ProxyInstance::setFieldValue(ExecState* exec, const Field* field, JSValue v m_instanceProxy->pluginID(), requestID, m_objectID, serverIdentifier, valueData, valueLength); mig_deallocate(reinterpret_cast<vm_address_t>(valueData), valueLength); - m_instanceProxy->releaseLocalObject(value); + if (m_instanceProxy) + m_instanceProxy->releaseLocalObject(value); if (kr != KERN_SUCCESS) return; diff --git a/WebKit/mac/Misc/EmptyProtocolDefinitions.h b/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.h index c52d8ce..af3c5db 100644 --- a/WebKit/mac/Misc/EmptyProtocolDefinitions.h +++ b/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2010 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -13,36 +13,41 @@ * THIS SOFTWARE IS PROVIDED BY APPLE 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 INC. OR + * 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. + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#if defined(__OBJC__) +#if USE(PLUGIN_HOST_PROCESS) -#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) -#define DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS 0 -#else -#define DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS 1 -#endif +#ifndef ProxyRuntimeObject_h +#define ProxyRuntimeObject_h + +#include <WebCore/runtime_object.h> + +namespace WebKit { -#if !DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS +class ProxyInstance; -#define EMPTY_PROTOCOL(NAME) \ -@protocol NAME <NSObject> \ -@end +class ProxyRuntimeObject : public JSC::Bindings::RuntimeObject { +public: + ProxyRuntimeObject(JSC::ExecState*, PassRefPtr<ProxyInstance>); + virtual ~ProxyRuntimeObject(); -EMPTY_PROTOCOL(NSTableViewDataSource) -EMPTY_PROTOCOL(NSTableViewDelegate) -EMPTY_PROTOCOL(NSWindowDelegate) + ProxyInstance* getInternalProxyInstance() const; -#undef EMPTY_PROTOCOL + static const JSC::ClassInfo s_info; -#endif /* !DELEGATES_DECLARED_AS_FORMAL_PROTOCOLS */ +private: + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } +}; -#endif /* defined(__OBJC__) */ +} + +#endif +#endif diff --git a/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.mm b/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.mm new file mode 100644 index 0000000..5ba6e15 --- /dev/null +++ b/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.mm @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2010 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 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. + */ + +#if USE(PLUGIN_HOST_PROCESS) + +#include "ProxyInstance.h" +#include "ProxyRuntimeObject.h" + +using namespace JSC; + +namespace WebKit { + + +const ClassInfo ProxyRuntimeObject::s_info = { "ProxyRuntimeObject", &RuntimeObject::s_info, 0, 0 }; + +ProxyRuntimeObject::ProxyRuntimeObject(ExecState* exec, PassRefPtr<ProxyInstance> instance) + : RuntimeObject(exec, instance) +{ +} + +ProxyRuntimeObject::~ProxyRuntimeObject() +{ +} + +ProxyInstance* ProxyRuntimeObject::getInternalProxyInstance() const +{ + return static_cast<ProxyInstance*>(getInternalInstance()); +} + + +} + +#endif diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h index 5313ff2..1eb164d 100644 --- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h +++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.h @@ -45,7 +45,6 @@ namespace WebKit { NSSize _previousSize; RefPtr<WebKit::NetscapePluginInstanceProxy> _proxy; - BOOL _pluginHostDied; } - (id)initWithFrame:(NSRect)r diff --git a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm index 0ad76f0..cd3724e 100644 --- a/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm +++ b/WebKit/mac/Plugins/Hosted/WebHostedNetscapePluginView.mm @@ -41,8 +41,9 @@ #import <WebCore/Frame.h> #import <WebCore/FrameLoaderTypes.h> #import <WebCore/HTMLPlugInElement.h> -#import <WebCore/runtime_root.h> +#import <WebCore/RenderEmbeddedObject.h> #import <WebCore/WebCoreObjCExtras.h> +#import <WebCore/runtime_root.h> #import <runtime/InitializeThreading.h> #import <wtf/Assertions.h> @@ -180,10 +181,9 @@ extern "C" { if (!shouldClipOutPlugin) visibleRectInWindow.origin.y = borderViewHeight - NSMaxY(visibleRectInWindow); - BOOL sizeChanged = !NSEqualSizes(_previousSize, boundsInWindow.size); _previousSize = boundsInWindow.size; - _proxy->resize(boundsInWindow, visibleRectInWindow, sizeChanged); + _proxy->resize(boundsInWindow, visibleRectInWindow); } - (void)windowFocusChanged:(BOOL)hasFocus @@ -287,6 +287,9 @@ extern "C" { - (void)handleMouseEntered:(NSEvent *)event { + // Set cursor to arrow. Plugins often handle cursor internally, but those that don't will just get this default one. + [[NSCursor arrowCursor] set]; + if (_isStarted && _proxy) _proxy->mouseEvent(self, event, NPCocoaEventMouseEntered); } @@ -295,6 +298,11 @@ extern "C" { { if (_isStarted && _proxy) _proxy->mouseEvent(self, event, NPCocoaEventMouseExited); + + // Set cursor back to arrow cursor. Because NSCursor doesn't know about changes that the plugin made, we could get confused about what we think the + // current cursor is otherwise. Therefore we have no choice but to unconditionally reset the cursor when the mouse exits the plugin. + // FIXME: This should be job of plugin host, see <rdar://problem/7654434>. + [[NSCursor arrowCursor] set]; } - (void)scrollWheel:(NSEvent *)event @@ -348,7 +356,9 @@ extern "C" { - (void)pluginHostDied { - _pluginHostDied = YES; + RenderEmbeddedObject* renderer = toRenderEmbeddedObject(_element->renderer()); + if (renderer) + renderer->setShowsCrashedPluginIndicator(); _pluginLayer = nil; _proxy = 0; @@ -359,6 +369,11 @@ extern "C" { [self invalidatePluginContentRect:[self bounds]]; } +- (void)visibleRectDidChange +{ + [super visibleRectDidChange]; + WKSyncSurfaceToView(self); +} - (void)drawRect:(NSRect)rect { @@ -369,28 +384,12 @@ extern "C" { _proxy->didDraw(); } else _proxy->print(reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), [self bounds].size.width, [self bounds].size.height); + } else if ([self inFlatteningPaint] && [self supportsSnapshotting]) { + _proxy->snapshot(reinterpret_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]), [self bounds].size.width, [self bounds].size.height); } - + return; } - - if (_pluginHostDied) { - static NSImage *nullPlugInImage; - if (!nullPlugInImage) { - NSBundle *bundle = [NSBundle bundleForClass:[WebHostedNetscapePluginView class]]; - nullPlugInImage = [[NSImage alloc] initWithContentsOfFile:[bundle pathForResource:@"nullplugin" ofType:@"tiff"]]; - [nullPlugInImage setFlipped:YES]; - } - - if (!nullPlugInImage) - return; - - NSSize imageSize = [nullPlugInImage size]; - NSSize viewSize = [self bounds].size; - - NSPoint point = NSMakePoint((viewSize.width - imageSize.width) / 2.0, (viewSize.height - imageSize.height) / 2.0); - [nullPlugInImage drawAtPoint:point fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; - } } - (PassRefPtr<JSC::Bindings::Instance>)createPluginBindingsInstance:(PassRefPtr<JSC::Bindings::RootObject>)rootObject diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs index 6522bf7..6b1a319 100644 --- a/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs +++ b/WebKit/mac/Plugins/Hosted/WebKitPluginClient.defs @@ -234,7 +234,7 @@ simpleroutine PCBooleanAndDataReply(clientPort :mach_port_t; simpleroutine PCRunSyncOpenPanel(clientPort :mach_port_t; panelData :data_t); -simpleroutine PCSetFullScreenWindowIsShowing(clientPort :mach_port_t; +simpleroutine PCSetFullscreenWindowIsShowing(clientPort :mach_port_t; isShowing :boolean_t); simpleroutine PCSetException(clientPort :mach_port_t; diff --git a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs index c7cec89..5d9df45 100644 --- a/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs +++ b/WebKit/mac/Plugins/Hosted/WebKitPluginHost.defs @@ -242,3 +242,9 @@ simpleroutine PHPluginInstancePrivateBrowsingModeDidChange(pluginHostPort :mach_ simpleroutine PHSyncOpenPanelReply(pluginHostPort :mach_port_t; filenames :data_t); + +simpleroutine PHPluginInstanceSnapshot(pluginHostPort :mach_port_t; + pluginID :uint32_t; + requestID :uint32_t; + width :uint32_t; + height :uint32_t); diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h index 18dc004..81d801a 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.h +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.h @@ -41,13 +41,21 @@ @class WebFrame; @class WebView; -namespace WebCore { +namespace WTF { class CString; +} + +namespace WebCore { class HTMLPlugInElement; } class WebHaltablePlugin; +// Also declared in WebCore/WidgetMac.mm +@interface NSView (Widget) +- (void)visibleRectDidChange; +@end + @interface WebBaseNetscapePluginView : NSView { RetainPtr<WebNetscapePluginPackage> _pluginPackage; @@ -123,10 +131,12 @@ class WebHaltablePlugin; - (void)addWindowObservers; - (void)removeWindowObservers; - (BOOL)shouldClipOutPlugin; +- (BOOL)inFlatteningPaint; +- (BOOL)supportsSnapshotting; - (BOOL)convertFromX:(double)sourceX andY:(double)sourceY space:(NPCoordinateSpace)sourceSpace toX:(double *)destX andY:(double *)destY space:(NPCoordinateSpace)destSpace; -- (WebCore::CString)resolvedURLStringForURL:(const char*)url target:(const char*)target; +- (WTF::CString)resolvedURLStringForURL:(const char*)url target:(const char*)target; - (void)invalidatePluginContentRect:(NSRect)rect; @@ -135,11 +145,11 @@ class WebHaltablePlugin; namespace WebKit { #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) -WebCore::CString proxiesForURL(NSURL *); +WTF::CString proxiesForURL(NSURL *); #endif bool getAuthenticationInfo(const char* protocolStr, const char* hostStr, int32_t port, const char* schemeStr, const char* realmStr, - WebCore::CString& username, WebCore::CString& password); + WTF::CString& username, WTF::CString& password); } #endif diff --git a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm index 04a42ea..eec80f8 100644 --- a/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm +++ b/WebKit/mac/Plugins/WebBaseNetscapePluginView.mm @@ -46,7 +46,6 @@ #import <WebCore/BitmapImage.h> #import <WebCore/Credential.h> #import <WebCore/CredentialStorage.h> -#import <WebCore/CString.h> #import <WebCore/Document.h> #import <WebCore/Element.h> #import <WebCore/Frame.h> @@ -60,6 +59,7 @@ #import <WebKit/DOMPrivate.h> #import <runtime/InitializeThreading.h> #import <wtf/Assertions.h> +#import <wtf/text/CString.h> #define LoginWindowDidSwitchFromUserNotification @"WebLoginWindowDidSwitchFromUserNotification" #define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification" @@ -337,13 +337,10 @@ String WebHaltablePlugin::pluginName() const - (NSRect)_windowClipRect { RenderObject* renderer = _element->renderer(); - - if (renderer && renderer->view()) { - if (FrameView* frameView = renderer->view()->frameView()) - return frameView->windowClipRectForLayer(renderer->enclosingLayer(), true); - } - - return NSZeroRect; + if (!renderer || !renderer->view()) + return NSZeroRect; + + return toRenderWidget(renderer)->windowClipRect(); } - (NSRect)visibleRect @@ -353,6 +350,11 @@ String WebHaltablePlugin::pluginName() const return NSIntersectionRect([self convertRect:[self _windowClipRect] fromView:nil], [super visibleRect]); } +- (void)visibleRectDidChange +{ + [self renewGState]; +} + - (BOOL)acceptsFirstResponder { return YES; @@ -560,7 +562,30 @@ String WebHaltablePlugin::pluginName() const NSWindow *window = [self window]; return !window || [window isMiniaturized] || [NSApp isHidden] || ![self isDescendantOf:[[self window] contentView]] || [self isHiddenOrHasHiddenAncestor]; } + +- (BOOL)inFlatteningPaint +{ + RenderObject* renderer = _element->renderer(); + if (renderer && renderer->view()) { + if (FrameView* frameView = renderer->view()->frameView()) + return frameView->paintBehavior() & PaintBehaviorFlattenCompositingLayers; + } + + return NO; +} + +- (BOOL)supportsSnapshotting +{ + NSBundle *pluginBundle = [_pluginPackage.get() bundle]; + if (![[pluginBundle bundleIdentifier] isEqualToString:@"com.macromedia.Flash Player.plugin"]) + return YES; + // Flash has a bogus Info.plist entry for CFBundleVersionString, so use CFBundleShortVersionString. + NSString *versionString = [pluginBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; + // Flash 10.1d51 has a crashing bug if sent a drawRect event when using the CA rendering model: <rdar://problem/7739922> + return ![versionString isEqual:@"10.1.51.95"]; +} + - (BOOL)hasBeenHalted { return _hasBeenHalted; diff --git a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm index d8324f7..a5e8f73 100644 --- a/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm +++ b/WebKit/mac/Plugins/WebNetscapePluginEventHandlerCarbon.mm @@ -199,8 +199,17 @@ void WebNetscapePluginEventHandlerCarbon::mouseDragged(NSEvent*) { } -void WebNetscapePluginEventHandlerCarbon::mouseMoved(NSEvent*) +void WebNetscapePluginEventHandlerCarbon::mouseMoved(NSEvent* theEvent) { + EventRecord event; + + getCarbonEvent(&event, theEvent); + event.what = adjustCursorEvent; + + BOOL acceptedEvent; + acceptedEvent = sendEvent(&event); + + LOG(PluginEvents, "NPP_HandleEvent(mouseMoved): %d", acceptedEvent); } void WebNetscapePluginEventHandlerCarbon::keyDown(NSEvent *theEvent) diff --git a/WebKit/mac/Plugins/WebNetscapePluginView.mm b/WebKit/mac/Plugins/WebNetscapePluginView.mm index 8fb1503..388b84b 100644 --- a/WebKit/mac/Plugins/WebNetscapePluginView.mm +++ b/WebKit/mac/Plugins/WebNetscapePluginView.mm @@ -50,7 +50,6 @@ #import "WebPluginContainerCheck.h" #import "WebNetscapeContainerCheckContextInfo.h" #import "WebNetscapePluginEventHandler.h" -#import "WebNullPluginView.h" #import "WebPreferences.h" #import "WebPluginRequest.h" #import "WebViewInternal.h" @@ -59,7 +58,6 @@ #import <runtime/JSLock.h> #import <WebCore/npruntime_impl.h> #import <WebCore/CookieJar.h> -#import <WebCore/CString.h> #import <WebCore/DocumentLoader.h> #import <WebCore/Element.h> #import <WebCore/Frame.h> @@ -77,12 +75,13 @@ #import <WebKit/WebUIDelegate.h> #import <runtime/InitializeThreading.h> #import <wtf/Assertions.h> +#import <wtf/text/CString.h> #import <objc/objc-runtime.h> #define LoginWindowDidSwitchFromUserNotification @"WebLoginWindowDidSwitchFromUserNotification" #define LoginWindowDidSwitchToUserNotification @"WebLoginWindowDidSwitchToUserNotification" #define WKNVSupportsCompositingCoreAnimationPluginsBool 74656 /* TRUE if the browser supports hardware compositing of Core Animation plug-ins */ -static const int WKNVSilverlightFullScreenPerformanceIssueFixed = 7288546; /* TRUE if Siverlight addressed its underlying bug in <rdar://problem/7288546> */ +static const int WKNVSilverlightFullscreenPerformanceIssueFixed = 7288546; /* TRUE if Siverlight addressed its underlying bug in <rdar://problem/7288546> */ using namespace WebCore; using namespace WebKit; @@ -754,6 +753,9 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) if (!_isStarted) return; + // Set cursor to arrow. Plugins often handle cursor internally, but those that don't will just get this default one. + [[NSCursor arrowCursor] set]; + _eventHandler->mouseEntered(theEvent); } @@ -1394,7 +1396,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) - (void)drawRect:(NSRect)rect { - if (drawingModel == NPDrawingModelCoreAnimation) + if (drawingModel == NPDrawingModelCoreAnimation && (![self inFlatteningPaint] || ![self supportsSnapshotting])) return; if (!_isStarted) @@ -2276,7 +2278,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) - (char*)resolveURL:(const char*)url forTarget:(const char*)target { - WebCore::CString location = [self resolvedURLStringForURL:url target:target]; + CString location = [self resolvedURLStringForURL:url target:target]; if (location.isNull()) return 0; @@ -2307,13 +2309,13 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) // 1) Microsoft releases a genuine fix for 7288546. // 2) Enough Silverlight users update to the new Silverlight. // For now, we'll distinguish older broken versions of Silverlight by asking the plug-in if it resolved its full screen badness. -- (void)_workaroundSilverlightFullScreenBug:(BOOL)initializedPlugin +- (void)_workaroundSilverlightFullscreenBug:(BOOL)initializedPlugin { #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) ASSERT(_isSilverlight); - NPBool isFullScreenPerformanceIssueFixed = 0; + NPBool isFullscreenPerformanceIssueFixed = 0; NPPluginFuncs *pluginFuncs = [_pluginPackage.get() pluginFuncs]; - if (pluginFuncs->getvalue && pluginFuncs->getvalue(plugin, static_cast<NPPVariable>(WKNVSilverlightFullScreenPerformanceIssueFixed), &isFullScreenPerformanceIssueFixed) == NPERR_NO_ERROR && isFullScreenPerformanceIssueFixed) + if (pluginFuncs->getvalue && pluginFuncs->getvalue(plugin, static_cast<NPPVariable>(WKNVSilverlightFullscreenPerformanceIssueFixed), &isFullscreenPerformanceIssueFixed) == NPERR_NO_ERROR && isFullscreenPerformanceIssueFixed) return; static CGLPixelFormatObj pixelFormatObject = 0; @@ -2354,7 +2356,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) NPError npErr = [_pluginPackage.get() pluginFuncs]->newp((char *)[_MIMEType.get() cString], plugin, _mode, argsCount, cAttributes, cValues, NULL); [[self class] setCurrentPluginView:nil]; if (_isSilverlight) - [self _workaroundSilverlightFullScreenBug:YES]; + [self _workaroundSilverlightFullscreenBug:YES]; LOG(Plugins, "NPP_New: %d", npErr); return npErr; } @@ -2364,7 +2366,7 @@ static inline void getNPRect(const NSRect& nr, NPRect& npr) PluginMainThreadScheduler::scheduler().unregisterPlugin(plugin); if (_isSilverlight) - [self _workaroundSilverlightFullScreenBug:NO]; + [self _workaroundSilverlightFullscreenBug:NO]; NPError npErr; npErr = ![_pluginPackage.get() pluginFuncs]->destroy(plugin, NULL); diff --git a/WebKit/mac/Plugins/WebNullPluginView.h b/WebKit/mac/Plugins/WebNullPluginView.h deleted file mode 100644 index 3ca1532..0000000 --- a/WebKit/mac/Plugins/WebNullPluginView.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2005, 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. - */ - -#import <AppKit/AppKit.h> - -@class DOMElement; - -@interface WebNullPluginView : NSImageView -{ - NSError *error; - DOMElement *element; -} - -- (id)initWithFrame:(NSRect)frame error:(NSError *)error DOMElement:(DOMElement *)element; - -@end diff --git a/WebKit/mac/Plugins/WebNullPluginView.mm b/WebKit/mac/Plugins/WebNullPluginView.mm deleted file mode 100644 index bcc7a4b..0000000 --- a/WebKit/mac/Plugins/WebNullPluginView.mm +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) 2005, 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. - */ - -#import "WebNullPluginView.h" - -#import "DOMElementInternal.h" -#import "WebDelegateImplementationCaching.h" -#import "WebFrameInternal.h" -#import "WebViewInternal.h" -#import <WebCore/Document.h> -#import <WebCore/Element.h> - -@implementation WebNullPluginView - -- initWithFrame:(NSRect)frame error:(NSError *)err DOMElement:(DOMElement *)elem -{ - static NSImage *nullPlugInImage; - if (!nullPlugInImage) { - NSBundle *bundle = [NSBundle bundleForClass:[WebNullPluginView class]]; - NSString *imagePath = [bundle pathForResource:@"nullplugin" ofType:@"tiff"]; - nullPlugInImage = [[NSImage alloc] initWithContentsOfFile:imagePath]; - } - - self = [super initWithFrame:frame]; - if (!self) - return nil; - - error = [err retain]; - if (err) - element = [elem retain]; - - [self setImage:nullPlugInImage]; - - return self; -} - -- (void)dealloc - -{ - [error release]; - [element release]; - [super dealloc]; -} - -- (void)reportFailure -{ - NSError *localError = error; - DOMElement *localElement = element; - - error = nil; - element = nil; - - WebFrame *webFrame = kit(core(localElement)->document()->frame()); - if (webFrame) { - WebView *webView = [webFrame webView]; - WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView); - if (implementations->plugInFailedWithErrorFunc) - CallResourceLoadDelegate(implementations->plugInFailedWithErrorFunc, webView, - @selector(webView:plugInFailedWithError:dataSource:), localError, [webFrame _dataSource]); - } - - [localError release]; - [localElement release]; -} - -- (void)viewDidMoveToWindow -{ - if (!error) - return; - - if ([self window]) - [self reportFailure]; -} - -@end diff --git a/WebKit/mac/Plugins/WebPluginController.mm b/WebKit/mac/Plugins/WebPluginController.mm index 4343119..1c85862 100644 --- a/WebKit/mac/Plugins/WebPluginController.mm +++ b/WebKit/mac/Plugins/WebPluginController.mm @@ -36,6 +36,7 @@ #import "WebHTMLViewPrivate.h" #import "WebKitErrorsPrivate.h" #import "WebKitLogging.h" +#import "WebNSObjectExtras.h" #import "WebNSURLExtras.h" #import "WebNSViewExtras.h" #import "WebPlugin.h" @@ -57,6 +58,7 @@ #import <WebCore/ResourceRequest.h> #import <WebCore/ScriptController.h> #import <WebCore/WebCoreURLResponse.h> +#import <objc/objc-runtime.h> #import <runtime/JSLock.h> using namespace WebCore; @@ -78,6 +80,10 @@ using namespace HTMLNames; - (void)pluginDestroy; @end +static bool isKindOfClass(id, NSString* className); +static void installFlip4MacPlugInWorkaroundIfNecessary(); + + static NSMutableSet *pluginViews = nil; @implementation WebPluginController @@ -209,7 +215,10 @@ static NSMutableSet *pluginViews = nil; BOOL oldDefersCallbacks = [[self webView] defersCallbacks]; if (!oldDefersCallbacks) [[self webView] setDefersCallbacks:YES]; - + + if (isKindOfClass(view, @"WmvPlugin")) + installFlip4MacPlugInWorkaroundIfNecessary(); + LOG(Plugins, "initializing plug-in %@", view); if ([view respondsToSelector:@selector(webPlugInInitialize)]) { JSC::JSLock::DropAllLocks dropAllLocks(JSC::SilenceAssertionsOnly); @@ -351,21 +360,11 @@ static void cancelOutstandingCheck(const void *item, void *context) } } -// For compatibility only. -- (void)showURL:(NSURL *)URL inFrame:(NSString *)target -{ - [self webPlugInContainerLoadRequest:[NSURLRequest requestWithURL:URL] inFrame:target]; -} - - (void)webPlugInContainerShowStatus:(NSString *)message { - if (!message) { + if (!message) message = @""; - } - if (!_documentView) { - LOG_ERROR("could not show status message (%@) because plug-in has already been destroyed", message); - return; - } + WebView *v = [_dataSource _webView]; [[v _UIDelegateForwarder] webView:v setStatusText:message]; } @@ -475,3 +474,85 @@ static WebCore::HTMLMediaElement* mediaProxyClient(DOMElement* element) #endif @end + +static bool isKindOfClass(id object, NSString *className) +{ + Class cls = NSClassFromString(className); + + if (!cls) + return false; + + return [object isKindOfClass:cls]; +} + + +// Existing versions of the Flip4Mac WebKit plug-in have an object lifetime bug related to an NSAlert that is +// used to notify the user about updates to the plug-in. This bug can result in Safari crashing if the page +// containing the plug-in navigates while the alert is displayed (<rdar://problem/7313430>). +// +// The gist of the bug is thus: Flip4Mac sets an instance of the TSUpdateCheck class as the modal delegate of the +// NSAlert instance. This TSUpdateCheck instance itself has a delegate. The delegate is set to the WmvPlugin +// instance which is the NSView subclass that is exposed to WebKit as the plug-in view. Since this relationship +// is that of delegates the TSUpdateCheck does not retain the WmvPlugin. This leads to a bug if the WmvPlugin +// instance is destroyed before the TSUpdateCheck instance as the TSUpdateCheck instance will be left with a +// pointer to a stale object. This will happen if a page containing the Flip4Mac plug-in triggers a navigation +// while the update sheet is visible as the WmvPlugin instance is removed from the view hierarchy and there are +// no other references to keep the object alive. +// +// We work around this bug by patching the following two messages: +// +// 1) -[NSAlert beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:] +// 2) -[TSUpdateCheck alertDidEnd:returnCode:contextInfo:] +// +// Our override of 1) detects whether it is Flip4Mac's update sheet triggering the alert by checking whether the +// modal delegate is an instance of TSUpdateCheck. If it is, it retains the modal delegate's delegate. +// +// Our override of 2) then autoreleases the delegate, balancing the retain we added in 1). +// +// These two overrides have the effect of ensuring that the WmvPlugin instance will always outlive the TSUpdateCheck +// instance, preventing the TSUpdateCheck instance from accessing a stale delegate pointer and crashing the application. + + +typedef void (*beginSheetModalForWindowIMP)(id, SEL, NSWindow *, id, SEL, void*); +static beginSheetModalForWindowIMP original_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_; + +typedef void (*alertDidEndIMP)(id, SEL, NSAlert *, NSInteger, void*); +static alertDidEndIMP original_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_; + +static void WebKit_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_(id object, SEL selector, NSAlert *alert, NSInteger returnCode, void* contextInfo) +{ + [[object delegate] autorelease]; + + original_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_(object, selector, alert, returnCode, contextInfo); +} + +static void WebKit_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(id object, SEL selector, NSWindow *window, id modalDelegate, SEL didEndSelector, void* contextInfo) +{ + if (isKindOfClass(modalDelegate, @"TSUpdateCheck")) + [[modalDelegate delegate] retain]; + + original_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(object, selector, window, modalDelegate, didEndSelector, contextInfo); +} + +static void installFlip4MacPlugInWorkaroundIfNecessary() +{ + static bool hasInstalledFlip4MacPlugInWorkaround; + if (!hasInstalledFlip4MacPlugInWorkaround) { + Class TSUpdateCheck = objc_lookUpClass("TSUpdateCheck"); + if (!TSUpdateCheck) + return; + + Method methodToPatch = class_getInstanceMethod(TSUpdateCheck, @selector(alertDidEnd:returnCode:contextInfo:)); + if (!methodToPatch) + return; + + IMP originalMethod = method_setImplementation(methodToPatch, reinterpret_cast<IMP>(WebKit_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_)); + original_TSUpdateCheck_alertDidEnd_returnCode_contextInfo_ = reinterpret_cast<alertDidEndIMP>(originalMethod); + + methodToPatch = class_getInstanceMethod(objc_getRequiredClass("NSAlert"), @selector(beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:)); + originalMethod = method_setImplementation(methodToPatch, reinterpret_cast<IMP>(WebKit_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_)); + original_NSAlert_beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_ = reinterpret_cast<beginSheetModalForWindowIMP>(originalMethod); + + hasInstalledFlip4MacPlugInWorkaround = true; + } +} diff --git a/WebKit/mac/Resources/nullplugin.tiff b/WebKit/mac/Resources/nullplugin.tiff Binary files differdeleted file mode 100644 index 8a2d9df..0000000 --- a/WebKit/mac/Resources/nullplugin.tiff +++ /dev/null diff --git a/WebKit/mac/Storage/WebDatabaseManager.mm b/WebKit/mac/Storage/WebDatabaseManager.mm index a84f235..2c58889 100644 --- a/WebKit/mac/Storage/WebDatabaseManager.mm +++ b/WebKit/mac/Storage/WebDatabaseManager.mm @@ -107,14 +107,14 @@ NSString *WebDatabaseIdentifierKey = @"WebDatabaseIdentifierKey"; DatabaseTracker::tracker().deleteAllDatabases(); } -- (void)deleteOrigin:(WebSecurityOrigin *)origin +- (BOOL)deleteOrigin:(WebSecurityOrigin *)origin { - DatabaseTracker::tracker().deleteOrigin([origin _core]); + return DatabaseTracker::tracker().deleteOrigin([origin _core]); } -- (void)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin +- (BOOL)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin { - DatabaseTracker::tracker().deleteDatabase([origin _core], databaseIdentifier); + return DatabaseTracker::tracker().deleteDatabase([origin _core], databaseIdentifier); } @end diff --git a/WebKit/mac/Storage/WebDatabaseManagerPrivate.h b/WebKit/mac/Storage/WebDatabaseManagerPrivate.h index e373b1c..94d8109 100644 --- a/WebKit/mac/Storage/WebDatabaseManagerPrivate.h +++ b/WebKit/mac/Storage/WebDatabaseManagerPrivate.h @@ -60,8 +60,8 @@ extern NSString *WebDatabaseIdentifierKey; - (NSDictionary *)detailsForDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; - (void)deleteAllDatabases; // Deletes all databases and all origins. -- (void)deleteOrigin:(WebSecurityOrigin *)origin; -- (void)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; +- (BOOL)deleteOrigin:(WebSecurityOrigin *)origin; +- (BOOL)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin; @end diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.h b/WebKit/mac/WebCoreSupport/WebChromeClient.h index c8da53b..478269c 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.h +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.h @@ -91,8 +91,11 @@ public: virtual WebCore::IntRect windowResizerRect() const; - virtual void repaint(const WebCore::IntRect&, bool contentChanged, bool immediate = false, bool repaintContentOnly = false); + virtual void invalidateWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); + virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); virtual void scroll(const WebCore::IntSize& scrollDelta, const WebCore::IntRect& rectToScroll, const WebCore::IntRect& clipRect); + virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; virtual PlatformPageClient platformPageClient() const; @@ -120,7 +123,7 @@ public: #endif virtual void runOpenPanel(WebCore::Frame*, PassRefPtr<WebCore::FileChooser>); - virtual void iconForFiles(const Vector<WebCore::String>&, PassRefPtr<WebCore::FileChooser>); + virtual void chooseIconForFiles(const Vector<WebCore::String>&, WebCore::FileChooser*); virtual bool setCursor(WebCore::PlatformCursorHandle) { return false; } @@ -160,7 +163,11 @@ public: #endif virtual void requestGeolocationPermissionForFrame(WebCore::Frame*, WebCore::Geolocation*); +<<<<<<< HEAD virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*) { } +======= + virtual void cancelGeolocationPermissionRequestForFrame(WebCore::Frame*, WebCore::Geolocation*) { } +>>>>>>> webkit.org at r58033 private: WebView *m_webView; diff --git a/WebKit/mac/WebCoreSupport/WebChromeClient.mm b/WebKit/mac/WebCoreSupport/WebChromeClient.mm index b2240d9..d27a19c 100644 --- a/WebKit/mac/WebCoreSupport/WebChromeClient.mm +++ b/WebKit/mac/WebCoreSupport/WebChromeClient.mm @@ -56,6 +56,7 @@ #import <WebCore/Geolocation.h> #import <WebCore/HitTestResult.h> #import <WebCore/HTMLNames.h> +#import <WebCore/Icon.h> #import <WebCore/IntRect.h> #import <WebCore/Page.h> #import <WebCore/PlatformScreen.h> @@ -439,20 +440,32 @@ IntRect WebChromeClient::windowResizerRect() const return enclosingIntRect([m_webView convertRect:rect fromView:nil]); } -void WebChromeClient::repaint(const IntRect& rect, bool contentChanged, bool immediate, bool repaintContentOnly) +void WebChromeClient::invalidateWindow(const IntRect&, bool immediate) +{ + if (immediate) { + [[m_webView window] displayIfNeeded]; + [[m_webView window] flushWindowIfNeeded]; + } +} + +void WebChromeClient::invalidateContentsAndWindow(const IntRect& rect, bool immediate) { if ([m_webView _usesDocumentViews]) return; - - if (contentChanged) - [m_webView setNeedsDisplayInRect:rect]; - + + [m_webView setNeedsDisplayInRect:rect]; + if (immediate) { [[m_webView window] displayIfNeeded]; [[m_webView window] flushWindowIfNeeded]; } } +void WebChromeClient::invalidateContentsForSlowScroll(const IntRect& rect, bool immediate) +{ + invalidateContentsAndWindow(rect, immediate); +} + void WebChromeClient::scroll(const IntSize&, const IntRect&, const IntRect&) { } @@ -631,9 +644,9 @@ void WebChromeClient::runOpenPanel(Frame*, PassRefPtr<FileChooser> chooser) END_BLOCK_OBJC_EXCEPTIONS; } -void WebChromeClient::iconForFiles(const Vector<String>&, PassRefPtr<FileChooser>) +void WebChromeClient::chooseIconForFiles(const Vector<String>& filenames, FileChooser* chooser) { - // FIXME: Move the code of Icon::createIconForFiles() here. + chooser->iconLoaded(Icon::createIconForFiles(filenames)); } KeyboardUIMode WebChromeClient::keyboardUIMode() diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h index 988b8a6..d497513 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h @@ -126,7 +126,6 @@ private: virtual void revertToProvisionalState(WebCore::DocumentLoader*); virtual void setMainDocumentError(WebCore::DocumentLoader*, const WebCore::ResourceError&); virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length); - virtual void dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const WebCore::ScriptString&); virtual void willChangeEstimatedProgress(); virtual void didChangeEstimatedProgress(); diff --git a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm index 52a24b4..0088eae 100644 --- a/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm +++ b/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm @@ -60,7 +60,6 @@ #import "WebNSURLExtras.h" #import "WebNetscapePluginView.h" #import "WebNetscapePluginPackage.h" -#import "WebNullPluginView.h" #import "WebPanelAuthenticationHandler.h" #import "WebPluginController.h" #import "WebPluginPackage.h" @@ -349,10 +348,6 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache(DocumentLoader return true; } -void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest(unsigned long identifier, const ScriptString& sourceString) -{ -} - void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identifier, DocumentLoader* loader, const ResourceRequest& request) { WebView *webView = getWebView(m_webFrame.get()); @@ -1524,8 +1519,11 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP WebView *webView = getWebView(m_webFrame.get()); SEL selector = @selector(webView:plugInViewWithArguments:); - NSURL *URL = url; + Document* document = core(m_webFrame.get())->document(); + NSURL *baseURL = document->baseURL(); + NSURL *pluginURL = url; + if ([[webView UIDelegate] respondsToSelector:selector]) { NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithObjects:kit(paramValues) forKeys:kit(paramNames)]; NSDictionary *arguments = [[NSDictionary alloc] initWithObjectsAndKeys: @@ -1533,7 +1531,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP [NSNumber numberWithInt:loadManually ? WebPlugInModeFull : WebPlugInModeEmbed], WebPlugInModeKey, [NSNumber numberWithBool:!loadManually], WebPlugInShouldLoadMainResourceKey, kit(element), WebPlugInContainingElementKey, - URL, WebPlugInBaseURLKey, // URL might be nil, so add it last + baseURL, WebPlugInBaseURLKey, nil]; NSView *view = CallUIDelegate(webView, selector, arguments); @@ -1555,7 +1553,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP pluginPackage = [webView _pluginForMIMEType:mimeType]; } - NSString *extension = [[URL path] pathExtension]; + NSString *extension = [[pluginURL path] pathExtension]; #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) // don't allow proxy plug-in selection by file extension if (element->hasTagName(videoTag) || element->hasTagName(audioTag)) @@ -1573,8 +1571,6 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP NSView *view = nil; - Document* document = core(m_webFrame.get())->document(); - NSURL *baseURL = document->baseURL(); if (pluginPackage) { if ([pluginPackage isKindOfClass:[WebPluginPackage class]]) view = pluginView(m_webFrame.get(), (WebPluginPackage *)pluginPackage, kit(paramNames), kit(paramValues), baseURL, kit(element), loadManually); @@ -1584,7 +1580,7 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP WebBaseNetscapePluginView *pluginView = [[[NETSCAPE_PLUGIN_VIEW alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) pluginPackage:(WebNetscapePluginPackage *)pluginPackage - URL:URL + URL:pluginURL baseURL:baseURL MIMEType:MIMEType attributeKeys:kit(paramNames) @@ -1600,17 +1596,21 @@ PassRefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize& size, HTMLP if (!errorCode && !view) errorCode = WebKitErrorCannotLoadPlugIn; + + if (errorCode && m_webFrame) { + WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(webView); + if (implementations->plugInFailedWithErrorFunc) { + KURL pluginPageURL = document->completeURL(deprecatedParseURL(parameterValue(paramNames, paramValues, "pluginspage"))); + if (!pluginPageURL.protocolInHTTPFamily()) + pluginPageURL = KURL(); + NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode + contentURL:pluginURL pluginPageURL:pluginPageURL pluginName:[pluginPackage name] MIMEType:MIMEType]; + CallResourceLoadDelegate(implementations->plugInFailedWithErrorFunc, [m_webFrame.get() webView], + @selector(webView:plugInFailedWithError:dataSource:), error, [m_webFrame.get() _dataSource]); + [error release]; + } - if (errorCode) { - KURL pluginPageURL = document->completeURL(deprecatedParseURL(parameterValue(paramNames, paramValues, "pluginspage"))); - if (!pluginPageURL.protocolInHTTPFamily()) - pluginPageURL = KURL(); - NSError *error = [[NSError alloc] _initWithPluginErrorCode:errorCode - contentURL:URL pluginPageURL:pluginPageURL pluginName:[pluginPackage name] MIMEType:MIMEType]; - WebNullPluginView *nullView = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) - error:error DOMElement:kit(element)] autorelease]; - view = nullView; - [error release]; + return 0; } ASSERT(view); @@ -1691,14 +1691,13 @@ PassRefPtr<Widget> WebFrameLoaderClient::createJavaAppletWidget(const IntSize& s } if (!view) { - NSError *error = [[NSError alloc] _initWithPluginErrorCode:WebKitErrorJavaUnavailable - contentURL:nil - pluginPageURL:nil - pluginName:[pluginPackage name] - MIMEType:MIMEType]; - view = [[[WebNullPluginView alloc] initWithFrame:NSMakeRect(0, 0, size.width(), size.height()) - error:error DOMElement:kit(element)] autorelease]; - [error release]; + WebResourceDelegateImplementationCache* implementations = WebViewGetResourceLoadDelegateImplementations(getWebView(m_webFrame.get())); + if (implementations->plugInFailedWithErrorFunc) { + NSError *error = [[NSError alloc] _initWithPluginErrorCode:WebKitErrorJavaUnavailable contentURL:nil pluginPageURL:nil pluginName:[pluginPackage name] MIMEType:MIMEType]; + CallResourceLoadDelegate(implementations->plugInFailedWithErrorFunc, [m_webFrame.get() webView], + @selector(webView:plugInFailedWithError:dataSource:), error, [m_webFrame.get() _dataSource]); + [error release]; + } } ASSERT(view); diff --git a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm b/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm index 32e8d0d..1bdb616 100644 --- a/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm +++ b/WebKit/mac/WebCoreSupport/WebGeolocationMock.mm @@ -38,6 +38,7 @@ using namespace WTF; + (void)setPosition:(double)latitude:(double)longitude:(double)accuracy { +#if ENABLE(GEOLOCATION) RefPtr<Coordinates> coordinates = Coordinates::create(latitude, longitude, false, 0.0, // altitude @@ -47,13 +48,16 @@ using namespace WTF; false, 0.0); // speed RefPtr<Geoposition> position = Geoposition::create(coordinates.release(), currentTime() * 1000.0); GeolocationServiceMock::setPosition(position.release()); +#endif } + (void)setError:(int)code:(NSString *)message { +#if ENABLE(GEOLOCATION) PositionError::ErrorCode codeEnum = static_cast<PositionError::ErrorCode>(code); RefPtr<PositionError> error = PositionError::create(codeEnum, message); GeolocationServiceMock::setError(error.release()); +#endif } @end diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.h b/WebKit/mac/WebCoreSupport/WebInspectorClient.h index 64621f8..ee81b25 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.h +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.h @@ -27,15 +27,18 @@ */ #import <WebCore/InspectorClient.h> +#import <WebCore/InspectorFrontendClientLocal.h> #import <WebCore/PlatformString.h> #import <wtf/RetainPtr.h> #ifdef __OBJC__ @class WebInspectorWindowController; +@class WebNodeHighlighter; @class WebView; #else class WebInspectorWindowController; +class WebNodeHighlighter; class WebView; #endif @@ -45,32 +48,41 @@ public: virtual void inspectorDestroyed(); - virtual WebCore::Page* createPage(); - virtual WebCore::String localizedStringsURL(); - - virtual WebCore::String hiddenPanels(); - - virtual void showWindow(); - virtual void closeWindow(); - - virtual void attachWindow(); - virtual void detachWindow(); - - virtual void setAttachedWindowHeight(unsigned height); + virtual void openInspectorFrontend(WebCore::InspectorController*); virtual void highlight(WebCore::Node*); virtual void hideHighlight(); - virtual void inspectedURLChanged(const WebCore::String& newURL); virtual void populateSetting(const WebCore::String& key, WebCore::String* value); virtual void storeSetting(const WebCore::String& key, const WebCore::String& value); - virtual void inspectorWindowObjectCleared(); +private: + WebView *m_webView; + RetainPtr<WebNodeHighlighter> m_highlighter; +}; + +class WebInspectorFrontendClient : public WebCore::InspectorFrontendClientLocal { +public: + WebInspectorFrontendClient(WebView*, WebInspectorWindowController*, WebCore::InspectorController*, WebCore::Page*); + + virtual void frontendLoaded(); + + virtual WebCore::String localizedStringsURL(); + virtual WebCore::String hiddenPanels(); + + virtual void bringToFront(); + virtual void closeWindow(); + + virtual void attachWindow(); + virtual void detachWindow(); + + virtual void setAttachedWindowHeight(unsigned height); + virtual void inspectedURLChanged(const WebCore::String& newURL); private: void updateWindowTitle() const; - WebView *m_webView; + WebView* m_inspectedWebView; RetainPtr<WebInspectorWindowController> m_windowController; WebCore::String m_inspectedURL; }; diff --git a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm index 01515b1..00c51a9 100644 --- a/WebKit/mac/WebCoreSupport/WebInspectorClient.mm +++ b/WebKit/mac/WebCoreSupport/WebInspectorClient.mm @@ -41,54 +41,102 @@ #import <WebCore/Page.h> #import <WebKit/DOMExtensions.h> #import <WebKitSystemInterface.h> +#import <wtf/PassOwnPtr.h> using namespace WebCore; -static const char* const inspectorStartsAttachedName = "inspectorStartsAttached"; - @interface WebInspectorWindowController : NSWindowController <NSWindowDelegate> { @private WebView *_inspectedWebView; WebView *_webView; - WebNodeHighlight *_currentHighlight; + WebInspectorFrontendClient* _frontendClient; BOOL _attachedToInspectedWebView; BOOL _shouldAttach; BOOL _visible; - BOOL _movingWindows; + BOOL _destroyingInspectorView; } - (id)initWithInspectedWebView:(WebView *)webView; -- (BOOL)inspectorVisible; - (WebView *)webView; - (void)attach; - (void)detach; +- (BOOL)attached; +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient; - (void)setAttachedWindowHeight:(unsigned)height; +- (void)destroyInspectorView; +@end + +#pragma mark - + +@interface WebNodeHighlighter : NSObject { +@private + WebView *_inspectedWebView; + WebNodeHighlight *_currentHighlight; +} +- (id)initWithInspectedWebView:(WebView *)webView; - (void)highlightNode:(DOMNode *)node; - (void)hideHighlight; @end #pragma mark - + WebInspectorClient::WebInspectorClient(WebView *webView) : m_webView(webView) +, m_highlighter(AdoptNS, [[WebNodeHighlighter alloc] initWithInspectedWebView:webView]) { } void WebInspectorClient::inspectorDestroyed() { - [[m_windowController.get() webView] close]; delete this; } -Page* WebInspectorClient::createPage() +void WebInspectorClient::openInspectorFrontend(InspectorController* inspectorController) +{ + RetainPtr<WebInspectorWindowController> windowController(AdoptNS, [[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + Page* frontendPage = core([windowController.get() webView]); + + frontendPage->inspectorController()->setInspectorFrontendClient(new WebInspectorFrontendClient(m_webView, windowController.get(), inspectorController, frontendPage)); +} + +void WebInspectorClient::highlight(Node* node) +{ + [m_highlighter.get() highlightNode:kit(node)]; +} + +void WebInspectorClient::hideHighlight() +{ + [m_highlighter.get() hideHighlight]; +} + +WebInspectorFrontendClient::WebInspectorFrontendClient(WebView* inspectedWebView, WebInspectorWindowController* windowController, InspectorController* inspectorController, Page* frontendPage) + : InspectorFrontendClientLocal(inspectorController, frontendPage) + , m_inspectedWebView(inspectedWebView) + , m_windowController(windowController) +{ + [windowController setFrontendClient:this]; +} + +void WebInspectorFrontendClient::frontendLoaded() { - if (m_windowController) - [[m_windowController.get() webView] close]; - m_windowController.adoptNS([[WebInspectorWindowController alloc] initWithInspectedWebView:m_webView]); + [m_windowController.get() showWindow:nil]; + if ([m_windowController.get() attached]) + restoreAttachedWindowHeight(); + + InspectorFrontendClientLocal::frontendLoaded(); + + WebFrame *frame = [m_inspectedWebView mainFrame]; + + WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_inspectedWebView); + if (implementations->didClearInspectorWindowObjectForFrameFunc) + CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_inspectedWebView, + @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); - return core([m_windowController.get() webView]); + bool attached = [m_windowController.get() attached]; + setAttachedWindow(attached); } -String WebInspectorClient::localizedStringsURL() +String WebInspectorFrontendClient::localizedStringsURL() { NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"localizedStrings" ofType:@"js"]; if (path) @@ -96,7 +144,7 @@ String WebInspectorClient::localizedStringsURL() return String(); } -String WebInspectorClient::hiddenPanels() +String WebInspectorFrontendClient::hiddenPanels() { NSString *hiddenPanels = [[NSUserDefaults standardUserDefaults] stringForKey:@"WebKitInspectorHiddenPanels"]; if (hiddenPanels) @@ -104,63 +152,47 @@ String WebInspectorClient::hiddenPanels() return String(); } -void WebInspectorClient::showWindow() +void WebInspectorFrontendClient::bringToFront() { updateWindowTitle(); [m_windowController.get() showWindow:nil]; } -void WebInspectorClient::closeWindow() +void WebInspectorFrontendClient::closeWindow() { - [m_windowController.get() close]; + [m_windowController.get() destroyInspectorView]; } -void WebInspectorClient::attachWindow() +void WebInspectorFrontendClient::attachWindow() { + if ([m_windowController.get() attached]) + return; [m_windowController.get() attach]; + restoreAttachedWindowHeight(); } -void WebInspectorClient::detachWindow() +void WebInspectorFrontendClient::detachWindow() { [m_windowController.get() detach]; } -void WebInspectorClient::setAttachedWindowHeight(unsigned height) +void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height) { [m_windowController.get() setAttachedWindowHeight:height]; } -void WebInspectorClient::highlight(Node* node) -{ - [m_windowController.get() highlightNode:kit(node)]; -} - -void WebInspectorClient::hideHighlight() -{ - [m_windowController.get() hideHighlight]; -} - -void WebInspectorClient::inspectedURLChanged(const String& newURL) +void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL) { m_inspectedURL = newURL; updateWindowTitle(); } -void WebInspectorClient::updateWindowTitle() const +void WebInspectorFrontendClient::updateWindowTitle() const { NSString *title = [NSString stringWithFormat:UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)m_inspectedURL]; [[m_windowController.get() window] setTitle:title]; } -void WebInspectorClient::inspectorWindowObjectCleared() -{ - WebFrame *frame = [m_webView mainFrame]; - - WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(m_webView); - if (implementations->didClearInspectorWindowObjectForFrameFunc) - CallFrameLoadDelegate(implementations->didClearInspectorWindowObjectForFrameFunc, m_webView, - @selector(webView:didClearInspectorWindowObject:forFrame:), [frame windowObject], frame); -} #pragma mark - @@ -223,18 +255,12 @@ void WebInspectorClient::inspectorWindowObjectCleared() - (void)dealloc { - ASSERT(!_currentHighlight); [_webView release]; [super dealloc]; } #pragma mark - -- (BOOL)inspectorVisible -{ - return _visible; -} - - (WebView *)webView { return _webView; @@ -273,11 +299,7 @@ void WebInspectorClient::inspectorWindowObjectCleared() - (BOOL)windowShouldClose:(id)sender { - _visible = NO; - - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; + [self destroyInspectorView]; return YES; } @@ -289,11 +311,6 @@ void WebInspectorClient::inspectorWindowObjectCleared() _visible = NO; - if (!_movingWindows) - [_inspectedWebView page]->inspectorController()->setWindowVisible(false); - - [self hideHighlight]; - if (_attachedToInspectedWebView) { if ([_inspectedWebView _isClosed]) return; @@ -327,8 +344,11 @@ void WebInspectorClient::inspectorWindowObjectCleared() _visible = YES; // If no preference is set - default to an attached window. This is important for inspector LayoutTests. - String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(inspectorStartsAttachedName); + String shouldAttach = [_inspectedWebView page]->inspectorController()->setting(InspectorController::inspectorStartsAttachedSettingName()); _shouldAttach = shouldAttach != "false"; + + if (_shouldAttach && !_frontendClient->canAttachWindow()) + _shouldAttach = NO; if (_shouldAttach) { WebFrameView *frameView = [[_inspectedWebView mainFrame] frameView]; @@ -351,8 +371,6 @@ void WebInspectorClient::inspectorWindowObjectCleared() [super showWindow:nil]; } - - [_inspectedWebView page]->inspectorController()->setWindowVisible(true, _shouldAttach); } #pragma mark - @@ -362,13 +380,10 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "true"); - _movingWindows = YES; + [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "true"); [self close]; [self showWindow:nil]; - - _movingWindows = NO; } - (void)detach @@ -376,14 +391,20 @@ void WebInspectorClient::inspectorWindowObjectCleared() if (!_attachedToInspectedWebView) return; - [_inspectedWebView page]->inspectorController()->setSetting(inspectorStartsAttachedName, "false"); - _movingWindows = YES; + [_inspectedWebView page]->inspectorController()->setSetting(InspectorController::inspectorStartsAttachedSettingName(), "false"); [self close]; [self showWindow:nil]; +} - _movingWindows = NO; +- (BOOL)attached +{ + return _attachedToInspectedWebView; +} +- (void)setFrontendClient:(WebInspectorFrontendClient*)frontendClient +{ + _frontendClient = frontendClient; } - (void)setAttachedWindowHeight:(unsigned)height @@ -404,29 +425,17 @@ void WebInspectorClient::inspectorWindowObjectCleared() [frameView setFrame:frameViewRect]; } -#pragma mark - - -- (void)highlightNode:(DOMNode *)node +- (void)destroyInspectorView { - // The scrollview's content view stays around between page navigations, so target it - NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; - if (![view window]) - return; // skip the highlight if we have no window (e.g. hidden tab) - - if (!_currentHighlight) { - _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; - [_currentHighlight setDelegate:self]; - [_currentHighlight attach]; - } else - [[_currentHighlight highlightView] setNeedsDisplay:YES]; -} + if (_destroyingInspectorView) + return; + _destroyingInspectorView = YES; -- (void)hideHighlight -{ - [_currentHighlight detach]; - [_currentHighlight setDelegate:nil]; - [_currentHighlight release]; - _currentHighlight = nil; + if (_attachedToInspectedWebView) + [self close]; + _visible = NO; + [_inspectedWebView page]->inspectorController()->disconnectFrontend(); + [_webView close]; } #pragma mark - @@ -496,3 +505,60 @@ void WebInspectorClient::inspectorWindowObjectCleared() } @end + + +#pragma mark - + +@implementation WebNodeHighlighter +- (id)initWithInspectedWebView:(WebView *)webView +{ + // Don't retain to avoid a circular reference + _inspectedWebView = webView; + return self; +} + +- (void)dealloc +{ + ASSERT(!_currentHighlight); + [super dealloc]; +} + +#pragma mark - + +- (void)highlightNode:(DOMNode *)node +{ + // The scrollview's content view stays around between page navigations, so target it + NSView *view = [[[[[_inspectedWebView mainFrame] frameView] documentView] enclosingScrollView] contentView]; + if (![view window]) + return; // skip the highlight if we have no window (e.g. hidden tab) + + if (!_currentHighlight) { + _currentHighlight = [[WebNodeHighlight alloc] initWithTargetView:view inspectorController:[_inspectedWebView page]->inspectorController()]; + [_currentHighlight setDelegate:self]; + [_currentHighlight attach]; + } else + [[_currentHighlight highlightView] setNeedsDisplay:YES]; +} + +- (void)hideHighlight +{ + [_currentHighlight detach]; + [_currentHighlight setDelegate:nil]; + [_currentHighlight release]; + _currentHighlight = nil; +} + +#pragma mark - +#pragma mark WebNodeHighlight delegate + +- (void)didAttachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:highlight]; +} + +- (void)willDetachWebNodeHighlight:(WebNodeHighlight *)highlight +{ + [_inspectedWebView setCurrentNodeHighlight:nil]; +} + +@end diff --git a/WebKit/mac/WebCoreSupport/WebSystemInterface.m b/WebKit/mac/WebCoreSupport/WebSystemInterface.m index 7f4effd..b792707 100644 --- a/WebKit/mac/WebCoreSupport/WebSystemInterface.m +++ b/WebKit/mac/WebCoreSupport/WebSystemInterface.m @@ -45,6 +45,7 @@ void InitWebCoreSystemInterface(void) INIT(AdvanceDefaultButtonPulseAnimation); INIT(CGContextGetShouldSmoothFonts); INIT(CopyCONNECTProxyResponse); + INIT(CopyNSURLResponseStatusLine); INIT(CreateCustomCFReadStream); INIT(CreateNSURLConnectionDelegateProxy); INIT(DrawCapsLockIndicator); @@ -89,6 +90,7 @@ void InitWebCoreSystemInterface(void) INIT(QTMovieGetType); INIT(QTMovieHasClosedCaptions); INIT(QTMovieSetShowClosedCaptions); + INIT(QTMovieSelectPreferredAlternates); INIT(QTMovieViewSetDrawSynchronously); #ifndef BUILDING_ON_TIGER diff --git a/WebKit/mac/WebCoreSupport/WebViewFactory.mm b/WebKit/mac/WebCoreSupport/WebViewFactory.mm index 2607f18..fd6d5b0 100644 --- a/WebKit/mac/WebCoreSupport/WebViewFactory.mm +++ b/WebKit/mac/WebCoreSupport/WebViewFactory.mm @@ -640,6 +640,16 @@ return nil; } +- (NSString *)missingPluginText +{ + return UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing"); +} + +- (NSString *)crashedPluginText +{ + return UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed"); +} + - (NSString *)multipleFileUploadTextForNumberOfFiles:(unsigned)numberOfFiles { return [NSString stringWithFormat:UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles]; diff --git a/WebKit/mac/WebInspector/WebInspector.mm b/WebKit/mac/WebInspector/WebInspector.mm index 258dd01..9b17459 100644 --- a/WebKit/mac/WebInspector/WebInspector.mm +++ b/WebKit/mac/WebInspector/WebInspector.mm @@ -175,14 +175,10 @@ using namespace WebCore; - (void)attach:(id)sender { - if (Page* page = core(_webView)) - page->inspectorController()->attachWindow(); } - (void)detach:(id)sender { - if (Page* page = core(_webView)) - page->inspectorController()->detachWindow(); } - (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script diff --git a/WebKit/mac/WebInspector/WebInspectorPrivate.h b/WebKit/mac/WebInspector/WebInspectorPrivate.h index c82bb92..d18f804 100644 --- a/WebKit/mac/WebInspector/WebInspectorPrivate.h +++ b/WebKit/mac/WebInspector/WebInspectorPrivate.h @@ -28,7 +28,7 @@ // This header contains the WebInspector SPI. -#import "WebInspector.h" +#import <WebKit/WebInspector.h> @interface WebInspector (WebPrivate) - (void)evaluateInFrontend:(id)sender callId:(long)callId script:(NSString *)script; diff --git a/WebKit/mac/WebKit.exp b/WebKit/mac/WebKit.exp index 904f389..d14d805 100644 --- a/WebKit/mac/WebKit.exp +++ b/WebKit/mac/WebKit.exp @@ -35,6 +35,7 @@ .objc_class_name_WebStringTruncator .objc_class_name_WebTextIterator .objc_class_name_WebURLsWithTitles +.objc_class_name_WebUserContentURLPattern .objc_class_name_WebView .objc_class_name_WebWorkersPrivate _HIWebViewCreate @@ -120,4 +121,6 @@ _WebViewDidEndEditingNotification _WebViewProgressEstimateChangedNotification _WebViewProgressFinishedNotification _WebViewProgressStartedNotification +__WebHTMLViewPrintingMaximumShrinkFactor +__WebHTMLViewPrintingMinimumShrinkFactor __WebViewDidStartAcceleratedCompositingNotification diff --git a/WebKit/mac/WebKitPrefix.h b/WebKit/mac/WebKitPrefix.h index 2a894e6..fe0f214 100644 --- a/WebKit/mac/WebKitPrefix.h +++ b/WebKit/mac/WebKitPrefix.h @@ -72,7 +72,7 @@ typedef float CGFloat; #include <wtf/Platform.h> -#include "EmptyProtocolDefinitions.h" +#include <WebCore/EmptyProtocolDefinitions.h> /* WebKit has no way to pull settings from WebCore/config.h for now */ /* so we assume WebKit is always being compiled on top of JavaScriptCore */ diff --git a/WebKit/mac/WebView/WebArchive.mm b/WebKit/mac/WebView/WebArchive.mm index 89c8335..86e29c8 100644 --- a/WebKit/mac/WebView/WebArchive.mm +++ b/WebKit/mac/WebView/WebArchive.mm @@ -239,13 +239,13 @@ static BOOL isArrayOfClass(id object, Class elementClass) @try { id object = [decoder decodeObjectForKey:WebMainResourceKey]; if ([object isKindOfClass:[WebResource class]]) - mainResource = [object retain]; + mainResource = object; object = [decoder decodeObjectForKey:WebSubresourcesKey]; if (isArrayOfClass(object, [WebResource class])) - subresources = [object retain]; + subresources = object; object = [decoder decodeObjectForKey:WebSubframeArchivesKey]; if (isArrayOfClass(object, [WebArchive class])) - subframeArchives = [object retain]; + subframeArchives = object; } @catch(id) { [self release]; return nil; diff --git a/WebKit/mac/WebView/WebDocumentPrivate.h b/WebKit/mac/WebView/WebDocumentPrivate.h index f09d3bd..a495e4b 100644 --- a/WebKit/mac/WebView/WebDocumentPrivate.h +++ b/WebKit/mac/WebView/WebDocumentPrivate.h @@ -30,6 +30,7 @@ #import <WebKit/WebHTMLView.h> @class DOMDocument; +@class PDFDocument; @protocol WebDocumentImage <NSObject> - (NSImage *)image; @@ -64,6 +65,10 @@ - (NSView *)selectionView; @end +@protocol WebDocumentPDF <WebDocumentText> +- (PDFDocument *)PDFDocument; +@end + @protocol WebDocumentIncrementalSearching /*! @method searchFor:direction:caseSensitive:wrap:startInSelection: diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.h b/WebKit/mac/WebView/WebDynamicScrollBarsView.h index 15ed7e4..c289a04 100644 --- a/WebKit/mac/WebView/WebDynamicScrollBarsView.h +++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.h @@ -1,53 +1,61 @@ /* - * Copyright (C) 2005, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2008, 2010 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. * - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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. */ // This is a Private header (containing SPI), despite the fact that its name // does not contain the word Private. -// This was once used by Safari, but has not been for a long time. +#import <AppKit/NSScrollView.h> // FIXME: <rdar://problem/5898985> Mail currently expects this header to define WebCoreScrollbarAlwaysOn. extern const int WebCoreScrollbarAlwaysOn; +struct WebDynamicScrollBarsViewPrivate; @interface WebDynamicScrollBarsView : NSScrollView { - int hScroll; // FIXME: Should be WebCore::ScrollbarMode if this was an ObjC++ header. - int vScroll; // Ditto. - BOOL hScrollModeLocked; - BOOL vScrollModeLocked; - BOOL suppressLayout; - BOOL suppressScrollers; - BOOL inUpdateScrollers; - BOOL verticallyPinnedByPreviousWheelEvent; - BOOL horizontallyPinnedByPreviousWheelEvent; - unsigned inUpdateScrollersLayoutPass; +@private + struct WebDynamicScrollBarsViewPrivate *_private; + +#ifndef __OBJC2__ + // We need to pad the class out to its former size. See <rdar://problem/7814899> for more information. + char padding[16]; +#endif } // This was originally added for Safari's benefit, but Safari has not used it for a long time. // Perhaps it can be removed. - (void)setAllowsHorizontalScrolling:(BOOL)flag; + +// Determines whether the scrollers should be drawn outside of the content (as in normal scroll views) +// or should overlap the content. +- (void)setAllowsScrollersToOverlapContent:(BOOL)flag; + +// These methods hide the scrollers in a way that does not prevent scrolling. +- (void)setAlwaysHideHorizontalScroller:(BOOL)flag; +- (void)setAlwaysHideVerticalScroller:(BOOL)flag; + +// These methods return YES if the scrollers are visible, or if the only reason that they are not +// visible is that they have been suppressed by setAlwaysHideHorizontal/VerticalScroller:. +- (BOOL)horizontalScrollingAllowed; +- (BOOL)verticalScrollingAllowed; @end diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm index b4424e1..3aaea46 100644 --- a/WebKit/mac/WebView/WebDynamicScrollBarsView.mm +++ b/WebKit/mac/WebView/WebDynamicScrollBarsView.mm @@ -1,29 +1,26 @@ /* - * Copyright (C) 2005, 2008 Apple Inc. All rights reserved. + * Copyright (C) 2005, 2008, 2010 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. * - * 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. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "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 OR ITS 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. + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``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 INC. OR ITS 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. */ #import "WebDynamicScrollBarsViewInternal.h" @@ -41,31 +38,150 @@ using namespace WebCore; // FIXME: <rdar://problem/5898985> Mail expects a constant of this name to exist. const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn; +#ifndef __OBJC2__ +// In <rdar://problem/7814899> we saw crashes because WebDynamicScrollBarsView increased in size, breaking ABI compatiblity. +COMPILE_ASSERT(sizeof(WebDynamicScrollBarsView) == 0x8c, WebDynamicScrollBarsView_is_expected_size); +#endif + +struct WebDynamicScrollBarsViewPrivate { + unsigned inUpdateScrollersLayoutPass; + + WebCore::ScrollbarMode hScroll; + WebCore::ScrollbarMode vScroll; + + bool hScrollModeLocked; + bool vScrollModeLocked; + bool suppressLayout; + bool suppressScrollers; + bool inUpdateScrollers; + bool verticallyPinnedByPreviousWheelEvent; + bool horizontallyPinnedByPreviousWheelEvent; + + bool allowsScrollersToOverlapContent; + bool alwaysHideHorizontalScroller; + bool alwaysHideVerticalScroller; + bool horizontalScrollingAllowedButScrollerHidden; + bool verticalScrollingAllowedButScrollerHidden; +}; + @implementation WebDynamicScrollBarsView +- (id)initWithFrame:(NSRect)frame +{ + if (!(self = [super initWithFrame:frame])) + return nil; + + _private = new WebDynamicScrollBarsViewPrivate; + memset(_private, 0, sizeof(WebDynamicScrollBarsViewPrivate)); + return self; +} + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + if (!(self = [super initWithCoder:aDecoder])) + return nil; + + _private = new WebDynamicScrollBarsViewPrivate; + memset(_private, 0, sizeof(WebDynamicScrollBarsViewPrivate)); + return self; +} + +- (void)dealloc +{ + delete _private; + [super dealloc]; +} + +- (void)finalize +{ + delete _private; + [super finalize]; +} + - (void)setAllowsHorizontalScrolling:(BOOL)flag { - if (hScrollModeLocked) + if (_private->hScrollModeLocked) return; - if (flag && hScroll == ScrollbarAlwaysOff) - hScroll = ScrollbarAuto; - else if (!flag && hScroll != ScrollbarAlwaysOff) - hScroll = ScrollbarAlwaysOff; + if (flag && _private->hScroll == ScrollbarAlwaysOff) + _private->hScroll = ScrollbarAuto; + else if (!flag && _private->hScroll != ScrollbarAlwaysOff) + _private->hScroll = ScrollbarAlwaysOff; [self updateScrollers]; } +- (void)setAllowsScrollersToOverlapContent:(BOOL)flag +{ + if (_private->allowsScrollersToOverlapContent == flag) + return; + + _private->allowsScrollersToOverlapContent = flag; + + [[self contentView] setFrame:[self contentViewFrame]]; + [[self documentView] setNeedsLayout:YES]; + [[self documentView] layout]; +} + +- (void)setAlwaysHideHorizontalScroller:(BOOL)shouldBeHidden +{ + if (_private->alwaysHideHorizontalScroller == shouldBeHidden) + return; + + _private->alwaysHideHorizontalScroller = shouldBeHidden; + [self updateScrollers]; +} + +- (void)setAlwaysHideVerticalScroller:(BOOL)shouldBeHidden +{ + if (_private->alwaysHideVerticalScroller == shouldBeHidden) + return; + + _private->alwaysHideVerticalScroller = shouldBeHidden; + [self updateScrollers]; +} + +- (BOOL)horizontalScrollingAllowed +{ + return _private->horizontalScrollingAllowedButScrollerHidden || [self hasHorizontalScroller]; +} + +- (BOOL)verticalScrollingAllowed +{ + return _private->verticalScrollingAllowedButScrollerHidden || [self hasVerticalScroller]; +} + @end @implementation WebDynamicScrollBarsView (WebInternal) +- (NSRect)contentViewFrame +{ + NSRect frame = [[self contentView] frame]; + + if ([self hasHorizontalScroller]) + frame.size.height = (_private->allowsScrollersToOverlapContent ? NSMaxY([[self horizontalScroller] frame]) : NSMinY([[self horizontalScroller] frame])); + if ([self hasVerticalScroller]) + frame.size.width = (_private->allowsScrollersToOverlapContent ? NSMaxX([[self verticalScroller] frame]) : NSMinX([[self verticalScroller] frame])); + return frame; +} + +- (void)tile +{ + [super tile]; + + // [super tile] sets the contentView size so that it does not overlap with the scrollers, + // we want to re-set the contentView to overlap scrollers before displaying. + if (_private->allowsScrollersToOverlapContent) + [[self contentView] setFrame:[self contentViewFrame]]; +} + - (void)setSuppressLayout:(BOOL)flag; { - suppressLayout = flag; + _private->suppressLayout = flag; } - (void)setScrollBarsSuppressed:(BOOL)suppressed repaintOnUnsuppress:(BOOL)repaint { - suppressScrollers = suppressed; + _private->suppressScrollers = suppressed; // This code was originally changes for a Leopard performance imporvement. We decided to // ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>. @@ -74,13 +190,13 @@ const int WebCoreScrollbarAlwaysOn = ScrollbarAlwaysOn; [[self verticalScroller] setNeedsDisplay:NO]; [[self horizontalScroller] setNeedsDisplay:NO]; } - + if (!suppressed && repaint) [super reflectScrolledClipView:[self contentView]]; #else - if (suppressed || repaint) { - [[self verticalScroller] setNeedsDisplay: !suppressed]; - [[self horizontalScroller] setNeedsDisplay: !suppressed]; + if (suppressed || repaint) { + [[self verticalScroller] setNeedsDisplay:!suppressed]; + [[self horizontalScroller] setNeedsDisplay:!suppressed]; } #endif } @@ -94,42 +210,50 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; // If we came in here with the view already needing a layout, then go ahead and do that // first. (This will be the common case, e.g., when the page changes due to window resizing for example). // This layout will not re-enter updateScrollers and does not count towards our max layout pass total. - if (!suppressLayout && !suppressScrollers && [documentView isKindOfClass:[WebHTMLView class]]) { + if (!_private->suppressLayout && !_private->suppressScrollers && [documentView isKindOfClass:[WebHTMLView class]]) { WebHTMLView* htmlView = (WebHTMLView*)documentView; if ([htmlView _needsLayout]) { - inUpdateScrollers = YES; + _private->inUpdateScrollers = YES; [(id <WebDocumentView>)documentView layout]; - inUpdateScrollers = NO; + _private->inUpdateScrollers = NO; } } BOOL hasHorizontalScroller = [self hasHorizontalScroller]; BOOL hasVerticalScroller = [self hasVerticalScroller]; - + BOOL newHasHorizontalScroller = hasHorizontalScroller; BOOL newHasVerticalScroller = hasVerticalScroller; - + if (!documentView) { newHasHorizontalScroller = NO; newHasVerticalScroller = NO; - } + } - if (hScroll != ScrollbarAuto) - newHasHorizontalScroller = (hScroll == ScrollbarAlwaysOn); - if (vScroll != ScrollbarAuto) - newHasVerticalScroller = (vScroll == ScrollbarAlwaysOn); - - if (!documentView || suppressLayout || suppressScrollers || (hScroll != ScrollbarAuto && vScroll != ScrollbarAuto)) { - inUpdateScrollers = YES; + if (_private->hScroll != ScrollbarAuto) + newHasHorizontalScroller = (_private->hScroll == ScrollbarAlwaysOn); + if (_private->vScroll != ScrollbarAuto) + newHasVerticalScroller = (_private->vScroll == ScrollbarAlwaysOn); + + if (!documentView || _private->suppressLayout || _private->suppressScrollers || (_private->hScroll != ScrollbarAuto && _private->vScroll != ScrollbarAuto)) { + _private->horizontalScrollingAllowedButScrollerHidden = newHasHorizontalScroller && _private->alwaysHideHorizontalScroller; + if (_private->horizontalScrollingAllowedButScrollerHidden) + newHasHorizontalScroller = NO; + + _private->verticalScrollingAllowedButScrollerHidden = newHasVerticalScroller && _private->alwaysHideVerticalScroller; + if (_private->verticalScrollingAllowedButScrollerHidden) + newHasVerticalScroller = NO; + + _private->inUpdateScrollers = YES; if (hasHorizontalScroller != newHasHorizontalScroller) [self setHasHorizontalScroller:newHasHorizontalScroller]; if (hasVerticalScroller != newHasVerticalScroller) [self setHasVerticalScroller:newHasVerticalScroller]; - if (suppressScrollers) { + if (_private->suppressScrollers) { [[self verticalScroller] setNeedsDisplay:NO]; [[self horizontalScroller] setNeedsDisplay:NO]; } - inUpdateScrollers = NO; + _private->inUpdateScrollers = NO; return; } @@ -139,42 +263,50 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; NSSize visibleSize = [self documentVisibleRect].size; NSSize frameSize = [self frame].size; - if (hScroll == ScrollbarAuto) { + if (_private->hScroll == ScrollbarAuto) { newHasHorizontalScroller = documentSize.width > visibleSize.width; - if (newHasHorizontalScroller && !inUpdateScrollersLayoutPass && documentSize.height <= frameSize.height && documentSize.width <= frameSize.width) + if (newHasHorizontalScroller && !_private->inUpdateScrollersLayoutPass && documentSize.height <= frameSize.height && documentSize.width <= frameSize.width) newHasHorizontalScroller = NO; } - - if (vScroll == ScrollbarAuto) { + + if (_private->vScroll == ScrollbarAuto) { newHasVerticalScroller = documentSize.height > visibleSize.height; - if (newHasVerticalScroller && !inUpdateScrollersLayoutPass && documentSize.height <= frameSize.height && documentSize.width <= frameSize.width) + if (newHasVerticalScroller && !_private->inUpdateScrollersLayoutPass && documentSize.height <= frameSize.height && documentSize.width <= frameSize.width) newHasVerticalScroller = NO; } // Unless in ScrollbarsAlwaysOn mode, if we ever turn one scrollbar off, always turn the other one off too. // Never ever try to both gain/lose a scrollbar in the same pass. - if (!newHasHorizontalScroller && hasHorizontalScroller && vScroll != ScrollbarAlwaysOn) + if (!newHasHorizontalScroller && hasHorizontalScroller && _private->vScroll != ScrollbarAlwaysOn) newHasVerticalScroller = NO; - if (!newHasVerticalScroller && hasVerticalScroller && hScroll != ScrollbarAlwaysOn) + if (!newHasVerticalScroller && hasVerticalScroller && _private->hScroll != ScrollbarAlwaysOn) + newHasHorizontalScroller = NO; + + _private->horizontalScrollingAllowedButScrollerHidden = newHasHorizontalScroller && _private->alwaysHideHorizontalScroller; + if (_private->horizontalScrollingAllowedButScrollerHidden) newHasHorizontalScroller = NO; + _private->verticalScrollingAllowedButScrollerHidden = newHasVerticalScroller && _private->alwaysHideVerticalScroller; + if (_private->verticalScrollingAllowedButScrollerHidden) + newHasVerticalScroller = NO; + if (hasHorizontalScroller != newHasHorizontalScroller) { - inUpdateScrollers = YES; + _private->inUpdateScrollers = YES; [self setHasHorizontalScroller:newHasHorizontalScroller]; - inUpdateScrollers = NO; + _private->inUpdateScrollers = NO; needsLayout = YES; } if (hasVerticalScroller != newHasVerticalScroller) { - inUpdateScrollers = YES; + _private->inUpdateScrollers = YES; [self setHasVerticalScroller:newHasVerticalScroller]; - inUpdateScrollers = NO; + _private->inUpdateScrollers = NO; needsLayout = YES; } - if (needsLayout && inUpdateScrollersLayoutPass < cMaxUpdateScrollbarsPass && + if (needsLayout && _private->inUpdateScrollersLayoutPass < cMaxUpdateScrollbarsPass && [documentView conformsToProtocol:@protocol(WebDocumentView)]) { - inUpdateScrollersLayoutPass++; + _private->inUpdateScrollersLayoutPass++; [(id <WebDocumentView>)documentView setNeedsLayout:YES]; [(id <WebDocumentView>)documentView layout]; NSSize newDocumentSize = [documentView frame].size; @@ -184,7 +316,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; // Recur manually. [self updateScrollers]; } - inUpdateScrollersLayoutPass--; + _private->inUpdateScrollersLayoutPass--; } } @@ -192,6 +324,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; - (void)reflectScrolledClipView:(NSClipView *)clipView { if (clipView == [self contentView]) { + // Prevent appearance of trails because of overlapping views + if (_private->allowsScrollersToOverlapContent) + [self setDrawsBackground:NO]; + // FIXME: This hack here prevents infinite recursion that takes place when we // gyrate between having a vertical scroller and not having one. A reproducible // case is clicking on the "the Policy Routing text" link at @@ -199,7 +335,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; // The underlying cause is some problem in the NSText machinery, but I was not // able to pin it down. NSGraphicsContext *currentContext = [NSGraphicsContext currentContext]; - if (!inUpdateScrollers && (!currentContext || [currentContext isDrawingToScreen])) + if (!_private->inUpdateScrollers && (!currentContext || [currentContext isDrawingToScreen])) [self updateScrollers]; } @@ -207,15 +343,15 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; // ifdef it to fix correctness issues on Tiger documented in <rdar://problem/5441823>. #ifndef BUILDING_ON_TIGER // Update the scrollers if they're not being suppressed. - if (!suppressScrollers) + if (!_private->suppressScrollers) [super reflectScrolledClipView:clipView]; #else - [super reflectScrolledClipView:clipView]; - - // Validate the scrollers if they're being suppressed. - if (suppressScrollers) { - [[self verticalScroller] setNeedsDisplay: NO]; - [[self horizontalScroller] setNeedsDisplay: NO]; + [super reflectScrolledClipView:clipView]; + + // Validate the scrollers if they're being suppressed. + if (_private->suppressScrollers) { + [[self verticalScroller] setNeedsDisplay:NO]; + [[self horizontalScroller] setNeedsDisplay:NO]; } #endif @@ -231,28 +367,28 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; - (BOOL)allowsHorizontalScrolling { - return hScroll != ScrollbarAlwaysOff; + return _private->hScroll != ScrollbarAlwaysOff; } - (BOOL)allowsVerticalScrolling { - return vScroll != ScrollbarAlwaysOff; + return _private->vScroll != ScrollbarAlwaysOff; } - (void)scrollingModes:(WebCore::ScrollbarMode*)hMode vertical:(WebCore::ScrollbarMode*)vMode { - *hMode = static_cast<ScrollbarMode>(hScroll); - *vMode = static_cast<ScrollbarMode>(vScroll); + *hMode = _private->hScroll; + *vMode = _private->vScroll; } - (ScrollbarMode)horizontalScrollingMode { - return static_cast<ScrollbarMode>(hScroll); + return _private->hScroll; } - (ScrollbarMode)verticalScrollingMode { - return static_cast<ScrollbarMode>(vScroll); + return _private->vScroll; } - (void)setHorizontalScrollingMode:(ScrollbarMode)horizontalMode andLock:(BOOL)lock @@ -274,13 +410,13 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; - (void)setScrollingModes:(ScrollbarMode)horizontalMode vertical:(ScrollbarMode)verticalMode andLock:(BOOL)lock { BOOL update = NO; - if (verticalMode != vScroll && !vScrollModeLocked) { - vScroll = verticalMode; + if (verticalMode != _private->vScroll && !_private->vScrollModeLocked) { + _private->vScroll = verticalMode; update = YES; } - if (horizontalMode != hScroll && !hScrollModeLocked) { - hScroll = horizontalMode; + if (horizontalMode != _private->hScroll && !_private->hScrollModeLocked) { + _private->hScroll = horizontalMode; update = YES; } @@ -293,27 +429,27 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; - (void)setHorizontalScrollingModeLocked:(BOOL)locked { - hScrollModeLocked = locked; + _private->hScrollModeLocked = locked; } - (void)setVerticalScrollingModeLocked:(BOOL)locked { - vScrollModeLocked = locked; + _private->vScrollModeLocked = locked; } - (void)setScrollingModesLocked:(BOOL)locked { - hScrollModeLocked = vScrollModeLocked = locked; + _private->hScrollModeLocked = _private->vScrollModeLocked = locked; } - (BOOL)horizontalScrollingModeLocked { - return hScrollModeLocked; + return _private->hScrollModeLocked; } - (BOOL)verticalScrollingModeLocked { - return vScrollModeLocked; + return _private->vScrollModeLocked; } - (BOOL)autoforwardsScrollWheelEvents @@ -325,8 +461,10 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; { float deltaX; float deltaY; + float wheelTicksX; + float wheelTicksY; BOOL isContinuous; - WKGetWheelEventDeltas(event, &deltaX, &deltaY, &isContinuous); + WKGetWheelEventDeltas(event, &deltaX, &deltaY, &wheelTicksX, &wheelTicksY, &isContinuous); BOOL isLatchingEvent = WKIsLatchingWheelEvent(event); @@ -336,7 +474,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; return; } - if (isLatchingEvent && !verticallyPinnedByPreviousWheelEvent) { + if (isLatchingEvent && !_private->verticallyPinnedByPreviousWheelEvent) { double verticalPosition = [[self verticalScroller] doubleValue]; if ((deltaY >= 0.0 && verticalPosition == 0.0) || (deltaY <= 0.0 && verticalPosition == 1.0)) return; @@ -347,7 +485,7 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; return; } - if (isLatchingEvent && !horizontallyPinnedByPreviousWheelEvent) { + if (isLatchingEvent && !_private->horizontallyPinnedByPreviousWheelEvent) { double horizontalPosition = [[self horizontalScroller] doubleValue]; if ((deltaX >= 0.0 && horizontalPosition == 0.0) || (deltaX <= 0.0 && horizontalPosition == 1.0)) return; @@ -364,8 +502,8 @@ static const unsigned cMaxUpdateScrollbarsPass = 2; double verticalPosition = [[self verticalScroller] doubleValue]; double horizontalPosition = [[self horizontalScroller] doubleValue]; - verticallyPinnedByPreviousWheelEvent = (verticalPosition == 0.0 || verticalPosition == 1.0); - horizontallyPinnedByPreviousWheelEvent = (horizontalPosition == 0.0 || horizontalPosition == 1.0); + _private->verticallyPinnedByPreviousWheelEvent = (verticalPosition == 0.0 || verticalPosition == 1.0); + _private->horizontallyPinnedByPreviousWheelEvent = (horizontalPosition == 0.0 || horizontalPosition == 1.0); } [self release]; diff --git a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h b/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h index 312cf9d..40be88d 100644 --- a/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h +++ b/WebKit/mac/WebView/WebDynamicScrollBarsViewInternal.h @@ -53,4 +53,6 @@ - (void)updateScrollers; - (void)setSuppressLayout:(BOOL)flag; +// Calculate the appropriate frame for the contentView based on allowsScrollersToOverlapContent. +- (NSRect)contentViewFrame; @end diff --git a/WebKit/mac/WebView/WebFrame.h b/WebKit/mac/WebView/WebFrame.h index a6cdebb..64015fd 100644 --- a/WebKit/mac/WebView/WebFrame.h +++ b/WebKit/mac/WebView/WebFrame.h @@ -213,5 +213,4 @@ bridge between the WebKit and JavaScriptCore APIs. */ - (JSGlobalContextRef)globalContext; - @end diff --git a/WebKit/mac/WebView/WebFrame.mm b/WebKit/mac/WebView/WebFrame.mm index 267d319..b4169b6 100644 --- a/WebKit/mac/WebView/WebFrame.mm +++ b/WebKit/mac/WebView/WebFrame.mm @@ -39,6 +39,7 @@ #import "WebChromeClient.h" #import "WebDataSourceInternal.h" #import "WebDocumentLoaderMac.h" +#import "WebDynamicScrollBarsView.h" #import "WebFrameLoaderClient.h" #import "WebFrameViewInternal.h" #import "WebHTMLView.h" @@ -73,6 +74,7 @@ #import <WebCore/LegacyWebArchive.h> #import <WebCore/Page.h> #import <WebCore/PluginData.h> +#import <WebCore/PrintContext.h> #import <WebCore/RenderLayer.h> #import <WebCore/RenderPart.h> #import <WebCore/RenderView.h> @@ -581,22 +583,16 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) if (!documentView) return pages; - float currPageHeight = printHeight; - float docHeight = root->layer()->height(); float docWidth = root->layer()->width(); - float printWidth = docWidth/printWidthScaleFactor; - - // We need to give the part the opportunity to adjust the page height at each step. - for (float i = 0; i < docHeight; i += currPageHeight) { - float proposedBottom = min(docHeight, i + printHeight); - view->adjustPageHeight(&proposedBottom, i, proposedBottom, i); - currPageHeight = max(1.0f, proposedBottom - i); - for (float j = 0; j < docWidth; j += printWidth) { - NSValue* val = [NSValue valueWithRect: NSMakeRect(j, i, printWidth, currPageHeight)]; - [pages addObject: val]; - } - } - + float printWidth = docWidth / printWidthScaleFactor; + + PrintContext printContext(_private->coreFrame); + printContext.computePageRectsWithPageSize(FloatSize(printWidth, printHeight), true); + + const Vector<IntRect>& pageRects = printContext.pageRects(); + const size_t pageCount = pageRects.size(); + for (size_t pageNumber = 0; pageNumber < pageCount; ++pageNumber) + [pages addObject: [NSValue valueWithRect: NSRect(pageRects[pageNumber])]]; return pages; } @@ -634,7 +630,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return @""; JSLock lock(SilenceAssertionsOnly); - return String(result.toString(_private->coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec())); + return ustringToString(result.toString(_private->coreFrame->script()->globalObject(mainThreadNormalWorld())->globalExec())); } - (NSRect)_caretRectAtNode:(DOMNode *)node offset:(int)offset affinity:(NSSelectionAffinity)affinity @@ -965,7 +961,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) - (BOOL)_canProvideDocumentSource { Frame* frame = _private->coreFrame; - String mimeType = frame->loader()->responseMIMEType(); + String mimeType = frame->loader()->writer()->mimeType(); PluginData* pluginData = frame->page() ? frame->page()->pluginData() : 0; if (WebCore::DOMImplementation::isTextMIMEType(mimeType) || @@ -990,7 +986,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) bool userChosen = !encoding.isNull(); if (encoding.isNull()) encoding = textEncodingName; - _private->coreFrame->loader()->setEncoding(encoding, userChosen); + _private->coreFrame->loader()->writer()->setEncoding(encoding, userChosen); [self _addData:data]; } @@ -1267,7 +1263,7 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return @""; JSLock lock(SilenceAssertionsOnly); - return String(result.toString(anyWorldGlobalObject->globalExec())); + return ustringToString(result.toString(anyWorldGlobalObject->globalExec())); } - (JSGlobalContextRef)_globalContextForScriptWorld:(WebScriptWorld *)world @@ -1281,6 +1277,48 @@ static inline WebDataSource *dataSource(DocumentLoader* loader) return toGlobalRef(coreFrame->script()->globalObject(coreWorld)->globalExec()); } +- (void)setAllowsScrollersToOverlapContent:(BOOL)flag +{ + ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]); + [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAllowsScrollersToOverlapContent:flag]; +} + +- (void)setAlwaysHideHorizontalScroller:(BOOL)flag +{ + ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]); + [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAlwaysHideHorizontalScroller:flag]; +} +- (void)setAlwaysHideVerticalScroller:(BOOL)flag +{ + ASSERT([[[self frameView] _scrollView] isKindOfClass:[WebDynamicScrollBarsView class]]); + [(WebDynamicScrollBarsView *)[[self frameView] _scrollView] setAlwaysHideVerticalScroller:flag]; +} + +- (void)setAccessibleName:(NSString *)name +{ +#if HAVE(ACCESSIBILITY) + if (!AXObjectCache::accessibilityEnabled()) + return; + + RenderView* root = toRenderView(_private->coreFrame->document()->renderer()); + if (!root) + return; + + AccessibilityObject* rootObject = _private->coreFrame->document()->axObjectCache()->getOrCreate(root); + String strName(name); + rootObject->setAccessibleName(strName); +#endif +} + +- (NSString*)_layerTreeAsText +{ + Frame* coreFrame = _private->coreFrame; + if (!coreFrame) + return @""; + + return coreFrame->layerTreeAsText(); +} + @end @implementation WebFrame diff --git a/WebKit/mac/WebView/WebFramePrivate.h b/WebKit/mac/WebView/WebFramePrivate.h index 462686f..0bda966 100644 --- a/WebKit/mac/WebView/WebFramePrivate.h +++ b/WebKit/mac/WebView/WebFramePrivate.h @@ -120,4 +120,20 @@ typedef enum { - (NSMutableDictionary *)_cacheabilityDictionary; - (BOOL)_allowsFollowingLink:(NSURL *)URL; + +// Sets whether the scrollbars, if any, should be shown inside the document's border +// (thus overlapping some content) or outside the webView's border (default behavior). +// Changing this flag changes the size of the contentView and maintains the size of the frameView. +- (void)setAllowsScrollersToOverlapContent:(BOOL)flag; + +// Sets if the scrollbar is always hidden, regardless of other scrollbar visibility settings. +// This does not affect the scrollability of the document. +- (void)setAlwaysHideHorizontalScroller:(BOOL)flag; +- (void)setAlwaysHideVerticalScroller:(BOOL)flag; + +// Sets the name presented to accessibility clients for the web area object. +- (void)setAccessibleName:(NSString *)name; + +- (NSString*)_layerTreeAsText; + @end diff --git a/WebKit/mac/WebView/WebFrameView.mm b/WebKit/mac/WebView/WebFrameView.mm index 422b605..9ded8e1 100644 --- a/WebKit/mac/WebView/WebFrameView.mm +++ b/WebKit/mac/WebView/WebFrameView.mm @@ -532,7 +532,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl { if ([self _scrollOverflowInDirection:ScrollUp granularity:ScrollByDocument]) return YES; - if (![self _hasScrollBars]) + if (![self _isScrollable]) return NO; NSPoint point = [[[self _scrollView] documentView] frame].origin; return [[self _contentView] _scrollTo:&point animate:YES]; @@ -542,7 +542,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl { if ([self _scrollOverflowInDirection:ScrollDown granularity:ScrollByDocument]) return YES; - if (![self _hasScrollBars]) + if (![self _isScrollable]) return NO; NSRect frame = [[[self _scrollView] documentView] frame]; NSPoint point = NSMakePoint(frame.origin.x, NSMaxY(frame)); @@ -554,7 +554,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollToBeginningOfDocument]) return; - if (WebFrameView *child = [self _largestChildWithScrollBars]) { + if (WebFrameView *child = [self _largestScrollableChild]) { if ([child _scrollToBeginningOfDocument]) return; } @@ -566,7 +566,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollToEndOfDocument]) return; - if (WebFrameView *child = [self _largestChildWithScrollBars]) { + if (WebFrameView *child = [self _largestScrollableChild]) { if ([child _scrollToEndOfDocument]) return; } @@ -619,8 +619,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByPage]) return YES; - if (![self _hasScrollBars]) - return [[self _largestChildWithScrollBars] _pageVertically:up]; + if (![self _isScrollable]) + return [[self _largestScrollableChild] _pageVertically:up]; float delta = [self _verticalPageScrollDistance]; return [self _scrollVerticallyBy:up ? -delta : delta]; @@ -631,8 +631,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByPage]) return YES; - if (![self _hasScrollBars]) - return [[self _largestChildWithScrollBars] _pageHorizontally:left]; + if (![self _isScrollable]) + return [[self _largestScrollableChild] _pageHorizontally:left]; float delta = [self _horizontalPageScrollDistance]; return [self _scrollHorizontallyBy:left ? -delta : delta]; @@ -643,8 +643,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollOverflowInDirection:up ? ScrollUp : ScrollDown granularity:ScrollByLine]) return YES; - if (![self _hasScrollBars]) - return [[self _largestChildWithScrollBars] _scrollLineVertically:up]; + if (![self _isScrollable]) + return [[self _largestScrollableChild] _scrollLineVertically:up]; float delta = [self _verticalKeyboardScrollDistance]; return [self _scrollVerticallyBy:up ? -delta : delta]; @@ -655,8 +655,8 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl if ([self _scrollOverflowInDirection:left ? ScrollLeft : ScrollRight granularity:ScrollByLine]) return YES; - if (![self _hasScrollBars]) - return [[self _largestChildWithScrollBars] _scrollLineHorizontally:left]; + if (![self _isScrollable]) + return [[self _largestScrollableChild] _scrollLineHorizontally:left]; float delta = [self _horizontalKeyboardScrollDistance]; return [self _scrollHorizontallyBy:left ? -delta : delta]; @@ -730,7 +730,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl // Checking for a control will allow events to percolate // correctly when the focus is on a form control and we // are in full keyboard access mode. - if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) || [self _firstResponderIsFormControl]) { + if ((![self allowsScrolling] && ![self _largestScrollableChild]) || [self _firstResponderIsFormControl]) { callSuper = YES; break; } @@ -742,7 +742,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = NO; break; case NSPageUpFunctionKey: - if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) { + if (![self allowsScrolling] && ![self _largestScrollableChild]) { callSuper = YES; break; } @@ -750,7 +750,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = NO; break; case NSPageDownFunctionKey: - if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) { + if (![self allowsScrolling] && ![self _largestScrollableChild]) { callSuper = YES; break; } @@ -758,7 +758,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = NO; break; case NSHomeFunctionKey: - if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) { + if (![self allowsScrolling] && ![self _largestScrollableChild]) { callSuper = YES; break; } @@ -766,7 +766,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = NO; break; case NSEndFunctionKey: - if (![self allowsScrolling] && ![self _largestChildWithScrollBars]) { + if (![self allowsScrolling] && ![self _largestScrollableChild]) { callSuper = YES; break; } @@ -779,7 +779,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = YES; break; } - if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) || + if ((![self allowsScrolling] && ![self _largestScrollableChild]) || [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) { // Let arrow keys go through to pop up buttons // <rdar://problem/3455910>: hitting up or down arrows when focus is on a @@ -802,7 +802,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl callSuper = YES; break; } - if ((![self allowsScrolling] && ![self _largestChildWithScrollBars]) || + if ((![self allowsScrolling] && ![self _largestScrollableChild]) || [[[self window] firstResponder] isKindOfClass:[NSPopUpButton class]]) { // Let arrow keys go through to pop up buttons // <rdar://problem/3455910>: hitting up or down arrows when focus is on a @@ -834,7 +834,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl [self _goBack]; } else { // Now check scrolling related keys. - if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) { + if ((![self allowsScrolling] && ![self _largestScrollableChild])) { callSuper = YES; break; } @@ -862,7 +862,7 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl [self _goForward]; } else { // Now check scrolling related keys. - if ((![self allowsScrolling] && ![self _largestChildWithScrollBars])) { + if ((![self allowsScrolling] && ![self _largestScrollableChild])) { callSuper = YES; break; } @@ -939,14 +939,52 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl return frame.size.height * frame.size.width; } +- (BOOL)_isScrollable +{ + WebDynamicScrollBarsView *scrollView = [self _scrollView]; + return [scrollView horizontalScrollingAllowed] || [scrollView verticalScrollingAllowed]; +} + +- (WebFrameView *)_largestScrollableChild +{ + WebFrameView *largest = nil; + NSArray *frameChildren = [[self webFrame] childFrames]; + + unsigned i; + for (i=0; i < [frameChildren count]; i++) { + WebFrameView *childFrameView = [[frameChildren objectAtIndex:i] frameView]; + WebFrameView *scrollableFrameView = [childFrameView _isScrollable] ? childFrameView : [childFrameView _largestScrollableChild]; + if (!scrollableFrameView) + continue; + + // Some ads lurk in child frames of zero width and height, see radar 4406994. These don't count as scrollable. + // Maybe someday we'll discover that this minimum area check should be larger, but this covers the known cases. + float area = [scrollableFrameView _area]; + if (area < 1.0) + continue; + + if (!largest || (area > [largest _area])) { + largest = scrollableFrameView; + } + } + + return largest; +} + - (BOOL)_hasScrollBars { + // FIXME: This method was used by Safari 4.0.x and older versions, but has not been used by any other WebKit + // clients to my knowledge, and will not be used by future versions of Safari. It can probably be removed + // once we no longer need to keep nightly WebKit builds working with Safari 4.0.x and earlier. NSScrollView *scrollView = [self _scrollView]; return [scrollView hasHorizontalScroller] || [scrollView hasVerticalScroller]; } - (WebFrameView *)_largestChildWithScrollBars { + // FIXME: This method was used by Safari 4.0.x and older versions, but has not been used by any other WebKit + // clients to my knowledge, and will not be used by future versions of Safari. It can probably be removed + // once we no longer need to keep nightly WebKit builds working with Safari 4.0.x and earlier. WebFrameView *largest = nil; NSArray *frameChildren = [[self webFrame] childFrames]; diff --git a/WebKit/mac/WebView/WebFrameViewPrivate.h b/WebKit/mac/WebView/WebFrameViewPrivate.h index 47c053e..93d36ec 100644 --- a/WebKit/mac/WebView/WebFrameViewPrivate.h +++ b/WebKit/mac/WebView/WebFrameViewPrivate.h @@ -30,13 +30,19 @@ @interface WebFrameView (WebPrivate) +// FIXME: This method was used by Safari 4.0.x and older versions, but has not been used by any other WebKit +// clients to my knowledge, and will not be used by future versions of Safari. It can probably be removed +// once we no longer need to keep nightly WebKit builds working with Safari 4.0.x and earlier. /*! @method _largestChildWithScrollBars @abstract Of the child WebFrameViews that are displaying scroll bars, determines which has the largest area. @result A child WebFrameView that is displaying scroll bars, or nil if none. -*/ + */ - (WebFrameView *)_largestChildWithScrollBars; +// FIXME: This method was used by Safari 4.0.x and older versions, but has not been used by any other WebKit +// clients to my knowledge, and will not be used by future versions of Safari. It can probably be removed +// once we no longer need to keep nightly WebKit builds working with Safari 4.0.x and earlier. /*! @method _hasScrollBars @result YES if at least one scroll bar is currently displayed @@ -44,6 +50,21 @@ - (BOOL)_hasScrollBars; /*! + @method _largestScrollableChild + @abstract Of the child WebFrameViews that allow scrolling, determines which has the largest area. + @result A child WebFrameView that is scrollable, or nil if none. + */ +- (WebFrameView *)_largestScrollableChild; + +/*! + @method _isScrollable + @result YES if scrolling is currently possible, whether or not scroll bars are currently showing. This + differs from -allowsScrolling in that the latter method only checks whether scrolling has been + explicitly disallowed via a call to setAllowsScrolling:NO. + */ +- (BOOL)_isScrollable; + +/*! @method _contentView @result The content view (NSClipView) of the WebFrameView's scroll view. */ diff --git a/WebKit/mac/WebView/WebHTMLRepresentation.mm b/WebKit/mac/WebView/WebHTMLRepresentation.mm index 3aaa914..2684004 100644 --- a/WebKit/mac/WebView/WebHTMLRepresentation.mm +++ b/WebKit/mac/WebView/WebHTMLRepresentation.mm @@ -302,7 +302,8 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element) { HTMLInputElement* inputElement = inputElementFromDOMElement(element); return inputElement - && inputElement->inputType() == HTMLInputElement::TEXT + && inputElement->isTextField() + && inputElement->inputType() != HTMLInputElement::PASSWORD && inputElement->autoComplete(); } diff --git a/WebKit/mac/WebView/WebHTMLView.mm b/WebKit/mac/WebView/WebHTMLView.mm index aa65920..daeeb10 100644 --- a/WebKit/mac/WebView/WebHTMLView.mm +++ b/WebKit/mac/WebView/WebHTMLView.mm @@ -148,26 +148,52 @@ using namespace std; - (BOOL)receivedUnhandledCommand; @end -static IMP oldSetCursorIMP = NULL; +// if YES, do the standard NSView hit test (which can't give the right result when HTML overlaps a view) +static BOOL forceNSViewHitTest; -#ifdef BUILDING_ON_TIGER +// if YES, do the "top WebHTMLView" hit test (which we'd like to do all the time but can't because of Java requirements [see bug 4349721]) +static BOOL forceWebHTMLViewHitTest; + +static WebHTMLView *lastHitView; + +static bool needsCursorRectsSupportAtPoint(NSWindow* window, NSPoint point) +{ + forceNSViewHitTest = YES; + NSView* view = [[window _web_borderView] hitTest:point]; + forceNSViewHitTest = NO; + + // WebHTMLView doesn't use cursor rects. + if ([view isKindOfClass:[WebHTMLView class]]) + return false; + + // Neither do NPAPI plug-ins. + if ([view isKindOfClass:[WebBaseNetscapePluginView class]]) + return false; + + // Non-Web content, WebPDFView, and WebKit plug-ins use normal cursor handling. + return true; +} + +#ifndef BUILDING_ON_TIGER + +static IMP oldSetCursorForMouseLocationIMP; + +// Overriding an internal method is a hack; <rdar://problem/7662987> tracks finding a better solution. +static void setCursor(NSWindow* self, SEL cmd, NSPoint point) +{ + if (needsCursorRectsSupportAtPoint(self, point)) + oldSetCursorForMouseLocationIMP(self, cmd, point); +} + +#else -static IMP oldResetCursorRectsIMP = NULL; +static IMP oldResetCursorRectsIMP; +static IMP oldSetCursorIMP; static BOOL canSetCursor = YES; static void resetCursorRects(NSWindow* self, SEL cmd) { - NSPoint point = [self mouseLocationOutsideOfEventStream]; - NSView* view = [[self _web_borderView] hitTest:point]; - if ([view isKindOfClass:[WebHTMLView class]]) { - WebHTMLView *htmlView = (WebHTMLView*)view; - NSPoint localPoint = [htmlView convertPoint:point fromView:nil]; - NSDictionary *dict = [htmlView elementAtPoint:localPoint allowShadowContent:NO]; - DOMElement *element = [dict objectForKey:WebElementDOMNodeKey]; - if (![element isKindOfClass:[DOMHTMLAppletElement class]] && ![element isKindOfClass:[DOMHTMLObjectElement class]] && - ![element isKindOfClass:[DOMHTMLEmbedElement class]]) - canSetCursor = NO; - } + canSetCursor = needsCursorRectsSupportAtPoint(self, [self mouseLocationOutsideOfEventStream]); oldResetCursorRectsIMP(self, cmd); canSetCursor = YES; } @@ -178,23 +204,6 @@ static void setCursor(NSCursor* self, SEL cmd) oldSetCursorIMP(self, cmd); } -#else - -static void setCursor(NSWindow* self, SEL cmd, NSPoint point) -{ - NSView* view = [[self _web_borderView] hitTest:point]; - if ([view isKindOfClass:[WebHTMLView class]]) { - WebHTMLView *htmlView = (WebHTMLView*)view; - NSPoint localPoint = [htmlView convertPoint:point fromView:nil]; - NSDictionary *dict = [htmlView elementAtPoint:localPoint allowShadowContent:NO]; - DOMElement *element = [dict objectForKey:WebElementDOMNodeKey]; - if (![element isKindOfClass:[DOMHTMLAppletElement class]] && ![element isKindOfClass:[DOMHTMLObjectElement class]] && - ![element isKindOfClass:[DOMHTMLEmbedElement class]]) - return; - } - oldSetCursorIMP(self, cmd, point); -} - #endif extern "C" { @@ -241,13 +250,13 @@ extern NSString *NSTextInputReplacementRangeAttributeName; // print in IE and Camino. This lets them use fewer sheets than they // would otherwise, which is presumably why other browsers do this. // Wide pages will be scaled down more than this. -#define PrintingMinimumShrinkFactor 1.25f +const float _WebHTMLViewPrintingMinimumShrinkFactor = 1.25; // This number determines how small we are willing to reduce the page content // in order to accommodate the widest line. If the page would have to be // reduced smaller to make the widest line fit, we just clip instead (this // behavior matches MacIE and Mozilla, at least) -#define PrintingMaximumShrinkFactor 2.0f +const float _WebHTMLViewPrintingMaximumShrinkFactor = 2; // This number determines how short the last printed page of a multi-page print session // can be before we try to shrink the scale in order to reduce the number of pages, and @@ -294,14 +303,6 @@ extern NSString *NSTextInputReplacementRangeAttributeName; @implementation WebCoreScrollView @end -// if YES, do the standard NSView hit test (which can't give the right result when HTML overlaps a view) -static BOOL forceNSViewHitTest; - -// if YES, do the "top WebHTMLView" hit test (which we'd like to do all the time but can't because of Java requirements [see bug 4349721]) -static BOOL forceWebHTMLViewHitTest; - -static WebHTMLView *lastHitView; - // We need this to be able to safely reference the CachedImage for the promised drag data static CachedResourceClient* promisedDataClient() { @@ -321,7 +322,6 @@ static CachedResourceClient* promisedDataClient() - (BOOL)_shouldInsertFragment:(DOMDocumentFragment *)fragment replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action; - (BOOL)_shouldInsertText:(NSString *)text replacingDOMRange:(DOMRange *)range givenAction:(WebViewInsertAction)action; - (BOOL)_shouldReplaceSelectionWithText:(NSString *)text givenAction:(WebViewInsertAction)action; -- (float)_calculatePrintHeight; - (DOMRange *)_selectedRange; - (BOOL)_shouldDeleteRange:(DOMRange *)range; - (NSView *)_hitViewForEvent:(NSEvent *)event; @@ -428,6 +428,9 @@ struct WebHTMLViewInterpretKeyEventsParameters { BOOL exposeInputContext; NSPoint lastScrollPosition; +#ifndef BUILDING_ON_TIGER + BOOL inScrollPositionChanged; +#endif WebPluginController *pluginController; @@ -490,20 +493,21 @@ static NSCellStateValue kit(TriState state) #ifndef BUILDING_ON_TIGER WebCoreObjCFinalizeOnMainThread(self); #endif - + +#ifndef BUILDING_ON_TIGER + if (!oldSetCursorForMouseLocationIMP) { + Method setCursorMethod = class_getInstanceMethod([NSWindow class], @selector(_setCursorForMouseLocation:)); + ASSERT(setCursorMethod); + oldSetCursorForMouseLocationIMP = method_setImplementation(setCursorMethod, (IMP)setCursor); + ASSERT(oldSetCursorForMouseLocationIMP); + } +#else if (!oldSetCursorIMP) { -#ifdef BUILDING_ON_TIGER Method setCursorMethod = class_getInstanceMethod([NSCursor class], @selector(set)); -#else - Method setCursorMethod = class_getInstanceMethod([NSWindow class], @selector(_setCursorForMouseLocation:)); -#endif ASSERT(setCursorMethod); - oldSetCursorIMP = method_setImplementation(setCursorMethod, (IMP)setCursor); ASSERT(oldSetCursorIMP); } - -#ifdef BUILDING_ON_TIGER if (!oldResetCursorRectsIMP) { Method resetCursorRectsMethod = class_getInstanceMethod([NSWindow class], @selector(resetCursorRects)); ASSERT(resetCursorRectsMethod); @@ -896,17 +900,6 @@ static NSURL* uniqueURLWithRelativePart(NSString *relativePart) return [self _shouldInsertText:text replacingDOMRange:[self _selectedRange] givenAction:action]; } -// Calculate the vertical size of the view that fits on a single page -- (float)_calculatePrintHeight -{ - // Obtain the print info object for the current operation - NSPrintInfo *pi = [[NSPrintOperation currentOperation] printInfo]; - - // Calculate the page height in points - NSSize paperSize = [pi paperSize]; - return paperSize.height - [pi topMargin] - [pi bottomMargin]; -} - - (DOMRange *)_selectedRange { Frame* coreFrame = core([self _frame]); @@ -1169,8 +1162,15 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) NSPoint origin = [[self superview] bounds].origin; if (!NSEqualPoints(_private->lastScrollPosition, origin)) { if (Frame* coreFrame = core([self _frame])) { - if (FrameView* coreView = coreFrame->view()) + if (FrameView* coreView = coreFrame->view()) { +#ifndef BUILDING_ON_TIGER + _private->inScrollPositionChanged = YES; +#endif coreView->scrollPositionChanged(); +#ifndef BUILDING_ON_TIGER + _private->inScrollPositionChanged = NO; +#endif + } } [_private->completionController endRevertingChange:NO moveLeft:NO]; @@ -1290,11 +1290,15 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) // There are known cases where -viewWillDraw is not called on all views being drawn. // See <rdar://problem/6964278> for example. Performing layout at this point prevents us from // trying to paint without layout (which WebCore now refuses to do, instead bailing out without - // drawing at all), but we may still fail to update and regions dirtied by the layout which are + // drawing at all), but we may still fail to update any regions dirtied by the layout which are // not already dirty. if ([self _needsLayout]) { - LOG_ERROR("View needs layout. Either -viewWillDraw wasn't called or layout was invalidated during the display operation. Performing layout now."); - [self _web_layoutIfNeededRecursive]; + NSInteger rectCount; + [self getRectsBeingDrawn:0 count:&rectCount]; + if (rectCount) { + LOG_ERROR("View needs layout. Either -viewWillDraw wasn't called or layout was invalidated during the display operation. Performing layout now."); + [self _web_layoutIfNeededRecursive]; + } } #else // Because Tiger does not have viewWillDraw we need to do layout here. @@ -1421,6 +1425,7 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) else if (forceWebHTMLViewHitTest) captureHitsOnSubviews = YES; else { + // FIXME: Why doesn't this include mouse entered/exited events, or other mouse button events? NSEvent *event = [[self window] currentEvent]; captureHitsOnSubviews = !([event type] == NSMouseMoved || [event type] == NSRightMouseDown @@ -2185,6 +2190,59 @@ static void _updateMouseoverTimerCallback(CFRunLoopTimerRef timer, void *info) #endif } +- (BOOL)_isInPrintMode +{ + return _private->printing; +} + +- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit +{ + Frame* frame = core([self _frame]); + if (!frame) + return NO; + + float minLayoutWidth = 0; + float maxLayoutWidth = 0; + + // If we are a frameset just print with the layout we have onscreen, otherwise relayout + // according to the page width. + if (!frame->document() || !frame->document()->isFrameSet()) { + minLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMinimumShrinkFactor : pageWidth; + maxLayoutWidth = shrinkToFit ? pageWidth * _WebHTMLViewPrintingMaximumShrinkFactor : pageWidth; + } + [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES]; + + return YES; +} + +- (void)_endPrintMode +{ + [self _setPrinting:NO minimumPageWidth:0 maximumPageWidth:0 adjustViewSize:YES]; +} + +- (CGFloat)_adjustedBottomOfPageWithTop:(CGFloat)top bottom:(CGFloat)bottom limit:(CGFloat)bottomLimit +{ + Frame* frame = core([self _frame]); + if (!frame) + return bottom; + + FrameView* view = frame->view(); + if (!view) + return bottom; + + float newBottom; + view->adjustPageHeight(&newBottom, top, bottom, bottomLimit); + +#ifdef __LP64__ + // If the new bottom is equal to the old bottom (when both are treated as floats), we just return the original + // bottom. This prevents rounding errors that can occur when converting newBottom to a double. + if (fabs(static_cast<float>(bottom) - newBottom) <= numeric_limits<float>::epsilon()) + return bottom; + else +#endif + return newBottom; +} + @end @implementation NSView (WebHTMLViewFileInternal) @@ -2522,7 +2580,13 @@ WEBCORE_COMMAND(yankAndSelect) - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType { BOOL isSendTypeOK = !sendType || ([[self pasteboardTypesForSelection] containsObject:sendType] && [self _hasSelection]); - BOOL isReturnTypeOK = !returnType || ([[[self class] _insertablePasteboardTypes] containsObject:returnType] && [self _isEditable]); + BOOL isReturnTypeOK = NO; + if (!returnType) + isReturnTypeOK = YES; + else if ([[[self class] _insertablePasteboardTypes] containsObject:returnType] && [self _isEditable]) { + // We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts. + isReturnTypeOK = [returnType isEqualToString:NSStringPboardType] || [self _canEditRichly]; + } if (isSendTypeOK && isReturnTypeOK) return self; return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType]; @@ -3130,11 +3194,29 @@ WEBCORE_COMMAND(yankAndSelect) return [[self _webView] drawsBackground]; } +#if !LOG_DISABLED - (void)setNeedsDisplay:(BOOL)flag { LOG(View, "%@ setNeedsDisplay:%@", self, flag ? @"YES" : @"NO"); [super setNeedsDisplay:flag]; } +#endif + +#ifndef BUILDING_ON_TIGER +- (void)setNeedsDisplayInRect:(NSRect)invalidRect +{ + if (_private->inScrollPositionChanged) { + // When scrolling, the dirty regions are adjusted for the scroll only + // after NSViewBoundsDidChangeNotification is sent. Translate the invalid + // rect to pre-scrolled coordinates in order to get the right dirty region + // after adjustment. See <rdar://problem/7678927>. + NSPoint origin = [[self superview] bounds].origin; + invalidRect.origin.x -= _private->lastScrollPosition.x - origin.x; + invalidRect.origin.y -= _private->lastScrollPosition.y - origin.y; + } + [super setNeedsDisplayInRect:invalidRect]; +} +#endif - (void)setNeedsLayout: (BOOL)flag { @@ -3720,7 +3802,7 @@ static BOOL isInPasswordField(Frame* coreFrame) } } - if (printing != _private->printing) { + if (printing || _private->printing) { [_private->pageRects release]; _private->pageRects = nil; _private->printing = printing; @@ -3751,21 +3833,8 @@ static BOOL isInPasswordField(Frame* coreFrame) if (!wasInPrintingMode) [self _setPrinting:YES minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:NO]; - float newBottomFloat = *newBottom; - if (Frame* frame = core([self _frame])) { - if (FrameView* view = frame->view()) - view->adjustPageHeight(&newBottomFloat, oldTop, oldBottom, bottomLimit); - } + *newBottom = [self _adjustedBottomOfPageWithTop:oldTop bottom:oldBottom limit:bottomLimit]; -#ifdef __LP64__ - // If the new bottom is equal to the old bottom (when both are treated as floats), we just copy - // oldBottom over to newBottom. This prevents rounding errors that can occur when converting newBottomFloat to a double. - if (fabs((float)oldBottom - newBottomFloat) <= numeric_limits<float>::epsilon()) - *newBottom = oldBottom; - else -#endif - *newBottom = newBottomFloat; - if (!wasInPrintingMode) { NSPrintOperation *currenPrintOperation = [NSPrintOperation currentOperation]; if (currenPrintOperation) @@ -3777,12 +3846,6 @@ static BOOL isInPasswordField(Frame* coreFrame) } } -- (float)_availablePaperWidthForPrintOperation:(NSPrintOperation *)printOperation -{ - NSPrintInfo *printInfo = [printOperation printInfo]; - return [printInfo paperSize].width - [printInfo leftMargin] - [printInfo rightMargin]; -} - - (float)_scaleFactorForPrintOperation:(NSPrintOperation *)printOperation { float viewWidth = NSWidth([self bounds]); @@ -3792,8 +3855,8 @@ static BOOL isInPasswordField(Frame* coreFrame) } float userScaleFactor = [printOperation _web_pageSetupScaleFactor]; - float maxShrinkToFitScaleFactor = 1.0f / PrintingMaximumShrinkFactor; - float shrinkToFitScaleFactor = [self _availablePaperWidthForPrintOperation:printOperation]/viewWidth; + float maxShrinkToFitScaleFactor = 1.0f / _WebHTMLViewPrintingMaximumShrinkFactor; + float shrinkToFitScaleFactor = [printOperation _web_availablePaperWidth] / viewWidth; float shrinkToAvoidOrphan = _private->avoidingPrintOrphan ? (1.0f / PrintingOrphanShrinkAdjustment) : 1.0f; return userScaleFactor * max(maxShrinkToFitScaleFactor, shrinkToFitScaleFactor) * shrinkToAvoidOrphan; } @@ -3813,9 +3876,9 @@ static BOOL isInPasswordField(Frame* coreFrame) [self _setPrinting:YES minimumPageWidth:pageWidth maximumPageWidth:pageWidth adjustViewSize:YES]; } -- (void)_endPrintMode +- (void)_endPrintModeAndRestoreWindowAutodisplay { - [self _setPrinting:NO minimumPageWidth:0.0f maximumPageWidth:0.0f adjustViewSize:YES]; + [self _endPrintMode]; [[self window] setAutodisplay:YES]; } @@ -3841,7 +3904,7 @@ static BOOL isInPasswordField(Frame* coreFrame) // cancelled, beginDocument and endDocument must not have been called, and we need to clean up // the print mode here. ASSERT(currentOperation == nil); - [self _endPrintMode]; + [self _endPrintModeAndRestoreWindowAutodisplay]; } } @@ -3851,22 +3914,12 @@ static BOOL isInPasswordField(Frame* coreFrame) // Must do this explicit display here, because otherwise the view might redisplay while the print // sheet was up, using printer fonts (and looking different). [self displayIfNeeded]; - [[self window] setAutodisplay:NO]; - - // If we are a frameset just print with the layout we have onscreen, otherwise relayout - // according to the paper size - float minLayoutWidth = 0.0f; - float maxLayoutWidth = 0.0f; - Frame* frame = core([self _frame]); - if (!frame) - return NO; - if (!frame->document() || !frame->document()->isFrameSet()) { - float paperWidth = [self _availablePaperWidthForPrintOperation:[NSPrintOperation currentOperation]]; - minLayoutWidth = paperWidth * PrintingMinimumShrinkFactor; - maxLayoutWidth = paperWidth * PrintingMaximumShrinkFactor; - } - [self _setPrinting:YES minimumPageWidth:minLayoutWidth maximumPageWidth:maxLayoutWidth adjustViewSize:YES]; // will relayout + [[self window] setAutodisplay:NO]; + NSPrintOperation *printOperation = [NSPrintOperation currentOperation]; + if (![self _beginPrintModeWithPageWidth:[printOperation _web_availablePaperWidth] shrinkToFit:YES]) + return NO; + // Certain types of errors, including invalid page ranges, can cause beginDocument and // endDocument to be skipped after we've put ourselves in print mode (see 4145905). In those cases // we need to get out of print mode without relying on any more callbacks from the printing mechanism. @@ -3884,9 +3937,9 @@ static BOOL isInPasswordField(Frame* coreFrame) float totalScaleFactor = [self _scaleFactorForPrintOperation:printOperation]; float userScaleFactor = [printOperation _web_pageSetupScaleFactor]; [_private->pageRects release]; - float fullPageHeight = floorf([self _calculatePrintHeight]/totalScaleFactor); - NSArray *newPageRects = [[self _frame] _computePageRectsWithPrintWidthScaleFactor:userScaleFactor - printHeight:fullPageHeight]; + float fullPageHeight = floorf([printOperation _web_availablePaperHeight] / totalScaleFactor); + WebFrame *frame = [self _frame]; + NSArray *newPageRects = [frame _computePageRectsWithPrintWidthScaleFactor:userScaleFactor printHeight:fullPageHeight]; // AppKit gets all messed up if you give it a zero-length page count (see 3576334), so if we // hit that case we'll pass along a degenerate 1 pixel square to print. This will print @@ -3899,8 +3952,7 @@ static BOOL isInPasswordField(Frame* coreFrame) // content onto one fewer page. If it does, use the adjusted scale. If not, use the original scale. float lastPageHeight = NSHeight([[newPageRects lastObject] rectValue]); if (lastPageHeight/fullPageHeight < LastPrintedPageOrphanRatio) { - NSArray *adjustedPageRects = [[self _frame] _computePageRectsWithPrintWidthScaleFactor:userScaleFactor - printHeight:fullPageHeight*PrintingOrphanShrinkAdjustment]; + NSArray *adjustedPageRects = [frame _computePageRectsWithPrintWidthScaleFactor:userScaleFactor printHeight:fullPageHeight * PrintingOrphanShrinkAdjustment]; // Use the adjusted rects only if the page count went down if ([adjustedPageRects count] < [newPageRects count]) { newPageRects = adjustedPageRects; @@ -3940,7 +3992,7 @@ static BOOL isInPasswordField(Frame* coreFrame) } @catch (NSException *localException) { // Exception during [super beginDocument] means that endDocument will not get called, // so we need to clean up our "print mode" here. - [self _endPrintMode]; + [self _endPrintModeAndRestoreWindowAutodisplay]; } } @@ -3948,7 +4000,7 @@ static BOOL isInPasswordField(Frame* coreFrame) { [super endDocument]; // Note sadly at this point [NSGraphicsContext currentContextDrawingToScreen] is still NO - [self _endPrintMode]; + [self _endPrintModeAndRestoreWindowAutodisplay]; } - (void)keyDown:(NSEvent *)event @@ -4986,22 +5038,21 @@ static BOOL writingDirectionKeyBindingsEnabled() { // FIXME: NSTextView bails out if becoming or resigning first responder, for which it has ivar flags. Not // sure if we need to do something similar. - + if (![self _canEdit]) return; - + NSWindow *window = [self window]; // FIXME: is this first-responder check correct? What happens if a subframe is editable and is first responder? - if ([NSApp keyWindow] != window || [window firstResponder] != self) + if (![window isKeyWindow] || [window firstResponder] != self) return; - + bool multipleFonts = false; NSFont *font = nil; if (Frame* coreFrame = core([self _frame])) { if (const SimpleFontData* fd = coreFrame->editor()->fontForSelection(multipleFonts)) font = fd->getNSFont(); } - // FIXME: for now, return a bogus font that distinguishes the empty selection from the non-empty // selection. We should be able to remove this once the rest of this code works properly. diff --git a/WebKit/mac/WebView/WebHTMLViewPrivate.h b/WebKit/mac/WebView/WebHTMLViewPrivate.h index cb121d8..3beb0d6 100644 --- a/WebKit/mac/WebView/WebHTMLViewPrivate.h +++ b/WebKit/mac/WebView/WebHTMLViewPrivate.h @@ -32,6 +32,12 @@ #define ENABLE_NETSCAPE_PLUGIN_API 1 #endif +#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 +#define WebCGFloat float +#else +#define WebCGFloat CGFloat +#endif + @class DOMDocumentFragment; @class DOMNode; @class DOMRange; @@ -46,6 +52,9 @@ - (void)paintHighlightForBox:(NSRect)boxRect onLine:(NSRect)lineRect behindText:(BOOL)text entireLine:(BOOL)line; @end +extern const float _WebHTMLViewPrintingMinimumShrinkFactor; +extern const float _WebHTMLViewPrintingMaximumShrinkFactor; + @interface WebHTMLView (WebPrivate) + (NSArray *)supportedMIMETypes; @@ -124,7 +133,13 @@ // directly, this method must be called before paginating, or the computed height might be incorrect. // Typically this would be called from inside an override of -[NSView knowsPageRange:]. - (void)_layoutForPrinting; +- (WebCGFloat)_adjustedBottomOfPageWithTop:(WebCGFloat)top bottom:(WebCGFloat)bottom limit:(WebCGFloat)bottomLimit; +- (BOOL)_isInPrintMode; +- (BOOL)_beginPrintModeWithPageWidth:(float)pageWidth shrinkToFit:(BOOL)shrinkToFit; +- (void)_endPrintMode; - (BOOL)_canSmartReplaceWithPasteboard:(NSPasteboard *)pasteboard; @end + +#undef WebCGFloat diff --git a/WebKit/mac/WebView/WebPDFView.h b/WebKit/mac/WebView/WebPDFView.h index bdd2a6e..e480a1b 100644 --- a/WebKit/mac/WebView/WebPDFView.h +++ b/WebKit/mac/WebView/WebPDFView.h @@ -32,7 +32,7 @@ @class PDFView; @class WebDataSource; -@interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentIncrementalSearching, WebMultipleTextMatches, WebDocumentSelection, WebDocumentElement, _WebDocumentViewState, _WebDocumentZooming> +@interface WebPDFView : NSView <WebDocumentView, WebDocumentSearching, WebDocumentIncrementalSearching, WebMultipleTextMatches, WebDocumentSelection, WebDocumentElement, WebDocumentPDF, _WebDocumentViewState, _WebDocumentZooming> { NSView *previewView; PDFView *PDFSubview; @@ -51,5 +51,6 @@ + (NSBundle *)PDFKitBundle; - (void)setPDFDocument:(PDFDocument *)doc; +- (PDFDocument *)PDFDocument; @end diff --git a/WebKit/mac/WebView/WebPDFView.mm b/WebKit/mac/WebView/WebPDFView.mm index a38412e..1be3033 100644 --- a/WebKit/mac/WebView/WebPDFView.mm +++ b/WebKit/mac/WebView/WebPDFView.mm @@ -182,6 +182,11 @@ static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selec _ignoreScaleAndDisplayModeAndPageNotifications = NO; } +- (PDFDocument *)PDFDocument +{ + return [PDFSubview document]; +} + #pragma mark NSObject OVERRIDES - (void)dealloc diff --git a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h index 150a020..e74d0e5 100644 --- a/WebKit/mac/WebView/WebPreferenceKeysPrivate.h +++ b/WebKit/mac/WebView/WebPreferenceKeysPrivate.h @@ -91,7 +91,7 @@ #define WebKitWebGLEnabledPreferenceKey @"WebKitWebGLEnabled" #define WebKitUsesProxiedOpenPanelPreferenceKey @"WebKitUsesProxiedOpenPanel" #define WebKitPluginAllowedRunTimePreferenceKey @"WebKitPluginAllowedRunTime" -#define WebKitFrameSetFlatteningEnabledPreferenceKey @"WebKitFrameSetFlatteningEnabled" +#define WebKitFrameFlatteningEnabledPreferenceKey @"WebKitFrameFlatteningEnabled" // These are private both because callers should be using the cover methods and because the // cover methods themselves are private. diff --git a/WebKit/mac/WebView/WebPreferences.mm b/WebKit/mac/WebView/WebPreferences.mm index bd3c2a7..84a6e9e 100644 --- a/WebKit/mac/WebView/WebPreferences.mm +++ b/WebKit/mac/WebView/WebPreferences.mm @@ -357,7 +357,7 @@ static WebCacheModel cacheModelForMainBundle(void) [NSNumber numberWithBool:NO], WebKitWebGLEnabledPreferenceKey, [NSNumber numberWithBool:NO], WebKitUsesProxiedOpenPanelPreferenceKey, [NSNumber numberWithUnsignedInt:4], WebKitPluginAllowedRunTimePreferenceKey, - [NSNumber numberWithBool:NO], WebKitFrameSetFlatteningEnabledPreferenceKey, + [NSNumber numberWithBool:NO], WebKitFrameFlatteningEnabledPreferenceKey, nil]; // This value shouldn't ever change, which is assumed in the initialization of WebKitPDFDisplayModePreferenceKey above @@ -1216,14 +1216,14 @@ static NSString *classIBCreatorID = nil; return [self _setIntegerValue:allowedRunTime forKey:WebKitPluginAllowedRunTimePreferenceKey]; } -- (BOOL)isFrameSetFlatteningEnabled +- (BOOL)isFrameFlatteningEnabled { - return [self _boolValueForKey:WebKitFrameSetFlatteningEnabledPreferenceKey]; + return [self _boolValueForKey:WebKitFrameFlatteningEnabledPreferenceKey]; } -- (void)setFrameSetFlatteningEnabled:(BOOL)flag +- (void)setFrameFlatteningEnabled:(BOOL)flag { - [self _setBoolValue:flag forKey:WebKitFrameSetFlatteningEnabledPreferenceKey]; + [self _setBoolValue:flag forKey:WebKitFrameFlatteningEnabledPreferenceKey]; } - (void)didRemoveFromWebView diff --git a/WebKit/mac/WebView/WebPreferencesPrivate.h b/WebKit/mac/WebView/WebPreferencesPrivate.h index b516640..0b5f969 100644 --- a/WebKit/mac/WebView/WebPreferencesPrivate.h +++ b/WebKit/mac/WebView/WebPreferencesPrivate.h @@ -116,8 +116,8 @@ extern NSString *WebPreferencesRemovedNotification; - (unsigned)pluginAllowedRunTime; - (void)setPluginAllowedRunTime:(unsigned)allowedRunTime; -- (BOOL)isFrameSetFlatteningEnabled; -- (void)setFrameSetFlatteningEnabled:(BOOL)flag; +- (BOOL)isFrameFlatteningEnabled; +- (void)setFrameFlatteningEnabled:(BOOL)flag; // zero means do AutoScale - (float)PDFScaleFactor; diff --git a/WebKit/mac/WebView/WebRenderNode.mm b/WebKit/mac/WebView/WebRenderNode.mm index 4a839a5..eff1929 100644 --- a/WebKit/mac/WebView/WebRenderNode.mm +++ b/WebKit/mac/WebView/WebRenderNode.mm @@ -118,8 +118,15 @@ static WebRenderNode *copyRenderNode(RenderObject* node) IntRect box = text->linesBoundingBox(); width = box.width(); height = box.height(); + } else if (node->isRenderInline()) { + RenderBoxModelObject* inlineFlow = toRenderBoxModelObject(node); + IntRect boundingBox = inlineFlow->borderBoundingBox(); + x = boundingBox.x(); + y = boundingBox.y(); + width = boundingBox.width(); + height = boundingBox.height(); } - + WebRenderNode *result = [[WebRenderNode alloc] _initWithName:name position:absPos rect:NSMakeRect(x, y, width, height) coreFrame:frame children:children]; diff --git a/WebKit/mac/WebView/WebScriptDebugDelegate.mm b/WebKit/mac/WebView/WebScriptDebugDelegate.mm index 8489c9b..9ffd36e 100644 --- a/WebKit/mac/WebView/WebScriptDebugDelegate.mm +++ b/WebKit/mac/WebView/WebScriptDebugDelegate.mm @@ -242,14 +242,14 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber"; DynamicGlobalObjectScope globalObjectScope(globalObject->globalExec(), globalObject); JSValue exception; - JSValue result = evaluateInGlobalCallFrame(String(script), exception, globalObject); + JSValue result = evaluateInGlobalCallFrame(stringToUString(script), exception, globalObject); if (exception) return [self _convertValueToObjcValue:exception]; return result ? [self _convertValueToObjcValue:result] : nil; } JSValue exception; - JSValue result = _private->debuggerCallFrame->evaluate(String(script), exception); + JSValue result = _private->debuggerCallFrame->evaluate(stringToUString(script), exception); if (exception) return [self _convertValueToObjcValue:exception]; return result ? [self _convertValueToObjcValue:result] : nil; diff --git a/WebKit/mac/WebView/WebScriptDebugger.mm b/WebKit/mac/WebView/WebScriptDebugger.mm index a71d78b..c5e0ac8 100644 --- a/WebKit/mac/WebView/WebScriptDebugger.mm +++ b/WebKit/mac/WebView/WebScriptDebugger.mm @@ -69,7 +69,7 @@ static NSURL *toNSURL(const UString& s) { if (s.isEmpty()) return nil; - return KURL(ParsedURLString, s); + return KURL(ParsedURLString, ustringToString(s)); } static WebFrame *toWebFrame(JSGlobalObject* globalObject) diff --git a/WebKit/mac/WebView/WebScriptWorld.h b/WebKit/mac/WebView/WebScriptWorld.h index 7059b76..9a05f7f 100644 --- a/WebKit/mac/WebView/WebScriptWorld.h +++ b/WebKit/mac/WebView/WebScriptWorld.h @@ -36,4 +36,6 @@ typedef struct OpaqueJSContext* JSGlobalContextRef; + (WebScriptWorld *)scriptWorldForGlobalContext:(JSGlobalContextRef)globalContext; +- (void)unregisterWorld; + @end diff --git a/WebKit/mac/WebView/WebScriptWorld.mm b/WebKit/mac/WebView/WebScriptWorld.mm index 7dab1b3..8ca6f44 100644 --- a/WebKit/mac/WebView/WebScriptWorld.mm +++ b/WebKit/mac/WebView/WebScriptWorld.mm @@ -75,6 +75,11 @@ static WorldMap& allWorlds() return [self initWithWorld:ScriptController::createWorld()]; } +- (void)unregisterWorld +{ + _private->world->unregisterWorld(); +} + - (void)dealloc { ASSERT(allWorlds().contains(_private->world.get())); diff --git a/WebKit/mac/WebView/WebTextCompletionController.mm b/WebKit/mac/WebView/WebTextCompletionController.mm index 4f8e6e0..2421fd7 100644 --- a/WebKit/mac/WebView/WebTextCompletionController.mm +++ b/WebKit/mac/WebView/WebTextCompletionController.mm @@ -84,8 +84,7 @@ using namespace std; NSRect scrollFrame = NSMakeRect(0, 0, 100, 100); NSRect tableFrame = NSZeroRect; tableFrame.size = [NSScrollView contentSizeForFrameSize:scrollFrame.size hasHorizontalScroller:NO hasVerticalScroller:YES borderType:NSNoBorder]; - // Added cast to work around problem with multiple Foundation initWithIdentifier: methods with different parameter types. - NSTableColumn *column = [(NSTableColumn *)[NSTableColumn alloc] initWithIdentifier:[NSNumber numberWithInt:0]]; + NSTableColumn *column = [[NSTableColumn alloc] init]; [column setWidth:tableFrame.size.width]; [column setEditable:NO]; diff --git a/WebKit/mac/WebView/WebVideoFullscreenController.mm b/WebKit/mac/WebView/WebVideoFullscreenController.mm index e5fde5e..21e4814 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenController.mm +++ b/WebKit/mac/WebView/WebVideoFullscreenController.mm @@ -37,7 +37,7 @@ #import <wtf/UnusedParam.h> SOFT_LINK_FRAMEWORK(QTKit) -SOFT_LINK_CLASS(QTKit, QTMovieView) +SOFT_LINK_CLASS(QTKit, QTMovieLayer) SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) @@ -85,17 +85,20 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) - (void)windowDidLoad { +#ifdef BUILDING_ON_TIGER + // WebVideoFullscreenController is not supported on Tiger: + ASSERT_NOT_REACHED(); +#else WebVideoFullscreenWindow *window = [self fullscreenWindow]; - QTMovieView *view = [[getQTMovieViewClass() alloc] init]; - [view setFillColor:[NSColor clearColor]]; - [window setContentView:view]; - [view setControllerVisible:NO]; - [view setPreservesAspectRatio:YES]; + QTMovieLayer *layer = [[getQTMovieLayerClass() alloc] init]; + [[window contentView] setLayer:layer]; + [[window contentView] setWantsLayer:YES]; if (_mediaElement) - [view setMovie:_mediaElement->platformMedia().qtMovie]; + [layer setMovie:_mediaElement->platformMedia().qtMovie]; [window setHasShadow:YES]; // This is nicer with a shadow. [window setLevel:NSPopUpMenuWindowLevel-1]; - [view release]; + [layer release]; +#endif } - (WebCore::HTMLMediaElement*)mediaElement; @@ -105,19 +108,24 @@ SOFT_LINK_POINTER(QTKit, QTMovieRateDidChangeNotification, NSString *) - (void)setMediaElement:(WebCore::HTMLMediaElement*)mediaElement; { +#ifdef BUILDING_ON_TIGER + // WebVideoFullscreenController is not supported on Tiger: + ASSERT_NOT_REACHED(); +#else _mediaElement = mediaElement; if ([self isWindowLoaded]) { - QTMovieView *movieView = (QTMovieView *)[[self fullscreenWindow] contentView]; QTMovie *movie = _mediaElement->platformMedia().qtMovie; + QTMovieLayer *movieLayer = (QTMovieLayer *)[[[self fullscreenWindow] contentView] layer]; - ASSERT(movieView && [movieView isKindOfClass:[getQTMovieViewClass() class]]); + ASSERT(movieLayer && [movieLayer isKindOfClass:[getQTMovieLayerClass() class]]); ASSERT(movie); - [movieView setMovie:movie]; + [movieLayer setMovie:movie]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rateChanged:) name:QTMovieRateDidChangeNotification object:movie]; } +#endif } - (id <WebVideoFullscreenControllerDelegate>)delegate diff --git a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm index 83e2d09..1aa501e 100644 --- a/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm +++ b/WebKit/mac/WebView/WebVideoFullscreenHUDWindowController.mm @@ -346,9 +346,9 @@ static NSTextField *createTimeTextField(NSRect frame) static const CGFloat volumeButtonHeight = 16; static const CGFloat volumeUpButtonLeftMargin = 4; static const CGFloat volumeControlsTopMargin = 13; - static const CGFloat exitFullScreenButtonWidth = 25; - static const CGFloat exitFullScreenButtonHeight = 21; - static const CGFloat exitFullScreenButtonTopMargin = 11; + static const CGFloat exitFullscreenButtonWidth = 25; + static const CGFloat exitFullscreenButtonHeight = 21; + static const CGFloat exitFullscreenButtonTopMargin = 11; static const CGFloat timelineWidth = 315; static const CGFloat timelineHeight = 14; static const CGFloat timelineBottomMargin = 7; @@ -380,8 +380,8 @@ static NSTextField *createTimeTextField(NSRect frame) [_playButton setAction:@selector(togglePlaying:)]; [contentView addSubview:_playButton]; - CGFloat closeToRight = windowWidth - horizontalMargin - exitFullScreenButtonWidth; - NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullScreenButtonTopMargin - exitFullScreenButtonHeight, exitFullScreenButtonWidth, exitFullScreenButtonHeight)); + CGFloat closeToRight = windowWidth - horizontalMargin - exitFullscreenButtonWidth; + NSControl *exitFullscreenButton = createControlWithMediaUIControlType(WKMediaUIControlExitFullscreenButton, NSMakeRect(closeToRight, windowHeight - exitFullscreenButtonTopMargin - exitFullscreenButtonHeight, exitFullscreenButtonWidth, exitFullscreenButtonHeight)); [exitFullscreenButton setAction:@selector(exitFullscreen:)]; [exitFullscreenButton setTarget:self]; [contentView addSubview:exitFullscreenButton]; diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 44d4b58..b1b5c38 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -101,11 +101,15 @@ #import "WebVideoFullscreenController.h" #import <CoreFoundation/CFSet.h> #import <Foundation/NSURLConnection.h> +#import <JavaScriptCore/APICast.h> +#import <JavaScriptCore/JSValueRef.h> #import <WebCore/ApplicationCacheStorage.h> #import <WebCore/BackForwardList.h> #import <WebCore/Cache.h> #import <WebCore/ColorMac.h> +#import <WebCore/CSSComputedStyleDeclaration.h> #import <WebCore/Cursor.h> +#import <WebCore/Database.h> #import <WebCore/Document.h> #import <WebCore/DocumentLoader.h> #import <WebCore/DragController.h> @@ -123,6 +127,8 @@ #import <WebCore/HTMLNames.h> #import <WebCore/HistoryItem.h> #import <WebCore/IconDatabase.h> +#import <WebCore/JSCSSStyleDeclaration.h> +#import <WebCore/JSElement.h> #import <WebCore/Logging.h> #import <WebCore/MIMETypeRegistry.h> #import <WebCore/Page.h> @@ -558,6 +564,16 @@ static bool runningTigerMail() return NO; } +static bool coreVideoHas7228836Fix() +{ +#ifdef BUILDING_ON_LEOPARD + NSBundle* coreVideoFrameworkBundle = [NSBundle bundleWithPath:@"/System/Library/Frameworks/CoreVideo.framework"]; + double version = [[coreVideoFrameworkBundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey] doubleValue]; + return (version >= 48); +#endif + return true; +} + static bool shouldEnableLoadDeferring() { return !applicationIsAdobeInstaller(); @@ -964,8 +980,6 @@ static bool shouldEnableLoadDeferring() WTF::RefCountedLeakCounter::suppressMessages("At least one WebView was closed with fast teardown."); #endif - _private->closed = YES; - [[NSDistributedNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -998,6 +1012,8 @@ static bool fastDocumentTeardownEnabled() if (!_private || _private->closed) return; + _private->closed = YES; + [self _closingEventHandling]; #ifndef NDEBUG @@ -1031,9 +1047,6 @@ static bool fastDocumentTeardownEnabled() [_private->inspector webViewClosed]; - // setHostWindow:nil must be called before this value is set (see 5408186) - _private->closed = YES; - // To avoid leaks, call removeDragCaret in case it wasn't called after moveDragCaretToPoint. [self removeDragCaret]; @@ -1294,7 +1307,9 @@ static bool fastDocumentTeardownEnabled() settings->setMinimumFontSize([preferences minimumFontSize]); settings->setMinimumLogicalFontSize([preferences minimumLogicalFontSize]); settings->setPluginsEnabled([preferences arePlugInsEnabled]); - settings->setDatabasesEnabled([preferences databasesEnabled]); +#if ENABLE(DATABASE) + Database::setIsAvailable([preferences databasesEnabled]); +#endif settings->setLocalStorageEnabled([preferences localStorageEnabled]); settings->setExperimentalNotificationsEnabled([preferences experimentalNotificationsEnabled]); settings->setPrivateBrowsingEnabled([preferences privateBrowsingEnabled]); @@ -1329,16 +1344,19 @@ static bool fastDocumentTeardownEnabled() settings->setWebArchiveDebugModeEnabled([preferences webArchiveDebugModeEnabled]); settings->setLocalFileContentSniffingEnabled([preferences localFileContentSniffingEnabled]); settings->setOfflineWebApplicationCacheEnabled([preferences offlineWebApplicationCacheEnabled]); - settings->setZoomsTextOnly([preferences zoomsTextOnly]); + settings->setZoomMode([preferences zoomsTextOnly] ? ZoomTextOnly : ZoomPage); settings->setXSSAuditorEnabled([preferences isXSSAuditorEnabled]); settings->setEnforceCSSMIMETypeInStrictMode(!WKAppVersionCheckLessThan(@"com.apple.iWeb", -1, 2.1)); - settings->setAcceleratedCompositingEnabled([preferences acceleratedCompositingEnabled]); + + // FIXME: Enabling accelerated compositing when WebGL is enabled causes tests to fail on Leopard which expect HW compositing to be disabled. + // Until we fix that, I will comment out the test (CFM) + settings->setAcceleratedCompositingEnabled((coreVideoHas7228836Fix() || [preferences webGLEnabled]) && [preferences acceleratedCompositingEnabled]); settings->setShowDebugBorders([preferences showDebugBorders]); settings->setShowRepaintCounter([preferences showRepaintCounter]); settings->setPluginAllowedRunTime([preferences pluginAllowedRunTime]); settings->setWebGLEnabled([preferences webGLEnabled]); settings->setLoadDeferringEnabled(shouldEnableLoadDeferring()); - settings->setFrameSetFlatteningEnabled([preferences isFrameSetFlatteningEnabled]); + settings->setFrameFlatteningEnabled([preferences isFrameFlatteningEnabled]); } static inline IMP getMethod(id o, SEL s) @@ -2229,14 +2247,19 @@ static WebBaseNetscapePluginView *_pluginViewForNode(DOMNode *node) return _private ? _private->insertionPasteboard : nil; } -+ (void)_whiteListAccessFromOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains ++ (void)_addOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains { - SecurityOrigin::whiteListAccessFromOrigin(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); } -+(void)_resetOriginAccessWhiteLists ++ (void)_removeOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains { - SecurityOrigin::resetOriginAccessWhiteLists(); + SecurityOrigin::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); +} + ++(void)_resetOriginAccessWhitelists +{ + SecurityOrigin::resetOriginAccessWhitelists(); } - (void)_updateActiveState @@ -2378,6 +2401,11 @@ static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns) SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(forbidden, scheme); } ++ (void)_registerURLSchemeAsSecure:(NSString *)scheme +{ + SecurityOrigin::registerURLSchemeAsSecure(scheme); +} + @end @implementation _WebSafeForwarder @@ -3105,13 +3133,13 @@ static bool needsWebViewInitThreadWorkaround() _private->zoomMultiplier = m; ASSERT(_private->page); if (_private->page) - _private->page->settings()->setZoomsTextOnly(isTextOnly); + _private->page->settings()->setZoomMode(isTextOnly ? ZoomTextOnly : ZoomPage); // FIXME: it would be nice to rework this code so that _private->zoomMultiplier doesn't exist and callers // all access _private->page->settings(). Frame* coreFrame = [self _mainCoreFrame]; if (coreFrame) - coreFrame->setZoomFactor(m, isTextOnly); + coreFrame->setZoomFactor(m, isTextOnly ? ZoomTextOnly : ZoomPage); } - (float)_zoomMultiplier:(BOOL)isTextOnly @@ -3131,7 +3159,7 @@ static bool needsWebViewInitThreadWorkaround() if (!_private->page) return NO; - return _private->page->settings()->zoomsTextOnly(); + return _private->page->settings()->zoomMode() == ZoomTextOnly; } #define MinimumZoomMultiplier 0.5f @@ -3318,7 +3346,7 @@ static bool needsWebViewInitThreadWorkaround() - (void)setHostWindow:(NSWindow *)hostWindow { - if (_private->closed) + if (_private->closed && hostWindow) return; if (hostWindow == _private->hostWindow) return; @@ -4130,7 +4158,7 @@ static NSAppleEventDescriptor* aeDescFromJSValue(ExecState* exec, JSValue jsValu if (jsValue.isBoolean()) return [NSAppleEventDescriptor descriptorWithBoolean:jsValue.getBoolean()]; if (jsValue.isString()) - return [NSAppleEventDescriptor descriptorWithString:String(jsValue.getString(exec))]; + return [NSAppleEventDescriptor descriptorWithString:ustringToString(jsValue.getString(exec))]; if (jsValue.isNumber()) { double value = jsValue.uncheckedGetNumber(); int intValue = value; @@ -5681,6 +5709,25 @@ static void layerSyncRunLoopObserverCallBack(CFRunLoopObserverRef, CFRunLoopActi @end +@implementation WebView (WebViewPrivateStyleInfo) + +- (JSValueRef)_computedStyleIncludingVisitedInfo:(JSContextRef)context forElement:(JSValueRef)value +{ + JSLock lock(SilenceAssertionsOnly); + ExecState* exec = toJS(context); + if (!value) + return JSValueMakeUndefined(context); + JSValue jsValue = toJS(exec, value); + if (!jsValue.inherits(&JSElement::s_info)) + return JSValueMakeUndefined(context); + JSElement* jsElement = static_cast<JSElement*>(asObject(jsValue)); + Element* element = jsElement->impl(); + RefPtr<CSSComputedStyleDeclaration> style = computedStyle(element, true); + return toRef(exec, toJS(exec, jsElement->globalObject(), style.get())); +} + +@end + #ifdef BUILDING_ON_LEOPARD static IMP originalRecursivelyRemoveMailAttributesImp; diff --git a/WebKit/mac/WebView/WebViewData.mm b/WebKit/mac/WebView/WebViewData.mm index 21ba4c8..bf81dad 100644 --- a/WebKit/mac/WebView/WebViewData.mm +++ b/WebKit/mac/WebView/WebViewData.mm @@ -65,7 +65,11 @@ int pluginDatabaseClientCount = 0; dashboardBehaviorAllowWheelScrolling = YES; #endif - shouldCloseWithWindow = objc_collecting_enabled(); +#if !defined(BUILDING_ON_TIGER) + shouldCloseWithWindow = objc_collectingEnabled(); +#else + shouldCloseWithWindow = NO; +#endif smartInsertDeleteEnabled = ![[NSUserDefaults standardUserDefaults] objectForKey:WebSmartInsertDeleteEnabled] || [[NSUserDefaults standardUserDefaults] boolForKey:WebSmartInsertDeleteEnabled]; diff --git a/WebKit/mac/WebView/WebViewInternal.h b/WebKit/mac/WebView/WebViewInternal.h index 3f38d58..a2ce646 100644 --- a/WebKit/mac/WebView/WebViewInternal.h +++ b/WebKit/mac/WebView/WebViewInternal.h @@ -174,4 +174,6 @@ namespace WebCore { - (void)_exitFullscreen; #endif +- (JSValueRef)_computedStyleIncludingVisitedInfo:(JSContextRef)context forElement:(JSValueRef)value; + @end diff --git a/WebKit/mac/WebView/WebViewPrivate.h b/WebKit/mac/WebView/WebViewPrivate.h index b0a7039..327743a 100644 --- a/WebKit/mac/WebView/WebViewPrivate.h +++ b/WebKit/mac/WebView/WebViewPrivate.h @@ -489,10 +489,11 @@ Could be worth adding to the API. // - destinationProtocol: The protocol to grant access to. // - destinationHost: The host to grant access to. // - allowDestinationSubdomains: If host is a domain, setting this to YES will whitelist host and all its subdomains, recursively. -+ (void)_whiteListAccessFromOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains; ++ (void)_addOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains; ++ (void)_removeOriginAccessWhitelistEntryWithSourceOrigin:(NSString *)sourceOrigin destinationProtocol:(NSString *)destinationProtocol destinationHost:(NSString *)destinationHost allowDestinationSubdomains:(BOOL)allowDestinationSubdomains; -// Removes all white list entries created with _whiteListAccessFromOrigin. -+ (void)_resetOriginAccessWhiteLists; +// Removes all white list entries created with _addOriginAccessWhitelistEntryWithSourceOrigin. ++ (void)_resetOriginAccessWhitelists; + (void)_addUserScriptToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist injectionTime:(WebUserScriptInjectionTime)injectionTime; + (void)_addUserStyleSheetToGroup:(NSString *)groupName world:(WebScriptWorld *)world source:(NSString *)source url:(NSURL *)url whitelist:(NSArray *)whitelist blacklist:(NSArray *)blacklist; @@ -517,6 +518,7 @@ Could be worth adding to the API. - (void)setCSSAnimationsSuspended:(BOOL)suspended; + (void)_setDomainRelaxationForbidden:(BOOL)forbidden forURLScheme:(NSString *)scheme; ++ (void)_registerURLSchemeAsSecure:(NSString *)scheme; @end @@ -598,6 +600,10 @@ Could be worth adding to the API. - (void)_geolocationDidFailWithError:(NSError *)error; @end +@interface WebView (WebViewPrivateStyleInfo) +- (JSValueRef)_computedStyleIncludingVisitedInfo:(JSContextRef)context forElement:(JSValueRef)value; +@end + @interface NSObject (WebFrameLoadDelegatePrivate) - (void)webView:(WebView *)sender didFirstLayoutInFrame:(WebFrame *)frame; |