ocd.
This commit is contained in:
1 parent
133942e78d
commit
2ff19b26c4
1 file changed
+22
-14
+22
-14
@@ -106,10 +106,10 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (closeRange.location == NSNotFound)
|
if (closeRange.location == NSNotFound)
|
||||||
closeRange.location = [_text length];
|
closeRange.location = _text.length;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_location = [_text length];
|
_location = _text.length;
|
||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
|
|
||||||
// If the internal content range location is equal to the text length
|
// If the internal content range location is equal to the text length
|
||||||
// it means there is no content at all
|
// it means there is no content at all
|
||||||
if (contentInternalRange.location == [_text length]) {
|
if (contentInternalRange.location == _text.length) {
|
||||||
return NSNotFound;
|
return NSNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,36 +184,43 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
|
|
||||||
- (void)serializeStyles
|
- (void)serializeStyles
|
||||||
{
|
{
|
||||||
NSMutableArray *serializedStyles = [[NSMutableArray alloc] init];
|
NSMutableArray<MP42Style *> *serializedStyles = [[NSMutableArray alloc] init];
|
||||||
MP42Style *currentStyle = [[MP42Style alloc] init];
|
MP42Style *currentStyle = [[MP42Style alloc] init];
|
||||||
|
|
||||||
for (MP42Style *nextStyle in _styles) {
|
for (MP42Style *nextStyle in _styles) {
|
||||||
if (currentStyle.location != nextStyle.location) {
|
if (currentStyle.location != nextStyle.location) {
|
||||||
currentStyle.length = nextStyle.location - currentStyle.location;
|
currentStyle.length = nextStyle.location - currentStyle.location;
|
||||||
if (currentStyle.style || compare_color(currentStyle.color, nextStyle.color))
|
if (currentStyle.style || compare_color(currentStyle.color, nextStyle.color)) {
|
||||||
if (currentStyle.length)
|
if (currentStyle.length) {
|
||||||
[serializedStyles addObject:[[currentStyle copy] autorelease]];
|
[serializedStyles addObject:[[currentStyle copy] autorelease]];
|
||||||
|
}
|
||||||
|
}
|
||||||
currentStyle.location = nextStyle.location;
|
currentStyle.location = nextStyle.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextStyle.type == kTagOpen) {
|
if (nextStyle.type == kTagOpen) {
|
||||||
if (nextStyle.style == kStyleColor)
|
if (nextStyle.style == kStyleColor) {
|
||||||
currentStyle.color = nextStyle.color;
|
currentStyle.color = nextStyle.color;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentStyle.style |= nextStyle.style;
|
currentStyle.style |= nextStyle.style;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (nextStyle.type == kTagClose) {
|
else if (nextStyle.type == kTagClose) {
|
||||||
if (nextStyle.style == kStyleColor)
|
if (nextStyle.style == kStyleColor) {
|
||||||
currentStyle.color = _defaultColor;
|
currentStyle.color = _defaultColor;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
currentStyle.style ^= nextStyle.style;
|
currentStyle.style ^= nextStyle.style;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentStyle.style || compare_color(currentStyle.color, _defaultColor)) {
|
if (currentStyle.style || compare_color(currentStyle.color, _defaultColor)) {
|
||||||
currentStyle.length = [_text length] - currentStyle.location;
|
currentStyle.length = _text.length - currentStyle.location;
|
||||||
if (currentStyle.length)
|
if (currentStyle.length) {
|
||||||
[serializedStyles addObject:[[currentStyle copy] autorelease]];
|
[serializedStyles addObject:[[currentStyle copy] autorelease]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[currentStyle release];
|
[currentStyle release];
|
||||||
@@ -225,11 +232,12 @@ int compare_color(rgba_color c1, rgba_color c2) {
|
|||||||
@synthesize styles = _styles;
|
@synthesize styles = _styles;
|
||||||
@synthesize defaultColor = _defaultColor;
|
@synthesize defaultColor = _defaultColor;
|
||||||
|
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
[_text release];
|
[_text release];
|
||||||
[_styles release];
|
[_styles release];
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
Reference in new issue
Block a user