Skip to content
Permalink
Browse files
Move animated resize into the layer tree transaction, and make it asy…
…nchronous

https://bugs.webkit.org/show_bug.cgi?id=186130
<rdar://problem/38477288>

Reviewed by Simon Fraser.

* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::setScrollPosition):
(WebKit::RemoteLayerTreeTransaction::dynamicViewportSizeUpdateID const):
(WebKit::RemoteLayerTreeTransaction::setDynamicViewportSizeUpdateID):
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode const):
(WebKit::RemoteLayerTreeTransaction::decode):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
Add scrollPosition to the transaction on all platforms, not just Mac.
Add the optional dynamicViewportSizeUpdateID to the transaction, representing
the most recent dynamicViewportSizeUpdate that commit contains, if any.

* Shared/ios/DynamicViewportSizeUpdate.h:
Added a typedef for DynamicViewportSizeUpdateID, and move the mode enum here.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget): Deleted.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
(WebKit::WebPageProxy::didCommitLayerTree):
(WebKit::WebPageProxy::synchronizeDynamicViewportUpdate): Deleted.
(WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::synchronizeDynamicViewportUpdate): Deleted.
Remove dynamicViewportUpdateChangedTarget and synchronizeDynamicViewportUpdate.
Move dynamicViewportSizeUpdateID maintenance into WKWebView.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
Remove _resizeAnimationTransformTransactionID. We now instead pack
the resize ID inside the transaction, instead of separately sending
back a transaction ID to wait for.

(-[WKWebView _didCommitLayerTreeDuringAnimatedResize:]):
(-[WKWebView _didCommitLayerTree:]):
Added, factored out of _didCommitLayerTree:.
If the transaction includes the result of the most recently-sent resize,
store the requisite adjustments required to counter the new scale and
scroll offset, update the resizeAnimationView, and, if endAnimatedResize
has already been called, call _didCompleteAnimatedResize to tear down
the animation view and put things back together.

Add some code so that if a commit arrives before the resize, we update
the scale of the resize animation view to keep the width fitting.

(activeMaximumUnobscuredSize):
(activeOrientation):
Move these because the code that depends on them moved.

(-[WKWebView _didCompleteAnimatedResize]):
Broken out of _endAnimatedResize. This can now be called from
either endAnimatedResize or _didCommitLayerTreeDuringAnimatedResize,
depending on which is called first.

(-[WKWebView _beginAnimatedResizeWithUpdates:]):
Don't create a new resize view if we still have one. Otherwise, we'll
get the view ordering all wrong when making the second one. This
didn't previously cause trouble, because we don't have a lot of
WKScrollView subviews, but it totally could.

Adopt _initialContentOffsetForScrollView just to make this code more clear.

(-[WKWebView _endAnimatedResize]):
(-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:


Canonical link: https://commits.webkit.org/201725@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232544 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Jun 6, 2018
1 parent c8c0d31 commit 6a0cb0ac86757c5372ebab46b6a93bac5d601490
@@ -1,3 +1,88 @@
2018-06-06 Tim Horton <timothy_horton@apple.com>

Move animated resize into the layer tree transaction, and make it asynchronous
https://bugs.webkit.org/show_bug.cgi?id=186130
<rdar://problem/38477288>

Reviewed by Simon Fraser.

* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
(WebKit::RemoteLayerTreeTransaction::setScrollPosition):
(WebKit::RemoteLayerTreeTransaction::dynamicViewportSizeUpdateID const):
(WebKit::RemoteLayerTreeTransaction::setDynamicViewportSizeUpdateID):
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::encode const):
(WebKit::RemoteLayerTreeTransaction::decode):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::willCommitLayerTree):
Add scrollPosition to the transaction on all platforms, not just Mac.
Add the optional dynamicViewportSizeUpdateID to the transaction, representing
the most recent dynamicViewportSizeUpdate that commit contains, if any.

* Shared/ios/DynamicViewportSizeUpdate.h:
Added a typedef for DynamicViewportSizeUpdateID, and move the mode enum here.

* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget): Deleted.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetState):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::dynamicViewportSizeUpdate):
(WebKit::WebPageProxy::didCommitLayerTree):
(WebKit::WebPageProxy::synchronizeDynamicViewportUpdate): Deleted.
(WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget): Deleted.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::dynamicViewportSizeUpdate):
(WebKit::WebPage::synchronizeDynamicViewportUpdate): Deleted.
Remove dynamicViewportUpdateChangedTarget and synchronizeDynamicViewportUpdate.
Move dynamicViewportSizeUpdateID maintenance into WKWebView.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _processDidExit]):
Remove _resizeAnimationTransformTransactionID. We now instead pack
the resize ID inside the transaction, instead of separately sending
back a transaction ID to wait for.

(-[WKWebView _didCommitLayerTreeDuringAnimatedResize:]):
(-[WKWebView _didCommitLayerTree:]):
Added, factored out of _didCommitLayerTree:.
If the transaction includes the result of the most recently-sent resize,
store the requisite adjustments required to counter the new scale and
scroll offset, update the resizeAnimationView, and, if endAnimatedResize
has already been called, call _didCompleteAnimatedResize to tear down
the animation view and put things back together.

Add some code so that if a commit arrives before the resize, we update
the scale of the resize animation view to keep the width fitting.

(activeMaximumUnobscuredSize):
(activeOrientation):
Move these because the code that depends on them moved.

(-[WKWebView _didCompleteAnimatedResize]):
Broken out of _endAnimatedResize. This can now be called from
either endAnimatedResize or _didCommitLayerTreeDuringAnimatedResize,
depending on which is called first.

(-[WKWebView _beginAnimatedResizeWithUpdates:]):
Don't create a new resize view if we still have one. Otherwise, we'll
get the view ordering all wrong when making the second one. This
didn't previously cause trouble, because we don't have a lot of
WKScrollView subviews, but it totally could.

Adopt _initialContentOffsetForScrollView just to make this code more clear.

(-[WKWebView _endAnimatedResize]):
(-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:


2018-06-05 Per Arne Vollan <pvollan@apple.com>

Move OpenGL display mask to screen data struct.
@@ -25,6 +25,7 @@

#pragma once

#include "DynamicViewportSizeUpdate.h"
#include "EditorState.h"
#include "GenericCallback.h"
#include "PlatformCAAnimationRemote.h"
@@ -218,10 +219,8 @@ class RemoteLayerTreeTransaction {
WebCore::Color pageExtendedBackgroundColor() const { return m_pageExtendedBackgroundColor; }
void setPageExtendedBackgroundColor(WebCore::Color color) { m_pageExtendedBackgroundColor = color; }

#if PLATFORM(MAC)
WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
void setScrollPosition(WebCore::IntPoint p) { m_scrollPosition = p; }
#endif

double pageScaleFactor() const { return m_pageScaleFactor; }
void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
@@ -272,6 +271,9 @@ class RemoteLayerTreeTransaction {
bool hasEditorState() const { return !!m_editorState; }
const EditorState& editorState() const { return m_editorState.value(); }
void setEditorState(const EditorState& editorState) { m_editorState = editorState; }

std::optional<DynamicViewportSizeUpdateID> dynamicViewportSizeUpdateID() const { return m_dynamicViewportSizeUpdateID; }
void setDynamicViewportSizeUpdateID(DynamicViewportSizeUpdateID resizeID) { m_dynamicViewportSizeUpdateID = resizeID; }

private:
WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
@@ -290,9 +292,7 @@ class RemoteLayerTreeTransaction {
WebCore::LayoutSize m_baseLayoutViewportSize;
WebCore::LayoutPoint m_minStableLayoutViewportOrigin;
WebCore::LayoutPoint m_maxStableLayoutViewportOrigin;
#if PLATFORM(MAC)
WebCore::IntPoint m_scrollPosition;
#endif
WebCore::Color m_pageExtendedBackgroundColor;
double m_pageScaleFactor { 1 };
double m_minimumScaleFactor { 1 };
@@ -309,7 +309,8 @@ class RemoteLayerTreeTransaction {
bool m_viewportMetaTagCameFromImageDocument { false };
bool m_isInStableState { false };

std::optional<EditorState> m_editorState { std::nullopt };
std::optional<EditorState> m_editorState;
std::optional<DynamicViewportSizeUpdateID> m_dynamicViewportSizeUpdateID;
};

} // namespace WebKit
@@ -533,9 +533,8 @@
encoder << m_minStableLayoutViewportOrigin;
encoder << m_maxStableLayoutViewportOrigin;

#if PLATFORM(MAC)
encoder << m_scrollPosition;
#endif

encoder << m_pageExtendedBackgroundColor;
encoder << m_pageScaleFactor;
encoder << m_minimumScaleFactor;
@@ -563,6 +562,8 @@
encoder << hasEditorState();
if (m_editorState)
encoder << *m_editorState;

encoder << m_dynamicViewportSizeUpdateID;
}

bool RemoteLayerTreeTransaction::decode(IPC::Decoder& decoder, RemoteLayerTreeTransaction& result)
@@ -624,11 +625,9 @@

if (!decoder.decode(result.m_maxStableLayoutViewportOrigin))
return false;

#if PLATFORM(MAC)

if (!decoder.decode(result.m_scrollPosition))
return false;
#endif

if (!decoder.decode(result.m_pageExtendedBackgroundColor))
return false;
@@ -692,6 +691,9 @@
result.setEditorState(editorState);
}

if (!decoder.decode(result.m_dynamicViewportSizeUpdateID))
return false;

return true;
}

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/

#pragma once

namespace WebKit {

typedef uint64_t DynamicViewportSizeUpdateID;

enum class DynamicViewportUpdateMode {
NotResizing,
ResizingWithAnimation,
ResizingWithDocumentHidden,
};

} // namespace WebKit

0 comments on commit 6a0cb0a

Please sign in to comment.