| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/guid.html"> | 8 <link rel="import" href="/tracing/base/guid.html"> |
| 9 <link rel="import" href="/tracing/model/event_set.html"> | 9 <link rel="import" href="/tracing/model/event_set.html"> |
| 10 <link rel="import" href="/tracing/model/selection_state.html"> | 10 <link rel="import" href="/tracing/model/selection_state.html"> |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 }, | 130 }, |
| 131 | 131 |
| 132 get viewSpecificBrushingStates() { | 132 get viewSpecificBrushingStates() { |
| 133 return this.viewSpecificBrushingStates_; | 133 return this.viewSpecificBrushingStates_; |
| 134 }, | 134 }, |
| 135 | 135 |
| 136 set viewSpecificBrushingStates(viewSpecificBrushingStates) { | 136 set viewSpecificBrushingStates(viewSpecificBrushingStates) { |
| 137 this.viewSpecificBrushingStates_ = viewSpecificBrushingStates; | 137 this.viewSpecificBrushingStates_ = viewSpecificBrushingStates; |
| 138 }, | 138 }, |
| 139 | 139 |
| 140 get causesDimming_() { |
| 141 return this.findMatches_.length > 0 || |
| 142 this.analysisViewRelatedEvents_.length > 0; |
| 143 }, |
| 140 | 144 |
| 141 get hasHighlight_() { | 145 get brightenedEvents_() { |
| 142 return this.findMatches_.length > 0 || | 146 var brightenedEvents = new EventSet(); |
| 143 this.analysisViewRelatedEvents_.length > 0 || | 147 brightenedEvents.addEventSet(this.selection_); |
| 144 this.analysisLinkHoveredEvents_.length > 0; | 148 brightenedEvents.addEventSet(this.analysisLinkHoveredEvents_); |
| 149 return brightenedEvents; |
| 145 }, | 150 }, |
| 146 | 151 |
| 147 applyToModelSelectionState: function(model) { | 152 applyToModelSelectionState: function(model) { |
| 148 this.appliedToModel_ = model; | 153 this.appliedToModel_ = model; |
| 149 | 154 |
| 150 | 155 if (!this.causesDimming_) { |
| 151 if (!this.hasHighlight_) { | 156 this.brightenedEvents_.forEach(function(e) { |
| 152 this.selection_.forEach(function(e) { | 157 var score; |
| 153 e.selectionState = SelectionState.SELECTED; | 158 score = 0; |
| 154 }); | 159 if (this.selection_.contains(e)) |
| 160 score++; |
| 161 if (this.analysisLinkHoveredEvents_.contains(e)) |
| 162 score++; |
| 163 e.selectionState = SelectionState.getFromBrighteningLevel(score); |
| 164 }, this); |
| 155 return; | 165 return; |
| 156 } | 166 } |
| 167 |
| 168 var brightenedEvents = this.brightenedEvents_; |
| 157 model.iterateAllEvents(function(e) { | 169 model.iterateAllEvents(function(e) { |
| 158 var selectionState; | 170 var score; |
| 159 if (this.selection_.contains(e)) { | 171 if (brightenedEvents.contains(e)) { |
| 160 selectionState = SelectionState.SELECTED; | 172 score = 0; |
| 161 } else if (this.findMatches_.contains(e) || | 173 if (this.selection_.contains(e)) |
| 162 this.analysisViewRelatedEvents_.contains(e) || | 174 score++; |
| 163 this.analysisLinkHoveredEvents_.contains(e)) { | 175 if (this.analysisLinkHoveredEvents_.contains(e)) |
| 164 selectionState = SelectionState.HIGHLIGHTED; | 176 score++; |
| 177 e.selectionState = SelectionState.getFromBrighteningLevel(score); |
| 165 } else { | 178 } else { |
| 166 selectionState = SelectionState.DIMMED; | 179 score = 0; |
| 180 if (this.findMatches_.contains(e)) |
| 181 score++; |
| 182 if (this.analysisViewRelatedEvents_.contains(e)) |
| 183 score++; |
| 184 e.selectionState = SelectionState.getFromDimmingLevel(score); |
| 167 } | 185 } |
| 168 e.selectionState = selectionState; | |
| 169 }.bind(this)); | 186 }.bind(this)); |
| 170 }, | 187 }, |
| 171 | 188 |
| 172 transferModelOwnershipToClone: function(that) { | 189 transferModelOwnershipToClone: function(that) { |
| 173 if (!this.appliedToModel_) | 190 if (!this.appliedToModel_) |
| 174 throw new Error('Not applied'); | 191 throw new Error('Not applied'); |
| 175 // Assumes this.equals(that). | 192 // Assumes this.equals(that). |
| 176 that.appliedToModel_ = this.appliedToModel_; | 193 that.appliedToModel_ = this.appliedToModel_; |
| 177 this.appliedToModel_ = undefined; | 194 this.appliedToModel_ = undefined; |
| 178 }, | 195 }, |
| 179 | 196 |
| 180 unapplyFromModelSelectionState: function() { | 197 unapplyFromModelSelectionState: function() { |
| 181 if (!this.appliedToModel_) | 198 if (!this.appliedToModel_) |
| 182 throw new Error('Not applied'); | 199 throw new Error('Not applied'); |
| 183 var model = this.appliedToModel_; | 200 var model = this.appliedToModel_; |
| 184 this.appliedToModel_ = undefined; | 201 this.appliedToModel_ = undefined; |
| 185 | 202 |
| 186 if (!this.hasHighlight_) { | 203 if (!this.causesDimming_) { |
| 187 this.selection_.forEach(function(e) { | 204 this.brightenedEvents_.forEach(function(e) { |
| 188 e.selectionState = SelectionState.NONE; | 205 e.selectionState = SelectionState.NONE; |
| 189 }); | 206 }); |
| 190 return; | 207 return; |
| 191 } | 208 } |
| 209 |
| 192 model.iterateAllEvents(function(e) { | 210 model.iterateAllEvents(function(e) { |
| 193 e.selectionState = SelectionState.NONE; | 211 e.selectionState = SelectionState.NONE; |
| 194 }); | 212 }); |
| 195 } | 213 } |
| 196 }; | 214 }; |
| 197 | 215 |
| 198 return { | 216 return { |
| 199 BrushingState: BrushingState | 217 BrushingState: BrushingState |
| 200 }; | 218 }; |
| 201 }); | 219 }); |
| 202 </script> | 220 </script> |
| OLD | NEW |