Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: ios/web/web_state/ui/crw_generic_content_view.mm

Issue 1342023002: Skip CRWGenericContentView layout if the bounds size hasn't changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_generic_content_view.mm
diff --git a/ios/web/web_state/ui/crw_generic_content_view.mm b/ios/web/web_state/ui/crw_generic_content_view.mm
index 93854a1f1aef13dd35c9f922176390440ddc3896..1c11489653cf57788336463c157e950b632c87e6 100644
--- a/ios/web/web_state/ui/crw_generic_content_view.mm
+++ b/ios/web/web_state/ui/crw_generic_content_view.mm
@@ -8,6 +8,8 @@
#include "base/mac/scoped_nsobject.h"
@interface CRWGenericContentView () {
+ // The size of the view's bounds at the last call to |-layoutSubviews|.
+ CGSize _lastLayoutSize;
// Backing objectect for |self.scrollView|.
base::scoped_nsobject<UIScrollView> _scrollView;
// Backing object for |self.view|.
@@ -22,6 +24,7 @@
self = [super initWithFrame:CGRectZero];
if (self) {
DCHECK(view);
+ _lastLayoutSize = CGSizeZero;
_view.reset([view retain]);
_scrollView.reset([[UIScrollView alloc] initWithFrame:CGRectZero]);
[self addSubview:_scrollView];
@@ -59,6 +62,11 @@
- (void)layoutSubviews {
[super layoutSubviews];
+ // Early return if the bounds' size hasn't changed since the last layout.
+ if (CGSizeEqualToSize(_lastLayoutSize, self.bounds.size))
+ return;
+ _lastLayoutSize = self.bounds.size;
+
// scrollView layout.
self.scrollView.frame = self.bounds;
@@ -69,7 +77,7 @@
self.view.frame = CGRectMake(0.0, 0.0, viewSize.width, viewSize.height);
// UIScrollViews only scroll vertically if the content size's height is
- // creater than that of its content rect.
+ // greater than that of its content rect.
if (viewSize.height <= CGRectGetHeight(contentRect)) {
CGFloat singlePixel = 1.0f / [[UIScreen mainScreen] scale];
viewSize.height = CGRectGetHeight(contentRect) + singlePixel;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698