Fri, 01 Feb 2019 20:15:03 +0100
Web Browser (NG): some compatibility changes for Qt 5.12.
--- a/APIs/Python3/eric6.api Fri Feb 01 19:18:45 2019 +0100 +++ b/APIs/Python3/eric6.api Fri Feb 01 20:15:03 2019 +0100 @@ -9849,6 +9849,7 @@ eric6.UI.FindFileNameDialog.FindFileNameDialog?1(project, parent=None) eric6.UI.Info.BugAddress?7 eric6.UI.Info.Copyright?7 +eric6.UI.Info.CopyrightShort?7 eric6.UI.Info.FeatureAddress?7 eric6.UI.Info.Homepage?7 eric6.UI.Info.Program?7 @@ -12167,6 +12168,7 @@ eric6.WebBrowser.Tools.Scripts.getFeedLinks?4() eric6.WebBrowser.Tools.Scripts.getFormData?4(pos) eric6.WebBrowser.Tools.Scripts.getOpenSearchLinks?4() +eric6.WebBrowser.Tools.Scripts.scrollToAnchor?4(anchor) eric6.WebBrowser.Tools.Scripts.sendPostData?4(url, data) eric6.WebBrowser.Tools.Scripts.setCss?4(css) eric6.WebBrowser.Tools.Scripts.setStyleSheet?4(css) @@ -12774,10 +12776,12 @@ eric6.install.defaultMacPythonExe?7 eric6.install.determinePyQtVariant?4() eric6.install.distDir?7 +eric6.install.doCleanDesktopLinks?7 eric6.install.doCleanup?7 eric6.install.doCompile?7 eric6.install.doDependancyChecks?4() eric6.install.exit?4(rcode=0) +eric6.install.forceCleanDesktopLinks?7 eric6.install.getWinregEntry?4(name, path) eric6.install.includePythonVariant?7 eric6.install.initGlobals?4()
--- a/Documentation/Help/source.qhp Fri Feb 01 19:18:45 2019 +0100 +++ b/Documentation/Help/source.qhp Fri Feb 01 20:15:03 2019 +0100 @@ -17842,6 +17842,7 @@ <keyword name="WebBrowserPage (Constructor)" id="WebBrowserPage (Constructor)" ref="eric6.WebBrowser.WebBrowserPage.html#WebBrowserPage.__init__" /> <keyword name="WebBrowserPage (Module)" id="WebBrowserPage (Module)" ref="eric6.Preferences.ConfigurationPages.WebBrowserPage.html" /> <keyword name="WebBrowserPage (Module)" id="WebBrowserPage (Module)" ref="eric6.WebBrowser.WebBrowserPage.html" /> + <keyword name="WebBrowserPage.__contentsSizeChanged" id="WebBrowserPage.__contentsSizeChanged" ref="eric6.WebBrowser.WebBrowserPage.html#WebBrowserPage.__contentsSizeChanged" /> <keyword name="WebBrowserPage.__featurePermissionRequested" id="WebBrowserPage.__featurePermissionRequested" ref="eric6.WebBrowser.WebBrowserPage.html#WebBrowserPage.__featurePermissionRequested" /> <keyword name="WebBrowserPage.__fullScreenRequested" id="WebBrowserPage.__fullScreenRequested" ref="eric6.WebBrowser.WebBrowserPage.html#WebBrowserPage.__fullScreenRequested" /> <keyword name="WebBrowserPage.__loadProgress" id="WebBrowserPage.__loadProgress" ref="eric6.WebBrowser.WebBrowserPage.html#WebBrowserPage.__loadProgress" /> @@ -19354,6 +19355,7 @@ <keyword name="saveToolGroups" id="saveToolGroups" ref="eric6.Preferences.__init__.html#saveToolGroups" /> <keyword name="sbsdiff" id="sbsdiff" ref="eric6.UI.CompareDialog.html#sbsdiff" /> <keyword name="schemeFromProxyType" id="schemeFromProxyType" ref="eric6.E5Network.E5NetworkProxyFactory.html#schemeFromProxyType" /> + <keyword name="scrollToAnchor" id="scrollToAnchor" ref="eric6.WebBrowser.Tools.Scripts.html#scrollToAnchor" /> <keyword name="sendPostData" id="sendPostData" ref="eric6.WebBrowser.Tools.Scripts.html#sendPostData" /> <keyword name="setActions" id="setActions" ref="eric6.Preferences.Shortcuts.html#setActions" /> <keyword name="setConfigDir" id="setConfigDir" ref="eric6.Globals.__init__.html#setConfigDir" />
--- a/Documentation/Source/eric6.UI.Info.html Fri Feb 01 19:18:45 2019 +0100 +++ b/Documentation/Source/eric6.UI.Info.html Fri Feb 01 20:15:03 2019 +0100 @@ -25,7 +25,7 @@ </p> <h3>Global Attributes</h3> <table> -<tr><td>BugAddress</td></tr><tr><td>Copyright</td></tr><tr><td>FeatureAddress</td></tr><tr><td>Homepage</td></tr><tr><td>Program</td></tr><tr><td>Version</td></tr><tr><td>VersionOnly</td></tr> +<tr><td>BugAddress</td></tr><tr><td>Copyright</td></tr><tr><td>CopyrightShort</td></tr><tr><td>FeatureAddress</td></tr><tr><td>Homepage</td></tr><tr><td>Program</td></tr><tr><td>Version</td></tr><tr><td>VersionOnly</td></tr> </table> <h3>Classes</h3> <table>
--- a/Documentation/Source/eric6.WebBrowser.Tools.Scripts.html Fri Feb 01 19:18:45 2019 +0100 +++ b/Documentation/Source/eric6.WebBrowser.Tools.Scripts.html Fri Feb 01 20:15:03 2019 +0100 @@ -52,6 +52,9 @@ <td><a href="#getOpenSearchLinks">getOpenSearchLinks</a></td> <td>Function generating a script to extract all open search links.</td> </tr><tr> +<td><a href="#scrollToAnchor">scrollToAnchor</a></td> +<td>Function generating script to scroll to a given anchor.</td> +</tr><tr> <td><a href="#sendPostData">sendPostData</a></td> <td>Function generating a script to send Post data.</td> </tr><tr> @@ -190,6 +193,29 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="scrollToAnchor" ID="scrollToAnchor"></a> +<h2>scrollToAnchor</h2> +<b>scrollToAnchor</b>(<i>anchor</i>) +<p> + Function generating script to scroll to a given anchor. +</p><dl> +<dt><i>anchor</i> (str)</dt> +<dd> +name of the anchor to scroll to +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +script to set the style sheet +</dd> +</dl><dl> +<dt>Return Type:</dt> +<dd> +str +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="sendPostData" ID="sendPostData"></a> <h2>sendPostData</h2> <b>sendPostData</b>(<i>url, data</i>)
--- a/Documentation/Source/eric6.WebBrowser.WebBrowserPage.html Fri Feb 01 19:18:45 2019 +0100 +++ b/Documentation/Source/eric6.WebBrowser.WebBrowserPage.html Fri Feb 01 20:15:03 2019 +0100 @@ -88,6 +88,9 @@ <td><a href="#WebBrowserPage.__init__">WebBrowserPage</a></td> <td>Constructor</td> </tr><tr> +<td><a href="#WebBrowserPage.__contentsSizeChanged">__contentsSizeChanged</a></td> +<td>Private slot to work around QWebEnginePage not scrolling to anchors when opened in a background tab.</td> +</tr><tr> <td><a href="#WebBrowserPage.__featurePermissionRequested">__featurePermissionRequested</a></td> <td>Private slot handling a feature permission request.</td> </tr><tr> @@ -210,6 +213,17 @@ <dd> parent widget of this window (QWidget) </dd> +</dl><a NAME="WebBrowserPage.__contentsSizeChanged" ID="WebBrowserPage.__contentsSizeChanged"></a> +<h4>WebBrowserPage.__contentsSizeChanged</h4> +<b>__contentsSizeChanged</b>(<i>size</i>) +<p> + Private slot to work around QWebEnginePage not scrolling to anchors + when opened in a background tab. +</p><dl> +<dt><i>size</i> (QSize)</dt> +<dd> +changed contents size (unused) +</dd> </dl><a NAME="WebBrowserPage.__featurePermissionRequested" ID="WebBrowserPage.__featurePermissionRequested"></a> <h4>WebBrowserPage.__featurePermissionRequested</h4> <b>__featurePermissionRequested</b>(<i>url, feature</i>)
--- a/Documentation/Source/eric6.install.html Fri Feb 01 19:18:45 2019 +0100 +++ b/Documentation/Source/eric6.install.html Fri Feb 01 20:15:03 2019 +0100 @@ -25,7 +25,7 @@ </p> <h3>Global Attributes</h3> <table> -<tr><td>BlackLists</td></tr><tr><td>PlatformsBlackLists</td></tr><tr><td>PythonMarkers</td></tr><tr><td>PythonTextMarkers</td></tr><tr><td>apisDir</td></tr><tr><td>cfg</td></tr><tr><td>configLength</td></tr><tr><td>configName</td></tr><tr><td>currDir</td></tr><tr><td>defaultMacAppBundleName</td></tr><tr><td>defaultMacAppBundlePath</td></tr><tr><td>defaultMacPythonExe</td></tr><tr><td>distDir</td></tr><tr><td>doCleanup</td></tr><tr><td>doCompile</td></tr><tr><td>includePythonVariant</td></tr><tr><td>installApis</td></tr><tr><td>macAppBundleName</td></tr><tr><td>macAppBundlePath</td></tr><tr><td>macPythonExe</td></tr><tr><td>modDir</td></tr><tr><td>platBinDir</td></tr><tr><td>platBinDirOld</td></tr><tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr><tr><td>pyqtOverride</td></tr><tr><td>pyqtVariant</td></tr><tr><td>sourceDir</td></tr> +<tr><td>BlackLists</td></tr><tr><td>PlatformsBlackLists</td></tr><tr><td>PythonMarkers</td></tr><tr><td>PythonTextMarkers</td></tr><tr><td>apisDir</td></tr><tr><td>cfg</td></tr><tr><td>configLength</td></tr><tr><td>configName</td></tr><tr><td>currDir</td></tr><tr><td>defaultMacAppBundleName</td></tr><tr><td>defaultMacAppBundlePath</td></tr><tr><td>defaultMacPythonExe</td></tr><tr><td>distDir</td></tr><tr><td>doCleanDesktopLinks</td></tr><tr><td>doCleanup</td></tr><tr><td>doCompile</td></tr><tr><td>forceCleanDesktopLinks</td></tr><tr><td>includePythonVariant</td></tr><tr><td>installApis</td></tr><tr><td>macAppBundleName</td></tr><tr><td>macAppBundlePath</td></tr><tr><td>macPythonExe</td></tr><tr><td>modDir</td></tr><tr><td>platBinDir</td></tr><tr><td>platBinDirOld</td></tr><tr><td>progLanguages</td></tr><tr><td>progName</td></tr><tr><td>pyModDir</td></tr><tr><td>pyqtOverride</td></tr><tr><td>pyqtVariant</td></tr><tr><td>sourceDir</td></tr> </table> <h3>Classes</h3> <table>
--- a/WebBrowser/Tools/Scripts.py Fri Feb 01 19:18:45 2019 +0100 +++ b/WebBrowser/Tools/Scripts.py Fri Feb 01 20:15:03 2019 +0100 @@ -413,6 +413,29 @@ style = css.replace("'", "\\'").replace("\n", "\\n") return source.format(style) + +def scrollToAnchor(anchor): + """ + Function generating script to scroll to a given anchor. + + @param anchor name of the anchor to scroll to + @type str + @return script to set the style sheet + @rtype str + """ + source = """ +(function() {{ + var e = document.getElementById("{0}") + if (!e) {{ + var els = document.querySelectorAll("[name='{0}']"); + if (els.length) + e = els[0] + }} + if (e) + e.scrollIntoView() + }})()""" + return source.format(anchor) + ########################################################################### ## scripts below are specific for eric ###########################################################################
--- a/WebBrowser/Tools/WebHitTestResult.py Fri Feb 01 19:18:45 2019 +0100 +++ b/WebBrowser/Tools/WebHitTestResult.py Fri Feb 01 20:15:03 2019 +0100 @@ -86,16 +86,16 @@ var r = e.getBoundingClientRect(); res.boundingRect = [r.top, r.left, r.width, r.height]; if (e.tagName.toLowerCase() == 'img') - res.imageUrl = e.getAttribute('src'); + res.imageUrl = e.getAttribute('src').trim(); if (e.tagName.toLowerCase() == 'a') {{ res.linkTitle = e.text; - res.linkUrl = e.getAttribute('href'); + res.linkUrl = e.getAttribute('href').trim(); }} while (e) {{ if (res.linkTitle == '' && e.tagName.toLowerCase() == 'a') res.linkTitle = e.text; if (res.linkUrl == '' && e.tagName.toLowerCase() == 'a') - res.linkUrl = e.getAttribute('href'); + res.linkUrl = e.getAttribute('href').trim(); if (res.mediaUrl == '' && isMediaElement(e)) {{ res.mediaUrl = e.currentSrc; res.mediaPaused = e.paused;
--- a/WebBrowser/WebBrowserPage.py Fri Feb 01 19:18:45 2019 +0100 +++ b/WebBrowser/WebBrowserPage.py Fri Feb 01 20:15:03 2019 +0100 @@ -28,6 +28,7 @@ from .JavaScript.ExternalJsObject import ExternalJsObject from .Tools.WebHitTestResult import WebHitTestResult +from .Tools import Scripts import Preferences from Globals import qVersionTuple @@ -83,6 +84,12 @@ self.urlChanged.connect(self.__urlChanged) + try: + self.contentsSizeChanged.connect(self.__contentsSizeChanged) + except AttributeError: + # defined for Qt >= 5.7 + pass + self.__printer = None self.__badSite = False @@ -466,6 +473,17 @@ loop.exec_() return resultDict["res"] + def __contentsSizeChanged(self, size): + """ + Private slot to work around QWebEnginePage not scrolling to anchors + when opened in a background tab. + + @param size changed contents size (unused) + @type QSize + """ + fragment = self.url().fragment() + self.runJavaScript(Scripts.scrollToAnchor(fragment)) + ############################################## ## Methods below deal with JavaScript messages ##############################################
--- a/WebBrowser/WebBrowserView.py Fri Feb 01 19:18:45 2019 +0100 +++ b/WebBrowser/WebBrowserView.py Fri Feb 01 20:15:03 2019 +0100 @@ -1519,7 +1519,7 @@ self.parentWidget().installEventFilter(self) # find the render widget receiving events for the web page - if qVersionTuple() < (5, 8, 0): + if qVersionTuple() < (5, 8, 0) or qVersionTuple() >= (5, 12, 0): if obj is self and evt.type() == QEvent.ChildAdded: child = evt.child() if child and child.inherits(