Bug #7054 » 0002-Fix-WTableView-race-between-scrollTo-and-wtResize.patch
src/Wt/WTableView.C | ||
---|---|---|
68 | 68 |
viewportHeight_(UNKNOWN_VIEWPORT_HEIGHT), |
69 | 69 |
scrollToRow_(-1), |
70 | 70 |
scrollToHint_(ScrollHint::EnsureVisible), |
71 |
columnResizeConnected_(false) |
|
71 |
columnResizeConnected_(false), |
|
72 |
scrollToCount_(0) |
|
72 | 73 |
{ |
73 | 74 |
preloadMargin_[0] = preloadMargin_[1] = preloadMargin_[2] = preloadMargin_[3] = WLength(); |
74 | 75 | |
... | ... | |
1635 | 1636 |
} |
1636 | 1637 |
} |
1637 | 1638 |
|
1638 |
void WTableView::onViewportChange(int left, int top, int width, int height) |
|
1639 |
void WTableView::onViewportChange(int left, int top, int width, int height, int scrollToCount)
|
|
1639 | 1640 |
{ |
1640 | 1641 |
assert(ajaxMode()); |
1641 | 1642 | |
1643 |
// ignore viewport change if it does not reflect latest scrollTo sent to client |
|
1644 |
if ((scrollToCount != -1) && (scrollToCount < scrollToCount_)) { |
|
1645 |
LOG_INFO("onViewportChange: Ignoring stale client resize"); |
|
1646 |
return; |
|
1647 |
} |
|
1648 | ||
1642 | 1649 |
viewportLeft_ = left; |
1643 | 1650 |
viewportWidth_ = width; |
1644 | 1651 |
viewportTop_ = top; |
... | ... | |
2117 | 2124 |
} |
2118 | 2125 | |
2119 | 2126 |
if (isRendered()) { |
2127 |
scrollToCount_++; |
|
2120 | 2128 |
WStringStream s; |
2121 | 2129 | |
2122 | 2130 |
s << jsRef() << ".wtObj.setScrollToPending();" |
2123 | 2131 |
<< "setTimeout(function() {" |
2124 | 2132 |
<< jsRef() << ".wtObj.scrollTo(-1, " |
2125 |
<< rowY << "," << (int)hint << "); }, 0);"; |
|
2133 |
<< rowY << "," << (int)hint << "," |
|
2134 |
<< scrollToCount_ << "); }, 0);"; |
|
2126 | 2135 | |
2127 | 2136 |
doJavaScript(s.str()); |
2128 | 2137 |
} |
src/Wt/WTableView.h | ||
---|---|---|
194 | 194 |
WTable *plainTable_; |
195 | 195 | |
196 | 196 |
JSignal<int, int, std::string, std::string, WMouseEvent> dropEvent_; |
197 |
JSignal<int, int, int, int> scrolled_; |
|
197 |
JSignal<int, int, int, int, int> scrolled_;
|
|
198 | 198 |
JSignal<WTouchEvent> itemTouchSelectEvent_; |
199 | 199 | |
200 | 200 |
Signals::connection touchStartConnection_; |
... | ... | |
222 | 222 |
ScrollHint scrollToHint_; |
223 | 223 |
bool columnResizeConnected_; |
224 | 224 | |
225 |
int scrollToCount_; |
|
226 | ||
225 | 227 |
void updateTableBackground(); |
226 | 228 | |
227 | 229 |
ColumnWidget *columnContainer(int renderedColumn) const; |
... | ... | |
264 | 266 | |
265 | 267 |
virtual WWidget *headerWidget(int column, bool contentsOnly = true) override; |
266 | 268 | |
267 |
void onViewportChange(int left, int top, int width, int height); |
|
269 |
void onViewportChange(int left, int top, int width, int height, int scrollToCount);
|
|
268 | 270 |
void onColumnResize(); |
269 | 271 |
void resetGeometry(); |
270 | 272 |
|
src/js/WTableView.js | ||
---|---|---|
33 | 33 | |
34 | 34 |
var scrollX1 = 0, scrollX2 = 0, scrollY1 = 0, scrollY2 = 0; |
35 | 35 |
var scrollToPending = 0; |
36 |
var scrollToCount = 0; |
|
36 | 37 | |
37 | 38 |
/* |
38 | 39 |
* We need to remember this for when going through a hide() |
... | ... | |
61 | 62 |
Math.round(rtlScrollLeft(contentsContainer)), |
62 | 63 |
Math.round(contentsContainer.scrollTop), |
63 | 64 |
Math.round(contentsContainer.clientWidth), |
64 |
Math.round(contentsContainer.clientHeight)); |
|
65 |
Math.round(contentsContainer.clientHeight), |
|
66 |
-1); |
|
65 | 67 |
} |
66 | 68 |
}; |
67 | 69 | |
... | ... | |
76 | 78 |
Math.round(rtlScrollLeft(o)), |
77 | 79 |
Math.round(o.scrollTop), |
78 | 80 |
Math.round(o.clientWidth), |
79 |
Math.round(height)); |
|
81 |
Math.round(height), |
|
82 |
scrollToCount); |
|
80 | 83 |
} |
81 | 84 |
}; |
82 | 85 | |
... | ... | |
314 | 317 |
this.resetScroll(); |
315 | 318 |
}; |
316 | 319 | |
317 |
this.scrollTo = function(x, y, hint) { |
|
318 |
if (scrollToPending > 0) |
|
320 |
this.scrollTo = function(x, y, hint, scrollToCountServer) {
|
|
321 |
if (scrollToPending > 0) {
|
|
319 | 322 |
scrollToPending -= 1; |
323 |
} |
|
324 |
else { |
|
325 |
scrollToCount = scrollToCountServer; |
|
326 |
} |
|
320 | 327 |
if (y != -1) { |
321 | 328 |
var top = contentsContainer.scrollTop, |
322 | 329 |
height = contentsContainer.clientHeight; |
323 |
- |
- « Previous
- 1
- 2
- 3
- 4
- Next »