WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
111700
Rename 'KURL::elidedString' and inspector's 'String::trimMiddle' for clarity.
https://bugs.webkit.org/show_bug.cgi?id=111700
Summary
Rename 'KURL::elidedString' and inspector's 'String::trimMiddle' for clarity.
Mike West
Reported
2013-03-07 02:02:01 PST
In
https://bugs.webkit.org/show_bug.cgi?id=111133#c21
, Darin suggested that the current name for the process of shortening a URL's string representation was poorly chosen. We should rename it for clarity. othermaciej suggested "centerEllipsizeToLength" or "centerTruncate". dydx liked "ellipsize". I'll put something together here, and rename the various callsites.
Attachments
Patch
(35.12 KB, patch)
2013-03-07 02:28 PST
,
Mike West
no flags
Details
Formatted Diff
Diff
Patch
(35.28 KB, patch)
2013-05-30 03:18 PDT
,
Mike West
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Mike West
Comment 1
2013-03-07 02:10:51 PST
For consistency, I'll adjust the 'trimMiddle' method that the Inspector adds to the String prototype as well.
Mike West
Comment 2
2013-03-07 02:28:45 PST
Created
attachment 191958
[details]
Patch
Alexey Proskuryakov
Comment 3
2013-03-07 10:45:54 PST
Comment on
attachment 191958
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=191958&action=review
A few drive by comments below. I'm unsure if trimming URLs at this level is the right approach. Ideally, Web Inspector would show a shorter URL, but still allow for copying the full one to pasteboard, or possibly expanding inline. Also, an ellipsis in the middle of a 1024 character string is extremely hard to spot, so it could be highlighted in the UI by using a prominent style.
> Source/WebCore/Modules/websockets/WebSocket.cpp:218 > + scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.stringCenterEllipsizedToLength());
All these call sites look a bit weird without a length argument. But I don't have a better suggestion.
> Source/WebCore/platform/KURL.cpp:1928 > +String KURL::stringCenterEllipsizedToLength(unsigned length) const
Since the result of this function is for viewing only, perhaps we should convert IDNA host names?
> Source/WebCore/platform/KURL.cpp:1933 > + return string().left(length / 2 - 1) + "..." + string().right(length / 2 - 2);
It would be nice to use an ellipsis (U+2026), not three periods.
Mike West
Comment 4
2013-03-07 10:55:34 PST
(In reply to
comment #3
)
> (From update of
attachment 191958
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=191958&action=review
> > A few drive by comments below.
Thanks, much appreciated.
> I'm unsure if trimming URLs at this level is the right approach. Ideally, Web Inspector would show a shorter URL, but still allow for copying the full one to pasteboard, or possibly expanding inline. Also, an ellipsis in the middle of a 1024 character string is extremely hard to spot, so it could be highlighted in the UI by using a prominent style.
It's a little complex. Here's a bit of background for context: Web Inspector does currently show a shorter, linkified URL for all those longer than ~150 characters. If the URL is shorter than 1k, the full URL is linked, and the short URL is displayed. Eric noted in
bug 111133
that we're potentially doing a _lot_ of copying in order to produce these strings, especially in the case of 'data:' URLs. These URLs especially cause problems when being dumped to the command line or to console.app. That discussion lead to the patch in 111133 trimming the underlying string before passing it into the inspector.
> > Source/WebCore/Modules/websockets/WebSocket.cpp:218 > > + scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, "Invalid url for WebSocket " + m_url.stringCenterEllipsizedToLength()); > > All these call sites look a bit weird without a length argument. But I don't have a better suggestion.
I considered adding a static property on Console to pass in here, but that seemed like pure overhead. I'd like to avoid boilerplate to the extent possible. What might make more sense is to move the method to Console, and to do the trimming there. Something like 'Console::centerEllipsizeForConsole(const String&)'. Would that be more clear?
> > Source/WebCore/platform/KURL.cpp:1928 > > +String KURL::stringCenterEllipsizedToLength(unsigned length) const > > Since the result of this function is for viewing only, perhaps we should convert IDNA host names?
I've no idea if we do anything useful with those, honestly. If we don't, it would be a good idea to teach the console about them when it goes through linkifying URLs.
> > Source/WebCore/platform/KURL.cpp:1933 > > + return string().left(length / 2 - 1) + "..." + string().right(length / 2 - 2); > > It would be nice to use an ellipsis (U+2026), not three periods.
I considered that; is it safe to throw unicode out to the console?
Mike West
Comment 5
2013-03-13 07:00:02 PDT
+jochen, eric: Since you reviewed the original patch, perhaps you have opinions about this renaming discussion? :)
Mike West
Comment 6
2013-05-30 03:18:00 PDT
Created
attachment 203337
[details]
Patch
Mike West
Comment 7
2013-05-30 03:18:40 PDT
Thanks for the review, Darin. Apologies for the belated rebase/upload. Assuming this passes the bots, I'll land it tonight.
WebKit Commit Bot
Comment 8
2013-05-30 05:08:47 PDT
Comment on
attachment 203337
[details]
Patch Clearing flags on attachment: 203337 Committed
r150957
: <
http://trac.webkit.org/changeset/150957
>
WebKit Commit Bot
Comment 9
2013-05-30 05:08:51 PDT
All reviewed patches have been landed. Closing bug.
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