[ASTextNode] placeholder image shouldn't draw for zero area strings (#2069)

* placeholder should not draw if area is zero

* styling fix

* super precision
This commit is contained in:
Hannah Troisi
2016-08-16 10:20:59 -07:00
committed by Adlai Holler
parent 56ee00986f
commit 14ccb0b886
2 changed files with 11 additions and 1 deletions

View File

@@ -27,6 +27,8 @@
#import "ASInternalHelpers.h"
#import "ASLayout.h"
#import "CGRect+ASConvenience.h"
static const NSTimeInterval ASTextNodeHighlightFadeOutDuration = 0.15;
static const NSTimeInterval ASTextNodeHighlightFadeInDuration = 0.1;
static const CGFloat ASTextNodeHighlightLightOpacity = 0.11;
@@ -910,7 +912,7 @@ static CGRect ASTextNodeAdjustRenderRectForShadowPadding(CGRect rendererRect, UI
// FIXME: Replace this implementation with reusable CALayers that have .backgroundColor set.
// This would completely eliminate the memory and performance cost of the backing store.
CGSize size = self.calculatedSize;
if (CGSizeEqualToSize(size, CGSizeZero)) {
if ((size.width * size.height) < CGFLOAT_EPSILON) {
return nil;
}

View File

@@ -14,6 +14,14 @@
#import "ASBaseDefines.h"
#import "ASLayoutController.h"
#ifndef CGFLOAT_EPSILON
#if CGFLOAT_IS_DOUBLE
#define CGFLOAT_EPSILON DBL_EPSILON
#else
#define CGFLOAT_EPSILON FLT_EPSILON
#endif
#endif
NS_ASSUME_NONNULL_BEGIN
ASDISPLAYNODE_EXTERN_C_BEGIN