Fix: clear the display mark on a view with no area - #867
Open
DTW-Thalion wants to merge 2 commits into
Open
Conversation
Both display walks reach a subview only when the rectangle being displayed and the subview's frame overlap. A subview whose frame has no width or height never overlaps anything, so it is never displayed, its mark is never cleared, and both walks copy that mark up to every view above it. An NSBox two pixels high is enough: its content view is left with a height of zero, and from then on the content view and the frame view of that window answer YES to -needsDisplay for good. When the overlap is empty because the subview itself has no area, let the subview run the display for an empty rectangle, which clears its own mark. A subview that has an area and merely falls outside the rectangle keeps its mark, as it should.
Contributor
|
Cool thing to spot. |
Member
|
Looks great, but I will have to review the whole working here. I wrote most of that, but that was a long time ago and I have to understand all of it again. Sorry,we could also just merge and I go through that later on. |
START_SET creates an autorelease pool and END_SET releases it, so the pool these tests create around the set is redundant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both of NSView's display walks reach a subview only when the rectangle being displayed and the subview's frame overlap. A subview with no width or height never overlaps anything, so it is never displayed, its mark is never cleared, and both walks copy that mark up to every view above it. An NSBox two pixels high is enough: it leaves its content view a height of zero, and from then on that view, the box, the window's content view and the frame view all answer YES to -needsDisplay for good.
When the overlap is empty because the subview has no area, it is now asked to display an empty rectangle, which clears its mark. A subview that has an area and merely falls outside the rectangle keeps its mark, and there is an assertion for that.
This turned up in the alert panel of #80, whose separator is such a box. The symptom reported there, contents invisible until the panel is moved, does not reproduce on Windows against current master, whether the alert is raised before the application loop starts or from inside a running one. This mark is the only defect found on that path.
Tests/gui/NSView/emptyViewNeedsDisplay.m: 5 of its 7 assertions fail before the change and none after. Tests/gui runs 4345 assertions green.
Closes #80