[iOS][WK2] Compute a good exposed rect when scaling WKContentView
https://bugs.webkit.org/show_bug.cgi?id=130761

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

Source/WebCore: 

* WebCore.exp.in:
* platform/ScrollView.h:
* platform/ios/ScrollViewIOS.mm:
(WebCore::ScrollView::setScrollVelocity):
(WebCore::ScrollView::computeCoverageRect):
While scaling in, do not add margins tiles. When scaling out, add 1 margin tile size
all around.

Source/WebKit2: 

Add a simple heuristic to improve tiling while zooming. In theory we could take the zoom
center and scaleRate to split the speed between scrolling and pinching. In practice,
zoom is transitory and is not as predictable as scrolling, so this patch just does a very
simple heuristic:
-When zooming in, do not expand coverage.
-When zooming out, add half a tile size on every side.

* Shared/VisibleContentRectUpdateInfo.cpp:
(WebKit::VisibleContentRectUpdateInfo::encode):
(WebKit::VisibleContentRectUpdateInfo::decode):
* Shared/VisibleContentRectUpdateInfo.h:
(WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
(WebKit::VisibleContentRectUpdateInfo::timestamp):
(WebKit::VisibleContentRectUpdateInfo::horizontalVelocity):
(WebKit::VisibleContentRectUpdateInfo::verticalVelocity):
(WebKit::VisibleContentRectUpdateInfo::scaleChangeRate):
* UIProcess/ios/WKContentView.mm:
(WebKit::HistoricalVelocityData::VelocityData::VelocityData):
(WebKit::HistoricalVelocityData::velocityForNewData):
(WebKit::HistoricalVelocityData::append):
(-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::adjustExposedRectForBoundedScale):
When zooming past the maximum size, adjust the exposed rect to continue tiling the area
at maximum size. Otherwise, we tile a tiny area, and have to retile larger when the animation
pull back the view to maximum scale.

(WebKit::adjustVelocityDataForBoundedScale):
Since we do not split the velocity from scrolling from the scaling, just clear the velocity when zooming.
Also clear the scaleChangeRate when the scale is out of bounds. There is no reason to add tiles for
temporary state.

(WebKit::WebPage::updateVisibleContentRects):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166380 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, rolling out r166364.
https://bugs.webkit.org/show_bug.cgi?id=130872

Caused a test assertion (Requested by smfr on #webkit).

Reverted changeset:

"Operator stretching: expose a math data API"
https://bugs.webkit.org/show_bug.cgi?id=130572
http://trac.webkit.org/changeset/166364

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WK2][iOS] <rdar://problem/16414684> WKWebView should draw a white background before the page loads
https://bugs.webkit.org/show_bug.cgi?id=130873

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

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView initWithFrame:configuration:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166382 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[CSS Shapes][css clip-path] rounded corner calculation for box shapes is wrong
https://bugs.webkit.org/show_bug.cgi?id=127982

Reviewed by Simon Fraser.

Source/WebCore:

Calculate rounded corners for box shapes as defined in the CSS Shapes
spec.

Tests: css3/masking/clip-path-border-radius-border-box-000.html
       css3/masking/clip-path-border-radius-content-box-000.html
       css3/masking/clip-path-border-radius-content-box-001.html
       css3/masking/clip-path-border-radius-padding-box-000.html
       css3/masking/clip-path-border-radius-padding-box-001.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-000.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-001.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-002.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-000.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-001.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-002.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-003.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-000.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-001.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-002.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-003.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-004.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-000.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-001.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-002.html
       fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-003.html

* platform/graphics/RoundedRect.h:
(WebCore::RoundedRect::Radii::transposedRadii): Transpose radii for
    vertical writing modes.
(WebCore::RoundedRect::moveBy): Add method for use with clip path.
(WebCore::RoundedRect::transposedRect): Transpose rect for vertical
    writing modes.
* rendering/RenderBox.h:
(WebCore::RenderBox::marginBoxRect): Return the margin box rect for
    the RenderBox.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::setupClipPath): Call the new function for the
    rounded corner calculation.
* rendering/shapes/ShapeInfo.cpp:
(WebCore::ShapeInfo<RenderType>::computedShape): Call the new function
    for the rounded corner calculation.
* rendering/shapes/BoxShape.cpp:
(WebCore::adjustRadiusForMarginBoxShape): Helper function for
    computeRoundedRectForLayoutBoxShape.
(WebCore::computeMarginBoxShapeRadius): Ditto.
(WebCore::computeMarginBoxShapeRadii): Ditto.
(WebCore::computeRoundedRectForBoxShape): Utility function to do the
    rounded corner calculation.
* rendering/shapes/BoxShape.h: Add new function.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::getRoundedInnerBorderFor): Add default argument
    values.

LayoutTests:

* css3/masking/clip-path-border-radius-border-box-000-expected.html: Added.
* css3/masking/clip-path-border-radius-border-box-000.html: Added.
* css3/masking/clip-path-border-radius-content-box-000-expected.html: Added.
* css3/masking/clip-path-border-radius-content-box-000.html: Added.
* css3/masking/clip-path-border-radius-content-box-001-expected.html: Added.
* css3/masking/clip-path-border-radius-content-box-001.html: Added.
* css3/masking/clip-path-border-radius-padding-box-000-expected.html: Added.
* css3/masking/clip-path-border-radius-padding-box-000.html: Added.
* css3/masking/clip-path-border-radius-padding-box-001-expected.html: Added.
* css3/masking/clip-path-border-radius-padding-box-001.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-000-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-000.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-001-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-001.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-002-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-border-box-002.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-000-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-000.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-001-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-001.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-002-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-002.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-003-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-content-box-003.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-000-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-000.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-001-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-001.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-002-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-002.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-003-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-003.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-004-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-margin-box-004.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-000-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-000.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-001-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-001.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-002-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-002.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-003-expected.html: Added.
* fast/shapes/shape-outside-floats/shape-outside-floats-border-radius-padding-box-003.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166383 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add support for AirPlay picker in WK2 for iOS.
https://bugs.webkit.org/show_bug.cgi?id=130855
<rdar://problem/15349859>

Source/WebCore: 

Reviewed by Eric Carlson, Joseph Pecoraro and Benjamin Poulain.

Adds support in HTMLMediaSession to display the airplay picker
and to monitor presence of available wireless targets.

* html/HTMLMediaSession.cpp:
(WebCore::HTMLMediaSession::showPlaybackTargetPicker):
(WebCore::HTMLMediaSession::hasWirelessPlaybackTargets):
(WebCore::HTMLMediaSession::setHasPlaybackTargetAvailabilityListeners):
* loader/EmptyClients.h:
* page/ChromeClient.h:
* platform/audio/MediaSessionManager.cpp:
(WebCore::MediaSessionManager::wirelessRoutesAvailableChanged):
* platform/audio/MediaSessionManager.h:
(WebCore::MediaSessionManager::hasWirelessTargetsAvailable):
(WebCore::MediaSessionManager::startMonitoringAirPlayRoutes):
(WebCore::MediaSessionManager::stopMonitoringAirPlayRoutes):
* platform/audio/ios/MediaSessionManagerIOS.h:
* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::hasWirelessTargetsAvailable):
(WebCore::MediaSessionManageriOS::startMonitoringAirPlayRoutes):
(WebCore::MediaSessionManageriOS::stopMonitoringAirPlayRoutes):
(-[WebMediaSessionHelper initWithCallback:]):
(-[WebMediaSessionHelper hasWirelessTargetsAvailable]):
(-[WebMediaSessionHelper startMonitoringAirPlayRoutes]):
(-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]):
(-[WebMediaSessionHelper wirelessRoutesAvailableDidChange:]):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::wirelessVideoPlaybackDisabled):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessVideoPlaybackDisabled):

Source/WebKit/ios: 

Reviewed by Eric Carlson, Joseph Pecoraro and Benjamin Poulain.

Adds stub for new WebKit chrome client method.

* WebCoreSupport/WebChromeClientIOS.h:
* WebCoreSupport/WebChromeClientIOS.mm:
(WebChromeClientIOS::showAirPlayRoutePicker):

Source/WebKit2: 

Reviewed by Joseph Pecoraro and Benjamin Poulain.

Adds support to display the airplay picker for iPhone and iPad
in WK2.
The picker on iPad is displayed next to the airplay button.

* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::showAirPlayRoutePicker):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _showAirPlayRoutePicker:fromRect:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::showAirPlayRoutePicker):
* UIProcess/ios/forms/WKAirPlayRoutePicker.h: Added.
* UIProcess/ios/forms/WKAirPlayRoutePicker.mm: Added.
(-[WKAirPlayRoutePicker initWithView:]):
(-[WKAirPlayRoutePicker dealloc]):
(-[WKAirPlayRoutePicker popoverControllerDidDismissPopover:]):
(-[WKAirPlayRoutePicker _presentAirPlayPopoverAnimated:fromRect:]):
(-[WKAirPlayRoutePicker _windowWillRotate:]):
(-[WKAirPlayRoutePicker _windowDidRotate:]):
(-[WKAirPlayRoutePicker _dismissAirPlayRoutePickerIPad]):
(-[WKAirPlayRoutePicker showAirPlayPickerIPad:fromRect:]):
(-[WKAirPlayRoutePicker showAirPlayPickerIPhone:]):
(-[WKAirPlayRoutePicker show:fromRect:]):
* WebKit2.xcodeproj/project.pbxproj:
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebCoreSupport/ios/WebChromeClientIOS.mm:
(WebKit::WebChromeClient::showAirPlayRoutePicker):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::touchEvent):
(WebKit::WebPage::touchEventSyncForTesting):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::rectForElementAtInteractionLocation):
(WebKit::WebPage::handleTap):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166384 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WebKit2] Share network process code between iOS and Mac
https://bugs.webkit.org/show_bug.cgi?id=130861

Reviewed by Sam Weinig.

Implement network process functions for iOS by moving common code from NetworkProcessMac.mm
to a new shared file NetworkProcessCocoa.mm and sharing between iOS and Mac.

* NetworkProcess/NetworkProcess.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm: Added.
(WebKit::NetworkProcess::platformLowMemoryHandler):
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
Common initialization code for iOS and Mac.
(WebKit::memorySize):
(WebKit::volumeFreeSize):
(WebKit::NetworkProcess::platformSetCacheModel):
* NetworkProcess/ios/NetworkProcessIOS.mm:
(WebKit::NetworkProcess::initializeProcess):
Remove unnecessary #if PLATFORM(IOS).
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
* NetworkProcess/mac/NetworkProcessMac.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcess):
* WebKit2.xcodeproj/project.pbxproj:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166385 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Switch the LLVMForJSC target to using the LLVM in /usr/local rather than /usr/local/LLVMForJavaScriptCore on iOS
https://bugs.webkit.org/show_bug.cgi?id=130867
<rdar://problem/16432456> 

Reviewed by Mark Hahnenberg.

Source/JavaScriptCore: 

* Configurations/Base.xcconfig:
* Configurations/LLVMForJSC.xcconfig:

Tools: 

* Scripts/build-webkit:
* Scripts/copy-webkitlibraries-to-product-directory:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166386 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS WebKit2] Don't pass disk cache directory path on iOS
https://bugs.webkit.org/show_bug.cgi?id=130862

Reviewed by Sam Weinig.

The diskPath passed to NSURLCache initializer is treated differently on Mac and iOS. Just
pass nil for now until we sort out the API.

* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Confirm composition in resignFirstResponder, don't cancel it
https://bugs.webkit.org/show_bug.cgi?id=130852

Reviewed by Darin Adler.

* UIProcess/API/mac/WKView.mm: (-[WKView resignFirstResponder]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, skip this test for now.

* tests/stress/recurse-infinitely-on-getter.js:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166389 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Revert http://trac.webkit.org/changeset/166386 because it broke builds.

Source/JavaScriptCore: 

* Configurations/Base.xcconfig:
* Configurations/LLVMForJSC.xcconfig:

Tools: 

* Scripts/build-webkit:
* Scripts/copy-webkitlibraries-to-product-directory:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166390 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Clean up unneeded "mutable" keyword
https://bugs.webkit.org/show_bug.cgi?id=130832

Reviewed by Andreas Kling.

As r166350, this patch cleans up unneeded "mutable" keywords.
Additionally, m_validatedSelectionCache is removed because it is not used anywhere else.

* css/CSSFontFaceRule.h:
* css/CSSStyleRule.h:
* editing/FrameSelection.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@166391 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Support spread operand in |new| expressions
https://bugs.webkit.org/show_bug.cgi?id=130877

Reviewed by Michael Saboff.

Source/JavaScriptCore:

Add support for the spread operator being applied in
|new| expressions.  This required adding support for
a new opcode, op_construct_varargs.  This is a relatively
simple refactoring of the call_varargs implementation.

* bytecode/BytecodeList.json:
* bytecode/BytecodeUseDef.h:
(JSC::computeUsesForBytecodeOffset):
(JSC::computeDefsForBytecodeOffset):
* bytecode/CallLinkInfo.cpp:
(JSC::CallLinkInfo::unlink):
* bytecode/CallLinkInfo.h:
(JSC::CallLinkInfo::callTypeFor):
(JSC::CallLinkInfo::specializationKind):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::dumpBytecode):
(JSC::CodeBlock::CodeBlock):
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::emitCallVarargs):
(JSC::BytecodeGenerator::emitConstructVarargs):
(JSC::BytecodeGenerator::emitConstruct):
* bytecompiler/BytecodeGenerator.h:
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
(JSC::JIT::privateCompileSlowCases):
* jit/JIT.h:
* jit/JITCall.cpp:
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):
(JSC::JIT::emit_op_construct_varargs):
(JSC::JIT::emitSlow_op_construct_varargs):
* jit/JITCall32_64.cpp:
(JSC::JIT::emitSlow_op_construct_varargs):
(JSC::JIT::emit_op_construct_varargs):
(JSC::JIT::compileOpCall):
(JSC::JIT::compileOpCallSlowCase):
* jit/JITOperations.cpp:
* llint/LLIntSlowPaths.cpp:
(JSC::LLInt::LLINT_SLOW_PATH_DECL):
* llint/LLIntSlowPaths.h:
* llint/LowLevelInterpreter.asm:
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseMemberExpression):

LayoutTests:

Correctness and performance tests for spread operands

* js/parser-syntax-check-expected.txt:
* js/regress/call-spread-expected.txt: Added.
* js/regress/call-spread.html: Added.
* js/regress/new-spread-expected.txt: Added.
* js/regress/new-spread.html: Added.
* js/regress/script-tests/call-spread.js: Added.
(testFunction):
(test2):
(test3):
* js/regress/script-tests/new-spread.js: Added.
(testFunction):
(test2):
(test3):
* js/script-tests/parser-syntax-check.js:

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