-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved element size rendering #143
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6c38e29
Adjust element widths and set document height
rs22 93f0f26
Merge branch 'master' into rendering/box-model
rs22 65459be
Fix two background image related bugs
rs22 75314a8
Fix scrollbars (and 6-digit-hex-color parsing)
rs22 413ba78
Fix two CSS parsing bugs
rs22 e2173f4
Improve Tanzmaus
rs22 653938b
Fix link bug and others
rs22 39415c7
Merge branch 'master' into rendering/box-model
rs22 b5da904
Fix code formatting issues.
Steditor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
10 changes: 10 additions & 0 deletions
10
packages/HTML.package/CSSFormatter.class/instance/isNumber..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
size-conversion | ||
isNumber: aString | ||
|
||
(aString size > 0 and: [aString first isDigit]) | ||
ifTrue: [ ^ true ]. | ||
|
||
(aString size > 1 and: [aString first = $-] and: [aString second isDigit]) | ||
ifTrue: [ ^ true ]. | ||
|
||
^ false |
This file contains 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
18 changes: 16 additions & 2 deletions
18
packages/HTML.package/CSSSizeFormatter.class/instance/parseTextAttributesFrom.into..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
parsing | ||
parseTextAttributesFrom: aCSSProperty into: aContext | ||
|
||
aCSSProperty propertyName = 'height' | ||
(aCSSProperty propertyName = 'height' and: [ self isNumber: aCSSProperty propertyString ]) | ||
ifTrue: [ aContext at: #height put: aCSSProperty propertyString asInteger ]. | ||
aCSSProperty propertyName = 'width' | ||
ifTrue: [ aContext at: #width put: aCSSProperty propertyString asInteger ] | ||
ifTrue: [ | ||
aContext at: #absoluteWidth put: nil. | ||
aContext at: #relativeWidth put: nil. | ||
|
||
aCSSProperty propertyString = 'auto' ifTrue: [ | ||
aContext at: #absoluteWidth put: #auto. | ||
^ self]. | ||
|
||
self isRelativeSize: aCSSProperty propertyString ifTrue: [ | ||
"hope it's percent" | ||
aContext at: #relativeWidth put: aCSSProperty propertyString asInteger. | ||
^ self]. | ||
self isAbsoluteSize: aCSSProperty propertyString | ||
ifTrue: [ aContext at: #absoluteWidth put: | ||
(self absoluteSizeToPx: aCSSProperty propertyString defaultSize: 0) ] ] |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
3 changes: 3 additions & 0 deletions
3
packages/HTML.package/HtmlBODYNode.class/instance/defaultBlockMorph.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
initialize-release | ||
defaultBlockMorph | ||
^ HtmlBodyMorph |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
"class" : { | ||
}, | ||
"instance" : { | ||
"defaultBlockMorph" : "rs 6/28/2014 14:10:32.202", | ||
"tag" : "" } } |
11 changes: 2 additions & 9 deletions
11
packages/HTML.package/HtmlDOMNode.class/instance/getHtmlBlockMorph.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
rendering | ||
getHtmlBlockMorph | ||
| inlineNodes | | ||
|
||
inlineNodes := OrderedCollection new. | ||
htmlMorph := self defaultBlockMorph newFor: self. | ||
|
||
self children do: [ :child | child isRenderedInline | ||
ifTrue: [ inlineNodes add: child ] | ||
ifFalse: [ self flushInlineNodes: inlineNodes to: htmlMorph; | ||
flushBlockNode: child to: htmlMorph] ]. | ||
self flushInlineNodes: inlineNodes to: htmlMorph. | ||
htmlMorph := self defaultBlockMorph newFor: self. | ||
self renderChildrenInto: htmlMorph. | ||
^ htmlMorph |
10 changes: 10 additions & 0 deletions
10
packages/HTML.package/HtmlDOMNode.class/instance/renderChildrenInto..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
rendering | ||
renderChildrenInto: aHtmlBlockMorph | ||
| inlineNodes | | ||
|
||
inlineNodes := OrderedCollection new. | ||
self children do: [ :child | child isRenderedInline | ||
ifTrue: [ inlineNodes add: child ] | ||
ifFalse: [ self flushInlineNodes: inlineNodes to: aHtmlBlockMorph; | ||
flushBlockNode: child to: aHtmlBlockMorph] ]. | ||
self flushInlineNodes: inlineNodes to: aHtmlBlockMorph |
This file contains 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
3 changes: 3 additions & 0 deletions
3
packages/HTML.package/HtmlDocument.class/instance/addToHtmlMorph..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rendering | ||
addToHtmlMorph: aHtmlBlockMorph | ||
self renderChildrenInto: aHtmlBlockMorph |
This file contains 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
3 changes: 3 additions & 0 deletions
3
packages/HTML.package/HtmlHTMLNode.class/instance/addToHtmlMorph..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rendering | ||
addToHtmlMorph: aHtmlBlockMorph | ||
self renderChildrenInto: aHtmlBlockMorph |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
fea643b6-5bbb-4b70-9584-e8f6b9377725 | ||
d8a3e21d-3ec3-0944-bc0b-bbb4351006a8 |
1 change: 1 addition & 0 deletions
1
...s/HTML.package/monticello.meta/version.d/HTML-rs.113_b49e40ea-38e5-3241-9e1a-5d692da8925f
This file contains 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
1 change: 1 addition & 0 deletions
1
...s/HTML.package/monticello.meta/version.d/HTML-rs.114_d8a3e21d-3ec3-0944-bc0b-bbb4351006a8
This file contains 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
23 changes: 23 additions & 0 deletions
23
packages/Scamper.package/HtmlBlockMorph.class/instance/adjustBoundsToSubmorphs.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
layout | ||
adjustBoundsToSubmorphs | ||
"My bounds should always enclose the submorph's bounds" | ||
"(that's actually not 100% correct, e.g. take the case of " | ||
"<div style='width:100px'><div style='width:200px'></div></div>)." | ||
"If I don't have submorphs (e.g. I'm just background-image'd), take " | ||
" my computedSize and the given position" | ||
"Otherwise take the submorphBounds and make sure they " | ||
" have at least an extent of computedSize (the resulting bounds " | ||
" may reside completely in the negative space because of " | ||
" TextMorph's submorph placement - see BitBltDisplayScanner)." | ||
" However it's important to set a correct width as it is used" | ||
" for table column breadth ratio calulation" | ||
| submorphCorner delta | | ||
submorphCorner := self submorphs | ||
ifEmpty: [ self position + self computedSize ] | ||
ifNotEmpty: [ ((self submorphBounds origin extent: self computedSize) quickMerge: self submorphBounds) corner asIntegerPoint ]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is kind of long |
||
delta := submorphCorner - self bounds corner. | ||
(delta isZero) | ||
ifTrue: [ ^ false ] | ||
ifFalse: | ||
[ self extent: submorphCorner - self position. | ||
^true ] |
4 changes: 4 additions & 0 deletions
4
packages/Scamper.package/HtmlBlockMorph.class/instance/computedSize.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
computedSize | ||
|
||
^ self computedWidth @ self cssHeight |
5 changes: 5 additions & 0 deletions
5
packages/Scamper.package/HtmlBlockMorph.class/instance/computedWidth..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
accessing | ||
computedWidth: aWidth | ||
|
||
computedWidth := aWidth. | ||
self layoutChanged |
4 changes: 4 additions & 0 deletions
4
packages/Scamper.package/HtmlBlockMorph.class/instance/computedWidth.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
accessing | ||
computedWidth | ||
|
||
^ computedWidth ifNil: [ 0 ] |
5 changes: 5 additions & 0 deletions
5
packages/Scamper.package/HtmlBlockMorph.class/instance/cornerOf.relativeTo..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
layout | ||
cornerOf: aRectangle relativeTo: aPoint | ||
| translation | | ||
translation := aPoint - aRectangle origin. | ||
^ aRectangle corner - translation |
8 changes: 8 additions & 0 deletions
8
packages/Scamper.package/HtmlBlockMorph.class/instance/cssHeight.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
layout | ||
cssHeight | ||
|
||
| resolver | | ||
self node ifNil: [ ^ 0 ]. | ||
|
||
resolver := CSSStyleResolver for: node. | ||
^ resolver ifStyleNotNil: #height do: [:value | value ] ifNil: [ 0 ] |
11 changes: 0 additions & 11 deletions
11
packages/Scamper.package/HtmlBlockMorph.class/instance/cssSize.st
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
packages/Scamper.package/HtmlBlockMorph.class/instance/defaultBounds.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
initialization | ||
defaultBounds | ||
"answer the default bounds for the receiver" | ||
^ 0 @ 0 corner: self cssSize | ||
^ 0 @ 0 corner: self computedSize |
This file contains 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
3 changes: 3 additions & 0 deletions
3
packages/Scamper.package/HtmlBlockMorph.class/instance/isHtmlBlockMorph.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
testing | ||
isHtmlBlockMorph | ||
^ true |
3 changes: 3 additions & 0 deletions
3
packages/Scamper.package/HtmlBlockMorph.class/instance/isHtmlBodyMorph.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
testing | ||
isHtmlBodyMorph | ||
^ false |
12 changes: 4 additions & 8 deletions
12
packages/Scamper.package/HtmlBlockMorph.class/instance/layoutChanged.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
layout | ||
layoutChanged | ||
| delta submorphCorner | | ||
submorphCorner := self submorphs | ||
ifEmpty: [ self defaultBounds corner ] | ||
ifNotEmpty: [ (self defaultBounds quickMerge: self submorphBounds) corner asIntegerPoint ]. | ||
delta := submorphCorner - self bounds corner. | ||
(delta isZero) | ||
ifTrue: [ super layoutChanged ] | ||
ifFalse: [ self extent: submorphCorner - self position ] | ||
self suppressLayoutUpdates ifTrue: [ ^ self ]. | ||
|
||
self adjustBoundsToSubmorphs | ||
ifFalse: [ super layoutChanged ] |
19 changes: 19 additions & 0 deletions
19
packages/Scamper.package/HtmlBlockMorph.class/instance/preferredMinimumWidth.st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
layout | ||
preferredMinimumWidth | ||
| resolver ownWidth childrenWidth | | ||
self node ifNil: [ ^ #auto ]. | ||
|
||
resolver := CSSStyleResolver for: node. | ||
|
||
"TODO: add support for intrinsic widths of replaced elements here" | ||
"add margins and paddings and border-widths here" | ||
resolver ifStyleNotNil: #absoluteWidth do: [:value | ownWidth := value ] ifNil: [ ^ ownWidth := #auto ]. | ||
|
||
childrenWidth := (self submorphs | ||
collect: [ :morph | morph preferredMinimumWidth ] | ||
thenSelect: [ :width | width ~= #auto ]) | ||
ifNotEmpty: [ :widths | widths max ] ifEmpty: [ #auto ]. | ||
|
||
(ownWidth == #auto) | ||
ifTrue: [ ^ childrenWidth ] | ||
ifFalse: [ ^ ownWidth ] |
20 changes: 20 additions & 0 deletions
20
packages/Scamper.package/HtmlBlockMorph.class/instance/setWidth..st
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
layout | ||
setWidth: availableWidth | ||
|
||
| resolver absoluteWidth relativeWidth resultWidth | | ||
self node ifNil: [ ^ self ]. | ||
|
||
resolver := CSSStyleResolver for: node. | ||
|
||
absoluteWidth := (resolver getStyle: #absoluteWidth) ifNil: [ #auto ]. | ||
relativeWidth := (resolver getStyle: #relativeWidth) ifNil: [ 100 ]. | ||
(absoluteWidth == #auto) | ||
ifTrue: [ | ||
"subtract margin, padding border-width here" | ||
resultWidth := availableWidth * relativeWidth / 100 ] | ||
ifFalse: [ resultWidth := absoluteWidth ]. | ||
self computedWidth: resultWidth; | ||
suppressLayoutUpdates: true; | ||
updateSubmorphWidth: resultWidth; | ||
suppressLayoutUpdates: false; | ||
layoutChanged |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should later be changed: Percent should be relative to the parent's width, em and ex should be relative to the local font size.
For now I wouldn't implement this, but defer to #145