(iframe, frameDoc, pageEle)
| 13151 | } |
| 13152 | |
| 13153 | function resizeIframe(iframe, frameDoc, pageEle) { |
| 13154 | if (targetY >= 0) { |
| 13155 | window.scrollTo({ top: targetY, behavior: 'instant'}); |
| 13156 | targetY = -1; |
| 13157 | } |
| 13158 | let curScroll = getBody(document).scrollTop || document.documentElement.scrollTop; |
| 13159 | if (ruleParser.curSiteRule.smart || forceState === 2) { |
| 13160 | let height = (getBody(frameDoc).scrollHeight || getBody(frameDoc).offsetHeight || 500); |
| 13161 | if (!iframe.style.height || parseInt(iframe.style.height) === 0 || height - parseInt(iframe.style.height) > window.innerHeight) { |
| 13162 | iframe.style.height = height + "px"; |
| 13163 | iframe.style.minHeight = iframe.style.height; |
| 13164 | } |
| 13165 | iframe.style.width = "100%"; |
| 13166 | frameDoc.documentElement.scrollTop = 0; |
| 13167 | frameDoc.documentElement.scrollLeft = 0; |
| 13168 | } else { |
| 13169 | if (pageEle) { |
| 13170 | if (document.body.scrollWidth) frameDoc.documentElement.style.width = document.body.scrollWidth + "px"; |
| 13171 | let fitWidth = ruleParser.curSiteRule.fitWidth !== false; |
| 13172 | let targetElement = pageEle[0]; |
| 13173 | if (!targetElement) return; |
| 13174 | if (pageEle.length > 1) { |
| 13175 | targetElement = targetElement.parentNode; |
| 13176 | } |
| 13177 | let scrollHeight = targetElement.scrollHeight || targetElement.offsetHeight || 500; |
| 13178 | iframe.style.height = scrollHeight + "px"; |
| 13179 | let scrollTop = 0, scrollLeft = 0; |
| 13180 | getBody(frameDoc).scrollTop = 0; |
| 13181 | getBody(frameDoc).scrollLeft = 0; |
| 13182 | while (targetElement && targetElement.offsetParent) { |
| 13183 | targetElement.offsetParent.scrollTop = targetElement.offsetTop; |
| 13184 | if (targetElement.offsetParent.scrollTop == 0) { |
| 13185 | scrollTop += targetElement.offsetTop; |
| 13186 | } |
| 13187 | if (fitWidth) { |
| 13188 | targetElement.offsetParent.scrollLeft = targetElement.offsetLeft; |
| 13189 | if (targetElement.offsetParent.scrollLeft == 0) { |
| 13190 | scrollLeft += targetElement.offsetLeft; |
| 13191 | } |
| 13192 | } |
| 13193 | targetElement = targetElement.offsetParent; |
| 13194 | } |
| 13195 | frameDoc.documentElement.scrollTop = scrollTop; |
| 13196 | frameDoc.documentElement.scrollLeft = scrollLeft; |
| 13197 | if (frameDoc.documentElement.scrollTop == 0 && frameDoc.documentElement.scrollLeft == 0) { |
| 13198 | getBody(frameDoc).scrollTop += scrollTop; |
| 13199 | getBody(frameDoc).scrollLeft += scrollLeft; |
| 13200 | } |
| 13201 | if (!fitWidth && iframe.style.marginLeft == '0px') { |
| 13202 | iframe.style.width = "100vw"; |
| 13203 | iframe.style.maxWidth = "100vw"; |
| 13204 | iframe.style.minWidth = "100vw"; |
| 13205 | var cWidth = document.body.clientWidth || document.documentElement.clientWidth; |
| 13206 | var iWidth = window.innerWidth; |
| 13207 | iframe.style.marginLeft = -iframe.getBoundingClientRect().left - (iWidth - cWidth) / 2 + "px"; |
| 13208 | } |
| 13209 | } |
| 13210 | } |
no test coverage detected