[Win] Implement a page load profiling tool
https://bugs.webkit.org/show_bug.cgi?id=137673

Reviewed by Dean Jackson.

Source/WebKit/win:

Add a new predicate (isMainFrame) to the IWebFrame interface so
that we can make decisions about a frames position in the page
load hierarchy in client programs.

* Interfaces/IWebFrame.idl: Added new isMainFrame
predicate to interface definition.
* WebFrame.cpp:
(WebFrame::isMainFrame): Added.
* WebFrame.h:

Tools:

Add a tool to capture and summarize page load statistics.

* WinLauncher/Common.cpp:
(parseCommandLine): Move from WinMain.cpp so that it can
be shared with internal tools.
* WinLauncher/PageLoadTestClient.cpp: Added.
(PageLoadTestClient::PageLoadTestClient):
(PageLoadTestClient::pageLoadStartedAtTime):
(PageLoadTestClient::didStartProvisionalLoad):
(PageLoadTestClient::didCommitLoad):
(PageLoadTestClient::didFirstLayoutForMainFrame):
(PageLoadTestClient::didHandleOnLoadEvents):
(PageLoadTestClient::didFinishLoad):
(PageLoadTestClient::didFailLoad):
(PageLoadTestClient::didInitiateResourceLoad):
(PageLoadTestClient::didEndResourceLoad):
(PageLoadTestClient::pageLoadEndedAtTime):
(PageLoadTestClient::endPageLoad):
(PageLoadTestClient::clearPageLoadState):
(PageLoadTestClient::shouldConsiderPageLoadEnded):
(PageLoadTestClient::maybeEndPageLoadSoon):
(PageLoadTestClient::setPageURL):
(PageLoadTestClient::dumpRunStatistics):
* WinLauncher/PrintWebUIDelegate.cpp:
(PrintWebUIDelegate::createWebViewWithRequest): Handle
nullptr URL properly.
* WinLauncher/ResourceLoadDelegate.cpp: Added.
(ResourceLoadDelegate::QueryInterface):
(ResourceLoadDelegate::AddRef):
(ResourceLoadDelegate::Release):
(ResourceLoadDelegate::identifierForInitialRequest):
(ResourceLoadDelegate::willSendRequest):
(ResourceLoadDelegate::didReceiveAuthenticationChallenge):
(ResourceLoadDelegate::didCancelAuthenticationChallenge):
(ResourceLoadDelegate::didReceiveResponse):
(ResourceLoadDelegate::didReceiveContentLength):
(ResourceLoadDelegate::didFinishLoadingFromDataSource):
(ResourceLoadDelegate::didFailLoadingWithError):
(ResourceLoadDelegate::plugInFailedWithError):
* WinLauncher/ResourceLoadDelegate.h: Added.
(ResourceLoadDelegate::ResourceLoadDelegate):
* WinLauncher/WinLauncher.cpp:
(WinLauncher::WinLauncher): Accept argument to indicate we want to capture
page loading statistics.
(WinLauncher::setFrameLoadDelegatePrivate): Get rid of stub implementation
and set private load delegate state.
(WinLauncher::setResourceLoadDelegate): Replace stub with a full implementation
that sets the view's resource load delegate.
(WinLauncher::loadURL): If no URL is passed, load the test document.
* WinLauncher/WinLauncher.h:
(WinLauncher::pageLoadTestClient):
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj: Updated for new source files.
* WinLauncher/WinLauncher.vcxproj/WinLauncherLib.vcxproj.filters: Ditto.
* WinLauncher/WinLauncherWebHost.cpp:
(WinLauncherWebHost::updateAddressBar): Hook into page load statistics routine.
(WinLauncherWebHost::loadURL): Moved 'SendMessage' call to its own method so that
it could be used from other source files.
(WinLauncherWebHost::didFinishLoadForFrame): Added overload to capture statistics.
(WinLauncherWebHost::didStartProvisionalLoadForFrame): Ditto.
(WinLauncherWebHost::didFailLoadWithError): Ditto.
(WinLauncherWebHost::didHandleOnloadEventsForFrame): Ditto.
(WinLauncherWebHost::didFirstLayoutInFrame): Ditto.
(WinLauncherWebHost::didFinishDocumentLoadForFrame): Ditto.
(WinLauncherWebHost::didFirstVisuallyNonEmptyLayoutInFrame): Ditto.
(WinLauncherWebHost::didStartProvisionalLoadForFrame): Deleted.
* WinLauncher/WinLauncherWebHost.h:
* WinLauncher/WinMain.cpp:
(wWinMain): Create and use new delegates for gathering page load data.
* WinLauncher/stdafx.h: Need to add <wtf/Platform> include for various macros used in build.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Return value of createImageSourceOptions() is leaked in ImageSourceCG
https://bugs.webkit.org/show_bug.cgi?id=137677

Reviewed by Simon Fraser.

The return value of createImageSourceOptions() was leaked in
ImageSourceCG.cpp. It was returning a CFDictionaryRef created using
CFDictionaryCreate(). Therefore, the return value should have been
released but wasn't.

This patch makes createImageSourceOptions() return a
RetainPtr<CFDictionaryRef> to make sure the CFDictionaryRef properly
gets released after use.

No new tests, no behavior change.

* platform/graphics/cg/ImageSourceCG.cpp:
(WebCore::createImageSourceOptions):
(WebCore::imageSourceOptions):
(WebCore::ImageSource::isSizeAvailable):
(WebCore::ImageSource::allowSubsamplingOfFrameAtIndex):
(WebCore::ImageSource::frameSizeAtIndex):
(WebCore::ImageSource::orientationAtIndex):
(WebCore::ImageSource::getHotSpot):
(WebCore::ImageSource::repetitionCount):
(WebCore::ImageSource::createFrameAtIndex):
(WebCore::ImageSource::frameDurationAtIndex):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174665 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] Refactor AirPlay monitoring code
https://bugs.webkit.org/show_bug.cgi?id=137645
<rdar://problem/18444817>

Reviewed by Jer Noble.

Refactor AirPlay route change monitoring code:
+ Have MediaSessionManager register/unregister for route changes depending on the state of
    all sessions so it does the right thing when there is more than one media element.
+ Make HTMLMediaElement unregister with MediaSession as soon as the media player is cleared
    because there can be no wireless playback without a player.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::~HTMLMediaElement): Call mediaSession->setHasPlaybackTargetAvailabilityListeners
    when there are target availability changed listeners.
(WebCore::HTMLMediaElement::clearMediaPlayer): Ditto.
(WebCore::HTMLMediaElement::wirelessRoutesAvailableDidChange): New, media session client method.
* html/HTMLMediaElement.h:

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::HTMLMediaSession): Initialize m_hasPlaybackTargetAvailabilityListeners.
(WebCore::HTMLMediaSession::setHasPlaybackTargetAvailabilityListeners): Remember whether or not
    the client has a target availability listener and tell the media session manager to reconfigure
    itself instead of telling it to start or stop listening for route changes so it does the
    right thing when there is more than one media element.
* html/HTMLMediaSession.h:
(WebCore::HTMLMediaSession::requiresPlaybackTargetRouteMonitoring): Return true when the client
    has a target availability listener, false otherwise.

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::wirelessRoutesAvailableDidChange): Inform the client that routes have changed.
* platform/audio/MediaSession.h:
(WebCore::MediaSession::requiresPlaybackTargetRouteMonitoring):
(WebCore::MediaSessionClient::wirelessRoutesAvailableDidChange):

* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::wirelessRoutesAvailableChanged): Implement it.
* platform/audio/MediaSessionManager.h:
(WebCore::MediaSessionManager::configureWireLessTargetMonitoring):
(WebCore::MediaSessionManager::hasWirelessTargetsAvailable):
(WebCore::MediaSessionManager::sessions):
(WebCore::MediaSessionManager::startMonitoringAirPlayRoutes): Deleted.
(WebCore::MediaSessionManager::stopMonitoringAirPlayRoutes): Deleted.

* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Start or stop monitoring
    for route changes depending on client state.
(WebCore::MediaSessionManageriOS::startMonitoringAirPlayRoutes): Deleted.
(WebCore::MediaSessionManageriOS::stopMonitoringAirPlayRoutes): Deleted.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174666 268f45cc-cd09-0410-ab3c-d52691b4dbfc