Consider the WebPage.addToDirty method source code:
private void addToDirty(WCRectangle toPaint) {
boolean add = true;
for (int i = 0; i < dirtyRects.size(); i++) {
WCRectangle d = dirtyRects.get(i);
if (d.contains(toPaint)) {
add = false;
break;
}
if (toPaint.contains(d)) {
dirtyRects.remove(i);
continue;
}
WCRectangle u = d.createUnion(toPaint);
if (u.getIntWidth() * u.getIntHeight() <
d.getIntWidth() * d.getIntHeight() + toPaint.getIntWidth() * toPaint.getIntHeight())
{
dirtyRects.remove(i);
toPaint = u;
continue;
}
}
if (add) {
dirtyRects.add(toPaint);
}
}
When the second "if" condition is true, the method removes the "current" item, thus making the next item "current", and then, as part of the next iteration, immediately shifts to the next item, effectively skipping the item next to the original "current" item.
This breaks the merging logic and often causes WebPage to paint the entire page twice during one paint cycle.
private void addToDirty(WCRectangle toPaint) {
boolean add = true;
for (int i = 0; i < dirtyRects.size(); i++) {
WCRectangle d = dirtyRects.get(i);
if (d.contains(toPaint)) {
add = false;
break;
}
if (toPaint.contains(d)) {
dirtyRects.remove(i);
continue;
}
WCRectangle u = d.createUnion(toPaint);
if (u.getIntWidth() * u.getIntHeight() <
d.getIntWidth() * d.getIntHeight() + toPaint.getIntWidth() * toPaint.getIntHeight())
{
dirtyRects.remove(i);
toPaint = u;
continue;
}
}
if (add) {
dirtyRects.add(toPaint);
}
}
When the second "if" condition is true, the method removes the "current" item, thus making the next item "current", and then, as part of the next iteration, immediately shifts to the next item, effectively skipping the item next to the original "current" item.
This breaks the merging logic and often causes WebPage to paint the entire page twice during one paint cycle.
- relates to
-
JDK-8118377 WebPage.scroll duplicates call to updateDirty
-
- Resolved
-
-
JDK-8126143 WebPage.scroll modifies dirtyRects without merging
-
- Resolved
-