⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 285936 in webkit


Ignore:
Timestamp:
Nov 17, 2021, 10:46:04 AM (5 years ago)
Author:
dino@apple.com
Message:

Add ModelDocument for directly showing content that can be handled by <model>
https://bugs.webkit.org/show_bug.cgi?id=233057
rdar://85265880

Reviewed by Darin Adler.

Source/WebCore:

Add a new ModelDocument class that is created when we encounter a MIME-type that
can be handled by the <model> element.

Test: http/tests/model/model-document.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj: Add new files.
  • dom/DOMImplementation.cpp:

(WebCore::DOMImplementation::createDocument): Create a ModelDocument when we
see a MIME-type that <model> can support.

  • dom/Document.h: Add a new ModelDocumentClass which meant I also had to

increase the sizeof DocumentClassFlags.
(WebCore::Document::isModelDocument const):

  • html/ModelDocument.cpp: Added.

(WebCore::ModelDocumentParser::createDocumentStructure):
(WebCore::ModelDocumentParser::appendBytes):
(WebCore::ModelDocumentParser::finish):
(WebCore::ModelDocument::ModelDocument):
(WebCore::ModelDocument::createParser):

  • html/ModelDocument.h: Added.

(isType):

  • platform/MIMETypeRegistry.cpp: Add isSupportedModelMIMEType and test for it

in canShowMIMEType.
(WebCore::MIMETypeRegistry::canShowMIMEType):
(WebCore::MIMETypeRegistry::isSupportedModelMIMEType):

  • platform/MIMETypeRegistry.h:

Source/WebKit:

We don't need to use WKUSDPreviewView if we have ModelDocument.

  • UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:

(-[WKWebViewContentProviderRegistry initWithConfiguration:]):

Source/WTF:

Add a experimental feature: ModelDocumentEnabled
for loading content that can be handled by <model>.

  • Scripts/Preferences/WebPreferencesExperimental.yaml:

LayoutTests:

New test for ModelDocument.

  • http/conf/mime.types: Configure the testing Apache server to serve USDZ files

with the correct MIME type.

  • http/tests/model/UnitBox.usdz: Sample file.
  • http/tests/model/model-document-expected.txt: Added.
  • http/tests/model/model-document.html: New test for a ModelDocument.
Location:
trunk
Files:
6 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r285928 r285936  
     12021-11-17  Dean Jackson  <dino@apple.com>
     2
     3        Add ModelDocument for directly showing content that can be handled by <model>
     4        https://bugs.webkit.org/show_bug.cgi?id=233057
     5        rdar://85265880
     6
     7        Reviewed by Darin Adler.
     8
     9        New test for ModelDocument.
     10
     11        * http/conf/mime.types: Configure the testing Apache server to serve USDZ files
     12        with the correct MIME type.
     13        * http/tests/model/UnitBox.usdz: Sample file.
     14        * http/tests/model/model-document-expected.txt: Added.
     15        * http/tests/model/model-document.html: New test for a ModelDocument.
     16
    1172021-11-17  Youenn Fablet  <youenn@apple.com>
    218
  • trunk/LayoutTests/http/conf/mime.types

    r271939 r285936  
    516516model/vnd.parasolid.transmit.binary
    517517model/vnd.parasolid.transmit.text
     518model/vnd.usdz+zip usdz
    518519model/vnd.vtu
    519520model/vrml                      wrl vrml
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r285805 r285936  
    4848css-dark-mode [ Skip ]
    4949model-element [ Skip ]
     50http/tests/model [ Skip ]
    5051
    5152# Media Stream API testing is not supported for WK1 yet.
  • trunk/LayoutTests/platform/mac/TestExpectations

    r285727 r285936  
    17141714[ Catalina Mojave BigSur ] webaudio/decode-audio-data-webm-opus-resample.html [ Skip ]
    17151715[ Catalina Mojave BigSur ] webaudio/decode-audio-data-webm-vorbis.html [ Skip ]
     1716[ Catalina Mojave BigSur ] http/tests/model/model-document.html [ Skip ]
    17161717
    17171718webkit.org/b/214422 imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audiocontext-interface/suspend-after-construct.html [ Pass Failure ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r285857 r285936  
    132132fast/harness/platform-layer-tree-as-text.html [ Skip ]
    133133model-element/model-element-graphics-layers-opacity.html [ Skip ]
     134
     135# Apple Cocoa only for the moment.
     136http/tests/model [ Skip ]
    134137
    135138# color-filters are off by default
  • trunk/Source/WTF/ChangeLog

    r285910 r285936  
     12021-11-17  Dean Jackson  <dino@apple.com>
     2
     3        Add ModelDocument for directly showing content that can be handled by <model>
     4        https://bugs.webkit.org/show_bug.cgi?id=233057
     5        rdar://85265880
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a experimental feature: ModelDocumentEnabled
     10        for loading content that can be handled by <model>.
     11
     12        * Scripts/Preferences/WebPreferencesExperimental.yaml:
     13
    1142021-11-16  Devin Rousso  <drousso@apple.com>
    215
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml

    r285575 r285936  
    895895      default: false
    896896
     897ModelDocumentEnabled:
     898  type: bool
     899  humanReadableName: "HTML <model> elements for stand-alone document"
     900  humanReadableDescription: "HTML <model> element for model documents"
     901  condition: ENABLE(MODEL_ELEMENT)
     902  webcoreBinding: RuntimeEnabledFeatures
     903  defaultValue:
     904    WebKitLegacy:
     905      default: false
     906    WebKit:
     907      "ENABLE(SEPARATED_MODEL)": true
     908      default: false
     909
    897910ModelElementEnabled:
    898911  type: bool
  • trunk/Source/WebCore/ChangeLog

    r285935 r285936  
     12021-11-17  Dean Jackson  <dino@apple.com>
     2
     3        Add ModelDocument for directly showing content that can be handled by <model>
     4        https://bugs.webkit.org/show_bug.cgi?id=233057
     5        rdar://85265880
     6
     7        Reviewed by Darin Adler.
     8
     9        Add a new ModelDocument class that is created when we encounter a MIME-type that
     10        can be handled by the <model> element.
     11
     12        Test: http/tests/model/model-document.html
     13
     14        * Sources.txt:
     15        * WebCore.xcodeproj/project.pbxproj: Add new files.
     16
     17        * dom/DOMImplementation.cpp:
     18        (WebCore::DOMImplementation::createDocument): Create a ModelDocument when we
     19        see a MIME-type that <model> can support.
     20
     21        * dom/Document.h: Add a new ModelDocumentClass which meant I also had to
     22        increase the sizeof DocumentClassFlags.
     23        (WebCore::Document::isModelDocument const):
     24
     25        * html/ModelDocument.cpp: Added.
     26        (WebCore::ModelDocumentParser::createDocumentStructure):
     27        (WebCore::ModelDocumentParser::appendBytes):
     28        (WebCore::ModelDocumentParser::finish):
     29        (WebCore::ModelDocument::ModelDocument):
     30        (WebCore::ModelDocument::createParser):
     31        * html/ModelDocument.h: Added.
     32        (isType):
     33
     34        * platform/MIMETypeRegistry.cpp: Add isSupportedModelMIMEType and test for it
     35        in canShowMIMEType.
     36        (WebCore::MIMETypeRegistry::canShowMIMEType):
     37        (WebCore::MIMETypeRegistry::isSupportedModelMIMEType):
     38        * platform/MIMETypeRegistry.h:
     39
    1402021-11-17  Commit Queue  <commit-queue@webkit.org>
    241
  • trunk/Source/WebCore/Sources.txt

    r285822 r285936  
    12941294html/MediaElementSession.cpp
    12951295html/MediaFragmentURIParser.cpp
     1296html/ModelDocument.cpp
    12961297html/MonthInputType.cpp
    12971298html/NumberInputType.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r285916 r285936  
    944944                313BCE1C235E3BE500FC39E5 /* ElementContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 313BCE1B235E3BDB00FC39E5 /* ElementContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    945945                313DE87023A96973008FC47B /* GraphicsContextGL.h in Headers */ = {isa = PBXBuildFile; fileRef = 313DE86F23A96967008FC47B /* GraphicsContextGL.h */; settings = {ATTRIBUTES = (Private, ); }; };
     946                313E79EA273C86B80097F905 /* ModelDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 313E79E9273C86B80097F905 /* ModelDocument.h */; };
    946947                3140379B124BEA7F00AF40E4 /* WebCoreMotionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
    947948                3140379D124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31403799124BEA7F00AF40E4 /* DeviceOrientationClientIOS.h */; };
     
    79037904                313DE86D23A96966008FC47B /* GraphicsContextGL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGL.cpp; sourceTree = "<group>"; };
    79047905                313DE86F23A96967008FC47B /* GraphicsContextGL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGL.h; sourceTree = "<group>"; };
     7906                313E79E9273C86B80097F905 /* ModelDocument.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ModelDocument.h; sourceTree = "<group>"; };
     7907                313E79EC273C86E80097F905 /* ModelDocument.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ModelDocument.cpp; sourceTree = "<group>"; };
    79057908                31403797124BEA7F00AF40E4 /* WebCoreMotionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreMotionManager.h; sourceTree = "<group>"; };
    79067909                31403798124BEA7F00AF40E4 /* WebCoreMotionManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreMotionManager.mm; sourceTree = "<group>"; };
     
    1895518958                        isa = PBXGroup;
    1895618959                        children = (
    18957                                 59B5977111086556007159E8 /* jsc */,
    1895818960                                1A569CE20D7E2B82007C3983 /* objc */,
    1895918961                                599E758F11055A1F00D904FA /* Bridge.h */,
    1896018962                                1A71D5790F33819000F9CE4E /* IdentifierRep.cpp */,
    1896118963                                1A71D57A0F33819000F9CE4E /* IdentifierRep.h */,
     18964                                59B5977111086556007159E8 /* jsc */,
    1896218965                                1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */,
    1896318966                                1A569CF00D7E2B82007C3983 /* runtime_array.h */,
     
    2489624899                                07A6D1E91491137700051D0C /* MediaFragmentURIParser.cpp */,
    2489724900                                07A6D1EA1491137700051D0C /* MediaFragmentURIParser.h */,
     24901                                313E79EC273C86E80097F905 /* ModelDocument.cpp */,
     24902                                313E79E9273C86B80097F905 /* ModelDocument.h */,
    2489824903                                F55B3D911251F12D003EF269 /* MonthInputType.cpp */,
    2489924904                                F55B3D921251F12D003EF269 /* MonthInputType.h */,
     
    3521435219                                5715610C234C1CA1008FC7AB /* MockWebAuthenticationConfiguration.h in Headers */,
    3521535220                                2DC8D39825F2FE9700CFCBAB /* Model.h in Headers */,
     35221                                313E79EA273C86B80097F905 /* ModelDocument.h in Headers */,
    3521635222                                BC2B41172732F41E00A2D191 /* ModelPlayer.h in Headers */,
    3521735223                                BC2B41192732F42900A2D191 /* ModelPlayerClient.h in Headers */,
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r271011 r285936  
    4646#include "PluginData.h"
    4747#include "PluginDocument.h"
     48#include "RuntimeEnabledFeatures.h"
    4849#include "SVGDocument.h"
    4950#include "SVGNames.h"
     
    5859#include <wtf/StdLibExtras.h>
    5960
     61#if ENABLE(MODEL_ELEMENT)
     62#include "ModelDocument.h"
     63#endif
     64
    6065namespace WebCore {
    6166
     
    161166    if (MediaPlayer::supportsType(parameters) != MediaPlayer::SupportsType::IsNotSupported)
    162167        return MediaDocument::create(frame, settings, url);
     168#endif
     169
     170#if ENABLE(MODEL_ELEMENT)
     171    if (MIMETypeRegistry::isUSDMIMEType(contentType) && RuntimeEnabledFeatures::sharedFeatures().modelDocumentEnabled())
     172        return ModelDocument::create(frame, settings, url);
    163173#endif
    164174
  • trunk/Source/WebCore/dom/Document.h

    r285528 r285936  
    303303    TextDocumentClass = 1 << 6,
    304304    XMLDocumentClass = 1 << 7,
     305#if ENABLE(MODEL_ELEMENT)
     306    ModelDocumentClass = 1 << 8,
     307#endif
    305308};
    306 using DocumentClassFlags = unsigned char;
     309using DocumentClassFlags = uint16_t;
    307310
    308311enum class DocumentCompatibilityMode : unsigned char {
     
    541544    bool isMediaDocument() const { return m_documentClasses & MediaDocumentClass; }
    542545    bool isTextDocument() const { return m_documentClasses & TextDocumentClass; }
     546#if ENABLE(MODEL_ELEMENT)
     547    bool isModelDocument() const { return m_documentClasses & ModelDocumentClass; }
     548#endif
    543549    bool hasSVGRootNode() const;
    544550    virtual bool isFrameSet() const { return false; }
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r285575 r285936  
    259259#endif
    260260
     261#if ENABLE(MODEL_ELEMENT)
     262    void setModelDocumentEnabled(bool isEnabled) { m_modelDocumentEnabled = isEnabled; }
     263    bool modelDocumentEnabled() const { return m_modelDocumentEnabled; }
     264#endif
     265
    261266private:
    262267    // Never instantiate.
     
    399404#endif
    400405
     406#if ENABLE(MODEL_ELEMENT)
     407    bool m_modelDocumentEnabled { false };
     408#endif
     409
    401410    friend class NeverDestroyed<RuntimeEnabledFeatures>;
    402411};
  • trunk/Source/WebCore/platform/MIMETypeRegistry.cpp

    r285635 r285936  
    659659#endif
    660660
     661#if ENABLE(MODEL_ELEMENT)
     662    if (isSupportedModelMIMEType(mimeType))
     663        return true;
     664#endif
     665
    661666    if (startsWithLettersIgnoringASCIICase(mimeType, "text/"))
    662667        return !isUnsupportedTextMIMEType(mimeType);
     
    687692    static constexpr SortedArraySet usdMIMETypeSet { usdMIMETypeArray };
    688693    return usdMIMETypeSet.contains(mimeType);
     694}
     695
     696bool MIMETypeRegistry::isSupportedModelMIMEType(const String& mimeType)
     697{
     698    return MIMETypeRegistry::isUSDMIMEType(mimeType);
    689699}
    690700
  • trunk/Source/WebCore/platform/MIMETypeRegistry.h

    r285635 r285936  
    109109    WEBCORE_EXPORT static bool isUSDMIMEType(const String& mimeType);
    110110
     111    WEBCORE_EXPORT static bool isSupportedModelMIMEType(const String& mimeType);
     112
    111113    // Check to see if a MIME type is suitable for being shown inside a page.
    112114    // Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(),
  • trunk/Source/WebKit/ChangeLog

    r285922 r285936  
     12021-11-17  Dean Jackson  <dino@apple.com>
     2
     3        Add ModelDocument for directly showing content that can be handled by <model>
     4        https://bugs.webkit.org/show_bug.cgi?id=233057
     5        rdar://85265880
     6
     7        Reviewed by Darin Adler.
     8
     9        We don't need to use WKUSDPreviewView if we have ModelDocument.
     10
     11        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
     12        (-[WKWebViewContentProviderRegistry initWithConfiguration:]):
     13
    1142021-11-17  Antoine Quint  <graouts@webkit.org>
    215
  • trunk/Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm

    r285635 r285936  
    5555#endif
    5656
    57 #if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS)
     57#if USE(SYSTEM_PREVIEW) && !HAVE(UIKIT_WEBKIT_INTERNALS) && !ENABLE(MODEL_ELEMENT)
    5858    if (configuration._systemPreviewEnabled) {
    5959        for (auto& type : WebCore::MIMETypeRegistry::usdMIMETypes())
Note: See TracChangeset for help on using the changeset viewer.