Skip to content

Commit

Permalink
Merge pull request #148 from SWTI2014/rendering/css-text-attribute
Browse files Browse the repository at this point in the history
Rendering/css text attribute
  • Loading branch information
JenniferStamm committed Jul 5, 2014
2 parents ac11e6c + a1615c9 commit 6430402
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ constants
inheritableAttributes
"The following CSS Attributes are inheritable:"
"'azimuth', 'border-collapse', 'border-spacing', 'caption-side', 'color', 'cursor', 'direction', 'elevation', 'empty-cells', 'font-family', 'font-size', 'font-style', 'font-variant', 'font-weight', 'font', 'letter-spacing', 'line-height', 'list-style-image', 'list-style-position', 'list-style-type', 'list-style', 'orphans', 'pitch-range', 'pitch', 'quotes', 'richness', 'speak-header', 'speak-numeral', 'speak-punctuation', 'speak', 'speak-rate', 'stress', 'text-align', 'text-indent', 'text-transform', 'visibility', 'voice-family', 'volume', 'white-space', 'widows', 'word-spacing'"
^ #( #italic. #bold. #size. #color. #family)
^ #( #italic. #bold. #size. #color. #family. #align)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cssPrefixMap
sizeFormatter := CSSSizeFormatter new.
cssPrefixMap := Dictionary newFrom: {
'font' -> CSSFontFormatter new.
'text' -> CSSTextFormatter new.
'color' -> CSSColorFormatter new.
'display' -> CSSDisplayFormatter new.
'list' -> CSSListFormatter new.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"class" : {
"for:" : "rs 6/7/2014 11:24:06.679",
"inheritableAttributes" : "SN 6/15/2014 13:13" },
"inheritableAttributes" : "SN 7/5/2014 16:04" },
"instance" : {
"cssPrefixMap" : "rs 6/20/2014 20:17:24.757",
"cssPrefixMap" : "SN 7/5/2014 11:57",
"domNode:" : "rs 6/7/2014 11:23:34.652",
"evaluateLocalStylesFor:" : "rs 6/7/2014 13:22:25.554",
"getFormatterFor:" : "rs 6/8/2014 14:03:12.648",
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
accessing
attributeMap

^ attributeMap ifNil:
[ Dictionary newFrom: {
'text-decoration' -> [ :prop :fontAttribs |
self readTextDecorationAttribute: prop propertyString to: fontAttribs ].
'text-align' -> [ :prop :fontAttribs |
self readTextAlignAttribute: prop propertyString to: fontAttribs ]
}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parsing
parseTextAttributesFrom: aCSSProperty into: aContext
(self attributeMap at: aCSSProperty propertyName ifAbsent: [nil])
ifNotNilDo: [:process | process value: aCSSProperty value: aContext ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parsing
readTextAlignAttribute: aString to: aContext
aString splitBy: ' ' do: [:attribute |
(attribute = 'center') ifTrue: [aContext at: #align put: #centered].
((attribute = 'left') or: [attribute = 'start']) ifTrue: [aContext at: #align put: #leftFlush].
((attribute = 'right') or: [attribute = 'end']) ifTrue: [aContext at: #align put: #rightFlush].
(attribute = 'justify') ifTrue: [aContext at: #align put: #justified].]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parsing
readTextDecorationAttribute: aString to: aContext
aString splitBy: ' ' do: [:attribute |
(attribute = 'underline') ifTrue: [aContext at: #underlined put: true].
(attribute = 'line-through') ifTrue: [aContext at: #struckOut put: true]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"class" : {
},
"instance" : {
"attributeMap" : "SN 7/5/2014 12:30",
"parseTextAttributesFrom:into:" : "SN 7/5/2014 12:12",
"readTextAlignAttribute:to:" : "SN 7/5/2014 12:20",
"readTextDecorationAttribute:to:" : "SN 7/5/2014 11:57" } }
14 changes: 14 additions & 0 deletions packages/HTML.package/CSSTextFormatter.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "HTML-Formatter",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"attributeMap" ],
"name" : "CSSTextFormatter",
"pools" : [
],
"super" : "CSSFormatter",
"type" : "normal" }
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
running
setUp
self textFormatter: CSSTextFormatter new
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
test01TextDecorationUnderlinedShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-decoration';
propertyString: 'underline';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: true equals: (result at: #underlined)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
test02TextDecorationLineThroughShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-decoration';
propertyString: 'line-through';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: true equals: (result at: #struckOut)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
test03TextDecorationUnderlinedLineThroughShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-decoration';
propertyString: 'underline line-through';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: true equals: (result at: #underlined).
self assert: true equals: (result at: #struckOut)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
test04TextAlignCenterShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-align';
propertyString: 'center';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: #centered equals: (result at: #align).
self assert: (TextAlignment respondsTo: #centered)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
test05TextAlignLeftShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-align';
propertyString: 'left';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: #leftFlush equals: (result at: #align).
self assert: (TextAlignment respondsTo: #leftFlush)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
test06TextAlignRightShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-align';
propertyString: 'right';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: #rightFlush equals: (result at: #align).
self assert: (TextAlignment respondsTo: #rightFlush)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
testing
test07TextAlignJustifyShouldBeParsedCorrectly
| prop result |
result := Dictionary new.
prop := CSSProperty new
propertyName: 'text-align';
propertyString: 'justify';
yourself.
self textFormatter parseTextAttributesFrom: prop into: result.
self assert: #justified equals: (result at: #align).
self assert: (TextAlignment respondsTo: #justified)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
textFormatter: anObject

textFormatter := anObject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
textFormatter

^ textFormatter
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"class" : {
},
"instance" : {
"setUp" : "SN 7/5/2014 12:04",
"test01TextDecorationUnderlinedShouldBeParsedCorrectly" : "SN 7/5/2014 12:06",
"test02TextDecorationLineThroughShouldBeParsedCorrectly" : "SN 7/5/2014 12:05",
"test03TextDecorationUnderlinedLineThroughShouldBeParsedCorrectly" : "SN 7/5/2014 12:06",
"test04TextAlignCenterShouldBeParsedCorrectly" : "SN 7/5/2014 12:28",
"test05TextAlignLeftShouldBeParsedCorrectly" : "SN 7/5/2014 12:28",
"test06TextAlignRightShouldBeParsedCorrectly" : "SN 7/5/2014 12:28",
"test07TextAlignJustifyShouldBeParsedCorrectly" : "SN 7/5/2014 12:29",
"textFormatter" : "SN 7/5/2014 12:03",
"textFormatter:" : "SN 7/5/2014 12:03" } }
14 changes: 14 additions & 0 deletions packages/HTML.package/CSSTextFormatterTest.class/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"category" : "HTML-CSS-Tests",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
"textFormatter" ],
"name" : "CSSTextFormatterTest",
"pools" : [
],
"super" : "TestCase",
"type" : "normal" }
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ parseTextAttributesFor: aDomNode
resolver
ifStyleNotNil: #italic do: [:italic | italic ifTrue: [ attributes add: TextEmphasis italic ]];
ifStyleNotNil: #bold do: [:bold | bold ifTrue: [ attributes add: TextEmphasis bold ]];
ifStyleNotNil: #color do: [:color | attributes add: (TextColor color: color)].
ifStyleNotNil: #color do: [:color | attributes add: (TextColor color: color)];
ifStyleNotNil: #underlined do:
[:underlined | underlined ifTrue: [ attributes add: TextEmphasis underlined ]];
ifStyleNotNil: #struckOut do:
[:struckOut | struckOut ifTrue: [ attributes add: TextEmphasis struckOut ]];
ifStyleNotNil: #align do: [:align | attributes add: (TextAlignment perform: align)].
^ attributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"endFont:" : "bolot 5/18/2000 11:23",
"endStyles" : "rs 5/18/2014 14:00:49.41",
"fontWith:and:" : "SN 6/28/2014 14:15",
"parseTextAttributesFor:" : "SS 6/23/2014 11:52",
"parseTextAttributesFor:" : "SN 7/5/2014 12:22",
"parseTextStyleAttributesFor:in:" : "SN 6/28/2014 13:31",
"setAttributes" : "LaurentLaffont 2/26/2010 23:13",
"startFont:" : "rs 5/18/2014 13:53:54.124",
Expand Down
2 changes: 1 addition & 1 deletion packages/HTML.package/monticello.meta/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6e188467-d07d-4e49-be20-fa225e8f7845
ab6c8e1b-655f-184d-b480-fa6e02b7296a
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(name 'HTML-SN.114'message 'Configure text-align to be inheritable.'id 'ab6c8e1b-655f-184d-b480-fa6e02b7296a'date '5 July 2014'time '4:04:19.473 pm'author 'SN'ancestors ((id '6e188467-d07d-4e49-be20-fa225e8f7845'))stepChildren ())
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 6430402

Please sign in to comment.