{"action":"created","issue":{"url":"https://api.github.com/repos/servo/webrender/issues/1418","repository_url":"https://api.github.com/repos/servo/webrender","labels_url":"https://api.github.com/repos/servo/webrender/issues/1418/labels{/name}","comments_url":"https://api.github.com/repos/servo/webrender/issues/1418/comments","events_url":"https://api.github.com/repos/servo/webrender/issues/1418/events","html_url":"https://github.com/servo/webrender/issues/1418","id":237906480,"number":1418,"title":"plan: text decoration blob support","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars2.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"labels":[{"id":263326145,"url":"https://api.github.com/repos/servo/webrender/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-06-22T16:42:43Z","updated_at":"2017-06-30T22:08:13Z","closed_at":null,"body":"So today if gecko has text decorations that webrender can't handle we give up completely and produce a blob image for the text. I'd like to improve this situation so that webrender handles the things it can natively, but invokes gecko via blob images for the parts that it can't.\r\n\r\nAt the high level I want webrender to receive something like:\r\n\r\n```\r\ntext\r\n  - glyphs\r\n  - font/style details\r\n  - shadows [(color, offset, blur, ...), ...]\r\n  - underline (kindICanHandle | blob)\r\n  - overline (kindICanHandle | blob)\r\n  - line-through (kindICanHandle | blob)\r\n```\r\n\r\nAnd for its rendering strategy to be something like:\r\n\r\n```\r\ndrawText:\r\n  for shadow in shadows {\r\n    drawTextWithEffect(shadow)\r\n  }\r\n  drawTextWithEffect(None)\r\n\r\ndrawTextWithEffect(effect):\r\n  drawUnderline(effect)\r\n  drawOverline(effect)\r\n  drawText(effect)\r\n  drawLineThrough(effect) \r\n```\r\n\r\nPotentially the drawTextWithEffect can actually be cached like:\r\n\r\n```\r\ndrawText:\r\n  let text = drawTextToTemp() // like drawTextWithEffect(None), but to temporary surface\r\n  for shadow in shadows {\r\n    compositeAndApplyEffect(text, shadow)\r\n  }\r\n  compositeAndApplyEffect(text, None)\r\n```\r\n\r\nBut I have no idea if that approach is actually practical.\r\n\r\n\r\nNote: I am currently omitting [text-emphasis marks](https://developer.mozilla.org/en-US/docs/Web/CSS/text-emphasis) and selection from this description. I think selection can be handled by the client (drawing a box and tweaking colors), but I'm less certain about emphasis (they strictly should be drawn between text and linethrough -- possibly just needs to be a second list of glyphs).\r\n\r\n\r\n# Summary of Benefits\r\n\r\n* reduced bandwidth: currently clients are expected to just send the text again for each shadow with the effects applied. Under this system they would just send a list of shadow effects. (There's some sites that apply like 4 shadows to all their text to get a certain effect)\r\n* a path for migrating implementation from gecko to webrender incrementally (start all decorations as blobs, then teach it basic lines, then dashed lines, then wavy lines, etc.)\r\n* more text decoration/shadow logic can be shared between gecko and servo via webrender (e.g. Servo devs will do my job for me :P) "},"comment":{"url":"https://api.github.com/repos/servo/webrender/issues/comments/312383411","html_url":"https://github.com/servo/webrender/issues/1418#issuecomment-312383411","issue_url":"https://api.github.com/repos/servo/webrender/issues/1418","id":312383411,"user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars2.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"created_at":"2017-06-30T22:08:13Z","updated_at":"2017-06-30T22:08:13Z","body":"Ran into an issue in implementation: \"hello 👏 there\" will often contain two fonts -- one for the text, one for the emoji (because emoji aren't in many fonts). Similar thing for kanji and friends. *However* \"hello 👏 there\" should have a single shadow -- in fact all the paragraphs in a single stacking context should have their shadows on the same \"layer\" behind the text, per:\r\n\r\nhttps://drafts.csswg.org/css-text-decor-3/#text-shadow-property\r\n\r\n> The shadow effects are applied front-to-back: the first shadow is on top. The shadows may thus overlay each other, but they never overlay the text itself. The shadow must be painted at a stack level between the element’s border and/or background, if present, and the elements text and text decoration. UAs should avoid painting text shadows over text in adjacent elements belonging to the same stack level and stacking context. (This may mean that the exact stack level of the shadows depends on whether the element has a border or background: the exact stacking behavior of text shadows is thus UA-defined.) It is undefined whether a given shadow layer shadows each glyph or decoration independently or if the text and/or decorations are flattened and then shadowed. \r\n\r\nDiscussing with some of the folks it seemed like the best path forward would involve introducing some kind of non-stacking-context to group a bunch of elements and say \"these should have shadows\" so the shadows can be done all at once. This would also let us remove the decorations from the text and just have them as \"normal\" blob images.\r\n\r\nI need to do more experiments to figure out exactly what Gecko's doing here."}}
{"actor":{"display_login":"Gankro"}}