Bug 185249 - [LFC] Box invalidation logic should go to dedicated classes.
Summary: [LFC] Box invalidation logic should go to dedicated classes.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-03 07:39 PDT by zalan
Modified: 2018-05-04 07:43 PDT (History)
7 users (show)

See Also:


Attachments
Patch (22.05 KB, patch)
2018-05-03 07:44 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (21.93 KB, patch)
2018-05-03 09:04 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (21.86 KB, patch)
2018-05-03 09:28 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (22.00 KB, patch)
2018-05-03 09:34 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2018-05-03 07:39:54 PDT
The idea here is that when certain style attribute changes, the invalidation logic depends on the type of the formatting context the box lives in.
Comment 1 zalan 2018-05-03 07:44:29 PDT
Created attachment 339407 [details]
Patch
Comment 2 Antti Koivisto 2018-05-03 08:20:43 PDT
Comment on attachment 339407 [details]
Patch

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

> Source/WebCore/layout/FormattingState.h:60
> +    enum BaseTypeFlag {
> +        BlockStateFlag     = 1 << 0,
> +        InlineStateFlag    = 1 << 1
> +    };
> +
> +    FormattingState(Ref<FloatingState>&&, BaseTypeFlags);

These two are mutually exclusive so could be replaced with 'enum class Type { Block, Inline }'. But maybe there is going to be a deeper hierarchy of FormattingStates and this will expand?

This could be done with virtual functions but maybe it is a good idea to avoid them entirely.
Comment 3 zalan 2018-05-03 09:04:32 PDT
Created attachment 339411 [details]
Patch
Comment 4 Antti Koivisto 2018-05-03 09:09:26 PDT
Comment on attachment 339411 [details]
Patch

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

> Source/WebCore/layout/FormattingState.h:57
> +    enum StateType {
> +        BlockState,
> +        InlineState
> +    };

I would go with

enum class Type { Block, Inline }

This is all scoped to FormattingState so repeating word 'State' is redundant.

> Source/WebCore/layout/LayoutContext.h:62
> +    enum UpdateType {

enum class?
Comment 5 zalan 2018-05-03 09:28:11 PDT
Created attachment 339417 [details]
Patch
Comment 6 zalan 2018-05-03 09:34:50 PDT
Created attachment 339419 [details]
Patch
Comment 7 WebKit Commit Bot 2018-05-03 10:15:27 PDT
Comment on attachment 339419 [details]
Patch

Clearing flags on attachment: 339419

Committed r231312: <https://trac.webkit.org/changeset/231312>
Comment 8 WebKit Commit Bot 2018-05-03 10:15:29 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2018-05-03 10:16:26 PDT
<rdar://problem/39944996>
Comment 10 Antti Koivisto 2018-05-04 07:29:48 PDT
Comment on attachment 339419 [details]
Patch

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

> Source/WebCore/layout/LayoutContext.h:69
> +    enum class UpdateType {
> +        Overflow = 1 << 0,
> +        Position = 1 << 1,
> +        Size     = 1 << 2,
> +        All      = Overflow | Position | Size
> +    };
> +    void markNeedsUpdate(const Box&, OptionSet<UpdateType>);

'All' value like this is awkward with OptionSet (it will assert unless used with OptionSet::fromRaw), the enum should contain single bit values only. Defining constant like 

static constexpr OptionSet<UpdateType> UpdateAll = { Overflow, Position, Size };

should work (after 185298).
Comment 11 zalan 2018-05-04 07:43:57 PDT
(In reply to Antti Koivisto from comment #10)
> Comment on attachment 339419 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=339419&action=review
> 
> > Source/WebCore/layout/LayoutContext.h:69
> > +    enum class UpdateType {
> > +        Overflow = 1 << 0,
> > +        Position = 1 << 1,
> > +        Size     = 1 << 2,
> > +        All      = Overflow | Position | Size
> > +    };
> > +    void markNeedsUpdate(const Box&, OptionSet<UpdateType>);
> 
> 'All' value like this is awkward with OptionSet (it will assert unless used
> with OptionSet::fromRaw), the enum should contain single bit values only.
> Defining constant like 
> 
> static constexpr OptionSet<UpdateType> UpdateAll = { Overflow, Position,
> Size };
> 
> should work (after 185298).
Good point. Will fix it soon.