source: webkit/trunk/Source/WebCore/rendering/RenderModel.cpp

Last change on this file was 274033, checked in by [email protected], 4 years ago

<model> should create a model-owning compositing layer
https://bugs.webkit.org/show_bug.cgi?id=222798

Reviewed by Simon Fraser.

Source/JavaScriptCore:

  • inspector/protocol/LayerTree.json:

Add a compositing reason for <model>.

Source/WebCore:

Test: model-element/model-element-graphics-layers.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::setContentsToModel):

  • platform/graphics/Model.cpp: Added.

(WebCore::Model::create):
(WebCore::Model::Model):
(WebCore::operator<<):

  • platform/graphics/Model.h: Added.

(WebCore::Model::encode const):
(WebCore::Model::decode):
Add Model, a wrapper for the model.
For now, it just wraps a SharedBuffer.
In the future, it may contain other things, like file paths, identifiers, etc.

  • Modules/model-element/HTMLModelElement.cpp:

(WebCore::HTMLModelElement::model const):

  • Modules/model-element/HTMLModelElement.h:

HTMLModelElement can now vend a Model instead of just a SharedBuffer.

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::createPlatformCALayer):
(WebCore::GraphicsLayerCA::setContentsToModel):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCALayer.cpp:

(WebCore::operator<<):

  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:

(WebCore::PlatformCALayerCocoa::PlatformCALayerCocoa):
Allow a GraphicsLayer to be given a Model as contents (as we do for e.g. Image and other things).
For simplicity's sake, and because anything more is unnecessary, just re-create
the ModelLayer when the model changes.

  • rendering/RenderBoxModelObject.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::contentChanged):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateConfiguration):
(WebCore::RenderLayerBacking::contentChanged):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::requiresCompositingLayer const):
(WebCore::RenderLayerCompositor::requiresOwnBackingStore const):
(WebCore::RenderLayerCompositor::reasonsForCompositing const):
(WebCore::RenderLayerCompositor::logReasonsForCompositing):
(WebCore::RenderLayerCompositor::requiresCompositingForModel const):

  • rendering/RenderLayerCompositor.h:
  • rendering/RenderModel.cpp:

(WebCore::RenderModel::requiresLayer const):
(WebCore::RenderModel::updateFromElement):
(WebCore::RenderModel::update):

  • rendering/RenderModel.h:

Require compositing for <model>, and add a custom layer type.

  • inspector/agents/InspectorLayerTreeAgent.cpp:

(WebCore::InspectorLayerTreeAgent::reasonsForCompositingLayer):
Add a compositing reason for <model>.

Source/WebInspectorUI:

  • Localizations/en.lproj/localizedStrings.js:
  • UserInterface/Views/LayerTreeDetailsSidebarPanel.js:

(WI.LayerTreeDetailsSidebarPanel.prototype._populateListOfCompositingReasons):
(WI.LayerTreeDetailsSidebarPanel):

  • UserInterface/Views/Layers3DContentView.js:

(WI.Layers3DContentView.prototype._updateReasonsList):
(WI.Layers3DContentView):
Add a compositing reason for <model>.

Source/WebKit:

  • Shared/RemoteLayerTree/RemoteLayerBackingStore.mm:

(WebKit::RemoteLayerBackingStore::display):

  • Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h:
  • Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::encode const):
(WebKit::RemoteLayerTreeTransaction::LayerCreationProperties::decode):
(WebKit::RemoteLayerTreeTransaction::description const):

  • SourcesCocoa.txt:
  • UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:

(WebKit::RemoteLayerTreeHost::makeNode):

  • UIProcess/RemoteLayerTree/ios/RemoteLayerTreeHostIOS.mm:

(WebKit::RemoteLayerTreeHost::makeNode):

  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.cpp:

(WebKit::GraphicsLayerCARemote::createPlatformCALayer):

  • WebProcess/WebPage/RemoteLayerTree/GraphicsLayerCARemote.h:
  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:

(WebKit::PlatformCALayerRemote::create):
(WebKit::PlatformCALayerRemote::populateCreationProperties):

  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.h:
  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.h:
  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteCustom.mm:

(WebKit::PlatformCALayerRemoteCustom::populateCreationProperties):

  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.h: Added.
  • WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemoteModelHosting.mm: Added.

(WebKit::PlatformCALayerRemoteModelHosting::create):
(WebKit::PlatformCALayerRemoteModelHosting::PlatformCALayerRemoteModelHosting):
(WebKit::PlatformCALayerRemoteModelHosting::clone const):
(WebKit::PlatformCALayerRemoteModelHosting::populateCreationProperties):

  • WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeContext.mm:

(WebKit::RemoteLayerTreeContext::layerDidEnterContext):
Create a new PlatformCALayerRemote subclass that knows about Model, and
passes its model along in the layer creation properties.

For now, the special model layer type will just make a plain layer.
Future patches will replace it with model-specific rendering.

LayoutTests:

  • model-element/model-element-graphics-layers-expected.txt: Added.
  • model-element/model-element-graphics-layers.html: Added.
  • model-element/model-element-renderer-expected.txt:
  • model-element/model-element-renderer-no-source-expected.txt:

Add a test ensuring that we make a compositing layer via layer dump, and update
existing tests that also happen to reveal this via render tree dump as well.

File size: 2.2 KB
Line 
1/*
2 * Copyright (C) 2021 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include "config.h"
27#include "RenderModel.h"
28
29#if ENABLE(MODEL_ELEMENT)
30
31#include "HTMLModelElement.h"
32#include "RenderStyle.h"
33#include <wtf/IsoMallocInlines.h>
34
35namespace WebCore {
36
37WTF_MAKE_ISO_ALLOCATED_IMPL(RenderModel);
38
39RenderModel::RenderModel(HTMLModelElement& element, RenderStyle&& style)
40 : RenderReplaced { element, WTFMove(style) }
41{
42}
43
44// Do not add any code to the destructor, instead, add it to willBeDestroyed().
45RenderModel::~RenderModel() = default;
46
47HTMLModelElement& RenderModel::modelElement() const
48{
49 return downcast<HTMLModelElement>(nodeForNonAnonymous());
50}
51
52bool RenderModel::requiresLayer() const
53{
54 return true;
55}
56
57void RenderModel::updateFromElement()
58{
59 RenderReplaced::updateFromElement();
60 update();
61}
62
63void RenderModel::update()
64{
65 if (renderTreeBeingDestroyed())
66 return;
67
68 contentChanged(ModelChanged);
69}
70
71}
72
73#endif
Note: See TracBrowser for help on using the repository browser.