Remove MediaSessionClient::hasMediaCharacteristics() and MediaSessionClient::mediaStateDidChange().
https://bugs.webkit.org/show_bug.cgi?id=138153

Reviewed by Jer Noble.

After http://trac.webkit.org/changeset/175273, Document no longer keeps a set of MediaSessions
and it doesn't need to query each MediaSession for its characteristics and play state.
MediaSessionClient::hasMediaCharacteristics() is no longer needed and MediaSessionClient::mediaStateDidChange()
can be removed if HTMLMediaElement calls Document::updateIsPlayingAudio() after m_playing has changed.

No new tests, no behavior change.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::updatePlayState):
Call setPlaying() rather than setting m_playing directly.
(WebCore::HTMLMediaElement::setPlaying):
Update m_playing. If it has changed, call Document::updateIsPlayingAudio().
(WebCore::HTMLMediaElement::setPausedInternal):
Call setPlaying() rather than setting m_playing directly.
(WebCore::HTMLMediaElement::isPlayingAudio):
Call isPlaying() directly rather than checking the MediaSession's state.
* html/HTMLMediaElement.h:
* platform/audio/MediaSession.cpp:
(WebCore::MediaSession::setState):
MediaSessionClient::mediaStateDidChange() has been removed.
(WebCore::MediaSession::hasMediaCharacteristics): Deleted.
* platform/audio/MediaSession.h:
(WebCore::MediaSessionClient::mediaStateDidChange): Deleted.
* platform/audio/ios/AudioDestinationIOS.h:
* platform/audio/mac/AudioDestinationMac.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175330 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EME][Mac] MediaKeySession type "keyrelease" is ignored.
https://bugs.webkit.org/show_bug.cgi?id=138175

Reviewed by Eric Carlson.

To indicate that they would like to recevie expired session confirmation messages, clients
will create a MediaKeySession with a type parameter of "keyrelease". The code which validates
this type needs to be updated to recognize "keyrelease" as a valid type.

Also, the code which validates update() requests needs to allow updates containing the string
"acknowledged", so that clients can request the confirmation messages be discarded.

* platform/graphics/avfoundation/CDMPrivateMediaSourceAVFObjC.mm:
(WebCore::CDMPrivateMediaSourceAVFObjC::supportsMIMEType):
* platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
(WebCore::CDMSessionMediaSourceAVFObjC::update):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EME] MediaKeySession resources persist across page reloads
https://bugs.webkit.org/show_bug.cgi?id=138176

Reviewed by Eric Carlson.

MediaKeySession is an ActiveDOMObject, so when told to stop() by our execution context,
close() the session, releasing all our resources.

* Modules/encryptedmedia/MediaKeySession.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175332 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[EME] NULL-dereference crash in MediaKeys::setMediaElement().
https://bugs.webkit.org/show_bug.cgi?id=138177

Reviewed by Eric Carlson.

NULL-check m_mediaElement->player() before using. It may have been cleared if the HTMLMediaElement
has previously had stop() called.

* Modules/encryptedmedia/MediaKeys.cpp:
(WebCore::MediaKeys::setMediaElement):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] iPad: Occasional <select> crashes attempting to scroll to non-existing row 0 in viewWillAppear
https://bugs.webkit.org/show_bug.cgi?id=138165

Reviewed by David Kilzer.

This is a speculative fix for a crash attempting to scroll to a row in a
select picker on iPad. In these cases we are trying to scroll to the first
row of the first section, but no such row appears to exist. I was unable
to reproduce the issue, but if it is happening we should be able to protect
safely protect against crashing.

* UIProcess/ios/forms/WKFormSelectPopover.mm:
(-[WKSelectTableViewController viewWillAppear:]):
Protect against trying to scroll to a section/row that does not exist
by pre-checking that the section/row is valid.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175334 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Implement action menus for data detected items
https://bugs.webkit.org/show_bug.cgi?id=138178
<rdar://problem/18709436>

Reviewed by Anders Carlsson.

* WebCore.exp.in:
Export a symbol from Position that we need.

* WebCore.xcodeproj/project.pbxproj:
* platform/spi/mac/DataDetectorsSPI.h:
Add a combined SPI header for all of the random bits of DataDetectors that we use.

* Shared/API/c/WKActionMenuTypes.h:
Add a new type.

* Shared/WebHitTestResult.cpp:
(WebKit::WebHitTestResult::Data::Data):
(WebKit::WebHitTestResult::Data::encode):
(WebKit::WebHitTestResult::Data::decode):
* Shared/WebHitTestResult.h:
(WebKit::WebHitTestResult::isTextNode):
Determine, store, encode, and decode whether or not the hit node is a text node.

* Shared/mac/ActionMenuHitTestResult.h:
* Shared/mac/ActionMenuHitTestResult.mm: Renamed from Source/WebKit2/Shared/mac/ActionMenuHitTestResult.cpp.
(WebKit::ActionMenuHitTestResult::encode):
(WebKit::ActionMenuHitTestResult::decode):
Make ActionMenuHitTestResult an Obj-C++ file.
Store, encode, and decode (securely!) a DDActionContext and FloatRect
representing the bounding box of the data detected item, if any.

* UIProcess/API/mac/WKView.mm:
(-[WKView initWithFrame:context:configuration:webView:]):
(-[WKView willOpenMenu:withEvent:]): Deleted.
Stop using willOpenMenu; we'll use NSMenuDelegate's menuNeedsUpdate: instead.
Hook up WKActionMenuController as our action menu's delegate.

* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController prepareForMenu:withEvent:]):
Call _updateActionMenuItems *after* we've adjusted _state, so that it
can depend on the value being correct.

(-[WKActionMenuController willOpenMenu:withEvent:]):
(-[WKActionMenuController didPerformActionMenuHitTest:]):
Move menu updating to menuNeedsUpdate for more accurate timing.

(_updateActionMenuItems):
When building the menu, if we have a text node that is not a link,
and hit a data detected item, retrieve the menu from the DDActionContext.
If we have nothing, make sure to reset _type, and if the final hit-test
is still pending, build a menu with a dummy item.

* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::performActionMenuHitTestAtLocation): Moved to WebPageMac.
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::rangeExpandedAroundPosition):
Factor this out of performDictionaryLookupAtLocation.

(WebKit::WebPage::performDictionaryLookupAtLocation):
Make use of rangeExpandedAroundPosition.

(WebKit::scanForDataDetectedItems):
Expand to four lines of context around the hit point.
Convert that range to plain text, and feed it to DataDetectors.
Find the result that intersects the hit point, and make a DDActionContext
for it. Also, store the bounding box of the first quad of the detected
text, to provide to Data Detectors as a hint for UI placement.

(WebKit::WebPage::performActionMenuHitTestAtLocation):
If the hit node is a text node, call scanForDataDetectedItems and
store the resultant DDActionContext and bounding rect on our
ActionMenuHitTestResult for transfer to the UI process.

* WebKitSystemInterface.h:
* libWebKitSystemInterfaceMavericks.a:
* libWebKitSystemInterfaceMountainLion.a:
* libWebKitSystemInterfaceYosemite.a:
Update WebKitSystemInterface.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add API to mute/unmute a page.
https://bugs.webkit.org/show_bug.cgi?id=138150

Reviewed by Eric Carlson.

No new tests, since it's difficult to test whether the Page has indeed been muted.

* dom/Document.cpp:
(WebCore::Document::setMuted):
Go through each AudioProducer and call setMuted() on it.
* dom/Document.h:
* page/AudioProducer.h:
Add setMuted(bool). HTMLMediaElement, the only derived class of AudioProducer so far,
has already implemented setMuted().
* page/Page.cpp:
(WebCore::Page::setMuted):
Go through all its frames and call setMuted() on each frame's Document.
* page/Page.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@175336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Rename WebPageProxy::activeActionMenuHitTestResult to lastMouseMoveHitTestResult
https://bugs.webkit.org/show_bug.cgi?id=138137
<rdar://problem/18798257>

Reviewed by Anders Carlsson.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::mouseDidMoveOverElement):
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::lastMouseMoveHitTestResult):
(WebKit::WebPageProxy::activeActionMenuHitTestResult): Deleted.
* UIProcess/mac/WKActionMenuController.mm:
(-[WKActionMenuController _defaultMenuItemsForLink]):
(-[WKActionMenuController _openURLFromActionMenu:]):
(-[WKActionMenuController _addToReadingListFromActionMenu:]):
(-[WKActionMenuController _quickLookURLFromActionMenu:]):
(-[WKActionMenuController _saveImageToDownloads:]):
(imageForResource:name::if):
(-[WKActionMenuController _updateActionMenuItems]):
Rename to the more accurate and general name.


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