Bug 157722 - More CTTE and other cleanups for HTML editing header
Summary: More CTTE and other cleanups for HTML editing header
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-15 01:26 PDT by Darin Adler
Modified: 2016-05-15 15:08 PDT (History)
2 users (show)

See Also:


Attachments
Patch (98.99 KB, patch)
2016-05-15 13:43 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (99.17 KB, patch)
2016-05-15 13:57 PDT, Darin Adler
no flags Details | Formatted Diff | Diff
Patch (99.16 KB, patch)
2016-05-15 14:01 PDT, Darin Adler
cdumez: review+
darin: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2016-05-15 01:26:44 PDT
More CTTE and other cleanups for HTML editing header
Comment 1 Darin Adler 2016-05-15 13:43:04 PDT
Created attachment 278977 [details]
Patch
Comment 2 Chris Dumez 2016-05-15 13:46:46 PDT
red bubbles
Comment 3 Darin Adler 2016-05-15 13:57:41 PDT
Created attachment 278978 [details]
Patch
Comment 4 Darin Adler 2016-05-15 13:59:11 PDT
Comment on attachment 278978 [details]
Patch

Oops, tests not passing locally yet!
Comment 5 Darin Adler 2016-05-15 14:01:57 PDT
Created attachment 278979 [details]
Patch
Comment 6 Darin Adler 2016-05-15 14:02:18 PDT
Comment on attachment 278979 [details]
Patch

OK, tests passing locally now.
Comment 7 Darin Adler 2016-05-15 14:41:06 PDT
Here’s what was failing on the mac-debug EWS:

Regressions: Unexpected crashes (2)
  imported/blink/storage/indexeddb/blob-basics-metadata.html [ Crash ]
  imported/blink/storage/indexeddb/blob-valid-after-deletion.html [ Crash ]

I ran these tests locally, and they did not crash. Also seems highly unlikely the changes to editing code could have had any effect on these tests.
Comment 8 Chris Dumez 2016-05-15 14:59:06 PDT
Comment on attachment 278979 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278979&action=review

r=me

> Source/WebCore/dom/Position.cpp:219
> +    if (!m_anchorNode)

Could do a ternary and return on one line.

> Source/WebCore/editing/ApplyStyleCommand.cpp:1179
> +bool ApplyStyleCommand::nodeFullySelected(Node* node, const Position& start, const Position& end) const

We should either switch to using a reference for node or add a FIXME comment.

> Source/WebCore/editing/ApplyStyleCommand.cpp:1191
> +bool ApplyStyleCommand::nodeFullyUnselected(Node* node, const Position& start, const Position& end) const

We should either switch to using a reference for node or add a FIXME comment.

> Source/WebCore/editing/htmlediting.cpp:396
> +    for (unsigned i = 0; i < length; i++) {

++i

> Source/WebCore/editing/htmlediting.cpp:417
> +    if (!rebalancedString.length())

I would prefer if (rebalancedString.isEmpty())

> Source/WebCore/editing/markup.cpp:541
> +        if (auto* parentListNode = downcast<HTMLElement>(enclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isListItem))) {

Is this cast to HTMLElement here is safe? isListItem() can return true for an element that has a list renderer (e.g. elements with "display: list-item" in CSS, which are not HTML list elements).
Comment 9 Darin Adler 2016-05-15 15:07:10 PDT
Comment on attachment 278979 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=278979&action=review

>> Source/WebCore/dom/Position.cpp:219
>> +    if (!m_anchorNode)
> 
> Could do a ternary and return on one line.

OK, done.

>> Source/WebCore/editing/ApplyStyleCommand.cpp:1179
>> +bool ApplyStyleCommand::nodeFullySelected(Node* node, const Position& start, const Position& end) const
> 
> We should either switch to using a reference for node or add a FIXME comment.

I changed the type to Element& and the name to element. These files have so many other style issues nearby, but this was easy enough to do.

>> Source/WebCore/editing/ApplyStyleCommand.cpp:1191
>> +bool ApplyStyleCommand::nodeFullyUnselected(Node* node, const Position& start, const Position& end) const
> 
> We should either switch to using a reference for node or add a FIXME comment.

Ditto.

>> Source/WebCore/editing/htmlediting.cpp:396
>> +    for (unsigned i = 0; i < length; i++) {
> 
> ++i

Done.

>> Source/WebCore/editing/htmlediting.cpp:417
>> +    if (!rebalancedString.length())
> 
> I would prefer if (rebalancedString.isEmpty())

OK, done.

>> Source/WebCore/editing/markup.cpp:541
>> +        if (auto* parentListNode = downcast<HTMLElement>(enclosingNodeOfType(firstPositionInOrBeforeNode(range->firstNode()), isListItem))) {
> 
> Is this cast to HTMLElement here is safe? isListItem() can return true for an element that has a list renderer (e.g. elements with "display: list-item" in CSS, which are not HTML list elements).

It’s not; you are right. I changed the cast to Element instead of HTMLElement.
Comment 10 Darin Adler 2016-05-15 15:08:00 PDT
Committed r200931: <http://trac.webkit.org/changeset/200931>