Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1972.mcz
==================== Summary ====================
Name: Morphic-mt.1972
Author: mt
Time: 27 April 2022, 2:20:57.686668 pm
UUID: 5ff494ac-cefd-4348-a243-cb7ce9be22f7
Ancestors: Morphic-mt.1971
Fixes regression in "set style..." invoked via CMD+SHIFT+K.
Thanks to Nicolas (nice) for the hint!
***
There are a lot of ifNil checks against paragraph in TextMorph. I suppose this is to not invalidate-and-recompute paragraphs by accident, which would further slow down the overall input experience.
In #handleInteraction:fromEvent:, I can see two invariants:
1. The instVar paragraph must never be nil when entering the method.
2. Any "new" paragraph must be processed after "interactionBlock" so that visual glitches regarding the text selection can be avoided.
Thus, replacing all accesses to the instVar "paragraph" with the accessor #paragraph seems too risky performance-wise. For now, I will make sure that the paragraph is notNil after the interactionBlock.
=============== Diff against Morphic-mt.1971 ===============
Item was changed:
----- Method: TextMorph>>handleInteraction:fromEvent: (in category 'editing') -----
handleInteraction: interactionBlock fromEvent: evt
"Perform the changes in interactionBlock, noting any change in selection
and possibly a change in the size of the paragraph (ar 9/22/2001 - added for TextPrintIts)"
| oldEditor oldParagraph oldText oldSelection |
oldEditor := editor.
oldParagraph := paragraph.
oldText := oldParagraph text copy.
oldSelection := oldParagraph selectionRects. "already copy"
+ "1) Note old selection to avoid visual glitches."
- "Note old selection."
self selectionChanged: oldSelection.
+ "2) Evaluate the interaction. Ensure access to paragraph."
interactionBlock value.
+ paragraph ifNil: [self createParagraph].
+ "3) ?!! Account for premature #releaseEditor ?!!"
+ oldParagraph == paragraph ifTrue: [
+ self flag: #fixme.
+ editor := oldEditor].
- (oldParagraph == paragraph) ifTrue:[
- "this will not work if the paragraph changed"
- editor := oldEditor. "since it may have been changed while in block"
- ].
+ "4) Note new selection to avoid visual glitches."
- "Note new selection."
paragraph selectionRects in: [:newSelection |
newSelection ~= oldSelection ifTrue: [
self selectionChanged: newSelection]].
+
+ "5) Update my layout as a morph if necessary."
-
(oldText = paragraph text and: [ oldText runs = paragraph text runs ])
ifFalse: [ self updateFromParagraph ].
self flag: #ImmPlugin.
"self setCompositionWindow."!
Christoph Thiede uploaded a new version of PreferenceBrowser to project The Trunk:
http://source.squeak.org/trunk/PreferenceBrowser-ct.147.mcz
==================== Summary ====================
Name: PreferenceBrowser-ct.147
Author: ct
Time: 26 April 2022, 12:20:13.336476 pm
UUID: f83801fb-a0f1-404d-909c-588782113b6c
Ancestors: PreferenceBrowser-mt.146
Fixes help text of 'Colorful source code' checkbox in preference wizard, which always fell back to the ANSI preference. Let's hope that there are no further incidents like this one.
=============== Diff against PreferenceBrowser-mt.146 ===============
Item was changed:
----- Method: PreferenceWizardMorph>>initializePage01Themes (in category 'initialization - pages') -----
initializePage01Themes
| currentPage pane |
currentPage := pages add: self createPage.
pane := self createScrollPane.
+ currentPage addMorphBack: (self createLabel: 'Choose a theme' translated color: Color white).
- currentPage addMorphBack: (self createLabel: 'Choose a theme' color: Color white).
currentPage addMorphBack: pane.
((UserInterfaceTheme allThemes
select: [:uit | uit isGenuine])
sorted: [:a :b | a name <= b name])
do: [:ea |
pane scroller firstSubmorph addMorphBack: (self
createRadioButton: ea name
for: #Theme
argument: ea)].
pane scroller firstSubmorph addAllMorphsBack: {
self createVerticalSpace.
self createCheckbox: 'Colorful windows' translated for: #UseColorfulWindows help: #(color window).
+ self createCheckbox: 'Colorful source code' translated for: #UseColorfulSourceCode help: 'Whether to use Shout (Syntax Highlighting As You Type) in code browsers.' translated.
- self createCheckbox: 'Colorful source code' translated for: #UseColorfulSourceCode help: #(syntax you type).
self createCheckbox: 'Flat widget look' translated for: #Gradients help: 'Whether to use gradients or not.' translated.
+ }.!
- }. !
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1461.mcz
==================== Summary ====================
Name: Kernel-nice.1461
Author: nice
Time: 26 April 2022, 11:22:41.16552 am
UUID: 45d507fb-8cd8-164a-94a7-66d354f4aeaa
Ancestors: Kernel-nice.1460
Provide a more robust version of Complex divideSecureBy:, at least passing the new tests.
=============== Diff against Kernel-nice.1460 ===============
Item was changed:
----- Method: Complex>>divideSecureBy: (in category 'arithmetic') -----
divideSecureBy: anObject
"Answer the result of dividing receiver by aNumber"
" Both operands are scaled to avoid arithmetic overflow. This algorithm
works for a wide range of values, but it requires six divisions.
#divideFastAndSecureBy: is also quite good, but it uses only 3 divisions.
+ Note: #reciprocal uses #/ for division"
- Note: #reciprocal uses #/ for devision"
| s ars ais brs bis newReal newImaginary |
anObject isComplex ifTrue:
+ [s := anObject real abs max: anObject imaginary abs.
- [s := anObject real abs + anObject imaginary abs.
ars := self real / s.
ais := self imaginary / s.
brs := anObject real / s.
bis := anObject imaginary / s.
s := brs squared + bis squared.
+ brs := brs / s.
+ bis := bis / s.
+ newReal := ars*brs + (ais*bis).
+ newImaginary := ais*brs - (ars*bis).
- newReal := ars*brs + (ais*bis) /s.
- newImaginary := ais*brs - (ars*bis)/s.
^ Complex real: newReal imaginary: newImaginary].
^ anObject adaptToComplex: self andSend: #/.!
Nicolas Cellier uploaded a new version of KernelTests to project The Trunk:
http://source.squeak.org/trunk/KernelTests-nice.421.mcz
==================== Summary ====================
Name: KernelTests-nice.421
Author: nice
Time: 26 April 2022, 11:09:45.55052 am
UUID: cadcb57f-5e1f-8247-be4c-5b1235c3b821
Ancestors: KernelTests-nice.420
Where we show that divideSecureBy: is not robust to some extreme test case.
For example this choice of scaling:
s := anObject real abs + anObject imaginary abs.
might create an overflow - just choose Float fmax for both divisor real and imaginary.
If we simply replace with:
s := anObject real abs max: anObject imaginary abs.
then a second test case shows another potential problem in the computation of result real/imaginary parts:
newReal := ars*brs + (ais*bis) / s.
The intermediate ars*brs + (ais*bis) does overflow, while pre-dividing each term with s would not.
=============== Diff against KernelTests-nice.420 ===============
Item was added:
+ ----- Method: ComplexTest>>testSecureDivisionDoesNotOverflow (in category 'tests') -----
+ testSecureDivisionDoesNotOverflow
+
+ | c1 c2 scale |
+ "Note: this test used to fail with legacy version of divideSecureBy:"
+ c1 := (2 + 1i).
+ c2 := (1 + 1i).
+ scale := Float fmax.
+ self testSecureDivisionOf: c1 by: c2 scaledBy: scale.
+ "And this one fails with incomplete correction of above method"
+ c1 := (1/2 + 1i) / (5 << 48).
+ c2 := (1 + 1i).
+ scale := Float fminDenormalized.
+ self testSecureDivisionOf: c1 by: c2 scaledBy: scale!
Item was added:
+ ----- Method: ComplexTest>>testSecureDivisionOf:by:scaledBy: (in category 'tests') -----
+ testSecureDivisionOf: c1 by: c2 scaledBy: scale
+ "Note: this test used to fail with legacy version of divideSecureBy:"
+
+ | quo expected |
+ quo := c1 / c2.
+ expected := quo real / scale + (quo imaginary / scale) i.
+ "check in precondition that the scaled division c1/(c2*scale) would not oevrflow"
+ self assert: expected real isFinite.
+ self assert: expected imaginary isFinite.
+ "now retry with scaling"
+ quo := c1 divideSecureBy: (c2 * scale).
+ self assert: quo real isFinite.
+ self assert: quo imaginary isFinite.
+ self assert: (expected real - quo real) abs / (expected real ulp) < 3.
+ self assert: (expected imaginary - quo imaginary) abs / (expected imaginary ulp) < 3.!
Marcel Taeumel uploaded a new version of Graphics to project The Trunk:
http://source.squeak.org/trunk/Graphics-mt.513.mcz
==================== Summary ====================
Name: Graphics-mt.513
Author: mt
Time: 25 April 2022, 4:16:34.244696 pm
UUID: dd521902-98db-e048-9702-83fcac30fee6
Ancestors: Graphics-mt.512
Tweak no-cursor-scale-on-macOS workaround to only be used directly before calling #beCursor and not in #scaleIconToDisplay, which also would affect Morphic cursors.
=============== Diff against Graphics-mt.512 ===============
Item was changed:
----- Method: Cursor class>>currentCursor: (in category 'current cursor') -----
currentCursor: aCursor
"Make the instance of cursor, aCursor, be the current cursor. Display it.
Create an error if the argument is not a Cursor."
(aCursor isKindOf: self)
ifTrue: [ | platformCursor |
CurrentCursor := aCursor. "unscaled"
+ self flag: #todo. "mt: The current OSVM platform code for macOS has an issue with *not* scaling up hardware cursors for Retina displays. So we avoid scaling it here and let the OS do it. Note that this is not good because we could never provide a high-resolution cursor from within Squeak since the OS would scale it up anyway."
+ Smalltalk platformName = 'Mac OS'
+ ifTrue: [platformCursor := aCursor]
+ ifFalse: [platformCursor := aCursor scaleIconToDisplay].
- platformCursor := aCursor scaleIconToDisplay.
self useBiggerCursors
ifTrue: [platformCursor := platformCursor enlargedBy: 2].
platformCursor beCursor]
ifFalse: [self error: 'The new cursor must be an instance of class Cursor']!
Item was changed:
----- Method: Cursor>>scaleIconToDisplay (in category 'converting') -----
scaleIconToDisplay
"Overwritten to use the custom #enlargedBy: method to scale up the receiver."
- self flag: #todo. "mt: The current OSVM platform code for macOS has an issue with *not* scaling up hardware cursors for Retina displays. So we avoid scaling it here and let the OS do it. Note that this is not good because we could never provide a high-resolution cursor from within Squeak since the OS would scale it up anyway."
- Smalltalk platformName = 'Mac OS' ifTrue: [^ self].
-
^ self enlargedBy: (RealEstateAgent scaleFactor max: 1)!