Refactor layout calculation
Fix a bug of content size in iOS