Bug 191352 - Make it possible to edit images inline
Summary: Make it possible to edit images inline
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tim Horton
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-07 00:58 PST by Tim Horton
Modified: 2018-11-13 15:28 PST (History)
14 users (show)

See Also:


Attachments
WIP (86.57 KB, patch)
2018-11-07 01:02 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-sierra (2.45 MB, application/zip)
2018-11-07 02:14 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews104 for mac-sierra-wk2 (1.83 MB, application/zip)
2018-11-07 02:57 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews117 for mac-sierra (3.35 MB, application/zip)
2018-11-07 06:13 PST, EWS Watchlist
no flags Details
WIP (95.21 KB, patch)
2018-11-07 11:12 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (99.33 KB, patch)
2018-11-07 15:34 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (99.67 KB, patch)
2018-11-08 01:17 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-sierra (2.47 MB, application/zip)
2018-11-08 02:30 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews106 for mac-sierra-wk2 (2.95 MB, application/zip)
2018-11-08 02:40 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews113 for mac-sierra (3.35 MB, application/zip)
2018-11-08 03:20 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews114 for mac-sierra (3.59 MB, application/zip)
2018-11-08 05:12 PST, EWS Watchlist
no flags Details
Patch (99.66 KB, patch)
2018-11-08 10:11 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-sierra (2.60 MB, application/zip)
2018-11-08 11:10 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews114 for mac-sierra (3.35 MB, application/zip)
2018-11-08 12:17 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews104 for mac-sierra-wk2 (3.36 MB, application/zip)
2018-11-08 13:59 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews113 for mac-sierra (3.46 MB, application/zip)
2018-11-08 14:14 PST, EWS Watchlist
no flags Details
Patch (101.35 KB, patch)
2018-11-09 14:49 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (101.30 KB, patch)
2018-11-09 15:53 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (101.39 KB, patch)
2018-11-09 21:43 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (100.86 KB, patch)
2018-11-10 00:32 PST, Tim Horton
no flags Details | Formatted Diff | Diff
Patch (101.18 KB, patch)
2018-11-12 12:55 PST, Tim Horton
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Horton 2018-11-07 00:58:47 PST
Make it possible to edit images inline
Comment 1 Tim Horton 2018-11-07 01:02:38 PST
Created attachment 354072 [details]
WIP
Comment 2 Tim Horton 2018-11-07 01:03:34 PST
<rdar://problem/30107985>
Comment 3 EWS Watchlist 2018-11-07 01:04:37 PST Comment hidden (obsolete)
Comment 4 EWS Watchlist 2018-11-07 02:14:07 PST Comment hidden (obsolete)
Comment 5 EWS Watchlist 2018-11-07 02:14:08 PST Comment hidden (obsolete)
Comment 6 EWS Watchlist 2018-11-07 02:57:05 PST Comment hidden (obsolete)
Comment 7 EWS Watchlist 2018-11-07 02:57:06 PST Comment hidden (obsolete)
Comment 8 EWS Watchlist 2018-11-07 06:13:36 PST Comment hidden (obsolete)
Comment 9 EWS Watchlist 2018-11-07 06:13:37 PST Comment hidden (obsolete)
Comment 10 Sam Weinig 2018-11-07 08:59:15 PST
I think you forgot to upload the whole patch.

From what I can see in the WebCore part, will this provide a generic mechanism for hosting arbitrary views (NS or UI) as an element (I'm getting this from the generic sounding EmbeddedView enum value in GraphicsLayer).
Comment 11 Tim Horton 2018-11-07 09:10:57 PST
(In reply to Sam Weinig from comment #10)
> I think you forgot to upload the whole patch.
> 
> From what I can see in the WebCore part, will this provide a generic
> mechanism for hosting arbitrary views (NS or UI) as an element (I'm getting
> this from the generic sounding EmbeddedView enum value in GraphicsLayer).

It’s also adopted for contenteditable image, if a pref is turned on. But right now it just plops in a native view, doesn’t do any serialization of the image in either direction, etc. There’s more to do!

But this is the first step. Just need a changelog.
Comment 12 Tim Horton 2018-11-07 11:12:26 PST
Created attachment 354111 [details]
WIP
Comment 13 Tim Horton 2018-11-07 15:34:01 PST
Created attachment 354169 [details]
Patch
Comment 14 EWS Watchlist 2018-11-07 15:37:00 PST Comment hidden (obsolete)
Comment 15 Tim Horton 2018-11-08 01:17:37 PST
Created attachment 354217 [details]
Patch
Comment 16 EWS Watchlist 2018-11-08 01:20:22 PST Comment hidden (obsolete)
Comment 17 EWS Watchlist 2018-11-08 02:30:10 PST Comment hidden (obsolete)
Comment 18 EWS Watchlist 2018-11-08 02:30:12 PST Comment hidden (obsolete)
Comment 19 EWS Watchlist 2018-11-08 02:40:16 PST Comment hidden (obsolete)
Comment 20 EWS Watchlist 2018-11-08 02:40:18 PST Comment hidden (obsolete)
Comment 21 EWS Watchlist 2018-11-08 03:20:05 PST Comment hidden (obsolete)
Comment 22 EWS Watchlist 2018-11-08 03:20:07 PST Comment hidden (obsolete)
Comment 23 EWS Watchlist 2018-11-08 05:12:55 PST Comment hidden (obsolete)
Comment 24 EWS Watchlist 2018-11-08 05:12:57 PST Comment hidden (obsolete)
Comment 25 Tim Horton 2018-11-08 10:10:34 PST
I'm guessing the test failure has something to do with shouldBeNormalFlowOnly/shouldBeSelfPaintingLayer
Comment 26 Tim Horton 2018-11-08 10:11:33 PST
Created attachment 354246 [details]
Patch
Comment 27 EWS Watchlist 2018-11-08 10:14:59 PST Comment hidden (obsolete)
Comment 28 EWS Watchlist 2018-11-08 11:10:29 PST Comment hidden (obsolete)
Comment 29 EWS Watchlist 2018-11-08 11:10:31 PST Comment hidden (obsolete)
Comment 30 EWS Watchlist 2018-11-08 12:17:16 PST Comment hidden (obsolete)
Comment 31 EWS Watchlist 2018-11-08 12:17:18 PST Comment hidden (obsolete)
Comment 32 Dean Jackson 2018-11-08 12:51:39 PST
Comment on attachment 354246 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354246&action=review

I feel like the EmbeddedView part should be a separate patch, and I'm not really qualified to review, but whatever 🤗

> Source/WebCore/platform/graphics/GraphicsLayer.cpp:745
> +    return ++nextEmbeddedViewID;

Shouldn't "next" mean nextEmbeddedViewID++? Or is 0 special?

(/me reads backwards and discovers that 0 is actually special in that it is treated as no assigned ID)

> Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:1170
> +        contentsLayerChanged = true;

Why not just put noteSublayersChanged() here and avoid contentsLayerChanged entirely?

> Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:1031
> +    return { };

Why { } vs 0?

> Source/WebCore/rendering/RenderImage.cpp:227
> +    auto editableValue = element()->attributeWithoutSynchronization(x_apple_editable_imageAttr);
> +    if (editableValue.isNull())
> +        return false;
> +
> +    return editableValue.isEmpty() || equalLettersIgnoringASCIICase(editableValue, "true");

I think this should follow the controls attribute behaviour on HTMLMediaElement. e.g.

return element()->hasAttributeWithoutSynchronization(x_apple_editable_imageAttr);

and don't even look at the value.

> Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:44
> +    , embeddedViewID(0)

You use 0 here :)

Also, why isn't this in the .h file?

> Source/WebKit/Shared/WebPreferences.yaml:1187
> +EditableImagesEnabled:
> +  type: bool
> +  defaultValue: false

No webcoreBinding needed?

> LayoutTests/editing/images/basic-editable-image.html:13
> +    const numberOfStrokesInEditableImageAfterDrawing = (await UIHelper.numberOfStrokesInEditableImage());

Please use WebML to detect if it was a square.

Nit: No need for the () around awaits.

> LayoutTests/editing/images/basic-editable-image.html:15
> +    testRunner.notifyDone();

No need to do this - I believe we wait until all promises are resolved by default.
Comment 33 EWS Watchlist 2018-11-08 13:59:18 PST Comment hidden (obsolete)
Comment 34 EWS Watchlist 2018-11-08 13:59:20 PST Comment hidden (obsolete)
Comment 35 EWS Watchlist 2018-11-08 14:14:43 PST Comment hidden (obsolete)
Comment 36 EWS Watchlist 2018-11-08 14:14:46 PST Comment hidden (obsolete)
Comment 37 Tim Horton 2018-11-09 11:10:23 PST
(In reply to Dean Jackson from comment #32)
> Comment on attachment 354246 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=354246&action=review
> 
> I feel like the EmbeddedView part should be a separate patch, and I'm not
> really qualified to review, but whatever 🤗

I didn't want to do that because it's not testable by itself.

> > Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:1170
> > +        contentsLayerChanged = true;
> 
> Why not just put noteSublayersChanged() here and avoid contentsLayerChanged
> entirely?

Sure

> > Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:1031
> > +    return { };
> 
> Why { } vs 0?

🤗

> > Source/WebCore/rendering/RenderImage.cpp:227
> > +    auto editableValue = element()->attributeWithoutSynchronization(x_apple_editable_imageAttr);
> > +    if (editableValue.isNull())
> > +        return false;
> > +
> > +    return editableValue.isEmpty() || equalLettersIgnoringASCIICase(editableValue, "true");
> 
> I think this should follow the controls attribute behaviour on
> HTMLMediaElement. e.g.
> 
> return
> element()->hasAttributeWithoutSynchronization(x_apple_editable_imageAttr);
> 
> and don't even look at the value.

GOOD IDEA

> > Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:44
> > +    , embeddedViewID(0)
> 
> You use 0 here :)
> 
> Also, why isn't this in the .h file?

Because I didn't want to move all of them.

> > Source/WebKit/Shared/WebPreferences.yaml:1187
> > +EditableImagesEnabled:
> > +  type: bool
> > +  defaultValue: false
> 
> No webcoreBinding needed?

Defaults to a WebCore::Setting with the same name, right?

> > LayoutTests/editing/images/basic-editable-image.html:13
> > +    const numberOfStrokesInEditableImageAfterDrawing = (await UIHelper.numberOfStrokesInEditableImage());
> 
> Please use WebML to detect if it was a square.

Patches welcome.

> Nit: No need for the () around awaits.
> > LayoutTests/editing/images/basic-editable-image.html:15
> > +    testRunner.notifyDone();
> 
> No need to do this - I believe we wait until all promises are resolved by
> default.

Both good to know!
Comment 38 Tim Horton 2018-11-09 11:11:27 PST
(In reply to Tim Horton from comment #37)
> (In reply to Dean Jackson from comment #32)
> > Comment on attachment 354246 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=354246&action=review
> > 
> > > Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:1170
> > > +        contentsLayerChanged = true;
> > 
> > Why not just put noteSublayersChanged() here and avoid contentsLayerChanged
> > entirely?
> 
> Sure

Wait, no, it's because if you're setting to 0 and it's already 0 we won't rebuild :P
Comment 39 Tim Horton 2018-11-09 14:49:40 PST
Created attachment 354389 [details]
Patch
Comment 40 EWS Watchlist 2018-11-09 14:51:31 PST
Attachment 354389 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:960:  developmentRegion is not en.  [xcodeproj/settings] [5]
ERROR: Tools/TestRunnerShared/spi/PencilKitTestSPI.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 61 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 41 Tim Horton 2018-11-09 15:53:52 PST
Created attachment 354401 [details]
Patch
Comment 42 EWS Watchlist 2018-11-09 15:56:38 PST
Attachment 354401 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:960:  developmentRegion is not en.  [xcodeproj/settings] [5]
ERROR: Tools/TestRunnerShared/spi/PencilKitTestSPI.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 61 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 43 Simon Fraser (smfr) 2018-11-09 16:13:07 PST
Comment on attachment 354401 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=354401&action=review

> Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:1168
> +        m_contentsLayer = createPlatformCALayerForEmbeddedView(platformType, embeddedViewID, this);

Probably don't want to create this very time.

> Source/WebCore/platform/graphics/ca/PlatformCALayer.h:80
> +        LayerTypeCustom,
> +        LayerTypeEditableImageLayer,

I would keep Custom at the end.

> Source/WebCore/rendering/RenderLayerCompositor.cpp:2464
> +    m_reevaluateCompositingAfterLayout = true;

I don't think you want this.

> Source/WebKit/UIProcess/ios/WKDrawingView.mm:47
> +    _pencilView = adoptNS([allocPKCanvasViewInstance() initWithFrame:CGRectMake(0, 0, 768, 400)]);

Hardcoded frame!

> Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:787
> +PKCanvasView *findEditableImageCanvas(void)

(void)?
Comment 44 Tim Horton 2018-11-09 21:43:31 PST
Created attachment 354440 [details]
Patch
Comment 45 EWS Watchlist 2018-11-09 21:46:40 PST
Attachment 354440 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:960:  developmentRegion is not en.  [xcodeproj/settings] [5]
ERROR: Tools/TestRunnerShared/spi/PencilKitTestSPI.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 61 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 46 Tim Horton 2018-11-10 00:32:46 PST
Created attachment 354453 [details]
Patch
Comment 47 EWS Watchlist 2018-11-10 00:35:46 PST
Attachment 354453 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:960:  developmentRegion is not en.  [xcodeproj/settings] [5]
ERROR: Tools/TestRunnerShared/spi/PencilKitTestSPI.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 60 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 48 WebKit Commit Bot 2018-11-10 01:58:11 PST
Comment on attachment 354453 [details]
Patch

Clearing flags on attachment: 354453

Committed r238065: <https://trac.webkit.org/changeset/238065>
Comment 49 WebKit Commit Bot 2018-11-10 01:58:14 PST
All reviewed patches have been landed.  Closing bug.
Comment 50 Ryan Haddad 2018-11-10 13:01:43 PST
Reverted r238065 for reason:

Breaks internal builds.

Committed r238070: <https://trac.webkit.org/changeset/238070>
Comment 51 Tim Horton 2018-11-12 12:55:34 PST
Created attachment 354575 [details]
Patch
Comment 52 EWS Watchlist 2018-11-12 12:58:15 PST
Attachment 354575 [details] did not pass style-queue:


ERROR: Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:960:  developmentRegion is not en.  [xcodeproj/settings] [5]
ERROR: Tools/TestRunnerShared/spi/PencilKitTestSPI.h:35:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 2 in 60 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 53 WebKit Commit Bot 2018-11-12 14:04:55 PST
Comment on attachment 354575 [details]
Patch

Clearing flags on attachment: 354575

Committed r238108: <https://trac.webkit.org/changeset/238108>
Comment 54 WebKit Commit Bot 2018-11-12 14:04:57 PST
All reviewed patches have been landed.  Closing bug.
Comment 55 Ryan Haddad 2018-11-13 11:29:44 PST
This change broke the Windows build:
C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(50): error C2259: 'WebCore::PlatformCALayerWin': cannot instantiate abstract class [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(50): note: due to following members:
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(50): note: 'WebCore::GraphicsLayer::EmbeddedViewID WebCore::PlatformCALayer::embeddedViewID(void) const': is abstract
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\PlatformCALayer.h(240): note: see declaration of 'WebCore::PlatformCALayer::embeddedViewID'
C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(55): error C2259: 'WebCore::PlatformCALayerWin': cannot instantiate abstract class [C:\cygwin\home\buildbot\WebKit\WebKitBuild\Release\Source\WebCore\WebCore.vcxproj]
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(55): note: due to following members:
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\win\PlatformCALayerWin.cpp(55): note: 'WebCore::GraphicsLayer::EmbeddedViewID WebCore::PlatformCALayer::embeddedViewID(void) const': is abstract
  C:\cygwin\home\buildbot\WebKit\Source\WebCore\platform\graphics\ca\PlatformCALayer.h(240): note: see declaration of 'WebCore::PlatformCALayer::embeddedViewID

https://build.webkit.org/builders/Apple%20Win%2010%20Release%20%28Build%29/builds/252/steps/compile-webkit/logs/stdio
Comment 56 Tim Horton 2018-11-13 11:30:38 PST
Will sort that out
Comment 57 Ross Kirsling 2018-11-13 15:28:52 PST
Fixed AppleWin build in r238152: <https://trac.webkit.org/changeset/238152>