From 7ccb09b34d108a444d7fa3e26e954a86e5232708 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 19 Nov 2014 17:00:11 +0100 Subject: [PATCH 1/8] Update web-platform-tests. --- tests/wpt/metadata/MANIFEST.json | 98 ++++++++++++++++--- .../Event-dispatch-omitted-capture.html.ini | 5 + tests/wpt/metadata/dom/interfaces.html.ini | 6 ++ ...Implementation-createHTMLDocument.html.ini | 6 +- .../nodes/Document-createAttribute.html.ini | 35 +++++++ .../dom/nodes/Text-constructor.html.ini | 3 + .../metadata/dom/nodes/attributes.html.ini | 36 +++++++ .../document.title-07.html.ini | 2 +- .../wpt/metadata/html/dom/interfaces.html.ini | 3 - tests/wpt/web-platform-tests | 2 +- 10 files changed, 172 insertions(+), 24 deletions(-) create mode 100644 tests/wpt/metadata/dom/events/Event-dispatch-omitted-capture.html.ini create mode 100644 tests/wpt/metadata/dom/nodes/Document-createAttribute.html.ini create mode 100644 tests/wpt/metadata/dom/nodes/Text-constructor.html.ini diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index 00bb855f96b..2f28e88f550 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -1210,6 +1210,12 @@ { "url": "/dom/nodes/ChildNode-remove.js" }, + { + "url": "/dom/nodes/Comment-Text-constructor.js" + }, + { + "url": "/dom/nodes/DOMImplementation-createHTMLDocument.js" + }, { "url": "/dom/nodes/Document-contentType/resources/blob.txt" }, @@ -1237,6 +1243,9 @@ { "url": "/dom/nodes/Document-contentType/support/contenttype_setter.py" }, + { + "url": "/dom/nodes/Document-createComment-createTextNode.js" + }, { "url": "/dom/nodes/Document-createElement-namespace-tests/bare_mathml.xml" }, @@ -1360,6 +1369,9 @@ { "url": "/dom/traversal/unfinished/TODO" }, + { + "url": "/encoding/resources/single-byte-raw.py" + }, { "url": "/eventsource/README.md" }, @@ -2851,6 +2863,12 @@ { "url": "/resource-timing/test_resource_timing.js" }, + { + "url": "/selectors-api/tests/submissions/Opera/Element-matches.js" + }, + { + "url": "/selectors-api/tests/submissions/Opera/ParentNode-find-findAll.js" + }, { "url": "/selectors-api/tests/submissions/Opera/level2-lib.js" }, @@ -2926,6 +2944,9 @@ { "url": "/web-animations/README.md" }, + { + "url": "/web-animations/testcommon.js" + }, { "url": "/webaudio/README.md" }, @@ -4995,6 +5016,9 @@ { "url": "/vibration/pattern-array-manual.html" }, + { + "url": "/vibration/pattern-array-with-0-manual.html" + }, { "url": "/vibration/simple-array-manual.html" }, @@ -9137,6 +9161,9 @@ { "url": "/DOMEvents/event-phases-order.html" }, + { + "url": "/DOMEvents/init-event-while-dispatching.html" + }, { "url": "/DOMEvents/tests/approved/DOM.event.flow.html" }, @@ -9167,15 +9194,9 @@ { "url": "/DOMEvents/tests/approved/Propagation.path.target.removed.html" }, - { - "url": "/DOMEvents/tests/approved/addEventListener.optional.useCapture.html" - }, { "url": "/DOMEvents/tests/approved/dispatchEvent.click.checkbox.html" }, - { - "url": "/DOMEvents/tests/approved/dispatchEvent.return.value.html" - }, { "url": "/DOMEvents/tests/approved/domnodeinserted.html" }, @@ -9218,9 +9239,6 @@ { "url": "/DOMEvents/tests/submissions/Microsoft/converted/Propagation.path.target.removed.html" }, - { - "url": "/DOMEvents/tests/submissions/Microsoft/converted/addEventListener.optional.useCapture.html" - }, { "url": "/DOMEvents/tests/submissions/Microsoft/converted/dispatchEvent.DISPATCH_REQUEST_ERR.html" }, @@ -9233,9 +9251,6 @@ { "url": "/DOMEvents/tests/submissions/Microsoft/converted/dispatchEvent.click.checkbox.html" }, - { - "url": "/DOMEvents/tests/submissions/Microsoft/converted/dispatchEvent.return.value.html" - }, { "url": "/DOMEvents/tests/submissions/Microsoft/converted/domnodeinserted.html" }, @@ -10331,9 +10346,15 @@ { "url": "/XMLHttpRequest/send-data-blob.htm" }, + { + "url": "/XMLHttpRequest/send-data-es-object.htm" + }, { "url": "/XMLHttpRequest/send-data-formdata.htm" }, + { + "url": "/XMLHttpRequest/send-data-unexpected-tostring.htm" + }, { "url": "/XMLHttpRequest/send-entity-body-basic.htm" }, @@ -10838,6 +10859,9 @@ { "url": "/dom/events/Event-defaultPrevented.html" }, + { + "url": "/dom/events/Event-dispatch-omitted-capture.html" + }, { "url": "/dom/events/Event-initEvent.html" }, @@ -10853,6 +10877,9 @@ { "url": "/dom/events/EventTarget-addEventListener.html" }, + { + "url": "/dom/events/EventTarget-dispatchEvent-returnvalue.html" + }, { "url": "/dom/events/EventTarget-dispatchEvent.html" }, @@ -10961,6 +10988,9 @@ { "url": "/dom/nodes/Document-contentType/contentType/xhr_responseType_document.html" }, + { + "url": "/dom/nodes/Document-createAttribute.html" + }, { "url": "/dom/nodes/Document-createComment.html" }, @@ -10982,6 +11012,9 @@ { "url": "/dom/nodes/Document-createProcessingInstruction.xhtml" }, + { + "url": "/dom/nodes/Document-createTextNode.html" + }, { "url": "/dom/nodes/Document-createTreeWalker.html" }, @@ -11231,6 +11264,9 @@ { "url": "/dom/nodes/ProcessingInstruction-literal-2.xhtml" }, + { + "url": "/dom/nodes/Text-constructor.html" + }, { "url": "/dom/nodes/attributes.html" }, @@ -11369,6 +11405,21 @@ { "url": "/domxpath/evaluator-constructor.html" }, + { + "url": "/encoding/gb18030-encoder.html" + }, + { + "url": "/encoding/gbk-encoder.html" + }, + { + "url": "/encoding/iso-2022-jp-decoder.html" + }, + { + "url": "/encoding/iso-2022-jp-encoder.html" + }, + { + "url": "/encoding/single-byte-decoder.html" + }, { "url": "/eventsource/dedicated-worker/eventsource-close.htm" }, @@ -15036,7 +15087,10 @@ "url": "/resource-timing/test_resource_timing.html" }, { - "url": "/selectors-api/tests/submissions/Opera/level2-baseline.html" + "url": "/selectors-api/tests/submissions/Opera/Element-matches.html" + }, + { + "url": "/selectors-api/tests/submissions/Opera/ParentNode-find-findAll.html" }, { "url": "/selectors/attribute-selectors/attribute-case/cssom.html" @@ -15534,10 +15588,19 @@ "url": "/vibration/silent-ignore.html" }, { - "url": "/web-animations/animation-timeline/animation-timeline.html" + "url": "/web-animations/animation-node/animation-node-after.html" }, { - "url": "/web-animations/animation-timeline/idlharness.html" + "url": "/web-animations/animation-node/animation-node-before.html" + }, + { + "url": "/web-animations/animation-node/animation-node-remove.html" + }, + { + "url": "/web-animations/animation-node/animation-node-replace.html" + }, + { + "url": "/web-animations/animation-node/idlharness.html" }, { "url": "/webaudio/the-audio-api/the-audiobuffer-interface/idl-test.html" @@ -16817,6 +16880,9 @@ { "url": "/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-null.html" }, + { + "url": "/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/second-argument-undefined.html" + }, { "url": "/workers/interfaces/DedicatedWorkerGlobalScope/postMessage/setting-postMessage.html" }, @@ -17625,6 +17691,6 @@ "deleted": [], "items": {} }, - "rev": "af1614eee3afcbd5ada2ba2da20535f72de22074", + "rev": "d917e4056a6a126e8edfc266db124923579bb441", "url_base": "/" } \ No newline at end of file diff --git a/tests/wpt/metadata/dom/events/Event-dispatch-omitted-capture.html.ini b/tests/wpt/metadata/dom/events/Event-dispatch-omitted-capture.html.ini new file mode 100644 index 00000000000..5108f7dcd51 --- /dev/null +++ b/tests/wpt/metadata/dom/events/Event-dispatch-omitted-capture.html.ini @@ -0,0 +1,5 @@ +[Event-dispatch-omitted-capture.html] + type: testharness + [EventTarget.addEventListener with the capture argument omitted] + expected: FAIL + diff --git a/tests/wpt/metadata/dom/interfaces.html.ini b/tests/wpt/metadata/dom/interfaces.html.ini index 06fb2a0ebea..77ab75c4e3b 100644 --- a/tests/wpt/metadata/dom/interfaces.html.ini +++ b/tests/wpt/metadata/dom/interfaces.html.ini @@ -1164,3 +1164,9 @@ [DOMTokenList interface object length] expected: FAIL + [Attr interface: attribute nodeValue] + expected: FAIL + + [Attr interface: document.querySelector("[id\]").attributes[0\] must inherit property "nodeValue" with the proper type (5)] + expected: FAIL + diff --git a/tests/wpt/metadata/dom/nodes/DOMImplementation-createHTMLDocument.html.ini b/tests/wpt/metadata/dom/nodes/DOMImplementation-createHTMLDocument.html.ini index 75cf27397ca..62f37b72e10 100644 --- a/tests/wpt/metadata/dom/nodes/DOMImplementation-createHTMLDocument.html.ini +++ b/tests/wpt/metadata/dom/nodes/DOMImplementation-createHTMLDocument.html.ini @@ -1,8 +1,8 @@ [DOMImplementation-createHTMLDocument.html] type: testharness - [DOMImplementation.createHTMLDocument 2] - expected: FAIL - [createHTMLDocument(): URL parsing] expected: FAIL + [createHTMLDocument test 2: undefined,undefined,""] + expected: FAIL + diff --git a/tests/wpt/metadata/dom/nodes/Document-createAttribute.html.ini b/tests/wpt/metadata/dom/nodes/Document-createAttribute.html.ini new file mode 100644 index 00000000000..4c77f8f7b19 --- /dev/null +++ b/tests/wpt/metadata/dom/nodes/Document-createAttribute.html.ini @@ -0,0 +1,35 @@ +[Document-createAttribute.html] + type: testharness + [createAttribute("")] + expected: FAIL + + [createAttribute("invalid^Name")] + expected: FAIL + + [createAttribute("\\\\")] + expected: FAIL + + [createAttribute("\'")] + expected: FAIL + + [createAttribute("\\"")] + expected: FAIL + + [createAttribute("0")] + expected: FAIL + + [createAttribute("0:a")] + expected: FAIL + + [createAttribute("title")] + expected: FAIL + + [createAttribute("TITLE")] + expected: FAIL + + [createAttribute(null)] + expected: FAIL + + [createAttribute(undefined)] + expected: FAIL + diff --git a/tests/wpt/metadata/dom/nodes/Text-constructor.html.ini b/tests/wpt/metadata/dom/nodes/Text-constructor.html.ini new file mode 100644 index 00000000000..77baf056168 --- /dev/null +++ b/tests/wpt/metadata/dom/nodes/Text-constructor.html.ini @@ -0,0 +1,3 @@ +[Text-constructor.html] + type: testharness + expected: TIMEOUT diff --git a/tests/wpt/metadata/dom/nodes/attributes.html.ini b/tests/wpt/metadata/dom/nodes/attributes.html.ini index f3e1c5bcdf8..e5932c51a18 100644 --- a/tests/wpt/metadata/dom/nodes/attributes.html.ini +++ b/tests/wpt/metadata/dom/nodes/attributes.html.ini @@ -15,3 +15,39 @@ [Attribute with prefix in local name] expected: FAIL + [setAttribute should not change the order of previously set attributes.] + expected: FAIL + + [setAttribute should set the first attribute with the given name] + expected: FAIL + + [null and the empty string should result in a null namespace.] + expected: FAIL + + [XML-namespaced attributes don\'t need an xml prefix] + expected: FAIL + + [xmlns should be allowed as local name] + expected: FAIL + + [xmlns should be allowed as prefix in the XMLNS namespace] + expected: FAIL + + [xmlns should be allowed as qualified name in the XMLNS namespace] + expected: FAIL + + [Setting the same attribute with another prefix should not change the prefix] + expected: FAIL + + [Attributes should work in document fragments.] + expected: FAIL + + [Attribute values should not be parsed.] + expected: FAIL + + [Specified attributes should be accessible.] + expected: FAIL + + [Entities in attributes should have been expanded while parsing.] + expected: FAIL + diff --git a/tests/wpt/metadata/html/dom/documents/dom-tree-accessors/document.title-07.html.ini b/tests/wpt/metadata/html/dom/documents/dom-tree-accessors/document.title-07.html.ini index c4a8b2f89ac..5fd8e536466 100644 --- a/tests/wpt/metadata/html/dom/documents/dom-tree-accessors/document.title-07.html.ini +++ b/tests/wpt/metadata/html/dom/documents/dom-tree-accessors/document.title-07.html.ini @@ -1,5 +1,5 @@ [document.title-07.html] type: testharness - [Document.title and DOMImplementation.createHTMLDocument 2] + [createHTMLDocument test 2: undefined,undefined,""] expected: FAIL diff --git a/tests/wpt/metadata/html/dom/interfaces.html.ini b/tests/wpt/metadata/html/dom/interfaces.html.ini index f61d940b9b2..ab0e440c3e4 100644 --- a/tests/wpt/metadata/html/dom/interfaces.html.ini +++ b/tests/wpt/metadata/html/dom/interfaces.html.ini @@ -282,9 +282,6 @@ [Document interface: attribute onwaiting] expected: FAIL - [Document must be primary interface of iframe.contentDocument] - expected: FAIL - [Stringification of iframe.contentDocument] expected: FAIL diff --git a/tests/wpt/web-platform-tests b/tests/wpt/web-platform-tests index f1d7cb0983f..d917e4056a6 160000 --- a/tests/wpt/web-platform-tests +++ b/tests/wpt/web-platform-tests @@ -1 +1 @@ -Subproject commit f1d7cb0983f5ca81ba7bd49b587156b949a6b367 +Subproject commit d917e4056a6a126e8edfc266db124923579bb441 From 37583ea8f5352f14dd39c3ad7c365fd7d1c3ea76 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 12 Nov 2014 15:13:19 -0500 Subject: [PATCH 2/8] embedding: add some commonly used string constants from chromium --- ports/cef/lib.rs | 1 + ports/cef/switches.rs | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 ports/cef/switches.rs diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index cd96f974d6c..5391c571799 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -54,6 +54,7 @@ pub mod string; pub mod string_list; pub mod string_map; pub mod string_multimap; +pub mod switches; pub mod task; pub mod types; pub mod urlrequest; diff --git a/ports/cef/switches.rs b/ports/cef/switches.rs new file mode 100644 index 00000000000..0638397ae65 --- /dev/null +++ b/ports/cef/switches.rs @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// values taken from chromium/base/base_switches.cc + +// Disables the crash reporting. +pub static KDISABLEBREAKPAD: &'static str = "disable-breakpad"; + +// Indicates that crash reporting should be enabled. On platforms where helper +// processes cannot access to files needed to make this decision, this flag is +// generated internally. +pub static KENABLECRASHREPORTER: &'static str = "enable-crash-reporter"; + +// Generates full memory crash dump. +pub static KFULLMEMORYCRASHREPORT: &'static str = "full-memory-crash-report"; + +// The value of this switch determines whether the process is started as a +// renderer or plugin host. If it's empty, it's the browser. +pub static KPROCESSTYPE: &'static str = "type"; + +// Suppresses all error dialogs when present. +pub static KNOERRDIALOGS: &'static str = "noerrdialogs"; + +// When running certain tests that spawn child processes, this switch indicates +// to the test framework that the current process is a child process. +pub static KTESTCHILDPROCESS: &'static str = "test-child-process"; + +// Gives the default maximal active V-logging level; 0 is the default. +// Normally positive values are used for V-logging levels. +pub static KV: &'static str = "v"; + +// Gives the per-module maximal V-logging levels to override the value +// given by --v. E.g. "my_module=2,foo*=3" would change the logging +// level for all code in source files "my_module.*" and "foo*.*" +// ("-inl" suffixes are also disregarded for this matching). +// +// Any pattern containing a forward or backward slash will be tested +// against the whole pathname and not just the module. E.g., +// "*/foo/bar/*=2" would change the logging level for all code in +// source files under a "foo/bar" directory. +pub static KVMODULE: &'static str = "vmodule"; + +// Will wait for 60 seconds for a debugger to come to attach to the process. +pub static KWAITFORDEBUGGER: &'static str = "wait-for-debugger"; + +// Sends a pretty-printed version of tracing info to the console. +pub static KTRACETOCONSOLE: &'static str = "trace-to-console"; + +// Configure whether chrome://profiler will contain timing information. This +// option is enabled by default. A value of "0" will disable profiler timing, +// while all other values will enable it. +pub static KPROFILERTIMING: &'static str = "profiler-timing"; +// Value of the --profiler-timing flag that will disable timing information for +// chrome://profiler. +pub static KPROFILERTIMINGDISABLEDVALUE: &'static str = "0"; From b0a65f491855dd6204f6c75e624a5f4f6217a5e2 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 16:41:44 -0500 Subject: [PATCH 3/8] embedding: implement cef_execute_process() stub this is missing signal handler functionality in rust and we currently have no use case for actual execution of secondary processes --- ports/cef/core.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ports/cef/core.rs b/ports/cef/core.rs index 69960b146bc..f566ee83c33 100644 --- a/ports/cef/core.rs +++ b/ports/cef/core.rs @@ -6,11 +6,14 @@ use command_line::command_line_init; use geom::size::TypedSize2D; use glfw_app; +use libc::funcs::c95::string::strlen; use libc::{c_int, c_void}; use native; use servo::Browser; use servo_util::opts; use servo_util::opts::OpenGL; +use std::slice; +use switches::{KPROCESSTYPE, KWAITFORDEBUGGER}; use types::{cef_app_t, cef_main_args_t, cef_settings_t}; #[no_mangle] @@ -84,9 +87,31 @@ pub extern "C" fn cef_quit_message_loop() { } #[no_mangle] -pub extern "C" fn cef_execute_process(_args: *const cef_main_args_t, +pub extern "C" fn cef_execute_process(args: *const cef_main_args_t, _app: *mut cef_app_t, _windows_sandbox_info: *mut c_void) -> c_int { + unsafe { + if args.is_null() { + println!("args must be passed"); + return -1; + } + for i in range(0u, (*args).argc as uint) { + let u = (*args).argv.offset(i as int) as *const u8; + slice::raw::buf_as_slice(u, strlen(u as *const i8) as uint, |s| { + if s.starts_with("--".as_bytes()) { + if s.slice_from(2) == KWAITFORDEBUGGER.as_bytes() { + //FIXME: this is NOT functionally equivalent to chromium! + + //this should be a pause() call with an installed signal + //handler callback, something which is impossible now in rust + } else if s.slice_from(2) == KPROCESSTYPE.as_bytes() { + //TODO: run other process now + } + } + }); + } + } + //process type not specified, must be browser process (NOOP) -1 } From 031963c91ed357c7ec1fdd6c9227e6098f167e9a Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:02:55 -0500 Subject: [PATCH 4/8] embedding: cef_string_wide_cmp() --- ports/cef/string.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 9f3baac8f10..650407f1d20 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -222,3 +222,18 @@ pub extern "C" fn cef_string_wide_set(src: *const wchar_t, src_len: size_t, outp } return 1; } + +#[no_mangle] +pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef_string_wide_t) -> c_int { + unsafe { + slice::raw::buf_as_slice((*a).str as *const wchar_t, (*a).length as uint, |astr:&[wchar_t]| { + slice::raw::buf_as_slice((*b).str as *const wchar_t, (*b).length as uint, |bstr:&[wchar_t]| { + match astr.cmp(bstr) { + Less => -1, + Equal => 0, + Greater => 1 + } + }) + }) + } +} From 8b5f4cff3d52c3d3439c40e372815a207e9ab5a3 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:31:23 -0500 Subject: [PATCH 5/8] embedding: cef_string_utf8_to_wide() --- ports/cef/string.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 650407f1d20..0d0453fa438 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -237,3 +237,14 @@ pub extern "C" fn cef_string_wide_cmp(a: *const cef_string_wide_t, b: *const cef }) } } + +#[no_mangle] +pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { + if mem::size_of::() == mem::size_of::() { + return cef_string_utf8_to_utf16(src, src_len, output as *mut cef_string_utf16_t); + } + slice_to_str(src, src_len as uint, |result| { + let conv = result.chars().map(|c| c as u32).collect::>(); + cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) + }) +} From bd5419418eaeba788a133a4b65a6721df050a23c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:31:45 -0500 Subject: [PATCH 6/8] embedding: cef_string_wide_to_utf8() --- ports/cef/string.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 0d0453fa438..e407efed52b 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -7,6 +7,7 @@ use eutil::slice_to_str; use libc::{size_t, c_int, c_ushort,c_void}; use libc::types::os::arch::c95::wchar_t; use mem::{new0,newarray0,delete,deletearray}; +use std::char; use std::mem; use std::ptr; use std::slice; @@ -248,3 +249,16 @@ pub extern "C" fn cef_string_utf8_to_wide(src: *const u8, src_len: size_t, outpu cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) }) } + +#[no_mangle] +pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, output: *mut cef_string_utf8_t) -> c_int { + if mem::size_of::() == mem::size_of::() { + return cef_string_utf16_to_utf8(src as *const u16, src_len, output); + } + unsafe { + slice::raw::buf_as_slice(src, src_len as uint, |ustr| { + let conv = ustr.iter().map(|&c| char::from_u32(c as u32).unwrap_or('\uFFFD')).collect::(); + cef_string_utf8_set(conv.as_bytes().as_ptr(), conv.len() as size_t, output, 1) + }) + } +} From 0d21a68ee7679e1894bf66da2c5f5ed42ac8c36d Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:32:02 -0500 Subject: [PATCH 7/8] embedding: cef_string_ascii_to_utf16() --- ports/cef/string.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index e407efed52b..f71e7e67611 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -262,3 +262,11 @@ pub extern "C" fn cef_string_wide_to_utf8(src: *const wchar_t, src_len: size_t, }) } } + +#[no_mangle] +pub extern "C" fn cef_string_ascii_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int { + slice_to_str(src, src_len as uint, |result| { + let conv = result.utf16_units().collect::>(); + cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1) + }) +} From c8da9e1a5471b2407502a152c625ab8b8fb0d1e8 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 17 Nov 2014 19:32:18 -0500 Subject: [PATCH 8/8] embedding: cef_string_ascii_to_wide() --- ports/cef/string.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index f71e7e67611..ce31c4330eb 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -270,3 +270,13 @@ pub extern "C" fn cef_string_ascii_to_utf16(src: *const u8, src_len: size_t, out cef_string_utf16_set(conv.as_ptr(), conv.len() as size_t, output, 1) }) } + +#[no_mangle] +pub extern "C" fn cef_string_ascii_to_wide(src: *const u8, src_len: size_t, output: *mut cef_string_wide_t) -> c_int { + unsafe { + slice::raw::buf_as_slice(src, src_len as uint, |ustr| { + let conv = ustr.iter().map(|&c| c as u8).collect::>(); + cef_string_wide_set(conv.as_ptr() as *const wchar_t, conv.len() as size_t, output, 1) + }) + } +}