Given a webpage with a Javascript animation running on a timeout, does the browser check whether the element being animated is hidden or is it cheaper for the browser to fire a repaint?
Very late answer but thought I'd throw it out there - Yes the browser knows internally if what needs to be repainted is in the viewport and prioritises the repaint accordingly (so changes the user will see happen faster). Firefox has the mozAfterPaint func which fires after repaint, and the mozPaintCount property which continually increments with every repaint and can be checked accordingly.
I am looking for a cross-browser solution for establishing when there has been a repaint but it is much harder in other browsers.
Related
I have not used Selenium myself, but I was wondering whether the browser window needs to be maximized during test execution? I have used some other tools where the mouse pointer does not find the correct HTML element if the window is too small.
Selenium 2.0 (WebDriver) automatically attempts to scroll an element into view when you're going to perform any action on this element. If it can't scroll it throws an exception. So, don't make your window too small, but there is no need to maximize it. Keep it "mid-size".
For the abovementioned reason, you may want to maximize the browser window to avoid excessive scrolling, that can cause some unnecesssary events on the page.
Sometimes Selenium (WebDriver) can't click an element if it is placed too close to the viewport border (half-visible). In this case you can try to tune the window size to make this element either totally visible, or totally invisible (to activate auto-scrolling).
If you use Selenium (WebDriver) with "native events" enabled, you'd better keep the browser window in foreground and in focus during test execution. No matter whether it is maximized or "mid-size" -- just don't minimize it!
If you're happy with "synthesized events" -- many chances for your tests to run successfully in foreground.
No, because Selenium uses the DOM Structure to act on and not the OS(mouse, windows and stuff). You can actually minimize your window during a test.
Maybe not maximized, but probably best to have test at set minimum and maximum size.
An idea would be to have selenium resize the window for you before it runs the tests... A quick search gave me this: https://makandracards.com/makandra/9773-how-to-start-selenium-browser-with-custom-window-size
I have developed a game but this is a serious problem I am facing. I don't have any threads in my code , but whenever I use alert
Display.setCurrent(my_alert)// my_alert has a timeout of 3000ms
then after this alert, a blank white screen appears.When the screen is pressed, then my game canvas reappears. Before setting alert, my game canvas of checkers board is set as the current display. This problems also appears after the automatic keypad lock.
This alert is vital for my game, Kindly suggest a solution.
Issues like that typically indicate missing or incorrect override of GameCanvas method showNotify():
The implementation calls showNotify() immediately prior to this Canvas being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc. The default implementation of this method in class Canvas is empty.
Above method is invoked at return from Alert to prior screen. GameCanvas should somehow trigger repaint of the the screen (eg using repaint or flushGraphics methods), otherwise it will be displayed blank.
The fact that this problems also appears after the automatic keypad lock makes it even more likely that showNotify is not done right in your MIDlet.
Thought about it some times, and I decided to ask:
Why do a browser don't block the screen when doing a postback?
I have always been bothered by the fact that web browsers usually (can't say I've used them all) doesn't block the screen after I click a button that produces a postback. As I see it, during post a browser is expecting the server to send some information back. If it doesn't, the connection will time out and the page will be replaced by an error. If the server answer, it has to be with a web page; In other words, there's no possibility to keep the current web page rendered.
But it happens rather often that I click a button, realize that I forget to check a checkbox and so I click it, but to no avail. I know, I should have realized that clicking the checkbox wouldn't help, but hey, I usually doing stuff in auto-mode.
I think that it could be that the browser blocked the web page after you pushed a button or clicked a link that will produce a post back, so you couldn't press anything. But for some reason most browsers don't. Why?
The browser only shows what the page says and does what the script tells it to. If the page designer didn't implement anything to disable input during the connection, the brower leaves it up. In some cases this can be useful, such as when the input devices need to be available (although I can't think of a good example off the top of my head). A quick way to disable them (aside from disabling each individual input) is to have a hidden div with a z-index higher than the rest of the page become unhidden with a low opacity (screen looks slightly tinted, div prevents anything underneath it from being used) and then hiding it again when a response is received.
Ultimately it's just the result of a design choice. Does that answer your question?
When a browser blocks input is generally intentionally programmed that way.
Postback and clicking a button is not coupled because a button is not always used to do a postback.
Even when the browser is doing a request to some server in background, this request is not always fired by a button pressed (see Ajax)
In other words, there are much more complex scenarios than "push button, then postback", in order to cover every scenario, browser let this control to the programmer.
Greetings.
I have to make a draggable MFC dialog window, which has a background - used that: http://www.codeproject.com/KB/graphics/picturewindow.aspx - and has several picturebox controls. I have tried two approaches, and while they do work, they have some problems.
First approach is "Manual" - on the LBUTTONDOWN message I check if it;s on a clean area of my window, and set a flag variable. On MOUSEMOVE, the flag is checked and if it's set, a MoveWindow function is called, and then, Invalidate(1). On LBUTTONUP, flag is unset.
This approach works correctly and redraws as needed, but is somehow very slow - if I'm moving the cursor too fast, the window falls behing and isn't dragged, as cursor's not over the window anymore.
The second approach is "Automatic" - I just call
DefWindowProc(WM_SYSCOMMAND, SC_MOVE+2,MAKELPARAM(point.x,point.y));
on LBUTTONDOWN, and it handles the rest, it's quick and never fall behind, but when I drag it over screen's edge ( so that some part of the window gets invisible), when I drag it back, all the controls get invisible and are not refreshed, background is okay. I suppose that's because Invalidate() isn't called during movement that way, as I actually call it after calling DefWindowProc() and so, everything is refreshed properly when I depress the button.
What should I do to improve either of those solutions? I need it both fast and correct. I may have not provided some required information, I'll add it is need arise.
Thanks in advance.
Solved the problem, by modifying the second way. I added a total redraw to the OnPaint(), and to get rid of flicker, I only redraw durng dragging, by using a flag variable.
We have this Flex app built on Builder 3 and we're using SuperTabNavigator from FlexLib to have some modules displayed. The thing is, whenever the user resizes the browser window all the contents on any tabs open simply disappear and there's no way to get them back. This only happens the first time, so if you close these 'broken' tabs and reopen them, you can resize all you want, but you still lost all you were doing in them and this is unacceptable. I've done some testing and found the module in that tab doesn't dispatch the resize events when this happens. It's dispatched when it opens (everything is set to 100% to fit the browser window, so it resizes on startup) and every other time you resize it without 'breaking' it. It gets weirder. I've also found that resizing works perfectly as long as you resize it to a size larger than the original (i.e. you open it in a browser window that is restored and then maximized), but even after doing that, if you change its size back to something even a pixel smaller than the original, the module just disappears. Everything else remains in perfect working conditions: any components outside tabs and the tabs itself work, but (summing up) anything within any tab open at the moment you first resize the browser window to a size smaller than the original just disappears.
I understand that this is a weird problem and hope some of you might be able to help me. Feel free to ask any questions if anything wasn't clear.
Thanks in advance.
I had this exact same problem with my application. The issue stemmed from the fact that the RemovedFromStage event was being fired when the window was sized smaller than its original size. I was catching the RemovedFromStage event and hiding my component, which resulted in this behavior. A more detailed explanation can be found here.