Bug 76428 - Each style rule should have its own ID
: Each style rule should have its own ID
Status: RESOLVED FIXED
: WebKit
WebKit Website
: 528+ (Nightly build)
: All All
: P5 Trivial
Assigned To:
:
:
:
: 78470
  Show dependency treegraph
 
Reported: 2012-01-16 22:05 PST by
Modified: 2012-02-13 00:27 PST (History)


Attachments
Patch (22.39 KB, patch)
2012-01-19 23:11 PST, Kent Tamura
no flags Review Patch | Details | Formatted Diff | Diff
Patch 2 (22.56 KB, patch)
2012-01-19 23:42 PST, Kent Tamura
no flags Review Patch | Details | Formatted Diff | Diff
Patch for landing (22.84 KB, patch)
2012-01-20 00:39 PST, Kent Tamura
no flags Review Patch | Details | Formatted Diff | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2012-01-16 22:05:33 PST
I sometimes want to introduce one style rule to another WebKit developer. Now we have to introduce like:
  "The third item of the Indentation section in http://www.webkit.org/coding/coding-style.html"

If we introduced id attributes like

<li id="indentation-namespace" title="#indentation-namespace">The contents of an outermost <code>namespace</code> block (and any nested namespaces with the same scope)

, we would be able to introduce it by a URI reference like http://www.webkit.org/coding/coding-style.html#indentation-namespace
------- Comment #1 From 2012-01-19 23:11:31 PST -------
Created an attachment (id=123256) [details]
Patch
------- Comment #2 From 2012-01-19 23:17:36 PST -------
How do I get a link to a rule?

I kind of want some sort of href so I can click it and it will update the address bar with the correct link for that rule. Does that make sense?
------- Comment #3 From 2012-01-19 23:42:14 PST -------
Created an attachment (id=123258) [details]
Patch 2

Make LI clickable
------- Comment #4 From 2012-01-19 23:44:30 PST -------
(In reply to comment #2)
> How do I get a link to a rule?
> 
> I kind of want some sort of href so I can click it and it will update the address bar with the correct link for that rule. Does that make sense?

I examined such idea, but I thought enclosing each of <li> with <a href=></a> looked bad.
WIth the latest patch, a LI element has title="#id" and is clickable to jump to #id.
------- Comment #5 From 2012-01-20 00:11:39 PST -------
(From update of attachment 123258 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=123258&action=review

> Websites/webkit.org/coding/coding-style.html:233
> +<li id="linebreaking-multiple-satements">Each statement should get its own line.

s/satements/statements/

> Websites/webkit.org/coding/coding-style.html:249
> +<li id="linebreaking-elese-braces">An <code>else</code> statement should go on the same line as a preceding close brace if one is present,

s/elese/else/

> Websites/webkit.org/coding/coding-style.html:1104
> +    listItems[i].setAttribute('title', '#' + listItems[i].id);

May I get a hand as well so I can quick tell what is clickable? (I don't think that is there just b/c you are listening for the click event.)

listItems[i].style.cursor = ' pointer';

> Websites/webkit.org/coding/coding-style.html:1107
> +    });

Perhaps it should check for duplicate ids as well?

Something like this:

var idsUsed = new Object();
for ...

  if (idsUsed[listItems[i].id])
     alert("The id " + listItems[i].id + " is used more than once in this document.");
  idsUsed[listItems[i].id] = 1;
------- Comment #6 From 2012-01-20 00:39:14 PST -------
Created an attachment (id=123266) [details]
Patch for landing
------- Comment #7 From 2012-01-20 00:40:18 PST -------
(From update of attachment 123258 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=123258&action=review

Thanks.  I followed your comments.

>> Websites/webkit.org/coding/coding-style.html:1104
>> +    listItems[i].setAttribute('title', '#' + listItems[i].id);
> 
> May I get a hand as well so I can quick tell what is clickable? (I don't think that is there just b/c you are listening for the click event.)
> 
> listItems[i].style.cursor = ' pointer';

Adding :hover style might be helpful too.
------- Comment #8 From 2012-01-20 01:23:23 PST -------
Committed r105494: <http://trac.webkit.org/changeset/105494>
------- Comment #9 From 2012-02-10 11:58:28 PST -------
This change made it extremely hard to use double- or triple-clicking to select anything on the Coding Style Guidelines webpage, and to click to clear the selection. In OS X, it also made WebKit almost always show a tool tip over the page, obscuring the content. I don’t see how any of the changes here that detracted from the page’s usability have to do with the statement “each style rule should have its own ID”.
------- Comment #10 From 2012-02-13 00:27:37 PST -------
(In reply to comment #9)
> This change made it extremely hard to use double- or triple-clicking to select anything on the Coding Style Guidelines webpage, and to click to clear the selection. In OS X, it also made WebKit almost always show a tool tip over the page, obscuring the content. I don’t see how any of the changes here that detracted from the page’s usability have to do with the statement “each style rule should have its own ID”.

Thank you for the comment.  Let's improve it in Bug 78470.