WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
144712
Clean up TextRun constructors
https://bugs.webkit.org/show_bug.cgi?id=144712
Summary
Clean up TextRun constructors
Myles C. Maxfield
Reported
2015-05-06 14:52:01 PDT
Simplify TextRun to only accept StringViews
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
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Myles C. Maxfield
Comment 1
2015-05-06 14:52:23 PDT
Created
attachment 252521
[details]
Patch
Myles C. Maxfield
Comment 2
2015-05-06 14:55:33 PDT
I'm not sure that this is actually better.
WebKit Commit Bot
Comment 3
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.
Myles C. Maxfield
Comment 4
2015-05-06 16:45:35 PDT
Created
attachment 252537
[details]
Patch
WebKit Commit Bot
Comment 5
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.
Myles C. Maxfield
Comment 6
2015-05-06 17:00:36 PDT
Created
attachment 252539
[details]
Patch
WebKit Commit Bot
Comment 7
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.
Myles C. Maxfield
Comment 8
2015-05-06 17:05:00 PDT
I'm not really sure that this is much better either
Myles C. Maxfield
Comment 9
2015-05-06 17:32:43 PDT
Created
attachment 252543
[details]
Patch
WebKit Commit Bot
Comment 10
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.
Myles C. Maxfield
Comment 11
2015-05-06 17:38:13 PDT
Created
attachment 252544
[details]
Patch
Myles C. Maxfield
Comment 12
2015-05-06 17:41:29 PDT
Created
attachment 252545
[details]
Patch
Myles C. Maxfield
Comment 13
2015-05-06 19:10:46 PDT
Committed
r183904
: <
http://trac.webkit.org/changeset/183904
>
Darin Adler
Comment 14
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.
Myles C. Maxfield
Comment 15
2015-05-07 12:18:57 PDT
Please see
https://bugs.webkit.org/show_bug.cgi?id=144752
Myles C. Maxfield
Comment 16
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
)
Myles C. Maxfield
Comment 17
2015-05-07 18:52:04 PDT
Addressed comments in
https://bugs.webkit.org/show_bug.cgi?id=144752
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug