Crash when going into video fullscreen on iOS
https://bugs.webkit.org/show_bug.cgi?id=129613

Reviewed by Dean Jackson.

We shouldn't reparent a UIView's layer without unparenting
the view first.

* UIProcess/ios/WebVideoFullscreenManagerProxy.mm:
(WebKit::WebVideoFullscreenManagerProxy::setVideoLayerID):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Shapes] Serialize circle positions
https://bugs.webkit.org/show_bug.cgi?id=129404

Reviewed by Dirk Schulze.

Source/WebCore:

Circle positions should always be present when serialized, and should
only have the 2 or 4-valued form. Keywords are converted to percentages
and simplified where possible. This patch adds some additional processing
that converts the parsed position into the serialized format, before
converting it to text. See http://dev.w3.org/csswg/css-shapes/#basic-shape-serialization.

Updated existing parsing tests.

* css/CSSBasicShapes.cpp:
(WebCore::serializePositionOffset): Convert a position offset to a serialized string.
The offset must be a pair, as generated by buildSerializablePositionOffset.
(WebCore::buildSerializablePositionOffset): Generates a keyword + offset pair for each
position offset. The keywords may later be dropped during serialization.
(WebCore::CSSBasicShapeCircle::cssText): Use the new serialization methods.

LayoutTests:

Modify each circle test to have a correctly serialized position.

* fast/masking/parsing-clip-path-shape-expected.html: Updated result.
* fast/masking/parsing-clip-path-shape.html: Updated test.
* fast/shapes/parsing/parsing-shape-inside-expected.txt: Updated results.
* fast/shapes/parsing/parsing-shape-outside-expected.txt: Updated results.
* fast/shapes/parsing/parsing-test-utils.js: Updated serialization results.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[MSE] YouTube videos fail to play
https://bugs.webkit.org/show_bug.cgi?id=129525

Reviewed by Darin Adler.

Source/WebCore:

Test: media/media-source/media-source-fudge-factor.html

Add a very simple playability metric to SourceBuffer. Track the number of seconds buffered
and use that metric to determine whether the MediaSource has buffered enough data to play
through.

* Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::currentTime): Added simple accessor.
(WebCore::MediaSource::monitorSourceBuffers): Replace the functor-based iterators with lambdas.
(WebCore::MediaSource::addSourceBuffer): Drive-by fix; only add new source buffers to the
    activeSourceBuffers list if those buffers are actually active.
* Modules/mediasource/MediaSource.h:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::SourceBuffer): Initialize new ivars.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Measure the number of seconds buffered.
(WebCore::SourceBuffer::monitorBufferingRate): Use a simple Exponential moving average to
    track the buffering rate.
(WebCore::SourceBuffer::hasCurrentTime): Return true if the current time is within 1/24 s
    of a buffered range.
(WebCore::SourceBuffer::hasFutureTime): Moved from MediaSource.
(WebCore::SourceBuffer::canPlayThrough): Return true if the buffering rate is > 1s per
    second, or if the rate is sufficient to keep up over the remaining time.
* Modules/mediasource/SourceBuffer.h:

LayoutTests:

* media/media-source/media-source-addsourcebuffer.html: Updated.
* media/media-source/media-source-addsourcebuffer-expected.txt: Updated.
* media/media-source/media-source-fudge-factor-expected.txt: Added.
* media/media-source/media-source-fudge-factor.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@164999 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Crash in MediaPlayer::rateChanged()
https://bugs.webkit.org/show_bug.cgi?id=129548

Reviewed by Darin Adler.

WTF::bind will automatically ref the parameters added to it. But MediaPlayerPrivate-
AVFoundation and -MediaSOurceAVFObjC are not RefCounted, so by the time the bound
function is called, the underlying objects may have been freed.

Replace or augment callOnMainThread arguments with lambdas and weakPtrs so that
if the argument has been destroyed, its methods will not be called.

Make the MediaPlayerPrivateAVFoundation::Notification function type a std::function:
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
(WebCore::MediaPlayerPrivateAVFoundation::Notification::Notification):
(WebCore::MediaPlayerPrivateAVFoundation::Notification::function):

Make createWeakPtr() public so that it can be called from non-class methods:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createWeakPtr):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::createWeakPtr):

Use a weakPtr to abort callOnMainThread() if the object has been destroyed:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::CMTimebaseEffectiveRateChangedCallback):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::play):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::pause):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165000 268f45cc-cd09-0410-ab3c-d52691b4dbfc
SelectorQuery failing RightMostWithIdMatch are compiling their selectors for each execution
https://bugs.webkit.org/show_bug.cgi?id=129601

Reviewed by Andreas Kling.

This caused a regression after r164924 for documents in quirks mode. Since those always fail
selectorForIdLookup(), they ended up compiling the selector every time they were called.

* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165001 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Find results on simple lines are not marked correctly
https://bugs.webkit.org/show_bug.cgi?id=129586

Reviewed by Andreas Kling.

Source/WebCore: 

Tests: editing/text-iterator/count-mark-lineboxes.html
       editing/text-iterator/count-mark-simple-lines.html
               
TextIterator operating on simple lines failed to take the end of the range into account.
This also causes performance issues on long documents as range traversals would miss the end
node and end up going through the entire document.

* editing/TextIterator.cpp:
(WebCore::TextIterator::handleTextNode):
        
    Stop when hitting the range end on simple text nodes.

(WebCore::SimplifiedBackwardsTextIterator::handleTextNode):
        
    Use hasRenderedText test instead of linebox-only firstTextBox.

* testing/Internals.cpp:
(WebCore::Internals::countMatchesForText):
* testing/Internals.h:
* testing/Internals.idl:
        
    Add testing interface for counting and marking matches.

LayoutTests: 

* editing/text-iterator/count-mark-lineboxes-expected.txt: Added.
* editing/text-iterator/count-mark-lineboxes.html: Added.
* editing/text-iterator/count-mark-simple-lines-expected.txt: Added.
* editing/text-iterator/count-mark-simple-lines.html: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165002 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Regression: ScrollView's scroll offset is never set after r164702
https://bugs.webkit.org/show_bug.cgi?id=129620

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-03-03
Reviewed by Simon Fraser.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::updateVisibleContentRects):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@165003 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Inspector test dom/dom-search-crash.html times out in release builds
https://bugs.webkit.org/show_bug.cgi?id=129462

Reviewed by Timothy Hatcher.

This test passes now, so stop skipping it.

* TestExpectations:


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