Skip to content

Commit

Permalink
* 修复BachEdito在delphi里,右键粘贴会卡死的问题
Browse files Browse the repository at this point in the history
原因是右键菜单里没走一遍心跳代码,而BachEdito的js,在onContextMenu的setTimeout里做了很多事情。
例如会把隐藏的用来接受文字的textArea清空。如果不走心跳代码,逻辑很多都不正常了。
但奇怪的是,wkexe下反而会先执行一次wm_timer,导致执行了心跳代码。delphi里可能这个消息的优先级不高,所以把问题
暴露出来了。
  • Loading branch information
weolar committed Nov 27, 2018
1 parent 6c75a2b commit fab34d8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 40 deletions.
4 changes: 4 additions & 0 deletions content/ui/ContextMeun.h
Expand Up @@ -2,6 +2,7 @@
#define content_browser_ContextMeun_h

#include "content/browser/WebPage.h"
#include "content/web_impl_win/WebThreadImpl.h"
#include "third_party/WebKit/Source/web/WebViewImpl.h"
#include "third_party/WebKit/Source/platform/Timer.h"
#include "third_party/WebKit/public/web/WebContextMenuData.h"
Expand Down Expand Up @@ -127,6 +128,9 @@ class ContextMenu {

void onCommand(UINT itemID)
{
content::WebThreadImpl* threadImpl = (content::WebThreadImpl*)(blink::Platform::current()->currentThread());
threadImpl->fire();

if (kCopySelectedTextId == itemID) {
m_webPage->webViewImpl()->focusedFrame()->executeCommand("Copy");
} else if (kCopyImageId == itemID) {
Expand Down
19 changes: 18 additions & 1 deletion net/WebURLLoaderInternal.h
Expand Up @@ -102,16 +102,33 @@ class WebURLLoaderInternal : public JobHead {
WebURLLoaderImplCurl* loader() { return m_loader; }
void setLoader(WebURLLoaderImplCurl* loader) { m_loader = loader; }

blink::WebURLRequest* firstRequest() { return m_firstRequest; }
blink::WebURLRequest* firstRequest()
{
#ifndef MINIBLINK_NO_MULTITHREAD_NET
RELEASE_ASSERT(WTF::isMainThread());
#endif
return m_firstRequest;
}

void resetFirstRequest(blink::WebURLRequest* newRequest)
{
#ifndef MINIBLINK_NO_MULTITHREAD_NET
RELEASE_ASSERT(WTF::isMainThread() && m_firstRequest);
#endif
delete m_firstRequest;
m_firstRequest = newRequest;
}

bool isCancelled() const { return kNoCancelled != m_cancelledReason; }

public:
WebURLLoaderClient* m_client;
bool m_isSynchronous;

private:
blink::WebURLRequest* m_firstRequest;

public:
String m_lastHTTPMethod;

// Suggested credentials for the current redirection step.
Expand Down
53 changes: 17 additions & 36 deletions net/WebURLLoaderManager.cpp
Expand Up @@ -1257,6 +1257,7 @@ void WebURLLoaderManager::dispatchSynchronousJobOnIoThread(WebURLLoaderInternal*
}

#if (defined ENABLE_WKE) && (ENABLE_WKE == 1)

static bool dispatchWkeLoadUrlBegin(WebURLLoaderInternal* job, InitializeHandleInfo* info)
{
RequestExtraData* requestExtraData = reinterpret_cast<RequestExtraData*>(job->firstRequest()->extraData());
Expand All @@ -1273,27 +1274,14 @@ static bool dispatchWkeLoadUrlBegin(WebURLLoaderInternal* job, InitializeHandleI

return job->m_isWkeNetSetDataBeSetted || b;
}

#endif

void WebURLLoaderManager::applyAuthenticationToRequest(WebURLLoaderInternal* handle, blink::WebURLRequest* request)
void WebURLLoaderManager::applyAuthenticationToRequest(WebURLLoaderInternal* handle)
{
// m_user/m_pass are credentials given manually, for instance, by the arguments passed to XMLHttpRequest.open().
WebURLLoaderInternal* job = handle;
//
// if (handle->shouldUseCredentialStorage()) {
// if (job->m_user.isEmpty() && job->m_pass.isEmpty()) {
// // <rdar://problem/7174050> - For URLs that match the paths of those previously challenged for HTTP Basic authentication,
// // try and reuse the credential preemptively, as allowed by RFC 2617.
// job->m_initialCredential = CredentialStorage::defaultCredentialStorage().get(request.url());
// } else {
// // If there is already a protection space known for the KURL, update stored credentials
// // before sending a request. This makes it possible to implement logout by sending an
// // XMLHttpRequest with known incorrect credentials, and aborting it immediately (so that
// // an authentication dialog doesn't pop up).
// CredentialStorage::defaultCredentialStorage().set(Credential(job->m_user, job->m_pass, CredentialPersistenceNone), request.url());
// }
// }
//

String user = job->m_user;
String password = job->m_pass;

Expand All @@ -1316,7 +1304,7 @@ InitializeHandleInfo* WebURLLoaderManager::preInitializeHandleOnMainThread(WebUR
{
InitializeHandleInfo* info = new InitializeHandleInfo();
KURL url = job->firstRequest()->url();

// Remove any fragment part, otherwise curl will send it as part of the request.
url.removeFragmentIdentifier();
String urlString = url.string();
Expand All @@ -1333,8 +1321,12 @@ InitializeHandleInfo* WebURLLoaderManager::preInitializeHandleOnMainThread(WebUR
}

info->url = WTF::ensureStringToUTF8(urlString, true).data();

info->method = job->firstRequest()->httpMethod().utf8();

#ifdef MINIBLINK_NO_MULTITHREAD_NET
ASSERT(!job->m_url); // url must remain valid through the request
job->m_url = fastStrDup(info->url.c_str()); // url is in ASCII so latin1() will only convert it to char* without character translation.
#endif

String contentType = job->firstRequest()->httpHeaderField("Content-Type");
if (WTF::kNotFound != url.host().find("huobi.pro") && "POST" == info->method && job->firstRequest()->httpBody().isNull())
Expand Down Expand Up @@ -1437,31 +1429,21 @@ void WebURLLoaderManager::initializeHandleOnIoThread(int jobId, InitializeHandle

if (!m_certificatePath.isNull())
curl_easy_setopt(job->m_handle, CURLOPT_CAINFO, m_certificatePath.data());

curl_easy_setopt(job->m_handle, CURLOPT_ENCODING, ""); // enable gzip and deflate through Accept-Encoding:

// enable gzip and deflate through Accept-Encoding:
curl_easy_setopt(job->m_handle, CURLOPT_ENCODING, "");

// url must remain valid through the request
ASSERT(!job->m_url);

// url is in ASCII so latin1() will only convert it to char* without character translation.
job->m_url = fastStrDup(info->url.c_str());
#ifndef MINIBLINK_NO_MULTITHREAD_NET
ASSERT(!job->m_url); // url must remain valid through the request
job->m_url = fastStrDup(info->url.c_str()); // url is in ASCII so latin1() will only convert it to char* without character translation.
#endif

KURL url = job->firstRequest()->url();
String urlString = job->m_url;
//ASSERT(url.string() == urlString);

curl_easy_setopt(job->m_handle, CURLOPT_URL, job->m_url);

std::string cookieJarFullPath;
if (job->m_pageNetExtraData) {
cookieJarFullPath = job->m_pageNetExtraData->getCookieJarFullPath();
} else {
// WTF::Mutex* mutex = sharedResourceMutex(CURL_LOCK_DATA_COOKIE);
// WTF::Locker<WTF::Mutex> locker(*mutex);
// const char* cookieJarPathString = cookieJarPath();
// if (cookieJarPathString && '\0' != cookieJarPathString[0])
// cookieJarFileName = cookieJarPathString;
cookieJarFullPath = m_shareCookieJar->getCookieJarFullPath();
}

Expand Down Expand Up @@ -1490,8 +1472,7 @@ void WebURLLoaderManager::initializeHandleOnIoThread(int jobId, InitializeHandle
}

// curl_easy_setopt(job->m_handle, CURLOPT_USERPWD, ":");

applyAuthenticationToRequest(job, job->firstRequest());
applyAuthenticationToRequest(job);

#if (defined ENABLE_WKE) && (ENABLE_WKE == 1)
if (info->proxy.size()) {
Expand Down
2 changes: 1 addition & 1 deletion net/WebURLLoaderManager.h
Expand Up @@ -135,7 +135,7 @@ class WebURLLoaderManager {
bool downloadOnIoThread();
void removeFromCurlOnIoThread(int jobId);

void applyAuthenticationToRequest(WebURLLoaderInternal*, blink::WebURLRequest*);
void applyAuthenticationToRequest(WebURLLoaderInternal* job);

int initializeHandleOnMainThread(WebURLLoaderInternal* job);
void initializeHandleOnIoThread(int jobId, InitializeHandleInfo* info);
Expand Down
3 changes: 1 addition & 2 deletions net/WebURLLoaderManagerMainTask.h
Expand Up @@ -565,8 +565,7 @@ static void doRedirect(WebURLLoaderInternal* job, const String& location, MainTa
if (isRedirectByHttpCode)
job->m_response.initialize();

delete job->m_firstRequest;
job->m_firstRequest = redirectedRequest;
job->resetFirstRequest(redirectedRequest);
}

static bool setHttpResponseDataToJobWhenDidReceiveResponseOnMainThread(WebURLLoaderInternal* job, MainTaskArgs* args)
Expand Down

0 comments on commit fab34d8

Please sign in to comment.