本文整理汇总了C++中webcore::String::length方法的典型用法代码示例。如果您正苦于以下问题:C++ String::length方法的具体用法?C++ String::length怎么用?C++ String::length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webcore::String
的用法示例。
在下文中一共展示了String::length方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: value
HRESULT STDMETHODCALLTYPE DOMHTMLTextAreaElement::value(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && m_element->hasTagName(textareaTag));
HTMLTextAreaElement* textareaElement = static_cast<HTMLTextAreaElement*>(m_element);
WebCore::String valueString = textareaElement->value();
*result = BString(valueString.characters(), valueString.length()).release();
if (valueString.length() && !*result)
return E_OUTOFMEMORY;
return S_OK;
}
示例2: getPropertyValue
HRESULT STDMETHODCALLTYPE DOMCSSStyleDeclaration::getPropertyValue(
/* [in] */ BSTR propertyName,
/* [retval][out] */ BSTR* result)
{
WebCore::String propertyNameString(propertyName);
WebCore::String value = m_style->getPropertyValue(propertyNameString);
*result = SysAllocStringLen(value.characters(), value.length());
if (value.length() && !*result)
return E_OUTOFMEMORY;
return S_OK;
}
示例3: write_string
static void write_string(WTF::Vector<char>& v, const WebCore::String& str)
{
unsigned strLen = str.length();
// Only do work if the string has data.
if (strLen) {
// Determine how much to grow the vector. Use the worst case for utf8 to
// avoid reading the string twice. Add sizeof(unsigned) to hold the
// string length in utf8.
unsigned vectorLen = v.size() + sizeof(unsigned);
unsigned length = (strLen << 2) + vectorLen;
// Grow the vector. This will change the value of v.size() but we
// remember the original size above.
v.grow(length);
// Grab the position to write to.
char* data = v.begin() + vectorLen;
// Write the actual string
int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
LOGV("Writing string %d %.*s", l, l, data);
// Go back and write the utf8 length. Subtract sizeof(unsigned) from
// data to get the position to write the length.
memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
// Shrink the internal state of the vector so we match what was
// actually written.
v.shrink(vectorLen + l);
} else
v.append((char*)&strLen, sizeof(unsigned));
}
示例4: malloc
static const char* anp_getApplicationDataDirectory() {
if (NULL == gApplicationDataDir) {
PluginClient* client = JavaSharedClient::GetPluginClient();
if (!client)
return NULL;
WebCore::String path = client->getPluginSharedDataDirectory();
int length = path.length();
if (length == 0)
return NULL;
char* storage = (char*) malloc(length + 1);
if (NULL == storage)
return NULL;
memcpy(storage, path.utf8().data(), length);
storage[length] = '\0';
// save this assignment for last, so that if multiple threads call us
// (which should never happen), we never return an incomplete global.
// At worst, we would allocate storage for the path twice.
gApplicationDataDir = storage;
}
return gApplicationDataDir;
}
示例5: RedirectedToUrl
jstring WebCoreResourceLoader::RedirectedToUrl(JNIEnv* env, jobject obj,
jstring baseUrl, jstring redirectTo, jint nativeResponse)
{
#ifdef ANDROID_INSTRUMENT
TimeCounterAuto counter(TimeCounter::ResourceTimeCounter);
#endif
LOGV("webcore_resourceloader redirectedToUrl");
WebCore::ResourceHandle* handle = GET_NATIVE_HANDLE(env, obj);
LOG_ASSERT(handle, "nativeRedirectedToUrl must take a valid handle!");
// ResourceLoader::didFail() can set handle to be NULL, we need to check
if (!handle)
return NULL;
LOG_ASSERT(handle->client(), "Why do we not have a client?");
WebCore::ResourceRequest r = handle->request();
WebCore::KURL url(WebCore::KURL(WebCore::ParsedURLString, to_string(env, baseUrl)),
to_string(env, redirectTo));
r.setURL(url);
if (r.httpMethod() == "POST") {
r.setHTTPMethod("GET");
r.clearHTTPReferrer();
r.setHTTPBody(0);
r.setHTTPContentType("");
}
WebCore::ResourceResponse* response = (WebCore::ResourceResponse*)nativeResponse;
// If the url fails to resolve the relative path, return null.
if (url.protocol().isEmpty()) {
delete response;
return NULL;
}
handle->client()->willSendRequest(handle, r, *response);
delete response;
WebCore::String s = url.string();
return env->NewString((unsigned short*)s.characters(), s.length());
}
示例6: GetOrigins
static jobject GetOrigins(JNIEnv* env, jobject obj)
{
Vector<RefPtr<WebCore::SecurityOrigin> > coreOrigins;
WebCore::DatabaseTracker::tracker().origins(coreOrigins);
Vector<WebCore::KURL> manifestUrls;
if (WebCore::cacheStorage().manifestURLs(&manifestUrls)) {
int size = manifestUrls.size();
for (int i = 0; i < size; ++i) {
RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]);
if (manifestOrigin.get() == 0)
continue;
coreOrigins.append(manifestOrigin);
}
}
jclass setClass = env->FindClass("java/util/HashSet");
jmethodID cid = env->GetMethodID(setClass, "<init>", "()V");
jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z");
jobject set = env->NewObject(setClass, cid);
for (unsigned i = 0; i < coreOrigins.size(); ++i) {
WebCore::SecurityOrigin* origin = coreOrigins[i].get();
WebCore::String url = origin->toString();
jstring jUrl = env->NewString(url.characters(), url.length());
env->CallBooleanMethod(set, mid, jUrl);
env->DeleteLocalRef(jUrl);
}
return set;
}
示例7: method
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && m_element->hasTagName(formTag));
WebCore::String methodString = static_cast<HTMLFormElement*>(m_element)->method();
*result = BString(methodString.characters(), methodString.length()).release();
return S_OK;
}
示例8: innerText
HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && m_element->isHTMLElement());
WebCore::String innerTextString = static_cast<HTMLElement*>(m_element)->innerText();
*result = BString(innerTextString.characters(), innerTextString.length()).release();
return S_OK;
}
示例9: willLoadFromCache
/*
* This static method is called to check to see if a POST response is in
* the cache. This may be slow, but is only used during a navigation to
* a POST response.
*/
bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
WebCore::String urlStr = url.string();
jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length());
jclass resourceLoader = env->FindClass("android/webkit/LoadListener");
bool val = env->CallStaticBooleanMethod(resourceLoader,
gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier);
checkException(env);
env->DeleteLocalRef(jUrlStr);
return val;
}
示例10: isValidProtocolString
static bool isValidProtocolString(const WebCore::String& protocol)
{
if (protocol.isNull())
return true;
if (protocol.isEmpty())
return false;
const UChar* characters = protocol.characters();
for (size_t i = 0; i < protocol.length(); i++) {
if (characters[i] < 0x21 || characters[i] > 0x7E)
return false;
}
return true;
}
示例11: Sync
//.........这里部分代码省略.........
s->setDefaultFixedFontSize(size);
jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically);
s->setLoadsImagesAutomatically(flag);
if (flag)
docLoader->setAutoLoadImages(true);
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage);
s->setBlockNetworkImage(flag);
if(!flag)
docLoader->setBlockNetworkImage(false);
#endif
flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
s->setJavaScriptEnabled(flag);
// ON = 0
// ON_DEMAND = 1
// OFF = 2
jobject pluginState = env->GetObjectField(obj, gFieldIds->mPluginState);
int state = env->CallIntMethod(pluginState, gFieldIds->mOrdinal);
s->setPluginsEnabled(state < 2);
#ifdef ANDROID_PLUGINS
s->setPluginsOnDemand(state == 1);
#endif
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
s->setOfflineWebApplicationCacheEnabled(flag);
str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath);
if (str) {
WebCore::String path = to_string(env, str);
if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) {
WebCore::cacheStorage().setCacheDirectory(path);
// This database is created on the first load. If the file
// doesn't exist, we create it and set its permissions. The
// filename must match that in ApplicationCacheStorage.cpp.
String filename = pathByAppendingComponent(path, "ApplicationCache.db");
int fd = open(filename.utf8().data(), O_CREAT | O_EXCL, permissionFlags660);
if (fd >= 0)
close(fd);
}
}
jlong maxsize = env->GetIntField(obj, gFieldIds->mAppCacheMaxSize);
WebCore::cacheStorage().setMaximumSize(maxsize);
#endif
flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptCanOpenWindowsAutomatically);
s->setJavaScriptCanOpenWindowsAutomatically(flag);
#ifdef ANDROID_LAYOUT
flag = env->GetBooleanField(obj, gFieldIds->mUseWideViewport);
s->setUseWideViewport(flag);
#endif
#ifdef ANDROID_MULTIPLE_WINDOWS
flag = env->GetBooleanField(obj, gFieldIds->mSupportMultipleWindows);
s->setSupportMultipleWindows(flag);
#endif
flag = env->GetBooleanField(obj, gFieldIds->mShrinksStandaloneImagesToFit);
s->setShrinksStandaloneImagesToFit(flag);
#if ENABLE(DATABASE)
flag = env->GetBooleanField(obj, gFieldIds->mDatabaseEnabled);
s->setDatabasesEnabled(flag);
示例12: Sync
static void Sync(JNIEnv* env, jobject obj, jint frame)
{
WebCore::Frame* pFrame = (WebCore::Frame*)frame;
LOG_ASSERT(pFrame, "%s must take a valid frame pointer!", __FUNCTION__);
WebCore::Settings* s = pFrame->settings();
if (!s)
return;
WebCore::DocLoader* docLoader = pFrame->document()->docLoader();
#ifdef ANDROID_LAYOUT
jobject layout = env->GetObjectField(obj, gFieldIds->mLayoutAlgorithm);
WebCore::Settings::LayoutAlgorithm l = (WebCore::Settings::LayoutAlgorithm)
env->CallIntMethod(layout, gFieldIds->mOrdinal);
if (s->layoutAlgorithm() != l) {
s->setLayoutAlgorithm(l);
if (pFrame->document()) {
pFrame->document()->updateStyleSelector();
if (pFrame->document()->renderer()) {
recursiveCleanupForFullLayout(pFrame->document()->renderer());
LOG_ASSERT(pFrame->view(), "No view for this frame when trying to relayout");
pFrame->view()->layout();
// FIXME: This call used to scroll the page to put the focus into view.
// It worked on the WebViewCore, but now scrolling is done outside of the
// WebViewCore, on the UI side, so there needs to be a new way to do this.
//pFrame->makeFocusVisible();
}
}
}
#endif
jobject textSize = env->GetObjectField(obj, gFieldIds->mTextSize);
float zoomFactor = env->GetIntField(textSize, gFieldIds->mTextSizeValue) / 100.0f;
if (pFrame->zoomFactor() != zoomFactor)
pFrame->setZoomFactor(zoomFactor, /*isTextOnly*/true);
jstring str = (jstring)env->GetObjectField(obj, gFieldIds->mStandardFontFamily);
s->setStandardFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mFixedFontFamily);
s->setFixedFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mSansSerifFontFamily);
s->setSansSerifFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mSerifFontFamily);
s->setSerifFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mCursiveFontFamily);
s->setCursiveFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mFantasyFontFamily);
s->setFantasyFontFamily(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mDefaultTextEncoding);
s->setDefaultTextEncodingName(to_string(env, str));
str = (jstring)env->GetObjectField(obj, gFieldIds->mUserAgent);
WebFrame::getWebFrame(pFrame)->setUserAgent(to_string(env, str));
jint size = env->GetIntField(obj, gFieldIds->mMinimumFontSize);
s->setMinimumFontSize(size);
size = env->GetIntField(obj, gFieldIds->mMinimumLogicalFontSize);
s->setMinimumLogicalFontSize(size);
size = env->GetIntField(obj, gFieldIds->mDefaultFontSize);
s->setDefaultFontSize(size);
size = env->GetIntField(obj, gFieldIds->mDefaultFixedFontSize);
s->setDefaultFixedFontSize(size);
jboolean flag = env->GetBooleanField(obj, gFieldIds->mLoadsImagesAutomatically);
s->setLoadsImagesAutomatically(flag);
if (flag)
docLoader->setAutoLoadImages(true);
#ifdef ANDROID_BLOCK_NETWORK_IMAGE
flag = env->GetBooleanField(obj, gFieldIds->mBlockNetworkImage);
s->setBlockNetworkImage(flag);
if(!flag)
docLoader->setBlockNetworkImage(false);
#endif
flag = env->GetBooleanField(obj, gFieldIds->mJavaScriptEnabled);
s->setJavaScriptEnabled(flag);
flag = env->GetBooleanField(obj, gFieldIds->mPluginsEnabled);
s->setPluginsEnabled(flag);
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
flag = env->GetBooleanField(obj, gFieldIds->mAppCacheEnabled);
s->setOfflineWebApplicationCacheEnabled(flag);
str = (jstring)env->GetObjectField(obj, gFieldIds->mAppCachePath);
if (str) {
WebCore::String path = to_string(env, str);
if (path.length() && WebCore::cacheStorage().cacheDirectory().isNull()) {
WebCore::cacheStorage().setCacheDirectory(path);
}
}
jlong maxsize = env->GetIntField(obj, gFieldIds->mAppCacheMaxSize);
WebCore::cacheStorage().setMaximumSize(maxsize);
//.........这里部分代码省略.........