Title: [291919] branches/safari-613-branch
Revision
291919
Author
[email protected]
Date
2022-03-25 18:51:32 -0700 (Fri, 25 Mar 2022)

Log Message

Cherry-pick r290564. rdar://problem/89524668

    Force -webkit-user-modify used style to readonly for inert nodes
    https://bugs.webkit.org/show_bug.cgi?id=237244

    Reviewed by Darin Adler.

    This disallows programmatic edition of contenteditable inert nodes. Edition via user-input is
    already prevented by forcing pointer-events style to none.

    We create a seperate effectiveUserModify, similar to effectiveUserSelect/effectivePointerEvents,
    to avoid changing the computed style.

    This behaviour also matches Blink & Gecko.

    LayoutTests/imported/w3c:

    * web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt:

    Source/WebCore:

    Test: imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative.html

    * dom/Node.cpp:
    (WebCore::computeEditabilityFromComputedStyle):
    * editing/ApplyBlockElementCommand.cpp:
    (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
    * editing/ReplaceSelectionCommand.cpp:
    (WebCore::ReplaceSelectionCommand::doApply):
    * rendering/EventRegion.cpp:
    (WebCore::EventRegion::unite):
    * rendering/RenderElement.cpp:
    (WebCore::RenderElement::styleWillChange):
    * rendering/style/RenderStyle.h:
    (WebCore::RenderStyle::effectiveUserModify const):
    * style/StyleTreeResolver.cpp:
    (WebCore::Style::TreeResolver::resolveElement):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290564 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog (291918 => 291919)


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-03-26 01:51:32 UTC (rev 291919)
@@ -1,5 +1,64 @@
 2022-03-23  Alan Coon  <[email protected]>
 
+        Cherry-pick r290564. rdar://problem/89524668
+
+    Force -webkit-user-modify used style to readonly for inert nodes
+    https://bugs.webkit.org/show_bug.cgi?id=237244
+    
+    Reviewed by Darin Adler.
+    
+    This disallows programmatic edition of contenteditable inert nodes. Edition via user-input is
+    already prevented by forcing pointer-events style to none.
+    
+    We create a seperate effectiveUserModify, similar to effectiveUserSelect/effectivePointerEvents,
+    to avoid changing the computed style.
+    
+    This behaviour also matches Blink & Gecko.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt:
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative.html
+    
+    * dom/Node.cpp:
+    (WebCore::computeEditabilityFromComputedStyle):
+    * editing/ApplyBlockElementCommand.cpp:
+    (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
+    * editing/ReplaceSelectionCommand.cpp:
+    (WebCore::ReplaceSelectionCommand::doApply):
+    * rendering/EventRegion.cpp:
+    (WebCore::EventRegion::unite):
+    * rendering/RenderElement.cpp:
+    (WebCore::RenderElement::styleWillChange):
+    * rendering/style/RenderStyle.h:
+    (WebCore::RenderStyle::effectiveUserModify const):
+    * style/StyleTreeResolver.cpp:
+    (WebCore::Style::TreeResolver::resolveElement):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-27  Tim Nguyen  <[email protected]>
+
+            Force -webkit-user-modify used style to readonly for inert nodes
+            https://bugs.webkit.org/show_bug.cgi?id=237244
+
+            Reviewed by Darin Adler.
+
+            This disallows programmatic edition of contenteditable inert nodes. Edition via user-input is
+            already prevented by forcing pointer-events style to none.
+
+            We create a seperate effectiveUserModify, similar to effectiveUserSelect/effectivePointerEvents,
+            to avoid changing the computed style.
+
+            This behaviour also matches Blink & Gecko.
+
+            * web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt:
+
+2022-03-23  Alan Coon  <[email protected]>
+
         Cherry-pick r290550. rdar://problem/88675827
 
     Update CSP handling of _javascript_ URLs

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt (291918 => 291919)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt	2022-03-26 01:51:32 UTC (rev 291919)
@@ -1,11 +1,10 @@
 
-FAIL execCommand should return the same value assert_equals: [false,true,false,false] at index 1 expected false but got true
-FAIL The resulting textContent should be the same value assert_equals: ["{target}","{}","{target}","{target}"] at index 1 expected "{target}" but got "{}"
+PASS execCommand should return the same value
+PASS The resulting textContent should be the same value
 {
 target
 
 }
-{}
 {
 target
 
@@ -14,3 +13,7 @@
 target
 
 }
+{
+target
+
+}

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-26 01:51:32 UTC (rev 291919)
@@ -1,5 +1,79 @@
 2022-03-23  Alan Coon  <[email protected]>
 
+        Cherry-pick r290564. rdar://problem/89524668
+
+    Force -webkit-user-modify used style to readonly for inert nodes
+    https://bugs.webkit.org/show_bug.cgi?id=237244
+    
+    Reviewed by Darin Adler.
+    
+    This disallows programmatic edition of contenteditable inert nodes. Edition via user-input is
+    already prevented by forcing pointer-events style to none.
+    
+    We create a seperate effectiveUserModify, similar to effectiveUserSelect/effectivePointerEvents,
+    to avoid changing the computed style.
+    
+    This behaviour also matches Blink & Gecko.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/inert/inert-and-contenteditable.tentative-expected.txt:
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative.html
+    
+    * dom/Node.cpp:
+    (WebCore::computeEditabilityFromComputedStyle):
+    * editing/ApplyBlockElementCommand.cpp:
+    (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
+    * editing/ReplaceSelectionCommand.cpp:
+    (WebCore::ReplaceSelectionCommand::doApply):
+    * rendering/EventRegion.cpp:
+    (WebCore::EventRegion::unite):
+    * rendering/RenderElement.cpp:
+    (WebCore::RenderElement::styleWillChange):
+    * rendering/style/RenderStyle.h:
+    (WebCore::RenderStyle::effectiveUserModify const):
+    * style/StyleTreeResolver.cpp:
+    (WebCore::Style::TreeResolver::resolveElement):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@290564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-27  Tim Nguyen  <[email protected]>
+
+            Force -webkit-user-modify used style to readonly for inert nodes
+            https://bugs.webkit.org/show_bug.cgi?id=237244
+
+            Reviewed by Darin Adler.
+
+            This disallows programmatic edition of contenteditable inert nodes. Edition via user-input is
+            already prevented by forcing pointer-events style to none.
+
+            We create a seperate effectiveUserModify, similar to effectiveUserSelect/effectivePointerEvents,
+            to avoid changing the computed style.
+
+            This behaviour also matches Blink & Gecko.
+
+            Test: imported/w3c/web-platform-tests/inert/inert-and-contenteditable.tentative.html
+
+            * dom/Node.cpp:
+            (WebCore::computeEditabilityFromComputedStyle):
+            * editing/ApplyBlockElementCommand.cpp:
+            (WebCore::ApplyBlockElementCommand::rangeForParagraphSplittingTextNodesIfNeeded):
+            * editing/ReplaceSelectionCommand.cpp:
+            (WebCore::ReplaceSelectionCommand::doApply):
+            * rendering/EventRegion.cpp:
+            (WebCore::EventRegion::unite):
+            * rendering/RenderElement.cpp:
+            (WebCore::RenderElement::styleWillChange):
+            * rendering/style/RenderStyle.h:
+            (WebCore::RenderStyle::effectiveUserModify const):
+            * style/StyleTreeResolver.cpp:
+            (WebCore::Style::TreeResolver::resolveElement):
+
+2022-03-23  Alan Coon  <[email protected]>
+
         Cherry-pick r290550. rdar://problem/88675827
 
     Update CSP handling of _javascript_ URLs

Modified: branches/safari-613-branch/Source/WebCore/dom/Node.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/dom/Node.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/dom/Node.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -766,7 +766,8 @@
         // therefore non editable.
         if (treatment == Node::UserSelectAllIsAlwaysNonEditable && style->effectiveUserSelect() == UserSelect::All)
             return Node::Editability::ReadOnly;
-        switch (style->userModify()) {
+
+        switch (style->effectiveUserModify()) {
         case UserModify::ReadOnly:
             return Node::Editability::ReadOnly;
         case UserModify::ReadWrite:

Modified: branches/safari-613-branch/Source/WebCore/editing/ApplyBlockElementCommand.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/editing/ApplyBlockElementCommand.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/editing/ApplyBlockElementCommand.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -238,7 +238,7 @@
         unsigned endOffset = end.offsetInContainerNode();
         bool preservesNewLine = endStyle->preserveNewline();
         bool collapseWhiteSpace = endStyle->collapseWhiteSpace();
-        auto userModify = endStyle->userModify();
+        auto userModify = endStyle->effectiveUserModify();
         endStyle = nullptr;
 
         if (preservesNewLine && start == end && endOffset < end.containerNode()->length()) {

Modified: branches/safari-613-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/editing/ReplaceSelectionCommand.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -1119,8 +1119,8 @@
         return;
     
     // We can skip matching the style if the selection is plain text.
-    if ((selection.start().deprecatedNode()->renderer() && selection.start().deprecatedNode()->renderer()->style().userModify() == UserModify::ReadWritePlaintextOnly)
-        && (selection.end().deprecatedNode()->renderer() && selection.end().deprecatedNode()->renderer()->style().userModify() == UserModify::ReadWritePlaintextOnly))
+    if ((selection.start().deprecatedNode()->renderer() && selection.start().deprecatedNode()->renderer()->style().effectiveUserModify() == UserModify::ReadWritePlaintextOnly)
+        && (selection.end().deprecatedNode()->renderer() && selection.end().deprecatedNode()->renderer()->style().effectiveUserModify() == UserModify::ReadWritePlaintextOnly))
         m_matchStyle = false;
     
     if (m_matchStyle) {

Modified: branches/safari-613-branch/Source/WebCore/rendering/EventRegion.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/rendering/EventRegion.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/rendering/EventRegion.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -132,7 +132,7 @@
 #endif
 
 #if ENABLE(EDITABLE_REGION)
-    if (m_editableRegion && (overrideUserModifyIsEditable || style.userModify() != UserModify::ReadOnly)) {
+    if (m_editableRegion && (overrideUserModifyIsEditable || style.effectiveUserModify() != UserModify::ReadOnly)) {
         m_editableRegion->unite(region);
         LOG_WITH_STREAM(EventRegions, stream << " uniting editable region");
     }

Modified: branches/safari-613-branch/Source/WebCore/rendering/RenderElement.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/rendering/RenderElement.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/rendering/RenderElement.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -858,8 +858,8 @@
             if (m_style.eventListenerRegionTypes() != newStyle.eventListenerRegionTypes())
                 return true;
 #if ENABLE(EDITABLE_REGION)
-            bool wasEditable = m_style.userModify() != UserModify::ReadOnly;
-            bool isEditable = newStyle.userModify() != UserModify::ReadOnly;
+            bool wasEditable = m_style.effectiveUserModify() != UserModify::ReadOnly;
+            bool isEditable = newStyle.effectiveUserModify() != UserModify::ReadOnly;
             if (wasEditable != isEditable)
                 return page().shouldBuildEditableRegion();
 #endif

Modified: branches/safari-613-branch/Source/WebCore/rendering/style/RenderStyle.h (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/rendering/style/RenderStyle.h	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/rendering/style/RenderStyle.h	2022-03-26 01:51:32 UTC (rev 291919)
@@ -610,6 +610,7 @@
     int marqueeLoopCount() const { return m_rareNonInheritedData->marquee->loops; }
     MarqueeBehavior marqueeBehavior() const { return static_cast<MarqueeBehavior>(m_rareNonInheritedData->marquee->behavior); }
     MarqueeDirection marqueeDirection() const { return static_cast<MarqueeDirection>(m_rareNonInheritedData->marquee->direction); }
+    UserModify effectiveUserModify() const { return effectiveInert() ? UserModify::ReadOnly : userModify(); }
     UserModify userModify() const { return static_cast<UserModify>(m_rareInheritedData->userModify); }
     UserDrag userDrag() const { return static_cast<UserDrag>(m_rareNonInheritedData->userDrag); }
     UserSelect effectiveUserSelect() const { return effectiveInert() ? UserSelect::None : userSelect(); }

Modified: branches/safari-613-branch/Source/WebCore/style/StyleTreeResolver.cpp (291918 => 291919)


--- branches/safari-613-branch/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-26 01:51:26 UTC (rev 291918)
+++ branches/safari-613-branch/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-26 01:51:32 UTC (rev 291919)
@@ -266,7 +266,7 @@
         m_document.setMayHaveElementsWithNonAutoTouchAction();
 #endif
 #if ENABLE(EDITABLE_REGION)
-    if (update.style->userModify() != UserModify::ReadOnly)
+    if (update.style->effectiveUserModify() != UserModify::ReadOnly)
         m_document.setMayHaveEditableElements();
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to