<commit_before>//
//  UniWebView.swift
//  UniLayout Pod
//
//  Library view: a web view
//  Extends UIView containing a UIWebView to support properties for UniLayout containers and padding
//

import UIKit

open class UniWebView: UIView, UniLayoutView, UniLayoutPaddedView {

    // ---
    // MARK: Members
    // ---
    
    public var layoutProperties = UniLayoutProperties()
    public var padding = UIEdgeInsets.zero
    private var webView = UniNotifyingWebView()

    
    // ---
    // MARK: UIWebView properties
    // ---
    
    public var delegate: UIWebViewDelegate? {
        get {
            return webView.delegate
        }
        set {
            webView.delegate = newValue
        }
    }
    
    public var request: URLRequest? {
        get {
            return webView.request
        }
    }

    public var canGoBack: Bool {
        get {
            return webView.canGoBack
        }
    }

    public var canGoForward: Bool {
        get {
            return webView.canGoForward
        }
    }
    
    public var isLoading: Bool {
        get {
            return webView.isLoading
        }
    }
    
    public var internalWebView: UIWebView {
        get {
            return webView
        }
    }

    
    // ---
    // MARK: Initialization
    // ---

    public override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }
    
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }
    
    private func setup() {
        addSubview(webView)
    }
    
    
    // ---
    // MARK: UIActivityIndicatorView methods
    // ---

    public func loadRequest(_ request: URLRequest) {
        webView.loadRequest(request)
    }

    public func loadHTMLString(_ string: String, baseURL: URL? = nil) {
        webView.loadHTMLString(string, baseURL: baseURL)
    }

    public func loadData(_ data: Data, mimeType: String, textEncodingName: String, baseURL: URL) {
        webView.load(data, mimeType: mimeType, textEncodingName: textEncodingName, baseURL: baseURL)
    }

    public func reload() {
        webView.reload()
    }

    public func stopLoading() {
        webView.stopLoading()
    }

    public func goBack() {
        webView.goBack()
    }

    public func goForward() {
        webView.goForward()
    }

    
    // ---
    // MARK: Custom layout
    // ---

    open func measuredSize(sizeSpec: CGSize, widthSpec: UniMeasureSpec, heightSpec: UniMeasureSpec) -> CGSize {
        let paddedSize = CGSize(width: max(0, sizeSpec.width - padding.left - padding.right), height: max(0, sizeSpec.height - padding.top - padding.bottom))
        var result = CGSize(width: padding.left + padding.right, height: padding.top + padding.bottom)
        var webviewResult = webView.systemLayoutSizeFitting(paddedSize, withHorizontalFittingPriority: widthSpec == .unspecified ? UILayoutPriorityFittingSizeLevel : UILayoutPriorityRequired, verticalFittingPriority: heightSpec == .unspecified ? UILayoutPriorityFittingSizeLevel : UILayoutPriorityRequired)
        result.width += webviewResult.width
        result.height += webviewResult.height
        if widthSpec == .exactSize {
            result.width = sizeSpec.width
        } else if widthSpec == .limitSize {
            result.width = min(result.width, sizeSpec.width)
        }
        if heightSpec == .exactSize {
            result.height = sizeSpec.height
        } else if heightSpec == .limitSize {
            result.height = min(result.height, sizeSpec.height)
        }
        return result
    }

    open override func layoutSubviews() {
        webView.frame = CGRect(x: padding.left, y: padding.top, width: max(0, frame.width - padding.left - padding.right), height: max(0, frame.height - padding.top - padding.bottom))
    }<commit_msg>Fixed cocoa pods lint warning<commit_after>//
//  UniWebView.swift
//  UniLayout Pod
//
//  Library view: a web view
//  Extends UIView containing a UIWebView to support properties for UniLayout containers and padding
//

import UIKit

open class UniWebView: UIView, UniLayoutView, UniLayoutPaddedView {

    // ---
    // MARK: Members
    // ---
    
    public var layoutProperties = UniLayoutProperties()
    public var padding = UIEdgeInsets.zero
    private var webView = UniNotifyingWebView()

    
    // ---
    // MARK: UIWebView properties
    // ---
    
    public var delegate: UIWebViewDelegate? {
        get {
            return webView.delegate
        }
        set {
            webView.delegate = newValue
        }
    }
    
    public var request: URLRequest? {
        get {
            return webView.request
        }
    }

    public var canGoBack: Bool {
        get {
            return webView.canGoBack
        }
    }

    public var canGoForward: Bool {
        get {
            return webView.canGoForward
        }
    }
    
    public var isLoading: Bool {
        get {
            return webView.isLoading
        }
    }
    
    public var internalWebView: UIWebView {
        get {
            return webView
        }
    }

    
    // ---
    // MARK: Initialization
    // ---

    public override init(frame: CGRect) {
        super.init(frame: frame)
        setup()
    }
    
    public required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        setup()
    }
    
    private func setup() {
        addSubview(webView)
    }
    
    
    // ---
    // MARK: UIActivityIndicatorView methods
    // ---

    public func loadRequest(_ request: URLRequest) {
        webView.loadRequest(request)
    }

    public func loadHTMLString(_ string: String, baseURL: URL? = nil) {
        webView.loadHTMLString(string, baseURL: baseURL)
    }

    public func loadData(_ data: Data, mimeType: String, textEncodingName: String, baseURL: URL) {
        webView.load(data, mimeType: mimeType, textEncodingName: textEncodingName, baseURL: baseURL)
    }

    public func reload() {
        webView.reload()
    }

    public func stopLoading() {
        webView.stopLoading()
    }

    public func goBack() {
        webView.goBack()
    }

    public func goForward() {
        webView.goForward()
    }

    
    // ---
    // MARK: Custom layout
    // ---

    open func measuredSize(sizeSpec: CGSize, widthSpec: UniMeasureSpec, heightSpec: UniMeasureSpec) -> CGSize {
        let paddedSize = CGSize(width: max(0, sizeSpec.width - padding.left - padding.right), height: max(0, sizeSpec.height - padding.top - padding.bottom))
        var result = CGSize(width: padding.left + padding.right, height: padding.top + padding.bottom)
        let webviewResult = webView.systemLayoutSizeFitting(paddedSize, withHorizontalFittingPriority: widthSpec == .unspecified ? UILayoutPriorityFittingSizeLevel : UILayoutPriorityRequired, verticalFittingPriority: heightSpec == .unspecified ? UILayoutPriorityFittingSizeLevel : UILayoutPriorityRequired)
        result.width += webviewResult.width
        result.height += webviewResult.height
        if widthSpec == .exactSize {
            result.width = sizeSpec.width
        } else if widthSpec == .limitSize {
            result.width = min(result.width, sizeSpec.width)
        }
        if heightSpec == .exactSize {
            result.height = sizeSpec.height
        } else if heightSpec == .limitSize {
            result.height = min(result.height, sizeSpec.height)
        }
        return result
    }

    open override func layoutSubviews() {
        webView.frame = CGRect(x: padding.left, y: padding.top, width: max(0, frame.width - padding.left - padding.right), height: max(0, frame.height - padding.top - padding.bottom))
    }
{'fraction_non_alphanumeric': 0.09875259875259876, 'fraction_numerical': 0.0010395010395010396, 'mean_word_length': 2.0291223927587563, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4818803', 'n_tokens_mistral': 2259, 'n_tokens_neox': 2174, 'n_words': 526}