From a5580a704d2a621f237c5acacfebbb22499e0cd8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 27 Jan 2015 08:12:33 -0700 Subject: [PATCH] Remove unused properties in EditorComponent and children --- src/highlights-component.coffee | 4 ++-- src/lines-component.coffee | 19 +++++++++---------- src/overlay-manager.coffee | 13 +++++++------ src/text-editor-component.coffee | 11 +++-------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/src/highlights-component.coffee b/src/highlights-component.coffee index 91602b597..332f63801 100644 --- a/src/highlights-component.coffee +++ b/src/highlights-component.coffee @@ -9,10 +9,10 @@ HighlightsComponent = React.createClass render: -> div className: 'highlights', - @renderHighlights() if @props.performedInitialMeasurement + @renderHighlights() if @props.presenter? renderHighlights: -> - {editor, presenter} = @props + {presenter} = @props highlightComponents = [] for key, state of presenter.state.content.highlights highlightComponents.push(HighlightComponent({key, state})) diff --git a/src/lines-component.coffee b/src/lines-component.coffee index 2334b1318..700e2dbf2 100644 --- a/src/lines-component.coffee +++ b/src/lines-component.coffee @@ -17,11 +17,10 @@ LinesComponent = React.createClass displayName: 'LinesComponent' render: -> - {presenter, performedInitialMeasurement, cursorBlinkPeriod, cursorBlinkResumeDelay} = @props + {presenter} = @props - if performedInitialMeasurement - {editor, presenter, overlayDecorations, highlightDecorations, placeholderText, backgroundColor} = @props - {lineHeightInPixels, defaultCharWidth, scrollViewHeight, scopedCharacterWidthsChangeCount, cursorPixelRects} = @props + if presenter? + {editor, presenter, overlayDecorations, placeholderText, backgroundColor} = @props @oldState ?= {content: {lines: {}}} @newState = presenter.state @@ -29,7 +28,7 @@ LinesComponent = React.createClass {scrollWidth} = @newState.content style = - height: Math.max(scrollHeight, scrollViewHeight) + height: scrollHeight width: scrollWidth WebkitTransform: @getTransform() backgroundColor: if editor.isMini() then null else backgroundColor @@ -38,7 +37,7 @@ LinesComponent = React.createClass div className: 'placeholder-text', placeholderText if placeholderText? CursorsComponent {presenter} - HighlightsComponent {presenter, performedInitialMeasurement} + HighlightsComponent {presenter} getTransform: -> {scrollTop} = @newState @@ -70,9 +69,9 @@ LinesComponent = React.createClass else @overlayManager = new OverlayManager(@getDOMNode()) - componentDidUpdate: (prevProps) -> - {visible, scrollingVertically, performedInitialMeasurement} = @props - return unless performedInitialMeasurement + componentDidUpdate: -> + {visible, scrollingVertically, presenter} = @props + return unless presenter? @removeLineNodes() unless @oldState?.content.indentGuidesVisible is @newState?.content.indentGuidesVisible @updateLineNodes() @@ -268,7 +267,7 @@ LinesComponent = React.createClass editor.setDefaultCharWidth(charWidth) remeasureCharacterWidths: -> - return unless @props.performedInitialMeasurement + return unless @props.presenter? @clearScopedCharWidths() @measureCharactersInNewLines() diff --git a/src/overlay-manager.coffee b/src/overlay-manager.coffee index 6b3416b59..f5ff053c6 100644 --- a/src/overlay-manager.coffee +++ b/src/overlay-manager.coffee @@ -4,7 +4,8 @@ class OverlayManager @overlays = {} render: (props) -> - {editor, overlayDecorations, lineHeightInPixels} = props + {presenter, editor, overlayDecorations} = props + lineHeight = presenter.getLineHeight() existingDecorations = null for markerId, {headPixelPosition, tailPixelPosition, decorations} of overlayDecorations @@ -12,7 +13,7 @@ class OverlayManager pixelPosition = if decoration.position is 'tail' then tailPixelPosition else headPixelPosition - @renderOverlay(editor, decoration, pixelPosition, lineHeightInPixels) + @renderOverlay(editor, decoration, pixelPosition, lineHeight) existingDecorations ?= {} existingDecorations[decoration.id] = true @@ -24,7 +25,7 @@ class OverlayManager return - renderOverlay: (editor, decoration, pixelPosition, lineHeightInPixels) -> + renderOverlay: (editor, decoration, pixelPosition, lineHeight) -> item = atom.views.getView(decoration.item) unless overlay = @overlays[decoration.id] overlay = @overlays[decoration.id] = document.createElement('atom-overlay') @@ -38,9 +39,9 @@ class OverlayManager if left + itemWidth - editor.getScrollLeft() > editor.getWidth() and left - itemWidth >= editor.getScrollLeft() left -= itemWidth - top = pixelPosition.top + lineHeightInPixels - if top + itemHeight - editor.getScrollTop() > editor.getHeight() and top - itemHeight - lineHeightInPixels >= editor.getScrollTop() - top -= itemHeight + lineHeightInPixels + top = pixelPosition.top + lineHeight + if top + itemHeight - editor.getScrollTop() > editor.getHeight() and top - itemHeight - lineHeight >= editor.getScrollTop() + top -= itemHeight + lineHeight overlay.style.top = top + 'px' overlay.style.left = left + 'px' diff --git a/src/text-editor-component.coffee b/src/text-editor-component.coffee index 441cd758f..68a5c784f 100644 --- a/src/text-editor-component.coffee +++ b/src/text-editor-component.coffee @@ -113,14 +113,9 @@ TextEditorComponent = React.createClass style: hiddenInputStyle LinesComponent { - ref: 'lines', - editor, lineHeightInPixels, defaultCharWidth, tokenizedLines, - lineDecorations, highlightDecorations, overlayDecorations, hostElement, - renderedRowRange, @pendingChanges, scrollTop, scrollLeft, - @scrollingVertically, scrollHeight, scrollWidth, mouseWheelScreenRow, - visible, scrollViewHeight, @scopedCharacterWidthsChangeCount, lineWidth, @useHardwareAcceleration, - placeholderText, @performedInitialMeasurement, @backgroundColor, cursorPixelRects, - cursorBlinkPeriod, cursorBlinkResumeDelay, useShadowDOM, @presenter + ref: 'lines', @presenter, editor, hostElement, @useHardwareAcceleration, useShadowDOM, + @scrollingVertically, mouseWheelScreenRow, visible, placeholderText, @backgroundColor, + overlayDecorations } ScrollbarComponent