Title: [205381] trunk
Revision
205381
Author
[email protected]
Date
2016-09-02 16:14:34 -0700 (Fri, 02 Sep 2016)

Log Message

Need to updateEditorState if an element change edit-ability without changing 
selection
https://bugs.webkit.org/show_bug.cgi?id=161546
-and corresponding-
rdar://problem/27806012

Reviewed by Ryosuke Niwa.

Source/WebCore:

Call into the client in case edited state needs to be updated. 
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::updateAppearanceAfterLayout):
* loader/EmptyClients.h:
* page/EditorClient.h:

Source/WebKit/mac:

Every time WebEditorClient::respondToChangedSelection is called, we now save 
whether the last state was contentEditable. That way in 
updateEditorStateAfterLayoutIfNeeded() we can assess whether or not edit-ability 
has changed. 

* WebCoreSupport/WebEditorClient.h:
* WebCoreSupport/WebEditorClient.mm:
(WebEditorClient::respondToChangedSelection):
(WebEditorClient:: updateEditorStateAfterLayoutIfEditabilityChanged):

Source/WebKit2:

Every time WebPage::editorState() is called, we now save whether the last state 
was contentEditable. That way in updateEditorStateAfterLayoutIfNeeded() we can 
assess whether or not edit-ability has changed. 

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient:: updateEditorStateAfterLayoutIfEditabilityChanged):
* WebProcess/WebCoreSupport/WebEditorClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::editorState):
(WebKit::WebPage:: updateEditorStateAfterLayoutIfEditabilityChanged):
(WebKit::WebPage::didStartPageTransition):
* WebProcess/WebPage/WebPage.h:

LayoutTests:

This patch seems to have fixed a bug!
* editing/secure-input/removed-password-input-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205380 => 205381)


--- trunk/LayoutTests/ChangeLog	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/LayoutTests/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
@@ -1,3 +1,16 @@
+2016-09-02  Beth Dakin  <[email protected]>
+
+        Need to updateEditorState if an element change edit-ability without changing 
+        selection
+        https://bugs.webkit.org/show_bug.cgi?id=161546
+        -and corresponding-
+        rdar://problem/27806012
+
+        Reviewed by Ryosuke Niwa.
+
+        This patch seems to have fixed a bug!
+        * editing/secure-input/removed-password-input-expected.txt:
+
 2016-09-02  Jonathan Bedard  <[email protected]>
 
         WebKitTestRunner needs layoutTestController.setDashboardCompatibilityMode

Modified: trunk/LayoutTests/editing/secure-input/removed-password-input-expected.txt (205380 => 205381)


--- trunk/LayoutTests/editing/secure-input/removed-password-input-expected.txt	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/LayoutTests/editing/secure-input/removed-password-input-expected.txt	2016-09-02 23:14:34 UTC (rev 205381)
@@ -7,7 +7,7 @@
 PASS testRunner.secureEventInputIsEnabled is true
 
 After deleting the input:
-FAIL testRunner.secureEventInputIsEnabled should be false. Was true.
+PASS testRunner.secureEventInputIsEnabled is false
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/Source/WebCore/ChangeLog (205380 => 205381)


--- trunk/Source/WebCore/ChangeLog	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebCore/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
@@ -1,3 +1,19 @@
+2016-09-02  Beth Dakin  <[email protected]>
+
+        Need to updateEditorState if an element change edit-ability without changing 
+        selection
+        https://bugs.webkit.org/show_bug.cgi?id=161546
+        -and corresponding-
+        rdar://problem/27806012
+
+        Reviewed by Ryosuke Niwa.
+
+        Call into the client in case edited state needs to be updated. 
+        * editing/FrameSelection.cpp:
+        (WebCore::FrameSelection::updateAppearanceAfterLayout):
+        * loader/EmptyClients.h:
+        * page/EditorClient.h:
+
 2016-09-02  Zalan Bujtas  <[email protected]>
 
         ASSERTION FAILED: !m_committedWidth in WebCore::LineWidth::fitBelowFloats

Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (205380 => 205381)


--- trunk/Source/WebCore/editing/FrameSelection.cpp	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp	2016-09-02 23:14:34 UTC (rev 205381)
@@ -2382,6 +2382,9 @@
 
 void FrameSelection::updateAppearanceAfterLayout()
 {
+    if (auto* client = m_frame->editor().client())
+        client->updateEditorStateAfterLayoutIfEditabilityChanged();
+
     setCaretRectNeedsUpdate();
     updateAndRevealSelection(AXTextStateChangeIntent());
     updateDataDetectorsForSelection();

Modified: trunk/Source/WebCore/loader/EmptyClients.h (205380 => 205381)


--- trunk/Source/WebCore/loader/EmptyClients.h	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebCore/loader/EmptyClients.h	2016-09-02 23:14:34 UTC (rev 205381)
@@ -466,6 +466,7 @@
     void respondToChangedContents() override { }
     void respondToChangedSelection(Frame*) override { }
     void didChangeSelectionAndUpdateLayout() override { }
+    void updateEditorStateAfterLayoutIfEditabilityChanged() override { }
     void discardedComposition(Frame*) override { }
     void didEndEditing() override { }
     void willWriteSelectionToPasteboard(Range*) override { }

Modified: trunk/Source/WebCore/page/EditorClient.h (205380 => 205381)


--- trunk/Source/WebCore/page/EditorClient.h	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebCore/page/EditorClient.h	2016-09-02 23:14:34 UTC (rev 205381)
@@ -91,6 +91,7 @@
     virtual void respondToChangedContents() = 0;
     virtual void respondToChangedSelection(Frame*) = 0;
     virtual void didChangeSelectionAndUpdateLayout() = 0;
+    virtual void updateEditorStateAfterLayoutIfEditabilityChanged() = 0;
     virtual void didEndEditing() = 0;
     virtual void willWriteSelectionToPasteboard(Range*) = 0;
     virtual void didWriteSelectionToPasteboard() = 0;

Modified: trunk/Source/WebKit/mac/ChangeLog (205380 => 205381)


--- trunk/Source/WebKit/mac/ChangeLog	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
@@ -1,3 +1,23 @@
+2016-09-02  Beth Dakin  <[email protected]>
+
+        Need to updateEditorState if an element change edit-ability without changing 
+        selection
+        https://bugs.webkit.org/show_bug.cgi?id=161546
+        -and corresponding-
+        rdar://problem/27806012
+
+        Reviewed by Ryosuke Niwa.
+
+        Every time WebEditorClient::respondToChangedSelection is called, we now save 
+        whether the last state was contentEditable. That way in 
+        updateEditorStateAfterLayoutIfNeeded() we can assess whether or not edit-ability 
+        has changed. 
+
+        * WebCoreSupport/WebEditorClient.h:
+        * WebCoreSupport/WebEditorClient.mm:
+        (WebEditorClient::respondToChangedSelection):
+        (WebEditorClient:: updateEditorStateAfterLayoutIfEditabilityChanged):
+
 2016-09-02  Joseph Pecoraro  <[email protected]>
 
         [Mac] RetainPtr misuse, AnimationController leaks

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h (205380 => 205381)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.h	2016-09-02 23:14:34 UTC (rev 205381)
@@ -111,6 +111,7 @@
     void respondToChangedContents() final;
     void respondToChangedSelection(WebCore::Frame*) final;
     void didChangeSelectionAndUpdateLayout() final { }
+    void updateEditorStateAfterLayoutIfEditabilityChanged() final;
     void discardedComposition(WebCore::Frame*) final;
 
     void registerUndoStep(PassRefPtr<WebCore::UndoStep>) final;
@@ -192,6 +193,9 @@
     NSInteger m_lastCandidateRequestSequenceNumber;
 #endif
 
+    enum class EditorStateIsContentEditable { No, Yes, Unset };
+    EditorStateIsContentEditable m_lastEditorStateWasContentEditable { EditorStateIsContentEditable::Unset };
+
     WeakPtrFactory<WebEditorClient> m_weakPtrFactory;
 };
 

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm (205380 => 205381)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebEditorClient.mm	2016-09-02 23:14:34 UTC (rev 205381)
@@ -345,6 +345,7 @@
     if ([documentView isKindOfClass:[WebHTMLView class]]) {
         [(WebHTMLView *)documentView _selectionChanged];
         [m_webView updateWebViewAdditions];
+        m_lastEditorStateWasContentEditable = [(WebHTMLView *)documentView _isEditable] ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
     }
 
 #if !PLATFORM(IOS)
@@ -628,6 +629,26 @@
     m_haveUndoRedoOperations = YES;
 }
 
+void WebEditorClient::updateEditorStateAfterLayoutIfEditabilityChanged()
+{
+    // FIXME: We should update EditorStateIsContentEditable to track whether the state is richly
+    // editable or plainttext-only.
+    if (m_lastEditorStateWasContentEditable == EditorStateIsContentEditable::Unset)
+        return;
+
+    Frame* frame = core([m_webView _selectedOrMainFrame]);
+    if (!frame)
+        return;
+
+    NSView<WebDocumentView> *documentView = [[kit(frame) frameView] documentView];
+    if (![documentView isKindOfClass:[WebHTMLView class]])
+        return;
+
+    EditorStateIsContentEditable editorStateIsContentEditable = [(WebHTMLView *)documentView _isEditable] ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
+    if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
+        [m_webView updateWebViewAdditions];
+}
+
 void WebEditorClient::registerUndoStep(PassRefPtr<UndoStep> cmd)
 {
     registerUndoOrRedoStep(cmd, false);

Modified: trunk/Source/WebKit2/ChangeLog (205380 => 205381)


--- trunk/Source/WebKit2/ChangeLog	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit2/ChangeLog	2016-09-02 23:14:34 UTC (rev 205381)
@@ -1,3 +1,26 @@
+2016-09-02  Beth Dakin  <[email protected]>
+
+        Need to updateEditorState if an element change edit-ability without changing 
+        selection
+        https://bugs.webkit.org/show_bug.cgi?id=161546
+        -and corresponding-
+        rdar://problem/27806012
+
+        Reviewed by Ryosuke Niwa.
+
+        Every time WebPage::editorState() is called, we now save whether the last state 
+        was contentEditable. That way in updateEditorStateAfterLayoutIfNeeded() we can 
+        assess whether or not edit-ability has changed. 
+
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient:: updateEditorStateAfterLayoutIfEditabilityChanged):
+        * WebProcess/WebCoreSupport/WebEditorClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::editorState):
+        (WebKit::WebPage:: updateEditorStateAfterLayoutIfEditabilityChanged):
+        (WebKit::WebPage::didStartPageTransition):
+        * WebProcess/WebPage/WebPage.h:
+
 2016-09-02  Jonathan Bedard  <[email protected]>
 
         WebKitTestRunner needs layoutTestController.setDashboardCompatibilityMode

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (205380 => 205381)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp	2016-09-02 23:14:34 UTC (rev 205381)
@@ -201,6 +201,11 @@
     m_page->sendPostLayoutEditorStateIfNeeded();
 }
 
+void WebEditorClient::updateEditorStateAfterLayoutIfEditabilityChanged()
+{
+    m_page->updateEditorStateAfterLayoutIfEditabilityChanged();
+}
+
 void WebEditorClient::discardedComposition(Frame*)
 {
     m_page->discardedComposition();

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (205380 => 205381)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h	2016-09-02 23:14:34 UTC (rev 205381)
@@ -63,6 +63,7 @@
     void respondToChangedContents() final;
     void respondToChangedSelection(WebCore::Frame*) final;
     void didChangeSelectionAndUpdateLayout() final;
+    void updateEditorStateAfterLayoutIfEditabilityChanged() final;
     void discardedComposition(WebCore::Frame*) final;
     void didEndEditing() final;
     void willWriteSelectionToPasteboard(WebCore::Range*) final;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (205380 => 205381)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2016-09-02 23:14:34 UTC (rev 205381)
@@ -900,9 +900,24 @@
 
     platformEditorState(frame, result, shouldIncludePostLayoutData);
 
+    m_lastEditorStateWasContentEditable = result.isContentEditable ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
+
     return result;
 }
 
+void WebPage::updateEditorStateAfterLayoutIfEditabilityChanged()
+{
+    // FIXME: We should update EditorStateIsContentEditable to track whether the state is richly
+    // editable or plainttext-only.
+    if (m_lastEditorStateWasContentEditable == EditorStateIsContentEditable::Unset)
+        return;
+
+    Frame& frame = m_page->focusController().focusedOrMainFrame();
+    EditorStateIsContentEditable editorStateIsContentEditable = frame.selection().selection().isContentEditable() ? EditorStateIsContentEditable::Yes : EditorStateIsContentEditable::No;
+    if (m_lastEditorStateWasContentEditable != editorStateIsContentEditable)
+        send(Messages::WebPageProxy::EditorStateChanged(editorState()));
+}
+
 String WebPage::renderTreeExternalRepresentation() const
 {
     return externalRepresentation(m_mainFrame->coreFrame(), RenderAsTextBehaviorNormal);
@@ -2610,6 +2625,7 @@
 #endif
     m_hasEverFocusedElementDueToUserInteractionSincePageTransition = false;
     m_isAssistingNodeDueToUserInteraction = false;
+    m_lastEditorStateWasContentEditable = EditorStateIsContentEditable::Unset;
 #if PLATFORM(MAC)
     if (hasPreviouslyFocusedDueToUserInteraction)
         send(Messages::WebPageProxy::SetHasHadSelectionChangesFromUserInteraction(m_hasEverFocusedElementDueToUserInteractionSincePageTransition));

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (205380 => 205381)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-02 23:13:50 UTC (rev 205380)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2016-09-02 23:14:34 UTC (rev 205381)
@@ -365,6 +365,7 @@
     enum class IncludePostLayoutDataHint { No, Yes };
     EditorState editorState(IncludePostLayoutDataHint = IncludePostLayoutDataHint::Yes) const;
     void sendPostLayoutEditorStateIfNeeded();
+    void updateEditorStateAfterLayoutIfEditabilityChanged();
 
     String renderTreeExternalRepresentation() const;
     String renderTreeExternalRepresentationForPrinting() const;
@@ -1478,6 +1479,9 @@
     bool m_shouldDispatchFakeMouseMoveEvents;
     bool m_isEditorStateMissingPostLayoutData { false };
 
+    enum class EditorStateIsContentEditable { No, Yes, Unset };
+    mutable EditorStateIsContentEditable m_lastEditorStateWasContentEditable { EditorStateIsContentEditable::Unset };
+
 #if PLATFORM(GTK)
     bool m_inputMethodEnabled { false };
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to