Merge pull request #4143 from atom/ns-fix-scrollbar-regression

Always re-render scrollbars after themes load/reload
This commit is contained in:
Nathan Sobo
2014-11-10 19:50:13 -07:00
2 changed files with 42 additions and 2 deletions

View File

@@ -56,3 +56,37 @@ describe "TextEditorElement", ->
document.body.focus()
expect(blurCalled).toBe true
describe "when the themes finish loading", ->
[themeReloadCallback, initialThemeLoadComplete, element] = []
beforeEach ->
themeReloadCallback = null
initialThemeLoadComplete = false
spyOn(atom.themes, 'isInitialLoadComplete').andCallFake ->
initialThemeLoadComplete
spyOn(atom.themes, 'onDidReloadAll').andCallFake (fn) ->
themeReloadCallback = fn
atom.config.set("editor.useShadowDOM", false)
element = new TextEditorElement()
element.style.height = '200px'
element.getModel().setText [0..20].join("\n")
it "re-renders the scrollbar", ->
jasmineContent.appendChild(element)
atom.styles.addStyleSheet """
::-webkit-scrollbar {
width: 8px;
}
"""
initialThemeLoadComplete = true
themeReloadCallback()
verticalScrollbarNode = element.querySelector(".vertical-scrollbar")
scrollbarWidth = verticalScrollbarNode.offsetWidth - verticalScrollbarNode.clientWidth
expect(scrollbarWidth).toEqual(8)

View File

@@ -182,7 +182,7 @@ TextEditorComponent = React.createClass
@subscribe stylesElement.onDidUpdateStyleElement @onStylesheetsChanged
@subscribe stylesElement.onDidRemoveStyleElement @onStylesheetsChanged
unless atom.themes.isInitialLoadComplete()
@subscribe atom.themes.onDidReloadAll @onStylesheetsChanged
@subscribe atom.themes.onDidReloadAll @onAllThemesLoaded
@subscribe scrollbarStyle.changes, @refreshScrollbars
@domPollingIntervalId = setInterval(@pollDOM, @domPollingInterval)
@@ -627,8 +627,14 @@ TextEditorComponent = React.createClass
onStylesheetsChanged: (styleElement) ->
return unless @performedInitialMeasurement
return unless atom.themes.isInitialLoadComplete()
@refreshScrollbars() if not styleElement.sheet? or @containsScrollbarSelector(styleElement.sheet)
@handleStylingChange()
onAllThemesLoaded: ->
@refreshScrollbars()
@handleStylingChange()
handleStylingChange: ->
@sampleFontStyling()
@sampleBackgroundColors()
@remeasureCharacterWidths()