Add ModelDocument for directly showing content that can be handled by <model>
rdar://85265880
Created attachment 444128 [details] Patch
Oh, I forgot <model> is only available in newer macOSes.
Comment on attachment 444128 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444128&action=review > Source/WTF/wtf/PlatformHave.h:1095 > +#define HAVE_MODEL_DOCUMENT 1 What's the rationale for having a separate flag for this? Seems like using ENABLE(MODEL_ELEMENT) would be fine.
Comment on attachment 444128 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444128&action=review >> Source/WTF/wtf/PlatformHave.h:1095 >> +#define HAVE_MODEL_DOCUMENT 1 > > What's the rationale for having a separate flag for this? Seems like using ENABLE(MODEL_ELEMENT) would be fine. No real reason other than I just wanted to keep it separate for now. We still need to improve <model> before this could completely replace the WKUSDPreviewView, which is one of the goals.
Created attachment 444148 [details] Patch
(In reply to Dean Jackson from comment #5) > Comment on attachment 444128 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=444128&action=review > > >> Source/WTF/wtf/PlatformHave.h:1095 > >> +#define HAVE_MODEL_DOCUMENT 1 > > > > What's the rationale for having a separate flag for this? Seems like using ENABLE(MODEL_ELEMENT) would be fine. > > No real reason other than I just wanted to keep it separate for now. We > still need to improve <model> before this could completely replace the > WKUSDPreviewView, which is one of the goals. I think a Setting would be better for this. Seems more useful to have it compiled in and testable, then compiled out.
Comment on attachment 444148 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444148&action=review > Source/WTF/wtf/PlatformHave.h:1096 > +#if PLATFORM(COCOA) > +#define HAVE_MODEL_DOCUMENT 1 > +#endif I'd remove this and replace it with a Setting. > Source/WebCore/dom/Document.h:309 > -using DocumentClassFlags = unsigned char; > +using DocumentClassFlags = uint32_t; Seems like uint16_t would be more appropriate for the size. > Source/WebCore/html/ModelDocument.cpp:98 > + auto styleContent = makeString("body { background-color: white; text-align: center; }\n", maybe I am missing it, but I think this has any values being concatenated, so this shouldn't use makeString(). Instead, it can just use a " .. "_s. > LayoutTests/platform/mac-wk1/TestExpectations:50 > +http/tests/model/model-document.html [ Skip ] I would skip all of 50http/tests/model. The feature isn't supported or enabled there so no reason to test it. > LayoutTests/platform/mac/TestExpectations:1716 > +[ Catalina Mojave BigSur ] http/tests/model/model-document.html [ Skip ] Why are these being skipped? > LayoutTests/platform/win/TestExpectations:136 > +# Apple Cocoa only for the moment. > +http/tests/model/model-document.html [ Skip ] Again, I would just skip the whole directory.
Created attachment 444188 [details] Patch
Oops. Didn't read Sam's comments before uploading. Will send a new patch.
Comment on attachment 444148 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444148&action=review >> Source/WTF/wtf/PlatformHave.h:1096 >> +#endif > > I'd remove this and replace it with a Setting. OK. >> Source/WebCore/dom/Document.h:309 >> +using DocumentClassFlags = uint32_t; > > Seems like uint16_t would be more appropriate for the size. OK. >> Source/WebCore/html/ModelDocument.cpp:98 >> + auto styleContent = makeString("body { background-color: white; text-align: center; }\n", > > maybe I am missing it, but I think this has any values being concatenated, so this shouldn't use makeString(). Instead, it can just use a " .. "_s. OK. >> LayoutTests/platform/mac-wk1/TestExpectations:50 >> +http/tests/model/model-document.html [ Skip ] > > I would skip all of 50http/tests/model. The feature isn't supported or enabled there so no reason to test it. OK. >> LayoutTests/platform/mac/TestExpectations:1716 >> +[ Catalina Mojave BigSur ] http/tests/model/model-document.html [ Skip ] > > Why are these being skipped? I'll check.
Created attachment 444452 [details] Patch
Comment on attachment 444452 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444452&action=review > Source/WebCore/dom/Document.h:309 > -using DocumentClassFlags = unsigned char; > +using DocumentClassFlags = uint16_t; This should be changed to be an OptionSet at some point; would be a pretty small change, believe it or not. That does not require using "enum class" in case someone tries to convince you it does, but also this would be a great choice for an enum class since all the values have DocumentClass in their names. Also, the DocumentClass enum should use uint16_t as its underlying type. Also does not require "enum class". > Source/WebCore/html/ModelDocument.cpp:98 > + auto styleContent = "body { background-color: white; text-align: center; }\n@media (prefers-color-scheme: dark) { body { background-color: rgb(32, 32, 37); } }\nmodel { width: 80vw; height: 80vh; }\n"_s; This does not have to be one large line. Can use string pasting to format however you like: auto styleContent = "body { background-color: white; text-align: center; }\n" "@media (prefers-color-scheme: dark) { body { background-color: rgb(32, 32, 37); } }\n" ; Maybe not exactly like that, but something like that. > Source/WebCore/html/ModelDocument.cpp:119 > + RefPtr<Frame> frame = document.frame(); Just RefPtr is fine, no need to write <Frame>. > Source/WebCore/html/ModelDocument.h:61 > +#endif // ENABLE(VIDEO) Oops, MODEL_ELEMENT.
Committed r285936 (244345@main): <https://commits.webkit.org/244345@main>