Synchronously sample font styling when global editor stylesheet changes

And don’t sample font styling in pollDOM, which we are aiming to
eliminate.

Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
Nathan Sobo
2017-02-08 15:48:07 -07:00
committed by Thomas Johansen
parent 0560ce7f18
commit 8bb3ec1563
2 changed files with 6 additions and 7 deletions

View File

@@ -649,11 +649,12 @@ class TextEditorComponent
return unless @performedInitialMeasurement
return unless @themes.isInitialLoadComplete()
# This delay prevents the styling from going haywire when stylesheets are
# reloaded in dev mode. It seems like a workaround for a browser bug, but
# not totally sure.
unless @stylingChangeAnimationFrameRequested
# Handle styling change synchronously if a global editor property such as
# font size might have changed. Otherwise coalesce multiple style sheet changes
# into a measurement on the next animation frame to prevent excessive thrashing.
if styleElement.getAttribute('source-path') is 'global-text-editor-styles'
@handleStylingChange()
else if not @stylingChangeAnimationFrameRequested
@stylingChangeAnimationFrameRequested = true
requestAnimationFrame =>
@stylingChangeAnimationFrameRequested = false
@@ -757,7 +758,6 @@ class TextEditorComponent
pollDOM: =>
if @isVisible()
@sampleBackgroundColors()
@sampleFontStyling()
@overlayManager?.measureOverlays()
# Measure explicitly-styled height and width and relay them to the model. If

View File

@@ -64,7 +64,6 @@ class WorkspaceElement extends HTMLElement {
line-height: ${this.config.get('editor.lineHeight')};
}`
this.styleManager.addStyleSheet(styleSheetSource, {sourcePath: 'global-text-editor-styles', priority: -1})
this.viewRegistry.performDocumentPoll()
}
initialize (model, {config, project, styleManager, viewRegistry}) {