Title: [281444] trunk
Revision
281444
Author
commit-qu...@webkit.org
Date
2021-08-23 07:53:04 -0700 (Mon, 23 Aug 2021)

Log Message

Create a RenderLineBreak when BR element has unsupported content data style
https://bugs.webkit.org/show_bug.cgi?id=224849

Patch by Carlos Garcia Campos <cgar...@igalia.com> on 2021-08-23
Reviewed by Antti Koivisto.

Source/WebCore:

Instead of falling back to RenderElement::createFor(), create a RenderLineBreak just ignoring the unsupported
content data.

* html/HTMLBRElement.cpp:
(WebCore::HTMLBRElement::createElementRenderer):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::isContentDataSupported):
(WebCore::RenderElement::createFor):
* rendering/RenderElement.h:

LayoutTests:

* editing/execCommand/insert-image-in-composed-list-expected.txt: Rebaseline.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281443 => 281444)


--- trunk/LayoutTests/ChangeLog	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/LayoutTests/ChangeLog	2021-08-23 14:53:04 UTC (rev 281444)
@@ -1,3 +1,12 @@
+2021-08-23  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Create a RenderLineBreak when BR element has unsupported content data style
+        https://bugs.webkit.org/show_bug.cgi?id=224849
+
+        Reviewed by Antti Koivisto.
+
+        * editing/execCommand/insert-image-in-composed-list-expected.txt: Rebaseline.
+
 2021-08-23  Chris Dumez  <cdu...@apple.com>
 
         HTMLStyleElement should be able to fire the load event more than once

Modified: trunk/LayoutTests/editing/execCommand/insert-image-in-composed-list-expected.txt (281443 => 281444)


--- trunk/LayoutTests/editing/execCommand/insert-image-in-composed-list-expected.txt	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/LayoutTests/editing/execCommand/insert-image-in-composed-list-expected.txt	2021-08-23 14:53:04 UTC (rev 281444)
@@ -1 +1,2 @@
-Test passes if it does not crash.
+Test passes if it does not crash. 
+

Modified: trunk/Source/WebCore/ChangeLog (281443 => 281444)


--- trunk/Source/WebCore/ChangeLog	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/Source/WebCore/ChangeLog	2021-08-23 14:53:04 UTC (rev 281444)
@@ -1,3 +1,20 @@
+2021-08-23  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Create a RenderLineBreak when BR element has unsupported content data style
+        https://bugs.webkit.org/show_bug.cgi?id=224849
+
+        Reviewed by Antti Koivisto.
+
+        Instead of falling back to RenderElement::createFor(), create a RenderLineBreak just ignoring the unsupported
+        content data.
+
+        * html/HTMLBRElement.cpp:
+        (WebCore::HTMLBRElement::createElementRenderer):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::isContentDataSupported):
+        (WebCore::RenderElement::createFor):
+        * rendering/RenderElement.h:
+
 2021-08-23  Chris Dumez  <cdu...@apple.com>
 
         HTMLStyleElement should be able to fire the load event more than once

Modified: trunk/Source/WebCore/html/HTMLBRElement.cpp (281443 => 281444)


--- trunk/Source/WebCore/html/HTMLBRElement.cpp	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/Source/WebCore/html/HTMLBRElement.cpp	2021-08-23 14:53:04 UTC (rev 281444)
@@ -75,7 +75,7 @@
 
 RenderPtr<RenderElement> HTMLBRElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
-    if (style.hasContent())
+    if (style.hasContent() && RenderElement::isContentDataSupported(*style.contentData()))
         return RenderElement::createFor(*this, WTFMove(style));
 
     return createRenderer<RenderLineBreak>(*this, WTFMove(style));

Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (281443 => 281444)


--- trunk/Source/WebCore/rendering/RenderElement.cpp	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp	2021-08-23 14:53:04 UTC (rev 281444)
@@ -145,13 +145,19 @@
     ASSERT(!m_firstChild);
 }
 
-RenderPtr<RenderElement> RenderElement::createFor(Element& element, RenderStyle&& style, OptionSet<ConstructBlockLevelRendererFor> rendererTypeOverride)
+bool RenderElement::isContentDataSupported(const ContentData& contentData)
 {
     // Minimal support for content properties replacing an entire element.
     // Works only if we have exactly one piece of content and it's a URL.
     // Otherwise acts as if we didn't support this feature.
+    return is<ImageContentData>(contentData) && !contentData.next();
+}
+
+RenderPtr<RenderElement> RenderElement::createFor(Element& element, RenderStyle&& style, OptionSet<ConstructBlockLevelRendererFor> rendererTypeOverride)
+{
+
     const ContentData* contentData = style.contentData();
-    if (!rendererTypeOverride && contentData && !contentData->next() && is<ImageContentData>(*contentData) && !element.isPseudoElement()) {
+    if (!rendererTypeOverride && contentData && isContentDataSupported(*contentData) && !element.isPseudoElement()) {
         Style::loadPendingResources(style, element.document(), &element);
         auto& styleImage = downcast<ImageContentData>(*contentData).image();
         auto image = createRenderer<RenderImage>(element, WTFMove(style), const_cast<StyleImage*>(&styleImage));

Modified: trunk/Source/WebCore/rendering/RenderElement.h (281443 => 281444)


--- trunk/Source/WebCore/rendering/RenderElement.h	2021-08-23 14:50:46 UTC (rev 281443)
+++ trunk/Source/WebCore/rendering/RenderElement.h	2021-08-23 14:53:04 UTC (rev 281444)
@@ -28,6 +28,7 @@
 
 namespace WebCore {
 
+class ContentData;
 class ControlStates;
 class KeyframeList;
 class RenderBlock;
@@ -39,6 +40,8 @@
 public:
     virtual ~RenderElement();
 
+    static bool isContentDataSupported(const ContentData&);
+
     enum class ConstructBlockLevelRendererFor {
         Inline           = 1 << 0,
         ListItem         = 1 << 1,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to