Crash in ServicesOverlayController::~ServicesOverlayController.
<rdar://problem/17622172> and https://bugs.webkit.org/show_bug.cgi?id=135022

Reviewed by Tim Horton.

* WebProcess/WebPage/mac/ServicesOverlayController.mm:
(WebKit::ServicesOverlayController::~ServicesOverlayController): Don’t need to uninstall the
    PageOverlay as it has already been destroyed by this point in WebPage::~WebPage.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171194 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Make console.profile record to the Timeline.

https://bugs.webkit.org/show_bug.cgi?id=134643

Reviewed by Joseph Pecoraro.

Source/WebCore:
Passes existing profiler tests in fast/profiler.

* bindings/js/ScriptState.cpp:
(WebCore::domWindowFromExecState):
(WebCore::frameFromExecState):
(WebCore::scriptExecutionContextFromExecState):
(WebCore::mainWorldExecState):
(WebCore::execStateFromNode):
* bindings/js/ScriptState.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::profilerEnabled):
(WebCore::InspectorController::setProfilerEnabled):
* inspector/InspectorController.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::startProfilingImpl):
(WebCore::InspectorInstrumentation::stopProfilingImpl):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::didCreateFrontendAndBackend):
(WebCore::InspectorTimelineAgent::willDestroyFrontendAndBackend):
(WebCore::InspectorTimelineAgent::start):
(WebCore::InspectorTimelineAgent::stop):
(WebCore::startProfiling):
(WebCore::stopProfiling):
(WebCore::InspectorTimelineAgent::startFromConsole):
(WebCore::InspectorTimelineAgent::stopFromConsole):
(WebCore::InspectorTimelineAgent::didWriteHTML):
(WebCore::InspectorTimelineAgent::breakpointActionProbe):
(WebCore::toProtocol):
(WebCore::InspectorTimelineAgent::addRecordToTimeline):
(WebCore::InspectorTimelineAgent::didCompleteRecordEntry):
(WebCore::InspectorTimelineAgent::didCompleteCurrentRecord):
(WebCore::InspectorTimelineAgent::InspectorTimelineAgent):
(WebCore::InspectorTimelineAgent::sendEvent):
(WebCore::InspectorTimelineAgent::createRecordEntry):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):
* inspector/InspectorTimelineAgent.h:
(WebCore::InspectorTimelineAgent::TimelineRecordEntry::TimelineRecordEntry):
(WebCore::InspectorTimelineAgent::pushCurrentRecord):
* inspector/InstrumentingAgents.cpp:
(WebCore::InstrumentingAgents::InstrumentingAgents):
(WebCore::InstrumentingAgents::reset):
* inspector/InstrumentingAgents.h:
(WebCore::InstrumentingAgents::persistentInspectorTimelineAgent):
(WebCore::InstrumentingAgents::setPersistentInspectorTimelineAgent):
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createConsoleProfileData):
* inspector/TimelineRecordFactory.h:
* inspector/protocol/Timeline.json:
* page/PageConsole.cpp:
(WebCore::PageConsole::profileEnd):

Source/WebInspectorUI:
* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Controllers/TimelineManager.js:
(WebInspector.TimelineManager.prototype.startCapturing):
(WebInspector.TimelineManager.prototype.stopCapturing):
(WebInspector.TimelineManager.prototype.capturingStarted):
(WebInspector.TimelineManager.prototype.capturingStopped):
(WebInspector.TimelineManager.prototype.eventRecorded.processRecord):
(WebInspector.TimelineManager.prototype.eventRecorded):
* UserInterface/Images/TimelineRecordConsoleProfile.svg: Added.
* UserInterface/Models/ScriptTimelineRecord.js:
* UserInterface/Protocol/TimelineObserver.js:
(WebInspector.TimelineObserver.prototype.eventRecorded):
(WebInspector.TimelineObserver.prototype.recordingStarted):
(WebInspector.TimelineObserver.prototype.recordingStopped):
* UserInterface/Views/TimelineIcons.css:
(.console-profile-record .icon):
* UserInterface/Views/TimelineRecordTreeElement.js:
(WebInspector.TimelineRecordTreeElement):

Source/WebKit/mac:
* WebInspector/WebInspector.mm:
(-[WebInspector isProfilingJavaScript]):
(-[WebInspector toggleProfilingJavaScript:]):
(-[WebInspector startProfilingJavaScript:]):
(-[WebInspector stopProfilingJavaScript:]):
(-[WebInspector isJavaScriptProfilingEnabled]):
(-[WebInspector setJavaScriptProfilingEnabled:]):

Source/WebKit2:
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::setJavaScriptProfilingEnabled):
(WebKit::WebInspector::startJavaScriptProfiling):
(WebKit::WebInspector::stopJavaScriptProfiling):

LayoutTests:
* fast/profiler/profile-with-no-title-expected.txt:

* inspector-protocol/profiler/console-profile-expected.txt: Removed.
* inspector-protocol/profiler/console-profile.html: Removed.
* inspector-protocol/profiler/console-profileEnd-parameterless-expected.txt: Removed.
* inspector-protocol/profiler/console-profileEnd-parameterless.html: Removed.
Removed because console.profile does not go through the profiler protocol now.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171195 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Remove inspector-protocol/profiler tests from TestExpectations, now that they no
longer exist.

* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171196 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[Mac] Full screen video not always animating in the correct Space
https://bugs.webkit.org/show_bug.cgi?id=135020
<rdar://problem/17542310>

Reviewed by Dean Jackson.

       The fullscreen window can "remember" the Space it was part of the first time you enter fullscreen
       mode. Subsequent fullscreen transitions will always start from this Space, even if you move
       the WebKit-hosted application to a different Space.

       We can help the display system know when we've moved to a new Space by calling NSWindow's
       'orderBack' method on the fullscreen window prior to starting the transition to fullscreen mode.
       This method call hooks the window into the current Space so everything works properly.

* UIProcess/mac/WKFullScreenWindowController.mm:
(-[WKFullScreenWindowController beganEnterFullScreenWithInitialFrame:finalFrame:]): Add the
new fullscreen window to the current Space before starting transition to fullscreen.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171197 268f45cc-cd09-0410-ab3c-d52691b4dbfc
fast/repaint/obscured-background-no-repaint.html is very flaky
https://bugs.webkit.org/show_bug.cgi?id=131477

* platform/mac-wk2/TestExpectations:
* platform/mac/TestExpectations:
Moved the expectation out of WK2, as this also happens with WK1 on some bots.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171198 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Fix failing API tests.

* TestWebKitAPI/mac/PlatformWebViewMac.mm:
(-[ActiveOffscreenWindow isVisible]):
Override isVisible to make the NSWindows pretend they are visible.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@171199 268f45cc-cd09-0410-ab3c-d52691b4dbfc
[iOS][WK2] Add SPI to do a dynamic viewport update without showing any content
https://bugs.webkit.org/show_bug.cgi?id=135010

Reviewed by Darin Adler.

This patch add a new SPI, [WKWebView _resizeWhileHidingContentWithUpdates:] to perform all the work
of a dynamic viewport size update, but instead of animating the old content, it is hidden.

The patch is built on top of the animated resize mechanism. Instead of having an animation driving
the beginning and end, we let the content do that. The dynamic resize begins, it runs for as long as
the WebProcess needs, and it ends when first layer tree commit with the new content is processed.

The attribute "_isAnimatingResize" is generalized to support two modes of resizing: animated and
hiding content.

The attribute "_hasCommittedLoadForMainFrame" is rather silly. It is only needed because
[WKWebView _resizeWhileHidingContentWithUpdates:] is intended to be called a lot before the page
is initialized, and doing an animated resize would trash the WebProcess state.
I wish I had a better solution, this is not great.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
(-[WKWebView _didCommitLoadForMainFrame]):
(-[WKWebView _didCommitLayerTree:]):
This is the key to make this work properly. We want _resizeWhileHidingContentWithUpdates: to behave
exactly like an animated resize to avoid bugs. So we went to the whole update mechanism using
_resizeAnimationTransformAdjustments to accumulate the adjustments, now we need to restore a correct
view state.

Calling [WKWebView _endAnimatedResize] will do exactly that, but we need to make sure we do not hit
the synchronization path or we would be blocked there for a while, which is what we are trying to avoid.

After r171154, WebPageProxy keeps track of what stage of dynamic viewport update we are in. Since we are
executing the layer tree update stage, with the right transaction ID, WebPageProxy already knows we have
everything we need and does not use any synchronous messages.

(-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]):
(-[WKWebView _restorePageStateToExposedRect:scale:]):
(-[WKWebView _restorePageStateToUnobscuredCenter:scale:]):
(-[WKWebView _scrollToContentOffset:]):
(-[WKWebView _frameOrBoundsChanged]):
(-[WKWebView _updateVisibleContentRects]):
(-[WKWebView _setMinimumLayoutSizeOverride:]):
(-[WKWebView _setMinimumLayoutSizeOverrideForMinimalUI:]):
(-[WKWebView _setInterfaceOrientationOverride:]):
(-[WKWebView _setMaximumUnobscuredSizeOverride:]):
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _endAnimatedResize]):
(-[WKWebView _resizeWhileHidingContentWithUpdates:]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:


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