Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting a web archive drops <picture> when wrapped in a <span> #28451

Merged
merged 1 commit into from
May 13, 2024

Conversation

pxlcoder
Copy link
Member

@pxlcoder pxlcoder commented May 12, 2024

efc8e7c

Pasting a web archive drops <picture> when wrapped in a <span>
https://bugs.webkit.org/show_bug.cgi?id=274062
rdar://127319160

Reviewed by Richard Robinson and Abrar Rahman Protyasha.

Pasting a web archive results in markup simplification being performed in
`SimplifyMarkupCommand`, via `ReplaceSelectionCommand`.

However, the logic for simplifying markup is incorrect. It currently
treats all inline elements that have the same style as equivalent. Then,
equivalent elements are removed bottom-up. This means that a `<picture>`
inside a `<span>` will be removed, as `<picture>` is an inline element,
with no custom style. Removing `<picture>` is incorrect, as it can affect the
rendered content due to source selection.

Fix by excluding `<picture>` from markup simplification. A better solution
would be to eliminate the `<span>` rather than the `<picture>`. However, that
approach requires a complete rewrite of the markup simplification algorithm.

* Source/WebCore/editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm:
(TEST(PasteWebArchive, PreservesPictureInsideSpan)):

Canonical link: https://commits.webkit.org/278714@main

15c8ae6

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 ⏳ πŸ›  wpe-skia
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ›  gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2-stress ❌ πŸ§ͺ api-gtk
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@pxlcoder pxlcoder requested a review from rniwa as a code owner May 12, 2024 23:19
@pxlcoder pxlcoder self-assigned this May 12, 2024
@pxlcoder pxlcoder added the HTML Editing For bugs in HTML editing support (including designMode and contentEditable). label May 12, 2024
@pxlcoder pxlcoder added the merge-queue Applied to send a pull request to merge-queue label May 13, 2024
https://bugs.webkit.org/show_bug.cgi?id=274062
rdar://127319160

Reviewed by Richard Robinson and Abrar Rahman Protyasha.

Pasting a web archive results in markup simplification being performed in
`SimplifyMarkupCommand`, via `ReplaceSelectionCommand`.

However, the logic for simplifying markup is incorrect. It currently
treats all inline elements that have the same style as equivalent. Then,
equivalent elements are removed bottom-up. This means that a `<picture>`
inside a `<span>` will be removed, as `<picture>` is an inline element,
with no custom style. Removing `<picture>` is incorrect, as it can affect the
rendered content due to source selection.

Fix by excluding `<picture>` from markup simplification. A better solution
would be to eliminate the `<span>` rather than the `<picture>`. However, that
approach requires a complete rewrite of the markup simplification algorithm.

* Source/WebCore/editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteWebArchive.mm:
(TEST(PasteWebArchive, PreservesPictureInsideSpan)):

Canonical link: https://commits.webkit.org/278714@main
@webkit-commit-queue
Copy link
Collaborator

Committed 278714@main (efc8e7c): https://commits.webkit.org/278714@main

Reviewed commits have been landed. Closing PR #28451 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit efc8e7c into WebKit:main May 13, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 13, 2024
@pxlcoder pxlcoder deleted the eng/274062 branch May 13, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTML Editing For bugs in HTML editing support (including designMode and contentEditable).
Projects
None yet
5 participants