[Win] Extend AVFoundationCF Media Implementation
https://bugs.webkit.org/show_bug.cgi?id=137409

Reviewed by Eric Carlson.

This code is not yet being built and tested by our system. Appropriate
tests will be activated when we enable the build.

Most of this patch involves correcting some misuse of the AVFoundationCF API.
1. It is never appropriate in AVCF to pass a null CFErrorRef; instead you must
   pass a CFErrorRef with error type kCFURLErrorUnknown.
2. Because of the asynchronous way we handle the request/response, it is possible
   for AVCF to make two AVCF requests while negotiating the key exchange.

* platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h: Add
missing declaration.
* platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
(WebCore::CDMSessionAVFoundationCF::generateKeyRequest): Tighten up scope
of 'underlyingError'.
(WebCore::CDMSessionAVFoundationCF::update): Add call to complete the
loading process.
* platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
(WebCore::InbandTextTrackPrivateAVCF::label): Handle null titles CFArray
found during testing.
(WebCore::InbandTextTrackPrivateAVCF::language): Ditto for a null locale.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::registerMediaEngine): Add support
for the new 'supportsKeySystem' method.
(WebCore::MediaPlayerPrivateAVFoundationCF::createContextVideoRenderer): Add
assertion for mainThread.
(WebCore::MediaPlayerPrivateAVFoundationCF::destroyContextVideoRenderer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::createVideoLayer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::destroyVideoLayer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::createAVPlayer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::createAVPlayerItem): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::platformLayer): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::platformSetVisible): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::paintCurrentFrameInContext): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::paint): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationCF::supportsKeySystem): Added.
(WebCore::MediaPlayerPrivateAVFoundationCF::sizeChanged): Add assertion that this
is being called on the main thread.
(WebCore::MediaPlayerPrivateAVFoundationCF::processMediaSelectionOptions): Handle
the allows empty media selection properly based on test behavior.
(WebCore::AVFWrapper::AVFWrapper): Initialize resource loader callback structure
when building with AVFOUNDATION_LOADER_DELEGATE.
(WebCore::AVFWrapper::createAssetForURL): Use AVFWrapper's loader callback struct,
rather than passing the address of a temporary value.
(WebCore::AVFWrapper::processNotification): Stop using the deprecated 
'dispatch_get_current_queue' function.
(WebCore::AVFWrapper::processCue): Ditto.
(WebCore::AVFWrapper::legibleOutputCallback): Ditto.
(WebCore::AVFWrapper::processShouldWaitForLoadingOfResource): Pass a valid CFError
object; nullptr is not allowed as an argument to the "...FinishedLoadingWithError"
method.
(WebCore::AVFWrapper::shouldWaitForLoadingOfResource): Add support for multiple
in-flight requests.
(WebCore::AVFWrapper::platformLayer): Assert we are on the main thread.
(WebCore::AVFWrapper::setRequestForKey): Add support for multiple in-flight requests.
(WebCore::AVFWrapper::takeRequestForKeyURI): Ditto.
(WebCore::LayerClient::platformCALayerLayoutSublayersOfLayer): Ditto.
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
* platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp: Make sure we pass
valid CFError objects, rather than nullptr.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174346 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Win] Project file gardening.

* WebCore.vcxproj/WebCore.vcxproj.filters: Move EditorWin.cpp and
  MediatTimeAVFoundation to proper folder locations in project.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174347 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Win] Project file gardening.

* WTF.vcxproj/WTF.vcxproj.filters: Move HashMethod.h and
FastBitVector.cpp to proper places in hierarchy.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Windows] Skip remaining failing media tests after adding audio devices to the bots Part 2.
* platform/win/TestExpectations:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174349 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Win] Build fix aftr r174347.

* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: Use correct build
macro to prevent build break when ENCRYPTED_MEDIA_V2 is not enabled.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174350 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use is<>() / downcast<>() for ScrollingTree subclasses
https://bugs.webkit.org/show_bug.cgi?id=137449

Reviewed by Ryosuke Niwa.

Use is<>() / downcast<>() for ScrollingTree subclasses.

Source/WebCore:

No new tests, no behavior change.

* page/scrolling/ScrollingTree.h:
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/ios/ScrollingTreeIOS.h:
* page/scrolling/mac/ScrollingCoordinatorMac.mm:
(WebCore::ScrollingCoordinatorMac::handleWheelEvent):
(WebCore::ScrollingCoordinatorMac::commitTreeState):

Source/WebKit2:

* UIProcess/Scrolling/RemoteScrollingTree.h:
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::addScrollingTreeForPage):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174351 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed build fix after r174333.

Forgot explicit WebCore:: namespace.

* Misc/WebCache.mm:
(+[WebCache imageForURL:]):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174352 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Implement Page::isPlayingAudio().
https://bugs.webkit.org/show_bug.cgi?id=137218

Reviewed by Eric Carlson.

- Add a hasMediaCharacteristics() method to MediaSession. There are three characteristics:
audible, visual, and legible. MediaSession gets the media characteristics information from
its MediaSessionClient.
- Add a mediaStateDidChange() method to MediaSessionClient that MediaSession can call when its
state changes.
- Each Document keeps a set of MediaSessions it contains. When that set changes, or when a MediaSession
changes state, or when its characteristics change, Document::updateIsPlayingAudio() is called. That method
iterates through all its MediaSessions to check if the overall isPlayingAudio state has changed in the Document.
- Each Page caches its overall isPlayingAudio state. Whenever a Document's isPlayingAudio state changes,
it calls Page::updateIsPlayingAudio() which iterates through its frames' documents to calculate its
overall isPlayingAudio state.

No new tests, no behavior change.

* dom/Document.cpp:
(WebCore::Document::Document):
Initialize m_isPlayingAudio.
(WebCore::Document::registerMediaSession):
Add the MediaSession to m_mediaSessions. Call updateIsPlayingAudio().
(WebCore::Document::unregisterMediaSession):
Remove the MediaSession from m_mediaSessions. Call updateIsPlayingAudio().
(WebCore::Document::updateIsPlayingAudio):
Go through all the MediaSessions in this Document and check if any has the Audible characteristic
and is playing. If the overall isPlayingAudio state changes, call Page::updateIsPlayingAudio().
* dom/Document.h:
(WebCore::Document::isPlayingAudio):

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::registerWithDocument):
Call Document::registerMediaSession().
(WebCore::HTMLMediaElement::unregisterWithDocument):
Call Document::unregisterMediaSession().
(WebCore::HTMLMediaElement::mediaPlayerCharacteristicChanged):
Call Document::updateIsPlayingAudio().
(WebCore::HTMLMediaElement::stop):
Call MediaSession::clientWillPausePlayback() so the MediaSession's state can be set back to Paused.
(WebCore::HTMLMediaElement::hasMediaCharacteristics):
Call hasAudio() to check if the HTMLMediaElement has the Audible characteristic. Call hasVideo()
to check if it has the Visual characteristic. Call hasClosedCaptions() to check if it has the
Legible characteristic.
(WebCore::HTMLMediaElement::mediaStateDidChange):
Call Document::updateIsPlayingAudio().
* html/HTMLMediaElement.h:

* page/Page.cpp:
(WebCore::Page::Page):
Initialize m_isPlayingAudio.
(WebCore::Page::updateIsPlayingAudio):
Iterate through all its frames' documents to check if any has audio playing. If the overall isPlayingAudio
state has changed, update m_isPlayingAudio.
* page/Page.h:
(WebCore::Page::isPlayingAudio):

* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::setState):
If the MediaSession's state has changed, call Document::updateIsPlayingAudio().
(WebCore::MediaSession::hasMediaCharacteristics):
Call MediaSessionClient::hasMediaCharacteristics().
* platform/audio/MediaSession.h:
(WebCore::MediaSessionClient::mediaStateDidChange):

* platform/audio/mac/AudioDestinationMac.h:
AudioDestination only has the Audible characteristic.

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

* Misc/WebCache.mm:
(+[WebCache imageForURL:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174354 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix the iOS build after https://trac.webkit.org/changeset/174353.

* platform/audio/ios/AudioDestinationIOS.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174355 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Some compositing logic cleanup
https://bugs.webkit.org/show_bug.cgi?id=133060

Reviewed by Zalan Bujtas.

Move compositing-related code from RenderLayer::styleChanged() to
RenderLayerCompositor::layerStyleChanged(). Combine various tests
(many clip-related) for changes that require layer rebuilding into
styleChangeRequiresLayerRebuild().

Remove code that calls setBackingNeedsRepaint() after filters change
between being composited or not; I verified that existing "repaint after
style change" code takes care those repaints.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects):
(WebCore::RenderLayer::checkIfDescendantClippingContextNeedsUpdate): Deleted.
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::checkIfDescendantClippingContextNeedsUpdate):
(WebCore::styleChangeRequiresLayerRebuild):
(WebCore::RenderLayerCompositor::layerStyleChanged):
* rendering/RenderLayerCompositor.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
webkit-queues PatchLog is incorrect for patches that took less than a second
https://bugs.webkit.org/show_bug.cgi?id=137453

Reviewed by Tim Horton.

* QueueStatusServer/app.yaml: Updated app version.

* QueueStatusServer/loggers/recordpatchevent.py: (RecordPatchEvent.stopped):
Don't bail out for patches that took 0 seconds to process (as frequently happens
when a patch is obsolete).



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@174357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use is<>() / downcast<>() for CryptoKey subclasses
https://bugs.webkit.org/show_bug.cgi?id=137436

Reviewed by Ryosuke Niwa.

Use is<>() / downcast<>() for CryptoKey subclasses.

No new tests, no behavior change.

* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::addJWKAlgorithmToJSON):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
* crypto/CryptoKey.h:
* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmAES_CBC::encrypt):
(WebCore::CryptoAlgorithmAES_CBC::decrypt):
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmAES_KW::encryptForWrapKey):
(WebCore::CryptoAlgorithmAES_KW::decryptForUnwrapKey):
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmHMAC::sign):
(WebCore::CryptoAlgorithmHMAC::verify):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::encrypt):
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::sign):
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::verify):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::keyAlgorithmMatches):
(WebCore::CryptoAlgorithmRSA_OAEP::encrypt):
(WebCore::CryptoAlgorithmRSA_OAEP::decrypt):
* crypto/keys/CryptoKeyAES.h:
(WebCore::isCryptoKeyAES): Deleted.
* crypto/keys/CryptoKeyHMAC.h:
(WebCore::isCryptoKeyHMAC): Deleted.
* crypto/keys/CryptoKeyRSA.h:
(WebCore::isCryptoKeyRSA): Deleted.


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