Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a clipboard media type #648

Closed
SebastianZ opened this issue Oct 26, 2016 · 6 comments
Closed

Add a clipboard media type #648

SebastianZ opened this issue Oct 26, 2016 · 6 comments
Labels
Closed Rejected as Wontfix by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. mediaqueries-5

Comments

@SebastianZ
Copy link
Contributor

It should be possible to style web contents differently when they are copied to the clipboard.

This would allow modifications like e.g. resizing or hiding images when copied, or removing some styling which should only be shown within the browser, or display some copyright information on copied text.

Example:

h2 {
  text-transform: uppercase;
}

#copyrightInfo {
  display: none;
}

@media clipboard {
  h2 {
    text-transform: none;
  }

  #copyrightInfo {
    display: block;
  }
}

To be able to style different clipboard formats individually, clipboard may be changed to a function like clipboard(<mime-type>):

@media clipboard("text/plain") {
  h2 {
    text-transform: none;
  }
}

@media clipboard("text/html") {
  h2 {
    text-transform: none;
  }
}

This idea rose in the issue about the copy/paste behavior with text-transform.

Sebastian

@Crissov
Copy link
Contributor

Crissov commented Oct 26, 2016

I'm worried about content: "copy protection" or just * {display: none}, though.

@SebastianZ
Copy link
Contributor Author

Yes, that's a downside from a user point of view. Though web authors can already achieve copy protection via * { user-select: none; }.

Sebastian

@frivoal
Copy link
Collaborator

frivoal commented Oct 28, 2016

As @Crissov commented, this is highly likely to be abused. And as @smfr commented on a recent conference call, this would significantly complicate how implementations deal with copying to the clipboard, as they would have to do a dedicated layout pass, which they currently do not do.

Besides, even if we do not have this in CSS, it should be doable in Javascript.

I'd like to close this as WONTFIX. Is that OK with you?

@SebastianZ
Copy link
Contributor Author

SebastianZ commented Oct 28, 2016

As @Crissov commented, this is highly likely to be abused.

As I said, a similar way to copy-protect a page is already available via user-select. Also @media print can be abused the same way.
But you're right, the risk that this feature would abused is high.

this would significantly complicate how implementations deal with copying to the clipboard, as they would have to do a dedicated layout pass, which they currently do not do.

The idea about the 'clipboard' media type could have been part of a larger discussion about specifying how implementations should deal with copying. (Currently they obviously differ a lot!)

I'm not an implementer, but I would have assumed the technical part to be relatively easy, because the layout algorithm would mostly be the same as the one used for the screen or print layout.

@fantasai in the minutes from 2016-10-26:

It won't interact properly with the cascade since we want the default behavior to be a set of UA-defined behavior.

I assume UAs would only be required to change the default style sheet for this and the cascade would work the same as now.

I'd like to close this as WONTFIX. Is that OK with you?

I still think it would be good to have a way to influence clipboard layout in some way, but I can understand your disagreement on the proposed 'clipboard' media type.
So, if you think, this is not feasible, feel free to WONTFIX this.

Sebastian

@frivoal
Copy link
Collaborator

frivoal commented Oct 28, 2016

I'm not an implementer, but I would have assumed the technical part to be relatively easy, because the layout algorithm would mostly be the same as the one used for the screen or print layout.

Well, on the one hand, you are right that code to do layout already exists. But that code does not get invoked when doing copy-paste operations today, and it would now need to. This would change a simple string manipulation operation into a much heaving operation doing selector matching, cascading, inheritance, style computation, and create a box tree separate from the one used for the page (since it has different styles), and then since you don't want to use the DOM as-is, you'd need some form of layout/paint...

Moreover, you couldn't actually reuse the existing layout and paint part of the code, because you'd need to render to a string, which is a one dimensional thing, very different from the two 2 canvas CSS rendering operates in. For sure, rendering to a string is going to be much simpler than rendering to 2D, but that's still code that doesn't exist today that needs to be written.

And then you have all sorts of weird questions. If part or all of the thing you have selected and are trying to copy is set to display:none in the clipboard media type, what do you do? What if you had selected the generated content of a pseudo element, and in the clipboard media type it has a different content?

I still think it would be good to have a way to influence clipboard layout in some way, but I can understand your disagreement on the proposed 'clipboard' media type.
So, if you think, this is not feasible, feel free to WONTFIX this.

I think this was a good instance of thinking out of the box to see if a different approach could get us somewhere. I'm glad we looked at it, but ultimately, it doesn't work out.

@frivoal frivoal closed this as completed Oct 28, 2016
@frivoal frivoal added Closed Rejected as Wontfix by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. labels Oct 28, 2016
@SebastianZ
Copy link
Contributor Author

Anyway, thank you for the consideration and the explanations!

Sebastian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Rejected as Wontfix by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. mediaqueries-5
Projects
None yet
Development

No branches or pull requests

3 participants