Skip to content

Commit

Permalink
Several changes:
Browse files Browse the repository at this point in the history
 - fix illegal use of modelindexes after removal (reported on Wt forum)
 - issue #5428: changed headers() implementation from map to vector
 - Fix issue 5463: Documentation missing on WModelIndexSet
 - issue #5314: WStackedWidget in a layout can receive incorrect height after animation
 - issue #5329: documented limitations to setTransitionAnimation
 - More debug logging for ackId checking
 - Wt.min.js: fixed if statement being optimized away by minifier
  • Loading branch information
RockinRoel committed Dec 30, 2016
1 parent bac28e1 commit f411b97
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 135 deletions.
2 changes: 1 addition & 1 deletion resources/webkit-transitions.css
Expand Up @@ -108,7 +108,7 @@


@-webkit-keyframes slideinfromtop {
from { -webkit-transform: translate3d(0,-100%,); }
from { -webkit-transform: translate3d(0,-100%,0); }
to { -webkit-transform: translate3d(0,0,0); }
}

Expand Down
3 changes: 2 additions & 1 deletion src/Wt/Http/Request
Expand Up @@ -13,6 +13,7 @@
#include <sstream>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <Wt/Http/Message>

#include <Wt/WDllDefs.h>

Expand Down Expand Up @@ -388,7 +389,7 @@ public:
* \note Use headerValue() if you need to know the value of certain known headers.
* This method is not written to be efficient, but can be useful for debugging.
*/
HeaderMap headers() const;
std::vector<Message::Header> headers() const;
#endif

/*! \brief Returns the request method.
Expand Down
3 changes: 2 additions & 1 deletion src/Wt/Http/Request.C
Expand Up @@ -15,6 +15,7 @@
#include "Wt/WSslInfo"
#include "WebUtils.h"
#include "WebRequest.h"
#include "Message"

#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -171,7 +172,7 @@ std::string Request::headerValue(const std::string& field) const
}

#ifndef WT_TARGET_JAVA
HeaderMap Request::headers() const
std::vector<Message::Header> Request::headers() const
{
return request_->headers();
}
Expand Down
13 changes: 11 additions & 2 deletions src/Wt/WAbstractProxyModel.C
Expand Up @@ -125,6 +125,9 @@ void WAbstractProxyModel::shiftModelIndexes(const WModelIndex& sourceParent,
/*
* We must shift all indexes within sourceParent >= start with count
* and delete items when count < 0.
*
* If count > 0 : rows inserted, after insertion
* If count < 0 : rows to be removed, before removal
*/
std::vector<BaseItem *> shifted;
std::vector<BaseItem *> erased;
Expand Down Expand Up @@ -159,14 +162,19 @@ void WAbstractProxyModel::shiftModelIndexes(const WModelIndex& sourceParent,
break;

if (p == sourceParent) {
shifted.push_back(it->second);
if (count < 0 &&
i.row() >= start &&
i.row() < start + (-count))
erased.push_back(it->second);
else
shifted.push_back(it->second);
} else if (count < 0) {
// delete indexes that are about to be deleted, if they are within
// the range of deleted indexes
do {
if (p.parent() == sourceParent
&& p.row() >= start
&& p.row() < start - count) {
&& p.row() < start + (-count)) {
erased.push_back(it->second);
break;
} else
Expand All @@ -188,6 +196,7 @@ void WAbstractProxyModel::shiftModelIndexes(const WModelIndex& sourceParent,
for (unsigned i = 0; i < shifted.size(); ++i) {
BaseItem *item = shifted[i];
items.erase(item->sourceIndex_);

if (item->sourceIndex_.row() + count >= start) {
item->sourceIndex_ = sourceModel()->index
(item->sourceIndex_.row() + count,
Expand Down
4 changes: 2 additions & 2 deletions src/Wt/WBatchEditProxyModel.C
Expand Up @@ -549,6 +549,8 @@ void WBatchEditProxyModel::sourceRowsAboutToBeRemoved
item->removedRows_.erase(item->removedRows_.begin() + remi);
}
}

shiftModelIndexes(parent, start, -(end - start + 1), mappedIndexes_);
}

void WBatchEditProxyModel::deleteItemsUnder(Item *item, int row)
Expand All @@ -570,8 +572,6 @@ void WBatchEditProxyModel::sourceRowsRemoved(const WModelIndex& parent,
{
if (isRemoved(parent))
return;

shiftModelIndexes(parent, start, -(end - start + 1), mappedIndexes_);
}

void WBatchEditProxyModel::sourceRowsAboutToBeInserted
Expand Down
2 changes: 2 additions & 0 deletions src/Wt/WModelIndex
Expand Up @@ -25,6 +25,8 @@ class WModelIndex;
}

#ifndef WT_TARGET_JAVA
/*! \brief A set of WModelIndexes
*/
typedef std::set<WModelIndex> WModelIndexSet;

extern std::size_t hash_value(const Wt::WModelIndex& index);
Expand Down
5 changes: 3 additions & 2 deletions src/Wt/WSortFilterProxyModel.C
Expand Up @@ -530,15 +530,16 @@ void WSortFilterProxyModel::sourceRowsAboutToBeRemoved
endRemoveRows();
}
}

int count = end - start + 1;
shiftModelIndexes(parent, start, -count, mappedIndexes_);
}

void WSortFilterProxyModel::sourceRowsRemoved(const WModelIndex& parent,
int start, int end)
{
int count = end - start + 1;

shiftModelIndexes(parent, start, -count, mappedIndexes_);

WModelIndex pparent = mapFromSource(parent);
// distinguish between invalid parent being root item or being filtered out
if (parent.isValid() && !pparent.isValid())
Expand Down
10 changes: 10 additions & 0 deletions src/Wt/WStackedWidget
Expand Up @@ -101,6 +101,16 @@ public:
* WAnimation::SlideInFromRight, WAnimation::SlideInFromUp or
* WAnimation::SlideInFromDown transition effects.
*
* \note If you intend to use a transition animation with a WStackedWidget
* you should set it before it is first rendered. Otherwise, transition
* animations caused by setCurrentIndex() may not be correctly performed.
* If you do want to force this change you can use WApplication::processEvents
* before calling setCurrentIndex().
*
* \note It is also not supported to use a WAnimation::Pop animation on a WStackedWidget.
*
*
*
* \sa setCurrentIndex()
*/
void setTransitionAnimation(const WAnimation& animation,
Expand Down
2 changes: 1 addition & 1 deletion src/Wt/WTreeView.C
Expand Up @@ -2217,7 +2217,7 @@ void WTreeView::modelRowsRemoved(const WModelIndex& parent,
// at the back. This is not affected by widgetForModelRow() returning
// accurate information of rows just deleted and indexes not yet
// shifted
if (end == model()->rowCount(parent) - 1 && start >= 1) {
if (end >= model()->rowCount(parent) && start >= 1) {
WTreeViewNode *n = dynamic_cast<WTreeViewNode *>
(parentNode->widgetForModelRow(start - 1));

Expand Down
27 changes: 13 additions & 14 deletions src/fcgi/FCGIStream.C
Expand Up @@ -133,8 +133,8 @@ namespace {
return envValue(cgiEnvName(name).c_str());
}

Http::HeaderMap headers() const {
Http::HeaderMap headerMap;
std::vector<Wt::Http::Message::Header> headers() const {
std::vector<Wt::Http::Message::Header> headerVector;
std::string header_prefix("HTTP_");
int prefix_length = header_prefix.length();

Expand All @@ -143,19 +143,18 @@ namespace {
if (env_string.compare(0,prefix_length, header_prefix) == 0){
std::string name = env_string.substr(prefix_length, env_string.find("=") - prefix_length);
std::string value = env_string.substr(env_string.find("=") + 1);
headerMap.insert(std::pair<std::string,std::string>(name,value));
}
const char *contentLength = envValue("CONTENT_LENGTH");
if (contentLength) {
headerMap.insert(std::pair<std::string,std::string>("CONTENT_LENGTH", contentLength));
}
const char *contentType = envValue("CONTENT_TYPE");
if (contentType){
headerMap.insert(std::pair<std::string,std::string>("CONTENT_TYPE",contentType));
}
headerVector.push_back(Wt::Http::Message::Header(name, value));
}
}

return headerMap;
const char *contentLength = envValue("CONTENT_LENGTH");
if (contentLength) {
headerVector.push_back(Wt::Http::Message::Header("CONTENT_LENGTH", contentLength));
}
const char *contentType = envValue("CONTENT_TYPE");
if (contentType){
headerVector.push_back(Wt::Http::Message::Header("CONTENT_TYPE", contentType));
}
return headerVector;
}


Expand Down
15 changes: 9 additions & 6 deletions src/http/HTTPRequest.C
Expand Up @@ -9,6 +9,7 @@
#include "HTTPRequest.h"
#include "Configuration.h"
#include "WtReply.h"
#include "Wt/Http/Message"

namespace http {
namespace server {
Expand Down Expand Up @@ -101,20 +102,22 @@ const char *HTTPRequest::headerValue(const char *name) const
return 0;
}

Wt::Http::HeaderMap HTTPRequest::headers() const
std::vector<Wt::Http::Message::Header> HTTPRequest::headers() const
{
Wt::Http::HeaderMap headerMap;
std::vector<Wt::Http::Message::Header> headerVector;
WtReplyPtr p = reply_;
if (!p.get())
return headerMap;
return headerVector;

std::list<Request::Header> headers = p->request().headers;
const std::list<Request::Header> &headers = p->request().headers;

for (std::list<Request::Header>::const_iterator it=headers.begin(); it != headers.end(); ++it){
headerMap.insert(std::pair<std::string,std::string>(cstr(it->name),cstr(it->value)));
if (cstr(it->name)) {
headerVector.push_back(Wt::Http::Message::Header(it->name.str(), it->value.str()));
}
}

return headerMap;
return headerVector;
}

const char *HTTPRequest::cstr(const buffer_string& bs) const {
Expand Down
3 changes: 2 additions & 1 deletion src/http/HTTPRequest.h
Expand Up @@ -11,6 +11,7 @@

#include "WebRequest.h"
#include "WtReply.h"
#include "Wt/Http/Message"

namespace http {
namespace server {
Expand Down Expand Up @@ -43,7 +44,7 @@ class HTTPRequest : public Wt::WebRequest

virtual const char *envValue(const char *name) const;
virtual const char *headerValue(const char *name) const;
virtual Wt::Http::HeaderMap headers() const;
virtual std::vector<Wt::Http::Message::Header> headers() const;
virtual const std::string& serverName() const;
virtual const std::string& serverPort() const;
virtual const std::string& scriptName() const;
Expand Down
10 changes: 5 additions & 5 deletions src/isapi/IsapiRequest.C
Expand Up @@ -467,12 +467,12 @@ const char *IsapiRequest::headerValue(const char *name) const
return retval ? retval->c_str() : 0;
}

Wt::Http::HeaderMap IsapiRequest::headers() const
std::vector<Wt::Http::Message::Header> IsapiRequest::headers() const
{
Wt::Http::HeaderMap headerMap;
std::vector<Wt::Http::Message::Header> headerVec;
std::string *pAllRaw = persistentEnvValue("ALL_RAW");
if (!pAllRaw)
return headerMap;
return headerVec;
std::string all_raw = *pAllRaw;

std::size_t headerStart = 0;
Expand All @@ -481,13 +481,13 @@ Wt::Http::HeaderMap IsapiRequest::headers() const
std::size_t colonPos = all_raw.find(':', headerStart);
std::string name = all_raw.substr(headerStart, colonPos - headerStart);
std::string value = all_raw.substr(colonPos + 2, headerEnd - (colonPos + 2));
headerMap[name] = value;
headerVec.push_back(Wt::Http::Message::Header(name, value));

headerStart = headerEnd + 2;
headerEnd = all_raw.find("\r\n", headerEnd + 2);
}

return headerMap;
return headerVec;
}

std::string *IsapiRequest::persistentEnvValue(const char *hdr) const
Expand Down
2 changes: 1 addition & 1 deletion src/isapi/IsapiRequest.h
Expand Up @@ -47,7 +47,7 @@ class IsapiRequest : public WebRequest

virtual const char *headerValue(const char *name) const;

virtual Wt::Http::HeaderMap headers() const;
virtual std::vector<Wt::Http::Message::Header> headers() const;

virtual const char *envValue(const char *name) const;

Expand Down
8 changes: 7 additions & 1 deletion src/js/WStackedWidget.js
Expand Up @@ -226,8 +226,14 @@ WT_DECLARE_WT_MEMBER
to.style.left = '';
to.style.width = '';
to.style.top = '';
to.style.height = to.nativeHeight;

/* If fade-only animation within a layout, retain set height */
if (!effects
|| typeof jQuery.data(stack.parentNode, 'layout') === 'undefined')
to.style.height = to.nativeHeight;

to.nativeHeight = null;

if (WT.isGecko && (effects & Fade))
to.style.opacity = '1';
to.style[WT.styleAttribute('animation-duration')] = '';
Expand Down
11 changes: 6 additions & 5 deletions src/js/WStackedWidget.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/js/WWebWidget.js
Expand Up @@ -170,7 +170,7 @@ WT_DECLARE_WT_MEMBER
elcStyle);
}

$el.one(transitionEventEnd, function() {
$el.one(transitionEventEnd, function() {
if (hide)
el.style.display = display;

Expand All @@ -183,7 +183,7 @@ WT_DECLARE_WT_MEMBER

onEnd();
});
}, 0);
}, 0);
}

function animateAbsolute(cssSize, cssOffset, topleft, U) {
Expand Down
7 changes: 6 additions & 1 deletion src/web/WebRenderer.C
Expand Up @@ -211,6 +211,7 @@ bool WebRenderer::ackUpdate(int updateId)
* If web socket request -> we assume last AJAX request got
* delivered ?
*/
LOG_DEBUG("ackUpdate: expecting " << expectedAckId_ << ", received " << updateId);
if (updateId == expectedAckId_) {
LOG_DEBUG("jsSynced(false) after ackUpdate okay");
setJSSynced(false);
Expand Down Expand Up @@ -730,8 +731,12 @@ void WebRenderer::addResponseAckPuzzle(WStringStream& out)
* client-side: only when libraries have been loaded, the application can
* continue. TO BE DONE.
*/

++expectedAckId_;
LOG_DEBUG("addResponseAckPuzzle: incremented expectedAckId to " << expectedAckId_);

out << session_.app()->javaScriptClass()
<< "._p_.response(" << ++expectedAckId_;
<< "._p_.response(" << expectedAckId_;
if (!puzzle.empty())
out << "," << puzzle;
out << ");";
Expand Down
2 changes: 1 addition & 1 deletion src/web/WebRequest.h
Expand Up @@ -162,7 +162,7 @@ class WT_API WebRequest
const char *referer() const;

#ifndef WT_TARGET_JAVA
virtual Http::HeaderMap headers() const = 0;
virtual std::vector<Wt::Http::Message::Header> headers() const = 0;
#endif

virtual const char *contentType() const;
Expand Down
2 changes: 1 addition & 1 deletion src/web/WebSocketMessage.C
Expand Up @@ -154,7 +154,7 @@ const char *WebSocketMessage::headerValue(const char *name) const
return webSocket()->headerValue(name);
}

Http::HeaderMap WebSocketMessage::headers() const
std::vector<Wt::Http::Message::Header> WebSocketMessage::headers() const
{
return webSocket()->headers();
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/WebSocketMessage.h
Expand Up @@ -52,7 +52,7 @@ class WT_API WebSocketMessage : public WebRequest
virtual const char * headerValue(const char *name) const;

#ifndef WT_TARGET_JAVA
virtual Http::HeaderMap headers() const;
virtual std::vector<Wt::Http::Message::Header> headers() const;
#endif

virtual bool isWebSocketMessage() const { return true; }
Expand Down

0 comments on commit f411b97

Please sign in to comment.