@@ -134,6 +134,7 @@ def size_frame(page,width):
134134 # viewport is resized; its content uses the requested responsive media queries.
135135 element = page .locator ('iframe[name="editor-canvas"]' )
136136 element .wait_for (state = 'visible' ,timeout = 60000 )
137+ grown = False
137138 for _ in range (8 ):
138139 element .evaluate ('(e,w)=>{e.style.setProperty("width",w+"px","important");e.style.setProperty("height","900px","important");e.style.setProperty("max-width","none","important")}' ,width )
139140 frame = element .element_handle ().content_frame ()
@@ -143,7 +144,18 @@ def size_frame(page,width):
143144 if actual == {'width' :width ,'height' :900 }:
144145 # Every row of the canvas viewport must reach the screenshot.
145146 clip = element .evaluate (CLIP )
146- if clip ['visibleTop' ]> clip ['top' ]+ .5 or clip ['visibleBottom' ]< clip ['bottom' ]- .5 :
147+ short = clip ['bottom' ]- clip ['visibleBottom' ]
148+ # The region holding the canvas is the admin window less its chrome
149+ # (WordPress 7.1 keeps its 32px toolbar in fullscreen mode and has a
150+ # taller footer: 891px for the 900px canvas). A region short at the
151+ # bottom only gets a window that much taller, once; the canvas's own
152+ # viewport is unchanged. Clipped again, or from above, it fails.
153+ if not grown and short > .5 and clip ['visibleTop' ]<= clip ['top' ]+ .5 :
154+ grown = True
155+ view = page .viewport_size
156+ page .set_viewport_size ({'width' :view ['width' ],'height' :view ['height' ]+ math .ceil (short )})
157+ continue
158+ if clip ['visibleTop' ]> clip ['top' ]+ .5 or short > .5 :
147159 raise RuntimeError (f'Editor canvas is clipped by the administration layout: { clip } ' )
148160 return frame
149161 raise RuntimeError (f'Editor iframe viewport differs: { actual } , expected { width } x900' )
@@ -168,11 +180,13 @@ def size_frame(page,width):
168180
169181# The administration chrome around the canvas keeps its layout space but is
170182# not painted: the admin toolbar's shadow extends one pixel over a mobile
171- # iframe's edge. The post editor's meta box pane takes none: with it, the
172- # region holding the canvas was 899px tall and clipped the 900px iframe's
173- # last row, which every scroll tile ended on (the pane's border, then the
174- # admin's white: a seam every 450px down a tall capture).
175- ADMIN_CHROME = '.interface-interface-skeleton__header,.interface-interface-skeleton__footer{visibility:hidden!important}.edit-post-meta-boxes-main{display:none!important}'
183+ # iframe's edge. Nor is WordPress's admin bar, which 7.1 keeps in fullscreen
184+ # mode: the capture's pointer, parked at 0,0, opened its WordPress menu over
185+ # the canvas; hidden, it takes no hover. The post editor's meta box pane
186+ # takes no space: with it, the region holding the canvas was 899px tall and
187+ # clipped the 900px iframe's last row, which every scroll tile ended on (the
188+ # pane's border, then the admin's white: a seam every 450px down a tall capture).
189+ ADMIN_CHROME = '#wpadminbar,.interface-interface-skeleton__header,.interface-interface-skeleton__footer{visibility:hidden!important}.edit-post-meta-boxes-main{display:none!important}'
176190# The canvas iframe's box against everything that clips it (the admin
177191# window and every ancestor with overflow): what a tile can capture.
178192CLIP = '''e=>{const r=e.getBoundingClientRect();let top=Math.max(0,r.top),bottom=Math.min(innerHeight,r.bottom);
0 commit comments