Skip to content

Commit

Permalink
Merge branch 'release-1.6.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Oct 4, 2013
2 parents 7b3364f + a179b2a commit 0886d14
Show file tree
Hide file tree
Showing 107 changed files with 3,344 additions and 1,435 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "Core/Externals/DTFoundation"]
path = Core/Externals/DTFoundation
[submodule "Externals/DTFoundation"]
path = Externals/DTFoundation
url = https://github.com/Cocoanetics/DTFoundation.git
12 changes: 10 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
language: objective-c
language: objective-c

script: Travis-CI/script.sh
before_script:
- sudo easy_install cpp-coveralls

script:
- xctool project DTCoreText.xcodeproj -scheme DemoApp build test -sdk iphonesimulator -arch i386 ONLY_ACTIVE_ARCH=NO
- xctool project DTCoreText.xcodeproj -scheme "Mac Framework" test -arch x86_64 ONLY_ACTIVE_ARCH=NO

after_success:
- ./coveralls.rb --extension m --exclude-folder Demo --exclude-folder Test --exclude-folder Externals
1 change: 0 additions & 1 deletion Core/Externals/DTFoundation
Submodule DTFoundation deleted from ccac55
23 changes: 18 additions & 5 deletions Core/Source/DTAttributedTextCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import "DTCoreText.h"
#import "DTAttributedTextCell.h"
#import "DTCSSStylesheet.h"
#import "DTVersion.h"
#import "DTLog.h"

@implementation DTAttributedTextCell
{
Expand Down Expand Up @@ -90,7 +90,7 @@ - (void)didMoveToSuperview
// on < iOS 7 we need to make the background translucent to avoid artefacts at rounded edges
if (_containingTableView.style == UITableViewStyleGrouped)
{
if ([DTVersion osVersionIsLessThen:@"7.0"])
if (NSFoundationVersionNumber < DTNSFoundationVersionNumber_iOS_7_0)
{
_attributedTextContextView.backgroundColor = [UIColor clearColor];
}
Expand Down Expand Up @@ -123,10 +123,10 @@ - (CGFloat)requiredRowHeightInTableView:(UITableView *)tableView
{
if (_hasFixedRowHeight)
{
NSLog(@"Warning: you are calling %s even though the cell is configured with fixed row height", (const char *)__PRETTY_FUNCTION__);
DTLogWarning(@"You are calling %s even though the cell is configured with fixed row height", (const char *)__PRETTY_FUNCTION__);
}

BOOL ios6Style = [DTVersion osVersionIsLessThen:@"7.0"];
BOOL ios6Style = (NSFoundationVersionNumber < DTNSFoundationVersionNumber_iOS_7_0);
CGFloat contentWidth = tableView.frame.size.width;

// reduce width for grouped table views
Expand All @@ -140,28 +140,41 @@ - (CGFloat)requiredRowHeightInTableView:(UITableView *)tableView
switch (self.accessoryType)
{
case UITableViewCellAccessoryDisclosureIndicator:
{
contentWidth -= ios6Style ? 20.0f : 10.0f + 8.0f + 15.0f;
break;
}

case UITableViewCellAccessoryCheckmark:
{
contentWidth -= ios6Style ? 20.0f : 10.0f + 14.0f + 15.0f;
break;
}

case UITableViewCellAccessoryDetailDisclosureButton:
{
contentWidth -= ios6Style ? 33.0f : 10.0f + 42.0f + 15.0f;
break;
}

#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1
case UITableViewCellAccessoryDetailButton:
{
contentWidth -= 10.0f + 22.0f + 15.0f;
break;
}
#endif

case UITableViewCellAccessoryNone:
{
break;
}

default:
NSLog(@"Warning: accessoryType %d not implemented on %@", self.accessoryType, NSStringFromClass([self class]));
{
DTLogWarning(@"AccessoryType %d not implemented on %@", self.accessoryType, NSStringFromClass([self class]));
break;
}
}

CGSize neededSize = [self.attributedTextContextView suggestedFrameSizeToFitEntireStringConstraintedToWidth:contentWidth];
Expand Down
59 changes: 29 additions & 30 deletions Core/Source/DTAttributedTextContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//

#import "DTAttributedTextContentView.h"
#import <QuartzCore/QuartzCore.h>

#import "DTCoreText.h"
#import "DTAttributedTextContentView.h"
#import "DTDictationPlaceholderTextAttachment.h"
#import <QuartzCore/QuartzCore.h>
#import "DTAccessibilityViewProxy.h"
#import "DTAccessibilityElement.h"
#import "DTCoreTextLayoutFrameAccessibilityElementGenerator.h"
#import "DTBlockFunctions.h"

#if !__has_feature(objc_arc)
#error THIS CODE MUST BE COMPILED WITH ARC ENABLED!
Expand Down Expand Up @@ -474,35 +476,32 @@ - (void)drawRect:(CGRect)rect

- (void)relayoutText
{
if (![NSThread isMainThread])
{
[self performSelectorOnMainThread:@selector(relayoutText) withObject:nil waitUntilDone:YES];
return;
}

// Make sure we actually have a superview and a previous layout before attempting to relayout the text.
if (_layoutFrame && self.superview)
{
// need new layout frame, layouter can remain because the attributed string is probably the same
self.layoutFrame = nil;

// remove all links because they might have merged or split
[self removeAllCustomViewsForLinks];

if (_attributedString)
{
// triggers new layout
CGSize neededSize = [self intrinsicContentSize];

CGRect optimalFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y, neededSize.width, neededSize.height);
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSValue valueWithCGRect:optimalFrame] forKey:@"OptimalFrame"];
DTBlockPerformSyncIfOnMainThreadElseAsync(^{

// Make sure we actually have a superview and a previous layout before attempting to relayout the text.
if (_layoutFrame && self.superview)
{
// need new layout frame, layouter can remain because the attributed string is probably the same
self.layoutFrame = nil;

[[NSNotificationCenter defaultCenter] postNotificationName:DTAttributedTextContentViewDidFinishLayoutNotification object:self userInfo:userInfo];
}

[self setNeedsLayout];
[self setNeedsDisplayInRect:self.bounds];
}
// remove all links because they might have merged or split
[self removeAllCustomViewsForLinks];

if (_attributedString)
{
// triggers new layout
CGSize neededSize = [self intrinsicContentSize];

CGRect optimalFrame = CGRectMake(self.frame.origin.x, self.frame.origin.y, neededSize.width, neededSize.height);
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:[NSValue valueWithCGRect:optimalFrame] forKey:@"OptimalFrame"];

[[NSNotificationCenter defaultCenter] postNotificationName:DTAttributedTextContentViewDidFinishLayoutNotification object:self userInfo:userInfo];
}

[self setNeedsLayout];
[self setNeedsDisplayInRect:self.bounds];
}
});
}

- (void)removeAllCustomViewsForLinks
Expand Down
63 changes: 30 additions & 33 deletions Core/Source/DTAttributedTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
// Copyright 2011 Drobnik.com. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>

#import "DTAttributedTextView.h"
#import "DTCoreText.h"
#import <QuartzCore/QuartzCore.h>
#import "DTTiledLayerWithoutFade.h"
#import "DTBlockFunctions.h"


@interface DTAttributedTextView ()

Expand Down Expand Up @@ -104,7 +107,7 @@ - (void)scrollToAnchorNamed:(NSString *)anchorName animated:(BOOL)animated
{
NSRange range = [self.attributedTextContentView.attributedString rangeOfAnchorNamed:anchorName];

if (range.length != NSNotFound)
if (range.location != NSNotFound)
{
[self scrollRangeToVisible:range animated:animated];
}
Expand All @@ -125,20 +128,17 @@ - (void)scrollRangeToVisible:(NSRange)range animated:(BOOL)animated

- (void)relayoutText
{
if (![NSThread isMainThread])
{
[self performSelectorOnMainThread:@selector(relayoutText) withObject:nil waitUntilDone:YES];
return;
}

// need to reset the layouter because otherwise we get the old framesetter or cached layout frames
_attributedTextContentView.layouter=nil;

// here we're layouting the entire string, might be more efficient to only relayout the paragraphs that contain these attachments
[_attributedTextContentView relayoutText];

// layout custom subviews for visible area
[self setNeedsLayout];
DTBlockPerformSyncIfOnMainThreadElseAsync(^{

// need to reset the layouter because otherwise we get the old framesetter or cached layout frames
_attributedTextContentView.layouter=nil;

// here we're layouting the entire string, might be more efficient to only relayout the paragraphs that contain these attachments
[_attributedTextContentView relayoutText];

// layout custom subviews for visible area
[self setNeedsLayout];
});
}

#pragma mark - Working with a Cursor
Expand All @@ -164,23 +164,20 @@ - (CGRect)cursorRectAtIndex:(NSInteger)index
#pragma mark Notifications
- (void)contentViewDidLayout:(NSNotification *)notification
{
if (![NSThread isMainThread])
{
[self performSelectorOnMainThread:@selector(contentViewDidLayout:) withObject:notification waitUntilDone:YES];
return;
}

NSDictionary *userInfo = [notification userInfo];
CGRect optimalFrame = [[userInfo objectForKey:@"OptimalFrame"] CGRectValue];

CGRect frame = UIEdgeInsetsInsetRect(self.bounds, self.contentInset);

// ignore possibly delayed layout notification for a different width
if (optimalFrame.size.width == frame.size.width)
{
_attributedTextContentView.frame = optimalFrame;
self.contentSize = [_attributedTextContentView intrinsicContentSize];
}
DTBlockPerformSyncIfOnMainThreadElseAsync(^{

NSDictionary *userInfo = [notification userInfo];
CGRect optimalFrame = [[userInfo objectForKey:@"OptimalFrame"] CGRectValue];

CGRect frame = UIEdgeInsetsInsetRect(self.bounds, self.contentInset);

// ignore possibly delayed layout notification for a different width
if (optimalFrame.size.width == frame.size.width)
{
_attributedTextContentView.frame = optimalFrame;
self.contentSize = [_attributedTextContentView intrinsicContentSize];
}
});
}

#pragma mark Properties
Expand Down
13 changes: 12 additions & 1 deletion Core/Source/DTCSSListStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ typedef NS_ENUM(NSUInteger, DTCSSListStylePosition)
- (NSInteger)startingItemNumber;


/**
@name Comparing Lists
*/

/**
Determine if another list style has equivalent settings. Note that this does not mean that they are identical, only that they look the same.
@param otherListStyle The other list style to compare the receiver with
@returns `YES` if the other list style has the same values
*/
- (BOOL)isEqualToListStyle:(DTCSSListStyle *)otherListStyle;


/**
@name Getting Information about Lists
*/
Expand All @@ -212,7 +224,6 @@ typedef NS_ENUM(NSUInteger, DTCSSListStylePosition)
*/
- (BOOL)isOrdered;


/**
If the list style is inherited.
Expand Down
18 changes: 12 additions & 6 deletions Core/Source/DTCSSListStyle.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ - (void)updateFromStyleDictionary:(NSDictionary *)styles
}
}

#ifndef COVERAGE
// exclude methods from coverage testing

- (NSString *)description
{
return [NSString stringWithFormat:@"<%@ %p type=%d position=%d>", NSStringFromClass([self class]), self, (int)_type, (int)_position];
Expand All @@ -259,25 +262,28 @@ - (NSUInteger)hash
return calcHash;
}

- (BOOL)isEqual:(id)object
#endif

/*
Note: this is not isEqual: because on iOS 7 -[NSMutableAttributedString initWithString:attributes:] calls this via -[NSArray isEqualToArray:]. There isEqual: needs to be returning NO, because otherwise there is some weird internal caching side effect where it reuses previous list arrays
*/
- (BOOL)isEqualToListStyle:(DTCSSListStyle *)otherListStyle
{
if (!object)
if (!otherListStyle)
{
return NO;
}

if (object == self)
if (otherListStyle == self)
{
return YES;
}

if (![object isKindOfClass:[DTCSSListStyle class]])
if (![otherListStyle isKindOfClass:[DTCSSListStyle class]])
{
return NO;
}

DTCSSListStyle *otherListStyle = object;

if (_inherit != otherListStyle->_inherit)
{
return NO;
Expand Down
Loading

0 comments on commit 0886d14

Please sign in to comment.