Title: [258077] trunk/Source/WebCore
Revision
258077
Author
[email protected]
Date
2020-03-07 13:46:23 -0800 (Sat, 07 Mar 2020)

Log Message

Make Editor::applyEditingStyleToBodyElement do things in a straightforward manner
https://bugs.webkit.org/show_bug.cgi?id=208177

Reviewed by Wenson Hsieh.

* editing/Editor.cpp:
(WebCore::Editor::applyEditingStyleToBodyElement const): Use Document::body and
StyledElement::setInlineStyleProperty to apply styles to the body. The older code
was looping over all body elements in the document, for no good reason, and using
the CSS object model wrapper object for the styles, also for no good reason.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (258076 => 258077)


--- trunk/Source/WebCore/ChangeLog	2020-03-07 19:35:44 UTC (rev 258076)
+++ trunk/Source/WebCore/ChangeLog	2020-03-07 21:46:23 UTC (rev 258077)
@@ -1,3 +1,16 @@
+2020-03-07  Darin Adler  <[email protected]>
+
+        Make Editor::applyEditingStyleToBodyElement do things in a straightforward manner
+        https://bugs.webkit.org/show_bug.cgi?id=208177
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::applyEditingStyleToBodyElement const): Use Document::body and
+        StyledElement::setInlineStyleProperty to apply styles to the body. The older code
+        was looping over all body elements in the document, for no good reason, and using
+        the CSS object model wrapper object for the styles, also for no good reason.
+
 2020-03-05  Sam Weinig  <[email protected]>
 
         Move _javascript_Core related feature defines from FeatureDefines.xcconfig to PlatformEnableCocoa.h

Modified: trunk/Source/WebCore/editing/Editor.cpp (258076 => 258077)


--- trunk/Source/WebCore/editing/Editor.cpp	2020-03-07 19:35:44 UTC (rev 258076)
+++ trunk/Source/WebCore/editing/Editor.cpp	2020-03-07 21:46:23 UTC (rev 258077)
@@ -3475,18 +3475,12 @@
 
 void Editor::applyEditingStyleToBodyElement() const
 {
-    // FIXME: Not clear it's valuable to do this to all body elements rather than just doing it on the single one returned by Document::body.
-    Vector<Ref<HTMLBodyElement>> bodies;
-    for (auto& body : descendantsOfType<HTMLBodyElement>(document()))
-        bodies.append(body);
-
-    for (auto& body : bodies) {
-        // Mutate using the CSSOM wrapper so we get the same event behavior as a script.
-        auto& style = body->cssomStyle();
-        style.setPropertyInternal(CSSPropertyWordWrap, "break-word", false);
-        style.setPropertyInternal(CSSPropertyWebkitNbspMode, "space", false);
-        style.setPropertyInternal(CSSPropertyLineBreak, "after-white-space", false);
-    }
+    auto body = makeRefPtr(document().body());
+    if (!body)
+        return;
+    body->setInlineStyleProperty(CSSPropertyWordWrap, CSSValueBreakWord);
+    body->setInlineStyleProperty(CSSPropertyWebkitNbspMode, CSSValueSpace);
+    body->setInlineStyleProperty(CSSPropertyLineBreak, CSSValueAfterWhiteSpace);
 }
 
 bool Editor::findString(const String& target, FindOptions options)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to