Permalink
Browse files

Correct CSS name for italic text (it was "text-style", but CSS uses "…

…font-style").
  • Loading branch information...
uliwitness committed Apr 5, 2016
1 parent e5b4889 commit 7fef3790c592c5c21830a02a0ea8ffbc7d27938a
@@ -5,7 +5,7 @@
}
.style2
{
text-style: italic;
font-style: italic;
}
.style3
{
@@ -546,7 +546,9 @@ static bool ListChunkCallback( const char* currStr, size_t currLen, size_t currS
}
[mTextView.textStorage setAttributedString: attrStr];
if( oldRTF )
{
SetAttributedStringWithCocoa( cppstr, attrStr ); // Save the parsed RTF back as something the cross-platform code understands.
}
}
else
[mTextView setString: @""];
@@ -1128,7 +1130,7 @@ static bool ListChunkCallback( const char* currStr, size_t currLen, size_t currS
// std::cout << "\tAdding underline." << std::endl;
[newAttrStr addAttribute: NSUnderlineStyleAttributeName value: @(NSUnderlineStyleSingle) range: currCocoaRange];
}
else if( currStyle.first.compare("text-style") == 0 && currStyle.second.compare("italic") == 0 )
else if( currStyle.first.compare("font-style") == 0 && currStyle.second.compare("italic") == 0 )
{
NSFont* changedFont = [[NSFontManager sharedFontManager] convertFont: (newFont ? newFont : defaultAttrs[NSFontAttributeName]) toHaveTrait: NSItalicFontMask];
if( changedFont && [[NSFontManager sharedFontManager] traitsOfFont: changedFont] & NSItalicFontMask )
@@ -1225,13 +1227,13 @@ static bool ListChunkCallback( const char* currStr, size_t currLen, size_t currS
}
if( traits & NSItalicFontMask )
{
stringToSet.AddAttributeValueForRange( "text-style", "italic", range.location, range.location +range.length );
stringToSet.AddAttributeValueForRange( "font-style", "italic", range.location, range.location +range.length );
}
// stringToSet.Dump();
}
else if( [currAttr isEqualToString: NSObliquenessAttributeName] && [attrValue integerValue] != 0 )
{
stringToSet.AddAttributeValueForRange( "text-style", "italic", range.location, range.location +range.length );
stringToSet.AddAttributeValueForRange( "font-style", "italic", range.location, range.location +range.length );
// stringToSet.Dump();
}
else if( [currAttr isEqualToString: NSUnderlineStyleAttributeName] && [attrValue integerValue] == NSUnderlineStyleSingle )
@@ -299,7 +299,7 @@ bool CFieldPart::GetPropertyNamed( const char* inPropertyName, size_t byteRangeS
snprintf(tmpKey, sizeof(tmpKey) -1, "%zu", ++x );
LEOAddStringConstantArrayEntryToRoot( &theArray, tmpKey, "bold", inContext );
}
else if( currStyle.first.compare( "text-style" ) == 0 && currStyle.second.compare( "italic" ) == 0 )
else if( currStyle.first.compare( "font-style" ) == 0 && currStyle.second.compare( "italic" ) == 0 )
{
snprintf(tmpKey, sizeof(tmpKey) -1, "%zu", ++x );
LEOAddStringConstantArrayEntryToRoot( &theArray, tmpKey, "italic", inContext );
@@ -415,13 +415,13 @@ bool CFieldPart::GetPropertyNamed( const char* inPropertyName, size_t byteRangeS
{
attrStr.ClearAttributeForRange( "text-decoration", byteRangeStart, byteRangeEnd );
attrStr.ClearAttributeForRange( "font-weight", byteRangeStart, byteRangeEnd );
attrStr.ClearAttributeForRange( "text-style", byteRangeStart, byteRangeEnd );
attrStr.ClearAttributeForRange( "font-style", byteRangeStart, byteRangeEnd );
attrStr.ClearAttributeForRange( "$link", byteRangeStart, byteRangeEnd );
}
else if( strcasecmp(currStyleName, "bold") == 0 )
attrStr.AddAttributeValueForRange( "font-weight", "bold", byteRangeStart, byteRangeEnd );
else if( strcasecmp(currStyleName, "italic") == 0 )
attrStr.AddAttributeValueForRange( "text-style", "italic", byteRangeStart, byteRangeEnd );
attrStr.AddAttributeValueForRange( "font-style", "italic", byteRangeStart, byteRangeEnd );
else if( strcasecmp(currStyleName, "underline") == 0 )
attrStr.AddAttributeValueForRange( "text-decoration", "underline", byteRangeStart, byteRangeEnd );
else if( strcasecmp(currStyleName, "group") == 0 )
@@ -881,10 +881,10 @@ int main(int argc, const char * argv[])
tinyxml2::XMLElement* elem = doc.FirstChildElement( "text" );
styles.LoadFromStream( ".style1 { font-weight: bold; } .style2 { text-style: italic; }" );
styles.LoadFromStream( ".style1 { font-weight: bold; } .style2 { font-style: italic; }" );
std::string css = styles.GetCSS();
WILDTest( "Read & Output round trip.", css.c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n text-style: italic;\n}\n" );
WILDTest( "Read & Output round trip.", css.c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n font-style: italic;\n}\n" );
WILDTest( "Number of classes", styles.GetNumClasses(), size_t(2) );
WILDTest( ".style1 is there", styles.GetClassAtIndex(0).c_str(), ".style1" );
auto styleOne = styles.GetStyleForClass("style1");
@@ -893,7 +893,7 @@ int main(int argc, const char * argv[])
WILDTest( ".style2 is there", styles.GetClassAtIndex(1).c_str(), ".style2" );
auto styleTwo = styles.GetStyleForClass("style2");
WILDTest( ".style2 contains 1 style", styleTwo.size(), size_t(1) );
WILDTest( ".style2 is italic", styleTwo["text-style"].c_str(), "italic" );
WILDTest( ".style2 is italic", styleTwo["font-style"].c_str(), "italic" );
attrStr.LoadFromElementWithStyles( elem, styles );
@@ -904,7 +904,7 @@ int main(int argc, const char * argv[])
doc2.InsertEndChild(elem2);
attrStr.SaveToXMLDocumentElementStyleSheet( &doc2, elem2, &writtenStyles );
WILDTest( "Output & Read round trip.", writtenStyles.GetCSS().c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n text-style: italic;\n}\n" );
WILDTest( "Output & Read round trip.", writtenStyles.GetCSS().c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n font-style: italic;\n}\n" );
WILDTest( "Number of classes", writtenStyles.GetNumClasses(), size_t(2) );
WILDTest( ".style1 is there", writtenStyles.GetClassAtIndex(0).c_str(), ".style1" );
styleOne = writtenStyles.GetStyleForClass("style1");
@@ -913,7 +913,7 @@ int main(int argc, const char * argv[])
WILDTest( ".style2 is there", writtenStyles.GetClassAtIndex(1).c_str(), ".style2" );
styleTwo = writtenStyles.GetStyleForClass("style2");
WILDTest( ".style2 contains 1 style", styleTwo.size(), size_t(1) );
WILDTest( ".style2 is italic", styleTwo["text-style"].c_str(), "italic" );
WILDTest( ".style2 is italic", styleTwo["font-style"].c_str(), "italic" );
}
{
@@ -925,10 +925,10 @@ int main(int argc, const char * argv[])
tinyxml2::XMLElement* elem = doc.FirstChildElement( "text" );
styles.LoadFromStream( ".style1 { font-weight: bold; } .style2 { text-style: italic; }" );
styles.LoadFromStream( ".style1 { font-weight: bold; } .style2 { font-style: italic; }" );
std::string css = styles.GetCSS();
WILDTest( "Read & Output round trip.", css.c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n text-style: italic;\n}\n" );
WILDTest( "Read & Output round trip.", css.c_str(), ".style1\n{\n font-weight: bold;\n}\n.style2\n{\n font-style: italic;\n}\n" );
WILDTest( "Number of classes", styles.GetNumClasses(), size_t(2) );
WILDTest( ".style1 is there", styles.GetClassAtIndex(0).c_str(), ".style1" );
auto styleOne = styles.GetStyleForClass("style1");
@@ -937,13 +937,13 @@ int main(int argc, const char * argv[])
WILDTest( ".style2 is there", styles.GetClassAtIndex(1).c_str(), ".style2" );
auto styleTwo = styles.GetStyleForClass("style2");
WILDTest( ".style2 contains 1 style", styleTwo.size(), size_t(1) );
WILDTest( ".style2 is italic", styleTwo["text-style"].c_str(), "italic" );
WILDTest( ".style2 is italic", styleTwo["font-style"].c_str(), "italic" );
attrStr.LoadFromElementWithStyles( elem, styles );
std::stringstream stylesStr;
attrStr.Dump(stylesStr);
WILDTest( "styles were read correctly", stylesStr.str().c_str(), "othervalue:foo\n<span style=\"text-style:italic;\">somestuff:This</span>\navalue:123.457\ncurrentbutton:First Choice\nd:\nb:\nc:\na:\n" );
WILDTest( "styles were read correctly", stylesStr.str().c_str(), "othervalue:foo\n<span style=\"font-style:italic;\">somestuff:This</span>\navalue:123.457\ncurrentbutton:First Choice\nd:\nb:\nc:\na:\n" );
}
// Set up some parser tables (but not enough to actually generate bytecode) to be able to test the parser:
Submodule stackimport updated 1 files
+1 −1 CStackFile.cpp

0 comments on commit 7fef379

Please sign in to comment.