haikuwebkit/Source/WebCore/rendering/RenderModel.h

60 lines
2.0 KiB
C
Raw Permalink Normal View History

HTMLModelElement needs a renderer https://bugs.webkit.org/show_bug.cgi?id=222114 Reviewed by Simon Fraser. Source/WebCore: Tests: model-element/model-element-ready-load-aborted.html model-element/model-element-ready-load-failed.html model-element/model-element-ready.html model-element/model-element-renderer-no-source.html model-element/model-element-renderer.html * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Add RenderModel.h/cpp * Modules/model-element/HTMLModelElement.cpp: (WebCore::HTMLModelElement::HTMLModelElement): (WebCore::HTMLModelElement::~HTMLModelElement): (WebCore::HTMLModelElement::modelData const): (WebCore::HTMLModelElement::sourcesChanged): (WebCore::HTMLModelElement::setSourceURL): (WebCore::HTMLModelElement::readyPromiseResolve): (WebCore::HTMLModelElement::createElementRenderer): (WebCore::HTMLModelElement::responseReceived): (WebCore::HTMLModelElement::dataReceived): (WebCore::HTMLModelElement::redirectReceived): (WebCore::HTMLModelElement::notifyFinished): * Modules/model-element/HTMLModelElement.h: * Modules/model-element/HTMLModelElement.idl: Add basic loading of model data as a CachedRawResource. In the future, we may want a more specialized loader, but for now this gets the data into a data buffer and that's a good start. Also adds a "ready" promise that resolves when the load completes. This may mutate to an event in the future as the spec moves forward. * rendering/RenderModel.cpp: Added. (WebCore::RenderModel::RenderModel): (WebCore::RenderModel::modelElement const): (WebCore::RenderModel::updateFromElement): * rendering/RenderModel.h: Added. * rendering/RenderObject.h: (WebCore::RenderObject::isRenderModel const): Add a simple RenderReplaced subclass as the starting point of a renderer for <model>. It's enough that it shows up in a render tree dump, but not really anything else. LayoutTests: Add basic tests for loading HTMLModelElement elements and rendering RenderModel elements. * model-element/model-element-ready-expected.txt: Added. * model-element/model-element-ready-load-aborted-expected.txt: Added. * model-element/model-element-ready-load-aborted.html: Added. * model-element/model-element-ready-load-failed-expected.txt: Added. * model-element/model-element-ready-load-failed.html: Added. * model-element/model-element-ready.html: Added. * model-element/model-element-renderer-expected.txt: Added. * model-element/model-element-renderer-no-source-expected.txt: Added. * model-element/model-element-renderer-no-source.html: Added. * model-element/model-element-renderer.html: Added. * model-element/resources: Added. * model-element/resources/heart.usdz: Added. Canonical link: https://commits.webkit.org/234452@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-23 01:43:27 +00:00
/*
* Copyright (C) 2021 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
#if ENABLE(MODEL_ELEMENT)
#include "RenderReplaced.h"
namespace WebCore {
class HTMLModelElement;
class RenderModel final : public RenderReplaced {
WTF_MAKE_ISO_ALLOCATED(RenderModel);
public:
RenderModel(HTMLModelElement&, RenderStyle&&);
virtual ~RenderModel();
HTMLModelElement& modelElement() const;
private:
void element() const = delete;
const char* renderName() const final { return "RenderModel"; }
bool isRenderModel() const final { return true; }
<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. Canonical link: https://commits.webkit.org/234969@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274033 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 11:13:42 +00:00
bool requiresLayer() const final;
HTMLModelElement needs a renderer https://bugs.webkit.org/show_bug.cgi?id=222114 Reviewed by Simon Fraser. Source/WebCore: Tests: model-element/model-element-ready-load-aborted.html model-element/model-element-ready-load-failed.html model-element/model-element-ready.html model-element/model-element-renderer-no-source.html model-element/model-element-renderer.html * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Add RenderModel.h/cpp * Modules/model-element/HTMLModelElement.cpp: (WebCore::HTMLModelElement::HTMLModelElement): (WebCore::HTMLModelElement::~HTMLModelElement): (WebCore::HTMLModelElement::modelData const): (WebCore::HTMLModelElement::sourcesChanged): (WebCore::HTMLModelElement::setSourceURL): (WebCore::HTMLModelElement::readyPromiseResolve): (WebCore::HTMLModelElement::createElementRenderer): (WebCore::HTMLModelElement::responseReceived): (WebCore::HTMLModelElement::dataReceived): (WebCore::HTMLModelElement::redirectReceived): (WebCore::HTMLModelElement::notifyFinished): * Modules/model-element/HTMLModelElement.h: * Modules/model-element/HTMLModelElement.idl: Add basic loading of model data as a CachedRawResource. In the future, we may want a more specialized loader, but for now this gets the data into a data buffer and that's a good start. Also adds a "ready" promise that resolves when the load completes. This may mutate to an event in the future as the spec moves forward. * rendering/RenderModel.cpp: Added. (WebCore::RenderModel::RenderModel): (WebCore::RenderModel::modelElement const): (WebCore::RenderModel::updateFromElement): * rendering/RenderModel.h: Added. * rendering/RenderObject.h: (WebCore::RenderObject::isRenderModel const): Add a simple RenderReplaced subclass as the starting point of a renderer for <model>. It's enough that it shows up in a render tree dump, but not really anything else. LayoutTests: Add basic tests for loading HTMLModelElement elements and rendering RenderModel elements. * model-element/model-element-ready-expected.txt: Added. * model-element/model-element-ready-load-aborted-expected.txt: Added. * model-element/model-element-ready-load-aborted.html: Added. * model-element/model-element-ready-load-failed-expected.txt: Added. * model-element/model-element-ready-load-failed.html: Added. * model-element/model-element-ready.html: Added. * model-element/model-element-renderer-expected.txt: Added. * model-element/model-element-renderer-no-source-expected.txt: Added. * model-element/model-element-renderer-no-source.html: Added. * model-element/model-element-renderer.html: Added. * model-element/resources: Added. * model-element/resources/heart.usdz: Added. Canonical link: https://commits.webkit.org/234452@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-23 01:43:27 +00:00
void updateFromElement() final;
<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. Canonical link: https://commits.webkit.org/234969@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274033 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-06 11:13:42 +00:00
void update();
HTMLModelElement needs a renderer https://bugs.webkit.org/show_bug.cgi?id=222114 Reviewed by Simon Fraser. Source/WebCore: Tests: model-element/model-element-ready-load-aborted.html model-element/model-element-ready-load-failed.html model-element/model-element-ready.html model-element/model-element-renderer-no-source.html model-element/model-element-renderer.html * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: Add RenderModel.h/cpp * Modules/model-element/HTMLModelElement.cpp: (WebCore::HTMLModelElement::HTMLModelElement): (WebCore::HTMLModelElement::~HTMLModelElement): (WebCore::HTMLModelElement::modelData const): (WebCore::HTMLModelElement::sourcesChanged): (WebCore::HTMLModelElement::setSourceURL): (WebCore::HTMLModelElement::readyPromiseResolve): (WebCore::HTMLModelElement::createElementRenderer): (WebCore::HTMLModelElement::responseReceived): (WebCore::HTMLModelElement::dataReceived): (WebCore::HTMLModelElement::redirectReceived): (WebCore::HTMLModelElement::notifyFinished): * Modules/model-element/HTMLModelElement.h: * Modules/model-element/HTMLModelElement.idl: Add basic loading of model data as a CachedRawResource. In the future, we may want a more specialized loader, but for now this gets the data into a data buffer and that's a good start. Also adds a "ready" promise that resolves when the load completes. This may mutate to an event in the future as the spec moves forward. * rendering/RenderModel.cpp: Added. (WebCore::RenderModel::RenderModel): (WebCore::RenderModel::modelElement const): (WebCore::RenderModel::updateFromElement): * rendering/RenderModel.h: Added. * rendering/RenderObject.h: (WebCore::RenderObject::isRenderModel const): Add a simple RenderReplaced subclass as the starting point of a renderer for <model>. It's enough that it shows up in a render tree dump, but not really anything else. LayoutTests: Add basic tests for loading HTMLModelElement elements and rendering RenderModel elements. * model-element/model-element-ready-expected.txt: Added. * model-element/model-element-ready-load-aborted-expected.txt: Added. * model-element/model-element-ready-load-aborted.html: Added. * model-element/model-element-ready-load-failed-expected.txt: Added. * model-element/model-element-ready-load-failed.html: Added. * model-element/model-element-ready.html: Added. * model-element/model-element-renderer-expected.txt: Added. * model-element/model-element-renderer-no-source-expected.txt: Added. * model-element/model-element-renderer-no-source.html: Added. * model-element/model-element-renderer.html: Added. * model-element/resources: Added. * model-element/resources/heart.usdz: Added. Canonical link: https://commits.webkit.org/234452@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273290 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-02-23 01:43:27 +00:00
};
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderModel, isRenderModel())
#endif