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

Typing style shouldn't inherit style from atomic elements #3675

Closed
wants to merge 1 commit into from
Closed

Typing style shouldn't inherit style from atomic elements #3675

wants to merge 1 commit into from

Conversation

Ahmad-S792
Copy link
Contributor

@Ahmad-S792 Ahmad-S792 commented Aug 25, 2022

Typing style shouldn't inherit style from atomic elements

https://bugs.webkit.org/show_bug.cgi?id=119116

Reviewed by NOBODY (OOPS!).

Merge - https://chromium.googlesource.com/chromium/blink/+/27371d2980715475f3443f7025141ebff8537179

This patch changes initialization of typing style not to populate from form control like elements, which can't have range ending point, e.g. img, input, object, textarea, and so on.

* Source/WebCore/editing/DeleteSelectionCommand.cpp
(DeleteSelectionCommand::initializePositionData()) - Updated to add static variable.
(DeleteSectionCommand::saveTypeStyleSheet()) - Added if condition to use static variable to not inherit style from atomic elements.

* LayoutTests/editing/inserting/insert-without-style.html - Testcase added from Blink / Chromium patch.
* LayoutTests/editing/inserting/insert-without-style-expected.txt- Added Testcase Expectations.

954effc

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

Typing style shouldn't inherit style from atomic elements

https://bugs.webkit.org/show_bug.cgi?id=119116

Reviewed by NOBODY (OOPS!).

Merge - https://chromium.googlesource.com/chromium/blink/+/27371d2980715475f3443f7025141ebff8537179

This patch changes initialization of typing style not to populate from form control like elements, which can't have range ending point, e.g. img, input, object, textarea, and so on.

*Source/WebCore/editing/DeleteSelectionCommand.cpp
(DeleteSelectionCommand::initializePositionData()) - Updated to add static variable.
(DeleteSectionCommand::saveTypeStyleSheet()) - Added if condition to by using static variable to not inherit style from atomic elements.
*LayoutTests/editing/inserting/insert-without-style.html - Testcase added from Blink / Chromium patch.
* LayoutTests/editing/inserting/insert-without-style-expected.txt- Added Testcase Expectations.
@Ahmad-S792 Ahmad-S792 requested a review from rniwa as a code owner August 25, 2022 21:30
Comment on lines +407 to +411
// We don't want to inherit style from an element which don't have contents.
static bool shouldNotInheritStyleFrom(const Node& node)
{
return !node.canContainRangeEndPoint();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to be indented wrong. Maybe you have a smart editor that wants to indent everything in the WebCore namespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I will fix it. Thanks!

@@ -420,6 +426,9 @@ void DeleteSelectionCommand::saveTypingStyleState()
return;
}

if (shouldNotInheritStyleFrom(*m_selectionToDelete.start().anchorNode()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the Chromium project already made this change, but I think it might not be entirely correct.

Makes sense that we would not want to inherit from, say, an image element but wouldn’t we want to inherit from what’s before/after that element? Like if the text after the image that we were deleting was bold? Test case might be something like either of these:

<b>This is bold <img></b> and this is not
<b>This is bold <img> yes, bold</b> and this is not

Deleting a range starting before the image and ending after the word "and". We’d want the typing style to be bold in both cases, I think. Maybe this isn’t the right test case. I’d like to see a lot more test cases to be sure we got this right.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is precisely why I stated Blink fix is wrong in https://bugs.webkit.org/show_bug.cgi?id=119116

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 25, 2022
@Ahmad-S792
Copy link
Contributor Author

Unfortunately, I am getting weird error on my GitHub fork and I have delete it and add again. I am closing this PR right now and will look into once I fix my Git errors. Thanks!

@Ahmad-S792 Ahmad-S792 closed this Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merging-blocked Applied to prevent a change from being merged
Projects
None yet
5 participants