Bug 144712 - Clean up TextRun constructors
Summary: Clean up TextRun constructors
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-06 14:52 PDT by Myles C. Maxfield
Modified: 2015-05-07 18:52 PDT (History)
2 users (show)

See Also:


Attachments
Patch (32.83 KB, patch)
2015-05-06 14:52 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (34.00 KB, patch)
2015-05-06 16:45 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (24.26 KB, patch)
2015-05-06 17:00 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (18.00 KB, patch)
2015-05-06 17:32 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (16.80 KB, patch)
2015-05-06 17:38 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (17.66 KB, patch)
2015-05-06 17:41 PDT, Myles C. Maxfield
zalan: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2015-05-06 14:52:01 PDT
Simplify TextRun to only accept StringViews
Comment 1 Myles C. Maxfield 2015-05-06 14:52:23 PDT
Created attachment 252521 [details]
Patch
Comment 2 Myles C. Maxfield 2015-05-06 14:55:33 PDT
I'm not sure that this is actually better.
Comment 3 WebKit Commit Bot 2015-05-06 14:57:59 PDT
Attachment 252521 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 19 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Myles C. Maxfield 2015-05-06 16:45:35 PDT
Created attachment 252537 [details]
Patch
Comment 5 WebKit Commit Bot 2015-05-06 16:47:54 PDT
Attachment 252537 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 20 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Myles C. Maxfield 2015-05-06 17:00:36 PDT
Created attachment 252539 [details]
Patch
Comment 7 WebKit Commit Bot 2015-05-06 17:02:09 PDT
Attachment 252539 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Myles C. Maxfield 2015-05-06 17:05:00 PDT
I'm not really sure that this is much better either
Comment 9 Myles C. Maxfield 2015-05-06 17:32:43 PDT
Created attachment 252543 [details]
Patch
Comment 10 WebKit Commit Bot 2015-05-06 17:34:39 PDT
Attachment 252543 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 11 Myles C. Maxfield 2015-05-06 17:38:13 PDT
Created attachment 252544 [details]
Patch
Comment 12 Myles C. Maxfield 2015-05-06 17:41:29 PDT
Created attachment 252545 [details]
Patch
Comment 13 Myles C. Maxfield 2015-05-06 19:10:46 PDT
Committed r183904: <http://trac.webkit.org/changeset/183904>
Comment 14 Darin Adler 2015-05-07 09:23:14 PDT
Comment on attachment 252545 [details]
Patch

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

> Source/WebCore/platform/graphics/TextRun.h:57
> +    explicit TextRun(StringView s, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false, bool characterScanForCodePath = true, RoundingHacks roundingHacks = RunRounding | WordRounding)
> +        : m_text(s)
> +        , m_charactersLength(s.length())

I suggest we consider a variable name other than "s" for this.

> Source/WebCore/platform/graphics/TextRun.h:76
> +    explicit TextRun(const String& s)
> +        : TextRun(StringView(s))
>      {
>      }

We should remove this overload if the performance characteristic of converting the String each time to a StringView is acceptable. If we remove the other overloads below, then this will just automatically do the right thing with explicitly writing code.

> Source/WebCore/platform/graphics/TextRun.h:81
> +    TextRun(const LChar* c, unsigned len)
> +        : TextRun(StringView(c, len))
>      {
>      }

If these overloads are not a performance problem, then I suggest we return to this class and remove them entirely, making the StringView at the call sites. I don’t think we need a convenience that builds a StringView for the caller. Moving the code that makes the StringView back to the call site will also help us make things more elegant in future refactoring.

Also, "c" and "len"? Those don’t sound like WebKit project argument names.

> Source/WebCore/platform/graphics/TextRun.h:86
> +    TextRun(const UChar* c, unsigned len)
> +        : TextRun(StringView(c, len))
>      {
>      }

Ditto.
Comment 15 Myles C. Maxfield 2015-05-07 12:18:57 PDT
Please see https://bugs.webkit.org/show_bug.cgi?id=144752
Comment 16 Myles C. Maxfield 2015-05-07 12:19:19 PDT
Comment on attachment 252545 [details]
Patch

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

>> Source/WebCore/platform/graphics/TextRun.h:81
>>      }
> 
> If these overloads are not a performance problem, then I suggest we return to this class and remove them entirely, making the StringView at the call sites. I don’t think we need a convenience that builds a StringView for the caller. Moving the code that makes the StringView back to the call site will also help us make things more elegant in future refactoring.
> 
> Also, "c" and "len"? Those don’t sound like WebKit project argument names.

It's funny you should mention this - A previous version of this patch (https://bugs.webkit.org/attachment.cgi?id=252539&action=review) did exactly that, but I moved away from it because I thought that littering up the call sites with StringView() calls was just added noise (https://bugs.webkit.org/show_bug.cgi?id=144712#c8)
Comment 17 Myles C. Maxfield 2015-05-07 18:52:04 PDT
Addressed comments in https://bugs.webkit.org/show_bug.cgi?id=144752