[wk2] Synchronously wait a short time for a layer tree update after bringing a web view in-window
https://bugs.webkit.org/show_bug.cgi?id=134189

Reviewed by Simon Fraser.

Make the old behavior of -[WKView endDeferringViewInWindowChangesSync] the default; synchronously wait
for a fraction of a second when a page that was previously in-window but currently isn't comes back in-window,
until new content is painted (or we hit a timeout).

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::waitForDidUpdateViewState):
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::waitForDidUpdateViewState):
Delegate waitForDidUpdateViewState to the DrawingAreaProxys, because behavior is very dependent on them.

* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::coreAnimationDidCommitLayers):
(WebKit::RemoteLayerTreeDrawingAreaProxy::waitForDidUpdateViewState):
Implement waitForDidUpdateViewState for the RemoteLayerTree; it waits for CommitLayerTree.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy):
(WebKit::WebPageProxy::updateViewState):
(WebKit::WebPageProxy::viewStateDidChange):
(WebKit::WebPageProxy::dispatchViewStateChange):
(WebKit::WebPageProxy::waitForDidUpdateViewState):
(WebKit::WebPageProxy::resetStateAfterProcessExited):
(WebKit::WebPageProxy::viewSize): Deleted.
* UIProcess/WebPageProxy.h:
(WebKit::WebPageProxy::didUpdateViewState):
* UIProcess/API/mac/WKView.mm:
(-[WKView endDeferringViewInWindowChangesSync]):
Always waitForDidUpdateViewState when a page that was previously in-window but currently isn't comes back in-window.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::viewStateDidChange):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setViewState):
(WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::flushLayers):
(WebKit::RemoteLayerTreeDrawingArea::viewStateDidChange):
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
(WebKit::TiledCoreAnimationDrawingArea::viewStateDidChange):
(WebKit::TiledCoreAnimationDrawingArea::didUpdateViewStateTimerFired):
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::didUpdateViewStateTimerFired): Deleted.
Delegate sending of didUpdateViewState to the DrawingAreas (RemoteLayerTreeDrawingArea won't send it,
    because the UI process waits for CommitLayerTree instead).


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170319 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Cocoa] No way to grant storage quotas for web application cache
https://bugs.webkit.org/show_bug.cgi?id=134213

Reviewed by Anders Carlsson.

* UIProcess/API/APIUIClient.h:
(API::UIClient::reachedApplicationCacheOriginQuota): Added this new client function, with
a default implementation that calls the completion handler with the current quota.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Declared a new delegate method.

* UIProcess/API/Cocoa/_WKSecurityOrigin.mm:
(-[_WKSecurityOrigin _initWithSecurityOrigin:WebCore::]): Changed the parameter into a const
reference, since we copy it.
* UIProcess/API/Cocoa/_WKSecurityOriginInternal.h:

* UIProcess/Cocoa/UIDelegate.h: Override API::UIClient::reachedApplicationCacheOriginQuota.
Added flag to m_delegateMethods struct for new delegate method.
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate): Set new flag in m_delegateMethods struct.
(WebKit::UIDelegate::UIClient::exceededDatabaseQuota): Updated for change in
_WKSecurityOrigin initializer.
(WebKit::UIDelegate::UIClient::reachedApplicationCacheOriginQuota): Added. Calls the new
delegate method.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::reachedApplicationCacheOriginQuota): Added. Forwards the message to
the UI client.
* UIProcess/WebPageProxy.h:

* UIProcess/WebPageProxy.messages.in: Added ReachedApplicationCacheOriginQuota message.

* WebProcess/InjectedBundle/API/APIInjectedBundlePageUIClient.h:
(API::InjectedBundle::PageUIClient::didReachApplicationCacheOriginQuota): Changed the return
type to bool, indicating whether the client handled the callback.

* WebProcess/InjectedBundle/InjectedBundlePageUIClient.cpp:
(WebKit::InjectedBundlePageUIClient::didReachApplicationCacheOriginQuota): Return the
appropriate value.
* WebProcess/InjectedBundle/InjectedBundlePageUIClient.h:

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::reachedApplicationCacheOriginQuota): If the bundle client didn’t
handle the callback, send a message the the UI process, and update the quota with the reply.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170320 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Don't use the WK prefix for internal C++ types
https://bugs.webkit.org/show_bug.cgi?id=134214

Reviewed by Dan Bernstein.

* Shared/AssistedNodeInformation.cpp:
(WebKit::OptionItem::encode):
(WebKit::OptionItem::decode):
(WebKit::WKOptionItem::encode): Deleted.
(WebKit::WKOptionItem::decode): Deleted.
* Shared/AssistedNodeInformation.h:
(WebKit::OptionItem::OptionItem):
(WebKit::AssistedNodeInformation::AssistedNodeInformation):
(WebKit::WKOptionItem::WKOptionItem): Deleted.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _requiresKeyboardWhenFirstResponder]):
(-[WKContentView inputView]):
(-[WKContentView requiresAccessoryView]):
(-[WKContentView _updateAccessory]):
(-[WKContentView textInputTraits]):
(-[WKContentView assistedNodeSelectOptions]):
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
(-[WKContentView _stopAssistingNode]):
* UIProcess/ios/forms/WKFormInputControl.mm:
(-[WKDateTimePicker initWithView:datePickerMode:]):
(-[WKFormInputControl initWithView:]):
* UIProcess/ios/forms/WKFormSelectControl.h:
* UIProcess/ios/forms/WKFormSelectControl.mm:
(adjustedFontSize):
* UIProcess/ios/forms/WKFormSelectPicker.mm:
(-[WKOptionPickerCell initWithOptionItem:]):
(-[WKOptionGroupPickerCell initWithOptionItem:]):
(-[WKMultipleSelectPicker initWithView:]):
(-[WKMultipleSelectPicker pickerView:viewForRow:forComponent:reusingView:]):
(-[WKMultipleSelectPicker pickerView:row:column:checked:]):
(-[WKSelectSinglePicker pickerView:attributedTitleForRow:forComponent:]):
(-[WKSelectSinglePicker pickerView:didSelectRow:inComponent:]):
* UIProcess/ios/forms/WKFormSelectPopover.mm:
(-[WKSelectTableViewController initWithView:hasGroups:]):
(-[WKSelectTableViewController tableView:numberOfRowsInSection:]):
(-[WKSelectTableViewController tableView:titleForHeaderInSection:]):
(-[WKSelectTableViewController populateCell:withItem:]):
(-[WKSelectTableViewController findItemIndexAt:]):
(-[WKSelectTableViewController findItemAt:]):
(-[WKSelectTableViewController tableView:cellForRowAtIndexPath:]):
(-[WKSelectTableViewController tableView:didSelectRowAtIndexPath:]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Policy delegate methods should use CompletionHandlerCallChecker
https://bugs.webkit.org/show_bug.cgi?id=134215

Reviewed by Dan Bernstein.

* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::PolicyClient::decidePolicyForNavigationAction):
(WebKit::NavigationState::PolicyClient::decidePolicyForResponse):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170322 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] process raw VTT in-band captions
https://bugs.webkit.org/show_bug.cgi?id=134178

Reviewed by NOBODY (OOPS!).

* CMakeLists.txt: Add ISOVTTCue.cpp|h.
* WebCore.vcxproj/WebCore.vcxproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.

* html/track/BufferedLineReader.h:
(WebCore::BufferedLineReader::reset): New, empty the input buffer.

Make it possible to process WebVTT captions. 
* html/track/InbandGenericTextTrack.cpp:
(WebCore::InbandGenericTextTrack::parser): Allocate, if necessary, and return a WebVTT parser.
(WebCore::InbandGenericTextTrack::parseWebVTTCueData): Pass a cue to the parser.
(WebCore::InbandGenericTextTrack::parseWebVTTFileHeader): Pass a VTT file header to the parser.
(WebCore::InbandGenericTextTrack::newCuesParsed): Parser callback.
(WebCore::InbandGenericTextTrack::newRegionsParsed): Ditto.
(WebCore::InbandGenericTextTrack::fileFailedToParse): Ditto.
* html/track/InbandGenericTextTrack.h:

* html/track/InbandTextTrack.h:

* html/track/InbandWebVTTTextTrack.cpp:
(WebCore::InbandWebVTTTextTrack::parser): New, parser accessor.
(WebCore::InbandWebVTTTextTrack::parseWebVTTCueData): New, parse VTT data in an ISOWebVTTCue
    object.
(WebCore::InbandWebVTTTextTrack::newCuesParsed): Cleanup.
(WebCore::InbandWebVTTTextTrack::newRegionsParsed): Implement.
(WebCore::InbandWebVTTTextTrack::fileFailedToParse): Change the error message.
* html/track/InbandWebVTTTextTrack.h:

* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGenericBoxElement::TextTrackCueGenericBoxElement): Change cue parameter
    from a pointer to a reference.
(WebCore::TextTrackCueGeneric::createDisplayTree): Ditto.

* html/track/VTTCue.cpp:
(WebCore::VTTCueBox::create): Change cue parameter from a pointer to a reference.
(WebCore::VTTCueBox::VTTCueBox): Ditto.
(WebCore::VTTCueBox::getCue): Return a reference.
(WebCore::VTTCueBox::applyCSSProperties): m_cue is a reference, not a pointer.
(WebCore::VTTCue::create): New, create a VTTCue from WebVTTCueData.
(WebCore::VTTCue::VTTCue): New, internal constructor that takes a WebVTTCueData.
(WebCore::VTTCue::initialize): New, shared constructor initialization.
(WebCore::VTTCue::createDisplayTree): m_cue is a reference, not a pointer.
(WebCore::VTTCue::markFutureAndPastNodes): Ditto.
(WebCore::VTTCue::setCueSettings): Ditto.
* html/track/VTTCue.h:
(WebCore::VTTCueBox::create): Deleted.
(WebCore::VTTCue::create): Deleted.

* html/track/WebVTTParser.cpp:
(WebCore::WebVTTParser::parseFileHeader): New. Reset the line reader buffer and parser state, 
    call the parser.
(WebCore::WebVTTParser::parseCueData): Create a cue from ISOWebVTTCue.
(WebCore::WebVTTParser::collectTimingsAndSettings): Return immediately if the string is empty.
(WebCore::WebVTTParser::collectTimeStamp): Ditto.
* html/track/WebVTTParser.h:
(WebCore::WebVTTCueData::originalStartTime): New.
(WebCore::WebVTTCueData::setOriginalStartTime): New.
(WebCore::WebVTTCueData::WebVTTCueData):

* loader/TextTrackLoader.cpp:
(WebCore::TextTrackLoader::getNewCues): Cleanup, use the new VTTCue::create.

* platform/graphics/InbandTextTrackPrivateClient.h:
(WebCore::InbandTextTrackPrivateClient::parseWebVTTFileHeader): New.

Parse ISO WebVTT cue boxes.
* platform/graphics/ISOVTTCue.cpp: Added.
(WebCore::ISOBox::ISOBox):
(WebCore::ISOBox::peekType):
(WebCore::ISOBox::peekLength):
(WebCore::ISOBox::peekString):
(WebCore::vttCueBoxType):
(WebCore::vttIdBoxType):
(WebCore::vttSettingsBoxType):
(WebCore::vttPayloadBoxType):
(WebCore::vttCurrentTimeBoxType):
(WebCore::vttCueSourceIDBoxType):
(WebCore::ISOWebVTTCue::boxType):
(WebCore::ISOWebVTTCue::ISOWebVTTCue):
* platform/graphics/ISOVTTCue.h: Added.
(WebCore::ISOBox::boxHeaderSize):
(WebCore::ISOBox::length):
(WebCore::ISOBox::type):
(WebCore::ISOWebVTTCue::presentationTime):
(WebCore::ISOWebVTTCue::duration):
(WebCore::ISOWebVTTCue::sourceID):
(WebCore::ISOWebVTTCue::id):
(WebCore::ISOWebVTTCue::originalStartTime):
(WebCore::ISOWebVTTCue::settings):
(WebCore::ISOWebVTTCue::cueText):

* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
(WebCore::InbandTextTrackPrivateAVF::InbandTextTrackPrivateAVF): Add a cue format parameter.
(WebCore::InbandTextTrackPrivateAVF::processCue): Call processNativeSamples.
(WebCore::InbandTextTrackPrivateAVF::processAttributedStrings): Add logging. Minor cleanup.
(WebCore::InbandTextTrackPrivateAVF::processNativeSamples): New, process an array of 
    CMSampleBuffers, create ISOWebVTTCue from the sample data.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:

* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.h:
(WebCore::InbandTextTrackPrivateAVFObjC::create): Add a cue format parameter.
* platform/graphics/avfoundation/objc/InbandTextTrackPrivateAVFObjC.mm:
(WebCore::InbandTextTrackPrivateAVFObjC::InbandTextTrackPrivateAVFObjC): Ditto.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Improve logging.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Don't leak an NSDictionary.
(WebCore::MediaPlayerPrivateAVFoundationObjC::tracksChanged): Don't process media selection
    options until we have tracks.
(WebCore::MediaPlayerPrivateAVFoundationObjC::processMediaSelectionOptions): 
(WebCore::MediaPlayerPrivateAVFoundationObjC::processCue): Pass native samples as well as 
    attributed strings to track.
(-[WebCoreAVFMovieObserver legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:]):
* platform/graphics/avfoundation/objc/OutOfBandTextTrackPrivateAVF.h:
(WebCore::OutOfBandTextTrackPrivateAVF::OutOfBandTextTrackPrivateAVF):

* platform/graphics/avfoundation/InbandTextTrackPrivateLegacyAVFObjC.cpp:
(WebCore::InbandTextTrackPrivateLegacyAVFObjC::InbandTextTrackPrivateLegacyAVFObjC): Pass cue
    format to base class.

* platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
(WebCore::InbandTextTrackPrivateAVCF::InbandTextTrackPrivateAVCF): Ditto.
* platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170323 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, revert an unintentional change committed with r170323.

* UIProcess/API/Cocoa/WKBackForwardList.mm:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170324 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Make the state restore from HistoryItem more precise and reliable
https://bugs.webkit.org/show_bug.cgi?id=134150

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-06-23
Reviewed by Tim Horton.


Source/WebCore: 
The two biggest changes for WebCore are:
-Store everything we need to handle changes of ViewportConfiguration on HistoryItem.
-Store the exposedRect with floating point coordinates.

* WebCore.exp.in:
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
We cannot determine a good scroll position from the WebProcess because the obscured insets can change
arbitrarily in the UIProcess. When we scroll here from the WebProcess, we would force an invalid position
to the UIProcess with the next layer tree update.

To avoid any problem, we prohibit scrolling when restoring the focus appearance.

* history/HistoryItem.cpp:
(WebCore::encodeRect):
(WebCore::encodeSize):
(WebCore::HistoryItem::encodeBackForwardTreeNode):
(WebCore::decodeRect):
(WebCore::decodeSize):
(WebCore::HistoryItem::decodeBackForwardTree):
* history/HistoryItem.h:
(WebCore::HistoryItem::exposedContentRect):
(WebCore::HistoryItem::setExposedContentRect):
(WebCore::HistoryItem::unobscuredContentRect):
(WebCore::HistoryItem::setUnobscuredContentRect):
(WebCore::HistoryItem::minimumLayoutSizeInScrollViewCoordinates):
(WebCore::HistoryItem::setMinimumLayoutSizeInScrollViewCoordinates):
(WebCore::HistoryItem::contentSize):
(WebCore::HistoryItem::setContentSize):
(WebCore::HistoryItem::exposedContentPosition): Deleted.
(WebCore::HistoryItem::setExposedContentPosition): Deleted.
* loader/HistoryController.cpp:
(WebCore::HistoryController::saveScrollPositionAndViewStateToItem):
* page/FrameView.h:
* platform/ScrollView.h:
* platform/ios/ScrollViewIOS.mm:
(WebCore::ScrollView::exposedContentRect):
(WebCore::ScrollView::setExposedContentRect):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::didChangeVisibleRect):

Source/WebKit2: 
This patch make several little improvements to improve how we restore the visible content rect and scale
from the HistoryItem.

The biggest architectural change is that the exposed rect is now restored on the UIProcess instead of the WebProcess,
this ensure we restore the same position regardless of any modification of obscured areas.

* Shared/VisibleContentRectUpdateInfo.cpp:
(WebKit::VisibleContentRectUpdateInfo::encode):
(WebKit::VisibleContentRectUpdateInfo::decode):
* Shared/VisibleContentRectUpdateInfo.h:
(WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo):
(WebKit::VisibleContentRectUpdateInfo::lastLayerTreeTransactionId):
(WebKit::WebPage::updateVisibleContentRects):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
A race between the UIProcess and the WebProcess could cause the viewport of the next page to be influenced by updates
of the previous page. To avoid that, VisibleContentRectUpdateInfo keeps track of the last transaction seen at the time
of the update.

The WebProcess updates the size and scale of the content through layer tree updates. If an update was generated for a layer tree
update of the old page, none of the information is valid for the current content. Since the UIProcess drives the state in case of conflicts,
the WebProcess was updating the scale of the current page based on incorrect information.

To avoid the problems, we save the layer tree transaction ID when we commit a new page. Only updates after that transaction are useful
for the current page.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
(withinEpsilon):
(changeContentOffsetBoundedInValidRange):
(-[WKWebView _didCommitLayerTree:WebKit::]):
(-[WKWebView _restorePageStateToExposedRect:WebCore::scale:]):
(-[WKWebView _restorePageStateToUnobscuredCenter:WebCore::scale:]):
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::restorePageState):
(WebKit::PageClientImpl::restorePageCenterAndScale):
Restoring the state is now done by WKWebView. The state is only updated on the next layer tree commit,
this is done to avoid any jumping if the page has scrolled since we tried to restore its state.

Both update path end up calling _updateVisibleContentRects. This is because the update on the WebProcess
never sets the ScrollPosition (because it does not know the current state of the obscured insets). Pushing
a new VisibleContentRect will nicely udpates the exposed rect, scroll position, fixed elements, etc.

* UIProcess/ios/WKContentView.mm:
(-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:]):
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::restorePageState):
(WebKit::WebPageProxy::restorePageCenterAndScale):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
(WebKit::RemoteLayerTreeDrawingAreaProxy::lastCommittedLayerTreeTransactionID):
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::RemoteLayerTreeDrawingAreaProxy):
* WebProcess/WebCoreSupport/ios/WebFrameLoaderClientIOS.mm:
(WebKit::WebFrameLoaderClient::saveViewStateToItem):
(WebKit::WebFrameLoaderClient::restoreViewState):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::didCommitLoad):
* WebProcess/WebPage/WebPage.h:
Get rid of m_obscuredTopInset. It was a bad idea. The UIProcess updates the obscured insets a lot during
page load, the value we used to restore the scroll position was frequently stale.

(WebKit::WebPage::userHasChangedPageScaleFactor): Deleted.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::savePageState):
(WebKit::scaleAfterViewportWidthChange):
(WebKit::relativeCenterAfterContentSizeChange):
(WebKit::adjustExposedRectForNewScale):
Extract this out of dynamicViewportSizeUpdate(). It is useful to adjust the exposed rect when restoring a HistoryItem
to a ViewportConfiguration that is different from when it was saved.

(WebKit::WebPage::restorePageState):
There are two variations of restorePage:
1) If the viewport configuration is compatible, restore the exact scale and position of the page.
2) Otherwise, restore the scale and position similarily to dynamicViewportSizeUpdate().

(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::viewportConfigurationChanged):
(WebKit::adjustExposedRectForBoundedScale):
(WebKit::RemoteLayerTreeDrawingArea::currentTransactionID):
Expose the transactionID for the race issue on VisibleRectUpdate.

* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::setExposedContentRect):
Store the exposed rect in floating point coordinates. This makes it possible to restore that exact
position when needed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170325 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][wk2] Don't use view snapshots if the destination layer is a different size
https://bugs.webkit.org/show_bug.cgi?id=134210
<rdar://problem/17369463>

Reviewed by Benjamin Poulain.

* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
Only use the view snapshot if the snapshot is the same (in device space) size
as the layer it's going to be put into, and only if the device scale factor is
the same as it was when the snapshot was taken.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170326 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Database process crashes when multiple transactions attempt to run at once
https://bugs.webkit.org/show_bug.cgi?id=134139

Reviewed by David Kilzer.

Source/WebCore:
Ensure that only one transaction can be running at a time.

Test: storage/indexeddb/transaction-overlapping.html

* Modules/indexeddb/IDBTransactionCoordinator.cpp:
(WebCore::IDBTransactionCoordinator::canRunTransaction):

LayoutTests:
* storage/indexeddb/transaction-overlapping-expected.txt: Added.
* storage/indexeddb/transaction-overlapping.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170327 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix release build

* Modules/indexeddb/IDBTransactionCoordinator.cpp:
(WebCore::IDBTransactionCoordinator::canRunTransaction):

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

lots of build breakage (Requested by bradeeoh on #webkit).

Reverted changeset:

"Unreviewed, revert an unintentional change committed with
r170323."
http://trac.webkit.org/changeset/170324

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170329 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add SPI for Injected Bundle to provide user agent for a given URL.
https://bugs.webkit.org/show_bug.cgi?id=133562

Patch by Grant Kennell <gkennell@apple.com> on 2014-06-23
Reviewed by Sam Weinig.

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h:
  Added delegate method to WebProcess PluIn protocol to provide UserAgent per URL.
* WebProcess/InjectedBundle/API/c/WKBundlePageLoaderClient.h:
  Added new typedef for function pointer for this new delegate call.
  Added new version (V8) of bundle loader client struct containing
  a function pointer of that new type.
* WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm:
(userAgentForURL): Makes delegate call with the new method.
(setUpPageLoaderClient): Sets the struct's new function pointer to the new method.
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
(WebKit::InjectedBundlePageLoaderClient::userAgentForURL):
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::userAgent):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::userAgent): Began using the new API to ask for user agent
  instead of simply returning what had been stored.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::userAgent): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170330 268f45cc-cd09-0410-ab3c-d52691b4dbfc
<rdar://problem/17413498> [Cocoa] Expose WebPreferences::offlineWebApplicationCacheEnabled
https://bugs.webkit.org/show_bug.cgi?id=134217

Reviewed by Anders Carlsson.

* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _offlineApplicationCacheIsEnabled]):
(-[WKPreferences _setOfflineApplicationCacheIsEnabled:]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h: Added _offlineWebApplicationCacheIsEnabled
property.



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

lots of build breakage (Requested by bradeeoh on #webkit).

Reverted changeset:

"[Mac] process raw VTT in-band captions"
https://bugs.webkit.org/show_bug.cgi?id=134178
http://trac.webkit.org/changeset/170323

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170332 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS] remove InbandTextTrackPrivateAVFIOS
https://bugs.webkit.org/show_bug.cgi?id=134220

Reviewed by Benjamin Poulain.

* WebCore.xcodeproj/project.pbxproj: Remove references to InbandTextTrackPrivateAVFIOS.

* platform/graphics/ios/InbandTextTrackPrivateAVFIOS.h: Removed.
* platform/graphics/ios/InbandTextTrackPrivateAVFIOS.mm: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Add -[WKBackForwardList _removeAllItems]
https://bugs.webkit.org/show_bug.cgi?id=134227
<rdar://problem/17291623>

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/WKBackForwardList.mm:
(-[WKBackForwardList _removeAllItems]):
* UIProcess/API/Cocoa/WKBackForwardListPrivate.h: Added.
* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170334 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[WK2] Use the page background color instead of white when swipe snapshots were purged (134218)
https://bugs.webkit.org/show_bug.cgi?id=134218
<rdar://problem/17426454>

Reviewed by Benjamin Poulain.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _updateScrollViewBackground]):
(-[WKWebView WebKit::]):
* UIProcess/API/mac/WKView.mm:
(-[WKView _takeViewSnapshot]):
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::shouldUseSnapshotForSize):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::retrieveSnapshotForItem): Deleted.
* UIProcess/mac/ViewSnapshotStore.h:
Store a color along with each snapshot.
Set the background color of the swipe snapshot layer accordingly.

* WebCore.exp.in:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170335 268f45cc-cd09-0410-ab3c-d52691b4dbfc
HTMLMediaElement seek algorithm should allow cancelling previous seeks.
https://bugs.webkit.org/show_bug.cgi?id=134116

Reviewed by Eric Carlson.

Source/WebCore:
Test: media/video-seek-double.html

Fulfill the requirement of the §4.7.14.9 seeking algorithm to do steps 5+ asynchronously and cancel
previous instances of the algorithm.

For the html/ parts of the algorithm, implement this by adding a seek timer, which when fired will
issue steps 5-12. MediaPlayerPrivateAVFoundation will already coalesce multiple seek operations, so nothing
additional needs be done there.  However, MediaPlayerPrivateMediaSourceAVFObjC needs to implement the same
pending seek logic in case additional seeks were issued after the html/ algorithm reached step 12.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Initialize the new m_seekTimer.
(WebCore::HTMLMediaElement::parseAttribute): Clear the seek timer.
(WebCore::HTMLMediaElement::seekInternal): Differentiate between DOM seeks and internal seeks.
(WebCore::HTMLMediaElement::seekWithTolerance:) Split into the seekTimerFired() method.
(WebCore::HTMLMediaElement::seekTimerFired:) Added, split from seekWithTolerance().
* html/HTMLMediaElement.h:
* html/MediaController.cpp:
(MediaController::bringElementUpToSpeed): Call seekInternal().
(WebCore::HTMLMediaElement::PendingSeek::PendingSeek): Added convenience struct for storing seek requests.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::PendingSeek::PendingSeek): Ditto.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC): Modify the time jumped
    handler to not clear the m_seeking flag if another seek request is pending.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekWithTolerance):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekInternal):

LayoutTests:
* media/video-seek-double-expected.txt: Added.
* media/video-seek-double.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Use unsigneds instead of ints for indexes into a string in text layout code
https://bugs.webkit.org/show_bug.cgi?id=133592

Reviewed by Zalan Bujtas.

Migrate much of the text-handling code to use unsigneds for indexes into a string.

No new tests because there is no behavior change.

* WebCore.exp.in:
* platform/graphics/Font.cpp:
(WebCore::Font::drawText):
(WebCore::Font::drawEmphasisMarks):
(WebCore::Font::adjustSelectionRectForText):
(WebCore::computeUnderlineType):
* platform/graphics/Font.h:
* platform/graphics/FontFastPath.cpp:
(WebCore::Font::getGlyphsAndAdvancesForSimpleText):
(WebCore::Font::drawSimpleText):
(WebCore::Font::drawEmphasisMarksForSimpleText):
(WebCore::Font::drawGlyphBuffer):
(WebCore::Font::drawEmphasisMarks):
(WebCore::Font::adjustSelectionRectForSimpleText):
* platform/graphics/GlyphBuffer.h:
(WebCore::GlyphBuffer::size):
(WebCore::GlyphBuffer::glyphs):
(WebCore::GlyphBuffer::advances):
(WebCore::GlyphBuffer::fontDataAt):
(WebCore::GlyphBuffer::advanceAt):
(WebCore::GlyphBuffer::offsetAt):
(WebCore::GlyphBuffer::reverse):
(WebCore::GlyphBuffer::offsetInString):
(WebCore::GlyphBuffer::swap):
* platform/graphics/GraphicsContext.cpp:
(WebCore::TextRunIterator::atEnd):
* platform/graphics/Latin1TextIterator.h:
(WebCore::Latin1TextIterator::Latin1TextIterator):
(WebCore::Latin1TextIterator::currentCharacter):
* platform/graphics/SimpleFontData.h:
* platform/graphics/SurrogatePairAwareTextIterator.cpp:
(WebCore::SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator):
* platform/graphics/SurrogatePairAwareTextIterator.h:
(WebCore::SurrogatePairAwareTextIterator::currentCharacter):
* platform/graphics/TextRun.h:
(WebCore::TextRun::length):
(WebCore::TextRun::charactersLength):
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::glyphDataForCharacter):
(WebCore::applyFontTransforms):
(WebCore::WidthIterator::advanceInternal):
(WebCore::WidthIterator::advance):
(WebCore::WidthIterator::advanceOneCharacter):
* platform/graphics/WidthIterator.h:
* platform/graphics/cairo/FontCairo.cpp:
(WebCore::Font::drawGlyphs):
* platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::adjustSelectionRectForComplexText):
* platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
(WebCore::HarfBuzzShaper::setNormalizedBuffer):
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::getGlyphsAndAdvancesForComplexText):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs):
* platform/graphics/win/FontCGWin.cpp:
(WebCore::Font::drawGlyphs):
* platform/graphics/win/FontWin.cpp:
(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::getGlyphsAndAdvancesForComplexText):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
* platform/graphics/wince/FontWinCE.cpp:
(WebCore::Font::drawGlyphs):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::selectionRectForComplexText):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::isSelected):
(WebCore::InlineTextBox::selectionState):
(WebCore::adjustCharactersAndLengthForHyphen):
(WebCore::InlineTextBox::localSelectionRect):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::selectionStartEnd):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintCompositionBackground):
(WebCore::InlineTextBox::paintDocumentMarker):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::computeRectForReplacementMarker):
(WebCore::InlineTextBox::paintCompositionUnderline):
(WebCore::InlineTextBox::positionForOffset):
(WebCore::InlineTextBox::constructTextRun):
* rendering/InlineTextBox.h:
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::getStringToRender):
* rendering/RenderCombineText.h:
* rendering/svg/SVGInlineFlowBox.cpp:
(WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::positionForOffset):
(WebCore::SVGInlineTextBox::localSelectionRect):
(WebCore::SVGInlineTextBox::paintSelectionBackground):
(WebCore::SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates):
(WebCore::SVGInlineTextBox::paintText):
* rendering/svg/SVGInlineTextBox.h:
* rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair):
(WebCore::SVGTextMetricsBuilder::advance):
* rendering/svg/SVGTextQuery.cpp:
(WebCore::SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates):
(WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures):
(WebCore::SVGTextQuery::subStringLengthCallback):
(WebCore::SVGTextQuery::startPositionOfCharacterCallback):
(WebCore::SVGTextQuery::endPositionOfCharacterCallback):
(WebCore::SVGTextQuery::rotationOfCharacterCallback):
(WebCore::SVGTextQuery::extentOfCharacterCallback):
(WebCore::SVGTextQuery::characterNumberAtPositionCallback):
* rendering/svg/SVGTextQuery.h:
* rendering/svg/SVGTextRunRenderingContext.cpp:
(WebCore::SVGGlyphToPathTranslator::SVGGlyphToPathTranslator):
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):
* rendering/svg/SVGTextRunRenderingContext.h:
* svg/SVGFontData.cpp:
(WebCore::SVGFontData::applySVGGlyphSelection):
* svg/SVGFontData.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@170337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Unreviewed, EFL build fix after r170330.

* WebProcess/WebPage/WebPage.cpp: Guard WKStringCF.h with PLATFORM(COCOA) macro.

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