Perf: remove unnecessary shadows and mask views
This commit is contained in:
@@ -149,6 +149,10 @@ class BrowserView: UIView
|
|||||||
autocompleteView.layer.cornerRadius = 8.0
|
autocompleteView.layer.cornerRadius = 8.0
|
||||||
autocompleteView.layer.masksToBounds = true
|
autocompleteView.layer.masksToBounds = true
|
||||||
|
|
||||||
|
let shadowPath = UIBezierPath(roundedRect: autocompleteView.bounds,
|
||||||
|
cornerRadius: autocompleteView.layer.cornerRadius)
|
||||||
|
autocompleteView.layer.shadowPath = shadowPath.cgPath
|
||||||
|
|
||||||
if let toolbarView = toolbarView, let urlBar = toolbarView.urlBar {
|
if let toolbarView = toolbarView, let urlBar = toolbarView.urlBar {
|
||||||
let urlFrame = self.convert(urlBar.frame, from: urlBar.superview)
|
let urlFrame = self.convert(urlBar.frame, from: urlBar.superview)
|
||||||
autocompleteView.frame = CGRect(
|
autocompleteView.frame = CGRect(
|
||||||
@@ -158,6 +162,9 @@ class BrowserView: UIView
|
|||||||
height: bounds.height / 2.5
|
height: bounds.height / 2.5
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
autocompleteView.layer.cornerRadius = 0.0
|
||||||
|
autocompleteView.layer.shadowOpacity = 0.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ class ReliefButton: UIButton
|
|||||||
backgroundView.layer.masksToBounds = true
|
backgroundView.layer.masksToBounds = true
|
||||||
backgroundView.layer.borderWidth = Self.borderWidth
|
backgroundView.layer.borderWidth = Self.borderWidth
|
||||||
backgroundView.layer.cornerCurve = .continuous
|
backgroundView.layer.cornerCurve = .continuous
|
||||||
|
backgroundView.layer.shouldRasterize = true
|
||||||
|
backgroundView.layer.rasterizationScale = UIScreen.main.scale
|
||||||
addSubview(backgroundView)
|
addSubview(backgroundView)
|
||||||
|
|
||||||
traitCollectionDidChange(nil)
|
traitCollectionDidChange(nil)
|
||||||
@@ -151,5 +153,8 @@ class ReliefButton: UIButton
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowView.frame = backgroundView.frame
|
shadowView.frame = backgroundView.frame
|
||||||
|
|
||||||
|
let shadowPath = UIBezierPath(roundedRect: shadowView.bounds, cornerRadius: Self.cornerRadius)
|
||||||
|
shadowView.layer.shadowPath = shadowPath.cgPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ class SegmentedReliefButton: ReliefButton
|
|||||||
didSet { children.forEach { addSubview($0) }; setNeedsLayout() }
|
didSet { children.forEach { addSubview($0) }; setNeedsLayout() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private let backgroundMaskView = UIView(frame: .zero)
|
|
||||||
private let backgroundsContainerView = UIView(frame: .zero)
|
private let backgroundsContainerView = UIView(frame: .zero)
|
||||||
private var childrenHighlighObservations: [NSKeyValueObservation] = []
|
private var childrenHighlighObservations: [NSKeyValueObservation] = []
|
||||||
|
|
||||||
@@ -22,12 +21,10 @@ class SegmentedReliefButton: ReliefButton
|
|||||||
super.init()
|
super.init()
|
||||||
self.children = children
|
self.children = children
|
||||||
|
|
||||||
backgroundMaskView.backgroundColor = .black
|
|
||||||
backgroundMaskView.layer.masksToBounds = true
|
|
||||||
backgroundMaskView.layer.cornerRadius = Self.cornerRadius - Self.borderWidth
|
|
||||||
|
|
||||||
backgroundsContainerView.clipsToBounds = true
|
backgroundsContainerView.clipsToBounds = true
|
||||||
backgroundsContainerView.mask = backgroundMaskView
|
backgroundsContainerView.layer.cornerRadius = Self.cornerRadius - Self.borderWidth
|
||||||
|
|
||||||
|
constrainedToSquare = false
|
||||||
|
|
||||||
addSubview(backgroundsContainerView)
|
addSubview(backgroundsContainerView)
|
||||||
}
|
}
|
||||||
@@ -57,10 +54,7 @@ class SegmentedReliefButton: ReliefButton
|
|||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
backgroundView.colors = [ .clear ]
|
backgroundView.colors = [ .clear ]
|
||||||
backgroundView.frame = bounds
|
|
||||||
shadowView.frame = bounds
|
|
||||||
|
|
||||||
backgroundMaskView.frame = backgroundView.frame.insetBy(dx: 1.0, dy: 1.0)
|
|
||||||
backgroundsContainerView.frame = backgroundView.frame
|
backgroundsContainerView.frame = backgroundView.frame
|
||||||
|
|
||||||
childrenHighlighObservations.removeAll()
|
childrenHighlighObservations.removeAll()
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ class ToolbarView: UIView
|
|||||||
override func layoutSubviews()
|
override func layoutSubviews()
|
||||||
{
|
{
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
|
|
||||||
|
let shadowPath = UIBezierPath(rect: bounds)
|
||||||
|
layer.shadowPath = shadowPath.cgPath
|
||||||
|
|
||||||
backgroundView.frame = bounds
|
backgroundView.frame = bounds
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class URLBar: ReliefButton
|
|||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
|
constrainedToSquare = false
|
||||||
|
|
||||||
backgroundView.addSubview(progressIndicatorView)
|
backgroundView.addSubview(progressIndicatorView)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user