Bug 132348 - NeverDestroyed objects should be constructable through std::initializer_list
Summary: NeverDestroyed objects should be constructable through std::initializer_list
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
: 157452 (view as bug list)
Depends on: 132345
Blocks:
  Show dependency treegraph
 
Reported: 2014-04-29 12:28 PDT by Zan Dobersek
Modified: 2017-07-21 20:23 PDT (History)
3 users (show)

See Also:


Attachments
Patch (9.73 KB, patch)
2014-04-29 12:35 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (9.92 KB, patch)
2014-04-29 23:45 PDT, Zan Dobersek
darin: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2014-04-29 12:28:29 PDT
NeverDestroyed objects should be constructable through std::initializer_list
Comment 1 Zan Dobersek 2014-04-29 12:35:57 PDT
Created attachment 230401 [details]
Patch
Comment 2 Darin Adler 2014-04-29 15:08:32 PDT
Comment on attachment 230401 [details]
Patch

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

> Source/WTF/wtf/NeverDestroyed.h:57
> +    template<typename U>
> +    NeverDestroyed(std::initializer_list<U> list)

This header needs to include <initializer_list>.
Comment 3 Darin Adler 2014-04-29 16:02:46 PDT
Comment on attachment 230401 [details]
Patch

Need the include.
Comment 4 Zan Dobersek 2014-04-29 23:45:06 PDT
Created attachment 230463 [details]
Patch

Still relies on the patch in bug #132345.
Comment 5 Darin Adler 2014-04-30 09:20:27 PDT
Comment on attachment 230463 [details]
Patch

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

> Source/WebCore/editing/EditingStyle.cpp:754
> +    static NeverDestroyed<Vector<std::unique_ptr<HTMLElementEquivalent>>> equivalents = {
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyFontWeight, CSSValueBold, HTMLNames::bTag),
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyFontWeight, CSSValueBold, HTMLNames::strongTag),
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyVerticalAlign, CSSValueSub, HTMLNames::subTag),
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyVerticalAlign, CSSValueSuper, HTMLNames::supTag),
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyFontStyle, CSSValueItalic, HTMLNames::iTag),
> +        std::make_unique<HTMLElementEquivalent>(CSSPropertyFontStyle, CSSValueItalic, HTMLNames::emTag),
> +        std::unique_ptr<HTMLElementEquivalent>(std::make_unique<HTMLTextDecorationEquivalent>(CSSValueUnderline, HTMLNames::uTag)),
> +        std::unique_ptr<HTMLElementEquivalent>(std::make_unique<HTMLTextDecorationEquivalent>(CSSValueLineThrough, HTMLNames::sTag)),
> +        std::unique_ptr<HTMLElementEquivalent>(std::make_unique<HTMLTextDecorationEquivalent>(CSSValueLineThrough, HTMLNames::strikeTag)),
> +    };

Anders has suggested that we not make initializer lists support move semantics--I think he’s right and so we should not make this change here.

The explicit cast to a different type of unique_ptr is also quite ugly.

Maybe there’s some other improvement we can make here, but we shouldn’t do exactly this.

> Source/WebCore/editing/EditingStyle.cpp:787
> +        std::make_unique<HTMLAttributeEquivalent>(CSSPropertyColor, HTMLNames::fontTag, HTMLNames::colorAttr),
> +        std::make_unique<HTMLAttributeEquivalent>(CSSPropertyFontFamily, HTMLNames::fontTag, HTMLNames::faceAttr),
> +        std::unique_ptr<HTMLAttributeEquivalent>(std::make_unique<HTMLFontSizeEquivalent>()),
> +        std::unique_ptr<HTMLAttributeEquivalent>(std::make_unique<HTMLAttributeEquivalent>(CSSPropertyDirection, HTMLNames::dirAttr)),
> +        std::unique_ptr<HTMLAttributeEquivalent>(std::make_unique<HTMLAttributeEquivalent>(CSSPropertyUnicodeBidi, HTMLNames::dirAttr)),

Ditto.
Comment 6 Darin Adler 2017-07-21 20:23:35 PDT
*** Bug 157452 has been marked as a duplicate of this bug. ***