Bug 161546

Summary: Need to updateEditorState if an element change edit-ability without changing selection
Product: WebKit Reporter: Beth Dakin <bdakin>
Component: WebKit Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, buildbot, rniwa, thorton
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
rniwa: review+, buildbot: commit-queue-
Archive of layout-test-results from ews105 for mac-yosemite-wk2 none

Description Beth Dakin 2016-09-02 13:52:39 PDT
Need to updateEditorState if an element change edit-ability without changing selection

rdar://problem/27806012
Comment 1 Beth Dakin 2016-09-02 14:02:47 PDT
Created attachment 287811 [details]
Patch
Comment 2 Build Bot 2016-09-02 14:42:58 PDT
Comment on attachment 287811 [details]
Patch

Attachment 287811 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1996343

New failing tests:
editing/secure-input/removed-password-input.html
Comment 3 Build Bot 2016-09-02 14:43:03 PDT
Created attachment 287817 [details]
Archive of layout-test-results from ews105 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 4 Ryosuke Niwa 2016-09-02 14:56:49 PDT
Comment on attachment 287811 [details]
Patch

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

r=me assuming you fix builds & tests and stuff.

> Source/WebCore/editing/FrameSelection.cpp:2386
> +        client->updateEditorStateAfterLayoutIfNeeded();

Instead of saying IfNeeded, can we explicitly say IfEditabilityChanged to make semantics clear?

> Source/WebCore/page/EditorClient.h:187
> +
> +    virtual void updateEditorStateAfterLayoutIfNeeded() = 0;

We should add this right at where didChangeSelectionAndUpdateLayout is declared.

> Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp:557
> +void WebEditorClient::updateEditorStateAfterLayoutIfNeeded()
> +{
> +    m_page->updateEditorStateAfterLayoutIfNeeded();
> +}
> +

Ditto about defining this next to didChangeSelectionAndUpdateLayout.

> Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h:172
> +    void updateEditorStateAfterLayoutIfNeeded() final;
> +

Ditto about the location.

> Source/WebKit2/WebProcess/WebPage/WebPage.cpp:910
> +    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;

This doesn't detect the case when the value changes between plaintextonly and true.
It's probably not a big deal but you can check that condition by checking both isContentEditable and isContentRichlyEditable.
You might wanna add FIXME for now.

> Source/WebKit2/WebProcess/WebPage/WebPage.h:1479
> +    EditorStateIsContentEditable m_lastEditorStateWasContentEditable { EditorStateIsContentEditable::Unset };

Should we just make this mutable instead of removing const from editorState?
Comment 5 Beth Dakin 2016-09-02 16:17:54 PDT
(In reply to comment #4)
> Comment on attachment 287811 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=287811&action=review
> 
> r=me assuming you fix builds & tests and stuff.

Thanks!

> 
> > Source/WebCore/editing/FrameSelection.cpp:2386
> > +        client->updateEditorStateAfterLayoutIfNeeded();
> 
> Instead of saying IfNeeded, can we explicitly say IfEditabilityChanged to
> make semantics clear?
> 

Yes, fixed.

> > Source/WebCore/page/EditorClient.h:187
> > +
> > +    virtual void updateEditorStateAfterLayoutIfNeeded() = 0;
> 
> We should add this right at where didChangeSelectionAndUpdateLayout is
> declared.
> 

Moved.

> > Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp:557
> > +void WebEditorClient::updateEditorStateAfterLayoutIfNeeded()
> > +{
> > +    m_page->updateEditorStateAfterLayoutIfNeeded();
> > +}
> > +
> 
> Ditto about defining this next to didChangeSelectionAndUpdateLayout.
> 

Moved.

> > Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h:172
> > +    void updateEditorStateAfterLayoutIfNeeded() final;
> > +
> 
> Ditto about the location.
> 

Moved.

> > Source/WebKit2/WebProcess/WebPage/WebPage.cpp:910
> > +    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
> 
> This doesn't detect the case when the value changes between plaintextonly
> and true.
> It's probably not a big deal but you can check that condition by checking
> both isContentEditable and isContentRichlyEditable.
> You might wanna add FIXME for now.
> 

OH, good point. FIXME for now.

> > Source/WebKit2/WebProcess/WebPage/WebPage.h:1479
> > +    EditorStateIsContentEditable m_lastEditorStateWasContentEditable { EditorStateIsContentEditable::Unset };
> 
> Should we just make this mutable instead of removing const from editorState?

Yeah, sure!

https://trac.webkit.org/changeset/205381
Comment 6 Ryosuke Niwa 2016-09-02 19:14:38 PDT
Windows build fix landed in http://trac.webkit.org/changeset/205393.