Bug 154424 - Enhance EditorState to include TypingAttributes, alignment, and color
Summary: Enhance EditorState to include TypingAttributes, alignment, and color
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-18 16:01 PST by Beth Dakin
Modified: 2016-02-19 14:15 PST (History)
4 users (show)

See Also:


Attachments
Patch (6.97 KB, patch)
2016-02-18 16:03 PST, Beth Dakin
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Beth Dakin 2016-02-18 16:01:19 PST
Enhance EditorState to include TypingAttributes, alignment, and color
Comment 1 Beth Dakin 2016-02-18 16:03:48 PST
Created attachment 271713 [details]
Patch
Comment 2 Dean Jackson 2016-02-18 16:24:55 PST
Comment on attachment 271713 [details]
Patch

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

> Source/WebKit2/Shared/EditorState.h:48
> +enum TextAlignment {

enum class?
Comment 3 Sam Weinig 2016-02-18 16:34:17 PST
Comment on attachment 271713 [details]
Patch

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

> Source/WebKit2/Shared/EditorState.h:95
> +        WebCore::Color textColor { WebCore::Color::black };

Since not every platform has these implemented, should they remain enabled? Can we refactor at all to make these supported on all platforms?

> Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm:160
> +        if (RenderStyle* style = Editor::styleForSelectionStart(&frame, nodeToRemove)) {
> +            NSFont *font = style->fontCascade().primaryFont().getNSFont();
> +            NSFontTraitMask traits = [[NSFontManager sharedFontManager] traitsOfFont:font];
> +
> +            if (traits & NSBoldFontMask)
> +                postLayoutData.typingAttributes |= AttributeBold;
> +            if (traits & NSItalicFontMask)
> +                postLayoutData.typingAttributes |= AttributeItalics;
> +            

Can this be done by doing:

if (style->fontCascade().weight() == FontWeightBold)
    postLayoutData.typingAttributes |= AttributeBold;
if (style->fontCascade().italic() == FontItalicOn)
    postLayoutData.typingAttributes |= AttributeItalics;

or 

just look at the style itself?

> Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm:200
> +                nodeToRemove->remove(ASSERT_NO_EXCEPTION);
> +        }

Can any of this be shared across Mac and iOS?
Comment 4 Beth Dakin 2016-02-19 14:15:39 PST
Thanks Sam and Dean! http://trac.webkit.org/changeset/196834