- Revision
- 225252
- Author
- [email protected]
- Date
- 2017-11-28 18:06:22 -0800 (Tue, 28 Nov 2017)
Log Message
Allow attachment elements with no appearance to defer rendering to child nodes
https://bugs.webkit.org/show_bug.cgi?id=180117
<rdar://problem/35735339>
Reviewed by Tim Horton.
Source/WebCore:
Test: fast/attachment/attachment-without-appearance.html
When -webkit-appearance: none; is specified on an attachment element, allow it to fall back to rendering its
subtree. Currently, attachment elements without an appearance don't allow this and truncate the render tree at
the RenderAttachment, since RenderAttachment cannot have any children.
In a followup, this will enable us to render a shadow subtree under the attachment element to display in-place
attachment content, and easily toggle between in-place and icon display by changing the appearance.
* html/HTMLAttachmentElement.cpp:
(WebCore::HTMLAttachmentElement::createElementRenderer):
If no appearance is specified, emit a RenderBlockFlow instead of a RenderAttachment.
(WebCore::HTMLAttachmentElement::setFile):
(WebCore::HTMLAttachmentElement::attachmentRenderer const):
Renamed from renderer(). HTMLAttachmentElement::renderer() now uses the superclass' implementation, and no
longer returns a RenderAttachment in all circumstances. Instead, places that expect a RenderAttachment now go
through HTMLAttachmentElement::renderAttachment() instead.
(WebCore::HTMLAttachmentElement::parseAttribute):
* html/HTMLAttachmentElement.h:
* page/DragController.cpp:
(WebCore::DragController::startDrag):
* rendering/RenderAttachment.h:
(WebCore::HTMLAttachmentElement::renderer const): Deleted.
LayoutTests:
Adds a ref test verifying that an appearance-less attachment can render child nodes. More extensive testing to
come in a followup patch.
* fast/attachment/attachment-without-appearance-expected.html: Added.
* fast/attachment/attachment-without-appearance.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (225251 => 225252)
--- trunk/LayoutTests/ChangeLog 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/LayoutTests/ChangeLog 2017-11-29 02:06:22 UTC (rev 225252)
@@ -1,3 +1,17 @@
+2017-11-28 Wenson Hsieh <[email protected]>
+
+ Allow attachment elements with no appearance to defer rendering to child nodes
+ https://bugs.webkit.org/show_bug.cgi?id=180117
+ <rdar://problem/35735339>
+
+ Reviewed by Tim Horton.
+
+ Adds a ref test verifying that an appearance-less attachment can render child nodes. More extensive testing to
+ come in a followup patch.
+
+ * fast/attachment/attachment-without-appearance-expected.html: Added.
+ * fast/attachment/attachment-without-appearance.html: Added.
+
2017-11-28 Chris Dumez <[email protected]>
ServiceWorkerGlobalScope.clients should always return the same object
Added: trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html (0 => 225252)
--- trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-without-appearance-expected.html 2017-11-29 02:06:22 UTC (rev 225252)
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+<style>
+ span {
+ display: inline-block;
+ }
+</style>
+<body>
+<div>This test passes if you observe two green squares below.</div>
+<span><div style="width: 100px; height: 100px; background-color: green; color: white;">Lorem.</div></span>
+<span><div style="width: 100px; height: 100px; background-color: green; color: white;">Ipsum.</div></span>
+</body>
+</html>
Added: trunk/LayoutTests/fast/attachment/attachment-without-appearance.html (0 => 225252)
--- trunk/LayoutTests/fast/attachment/attachment-without-appearance.html (rev 0)
+++ trunk/LayoutTests/fast/attachment/attachment-without-appearance.html 2017-11-29 02:06:22 UTC (rev 225252)
@@ -0,0 +1,11 @@
+<!DOCTYPE html><!-- webkit-test-runner [ enableAttachmentElement=true ] -->
+<html>
+<body>
+<div>This test passes if you observe two green squares below.</div>
+<attachment style="-webkit-appearance: none;"><div style="width: 100px; height: 100px; background-color: green; color: white;">Lorem.</div></attachment>
+<attachment id="attachment"><div style="width: 100px; height: 100px; background-color: green; color: white;">Ipsum.</div></attachment>
+<script>
+ attachment.style.webkitAppearance = "none";
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (225251 => 225252)
--- trunk/Source/WebCore/ChangeLog 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/Source/WebCore/ChangeLog 2017-11-29 02:06:22 UTC (rev 225252)
@@ -1,3 +1,39 @@
+2017-11-28 Wenson Hsieh <[email protected]>
+
+ Allow attachment elements with no appearance to defer rendering to child nodes
+ https://bugs.webkit.org/show_bug.cgi?id=180117
+ <rdar://problem/35735339>
+
+ Reviewed by Tim Horton.
+
+ Test: fast/attachment/attachment-without-appearance.html
+
+ When -webkit-appearance: none; is specified on an attachment element, allow it to fall back to rendering its
+ subtree. Currently, attachment elements without an appearance don't allow this and truncate the render tree at
+ the RenderAttachment, since RenderAttachment cannot have any children.
+
+ In a followup, this will enable us to render a shadow subtree under the attachment element to display in-place
+ attachment content, and easily toggle between in-place and icon display by changing the appearance.
+
+ * html/HTMLAttachmentElement.cpp:
+ (WebCore::HTMLAttachmentElement::createElementRenderer):
+
+ If no appearance is specified, emit a RenderBlockFlow instead of a RenderAttachment.
+
+ (WebCore::HTMLAttachmentElement::setFile):
+ (WebCore::HTMLAttachmentElement::attachmentRenderer const):
+
+ Renamed from renderer(). HTMLAttachmentElement::renderer() now uses the superclass' implementation, and no
+ longer returns a RenderAttachment in all circumstances. Instead, places that expect a RenderAttachment now go
+ through HTMLAttachmentElement::renderAttachment() instead.
+
+ (WebCore::HTMLAttachmentElement::parseAttribute):
+ * html/HTMLAttachmentElement.h:
+ * page/DragController.cpp:
+ (WebCore::DragController::startDrag):
+ * rendering/RenderAttachment.h:
+ (WebCore::HTMLAttachmentElement::renderer const): Deleted.
+
2017-11-28 Youenn Fablet <[email protected]>
Register Documents as ServiceWorker clients to the StorageProcess
Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.cpp (225251 => 225252)
--- trunk/Source/WebCore/html/HTMLAttachmentElement.cpp 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.cpp 2017-11-29 02:06:22 UTC (rev 225252)
@@ -35,6 +35,7 @@
#include "Frame.h"
#include "HTMLNames.h"
#include "RenderAttachment.h"
+#include "RenderBlockFlow.h"
#include "SharedBuffer.h"
namespace WebCore {
@@ -86,6 +87,11 @@
RenderPtr<RenderElement> HTMLAttachmentElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
{
+ if (!style.hasAppearance()) {
+ // If this attachment element doesn't have an appearance, defer rendering to child elements.
+ return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
+ }
+
return createRenderer<RenderAttachment>(*this, WTFMove(style));
}
@@ -105,10 +111,16 @@
setAttributeWithoutSynchronization(HTMLNames::webkitattachmentbloburlAttr, m_file ? m_file->url() : emptyString());
- if (auto* renderer = this->renderer())
- renderer->invalidate();
+ if (auto* renderAttachment = attachmentRenderer())
+ renderAttachment->invalidate();
}
+RenderAttachment* HTMLAttachmentElement::attachmentRenderer() const
+{
+ auto* renderer = this->renderer();
+ return is<RenderAttachment>(renderer) ? downcast<RenderAttachment>(renderer) : nullptr;
+}
+
Node::InsertedIntoAncestorResult HTMLAttachmentElement::insertedIntoAncestor(InsertionType type, ContainerNode& ancestor)
{
auto result = HTMLElement::insertedIntoAncestor(type, ancestor);
@@ -127,8 +139,8 @@
void HTMLAttachmentElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == progressAttr || name == subtitleAttr || name == titleAttr || name == typeAttr) {
- if (auto* renderer = this->renderer())
- renderer->invalidate();
+ if (auto* renderAttachment = attachmentRenderer())
+ renderAttachment->invalidate();
}
HTMLElement::parseAttribute(name, value);
Modified: trunk/Source/WebCore/html/HTMLAttachmentElement.h (225251 => 225252)
--- trunk/Source/WebCore/html/HTMLAttachmentElement.h 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/Source/WebCore/html/HTMLAttachmentElement.h 2017-11-29 02:06:22 UTC (rev 225252)
@@ -54,7 +54,7 @@
String attachmentType() const;
String attachmentPath() const;
- RenderAttachment* renderer() const;
+ RenderAttachment* attachmentRenderer() const;
WEBCORE_EXPORT void requestData(Function<void(RefPtr<SharedBuffer>&&)>&& callback);
void destroyReader(AttachmentDataReader&);
Modified: trunk/Source/WebCore/page/DragController.cpp (225251 => 225252)
--- trunk/Source/WebCore/page/DragController.cpp 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/Source/WebCore/page/DragController.cpp 2017-11-29 02:06:22 UTC (rev 225252)
@@ -1071,7 +1071,7 @@
#if ENABLE(ATTACHMENT_ELEMENT)
if (is<HTMLAttachmentElement>(element) && m_dragSourceAction & DragSourceActionAttachment) {
- auto* attachmentRenderer = downcast<HTMLAttachmentElement>(element).renderer();
+ auto* attachmentRenderer = downcast<HTMLAttachmentElement>(element).attachmentRenderer();
if (!attachmentRenderer)
return false;
Modified: trunk/Source/WebCore/rendering/RenderAttachment.h (225251 => 225252)
--- trunk/Source/WebCore/rendering/RenderAttachment.h 2017-11-29 01:50:03 UTC (rev 225251)
+++ trunk/Source/WebCore/rendering/RenderAttachment.h 2017-11-29 02:06:22 UTC (rev 225252)
@@ -59,11 +59,6 @@
bool m_shouldDrawBorder { true };
};
-inline RenderAttachment* HTMLAttachmentElement::renderer() const
-{
- return downcast<RenderAttachment>(HTMLElement::renderer());
-}
-
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderAttachment, isAttachment())