From cbafac774e5e9a74d67315aa8dd58af9fb1cef7f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 8 Dec 2014 21:15:18 -0800 Subject: [PATCH] Various webview cleanup Imported from: https://chromium.googlesource.com/chromium/src/+/848f1ed0482838d44ffd0bbbd3b8db0e5b6362c6%5E%21/ --- atom/renderer/lib/web-view/web-view.coffee | 53 +++------------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/atom/renderer/lib/web-view/web-view.coffee b/atom/renderer/lib/web-view/web-view.coffee index 577313bff9e..a0087826e69 100644 --- a/atom/renderer/lib/web-view/web-view.coffee +++ b/atom/renderer/lib/web-view/web-view.coffee @@ -41,9 +41,6 @@ class WebViewImpl v8Util.setHiddenValue browserPluginNode, 'internal', this browserPluginNode - getGuestInstanceId: -> - @guestInstanceId - # Resets some state upon reattaching element to the DOM. reset: -> # If guestInstanceId is defined then the has navigated and has @@ -79,10 +76,6 @@ class WebViewImpl # Blur the BrowserPlugin when the loses focus. @browserPluginNode.blur() - # Validation helper function for executeScript() and insertCSS(). - validateExecuteCodeCall: -> - throw new Error(webViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT) unless @guestInstanceId - setupWebviewNodeProperties: -> # We cannot use {writable: true} property descriptor because we want a # dynamic getter value. @@ -125,31 +118,10 @@ class WebViewImpl # Check the current bounds to make sure we do not resize # outside of current constraints. - if node.hasAttribute(webViewConstants.ATTRIBUTE_MAXWIDTH) and - node[webViewConstants.ATTRIBUTE_MAXWIDTH] - maxWidth = node[webViewConstants.ATTRIBUTE_MAXWIDTH] - else - maxWidth = width - - if node.hasAttribute(webViewConstants.ATTRIBUTE_MINWIDTH) and - node[webViewConstants.ATTRIBUTE_MINWIDTH] - minWidth = node[webViewConstants.ATTRIBUTE_MINWIDTH] - else - minWidth = width - minWidth = maxWidth if minWidth > maxWidth - - if node.hasAttribute(webViewConstants.ATTRIBUTE_MAXHEIGHT) and - node[webViewConstants.ATTRIBUTE_MAXHEIGHT] - maxHeight = node[webViewConstants.ATTRIBUTE_MAXHEIGHT] - else - maxHeight = height - - if node.hasAttribute(webViewConstants.ATTRIBUTE_MINHEIGHT) and - node[webViewConstants.ATTRIBUTE_MINHEIGHT] - minHeight = node[webViewConstants.ATTRIBUTE_MINHEIGHT] - else - minHeight = height - minHeight = maxHeight if minHeight > maxHeight + maxWidth = @attributes[webViewConstants.ATTRIBUTE_MAXWIDTH].getValue() | width + maxHeight = @attributes[webViewConstants.ATTRIBUTE_MAXHEIGHT].getValue() | width + minWidth = @attributes[webViewConstants.ATTRIBUTE_MINWIDTH].getValue() | width + minHeight = @attributes[webViewConstants.ATTRIBUTE_MINHEIGHT].getValue() | width if not @attributes[webViewConstants.ATTRIBUTE_AUTOSIZE].getValue() or (newWidth >= minWidth and @@ -162,13 +134,6 @@ class WebViewImpl # changed. @dispatchEvent webViewEvent - # Returns if is in the render tree. - isPluginInRenderTree: -> - !!@internalInstanceId && @internalInstanceId != 0 - - hasNavigated: -> - not @beforeFirstNavigation - parseSrcAttribute: -> if not @attributes[webViewConstants.ATTRIBUTE_PARTITION].validPartitionId or not @attributes[webViewConstants.ATTRIBUTE_SRC].getValue() @@ -185,11 +150,6 @@ class WebViewImpl urlOptions = if httpreferrer then {httpreferrer} else {} remote.getGuestWebContents(@guestInstanceId).loadUrl @attributes[webViewConstants.ATTRIBUTE_SRC].getValue(), urlOptions - parseAttributes: -> - return unless @elementAttached - hasNavigated = @hasNavigated() - @parseSrcAttribute() - createGuest: -> return if @pendingGuestCreation params = @@ -257,8 +217,7 @@ class WebViewImpl @guestInstanceId = guestInstanceId params = @buildAttachParams() - unless @isPluginInRenderTree() - return true + return true unless @internalInstanceId guestViewInternal.attachGuest @internalInstanceId, @guestInstanceId, params, (w) => @contentWindow = w @@ -313,7 +272,7 @@ registerWebViewElement = -> return unless internal unless internal.elementAttached internal.elementAttached = true - internal.parseAttributes() + internal.parseSrcAttribute() # Public-facing API methods. methods = [