Support @font-face rules in user style sheets
@font-face rules in author style sheets are passed back to StyleEngine via ScopedStyleResolver. With crrev.com/c/641294 we started treating style sheets injected by extensions as user style sheets instead. Since user style sheets apply to all scopes, they never go via ScopedStyleResolver but are rather managed by StyleEngine directly. crrev.com/c/641294 broke extensions using custom fonts because StyleEngine fails to account for @font-face rules in user style sheets. Fonts from both user and author style sheets must be maintained in the same font cache. Even though style sheets can be added in any order, @font-face rules in author style sheets must appear after those in user style sheets. In order to achieve this result efficiently, we use a "dirty" flag and refresh the font cache only once per cycle. StyleEngine::ApplyRuleSetChanges may be called twice, once for user style sheets (all scopes) and once for author style sheets (document scope). If fonts have changed in user style sheets, we simply set the dirty flag. If fonts have changed in author style sheets, we set the dirty flag but also then refresh the font cache by first adding all the @font-face rules from the active user style sheets and then re-adding all the new author style sheets. This ensures that the font cache is refreshed only once while the fonts are added in the correct order. BUG=632009,779048 Change-Id: I58c1070af3ecae925e4afb91cbbb7cb00ee187fd Reviewed-on: https://chromium-review.googlesource.com/743642 Commit-Queue: nainar <nainar@chromium.org> Reviewed-by:nainar <nainar@chromium.org> Cr-Commit-Position: refs/heads/master@{#513154}
Showing
Please register or sign in to comment