Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding: revenge of cargo #6175

Merged
merged 27 commits into from May 27, 2015
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d7ad5d6
add cef method for notifying the main loop of work available
May 19, 2015
83e605d
add no_mangle to servo_test() embedding function
May 19, 2015
af1dce5
add new browser process interface method for main loop integration
May 19, 2015
caa8172
implement cef browser title setting callback
May 19, 2015
cf388cd
call compositor.window.set_page_url() on WindowEvent::LoadUrl
May 19, 2015
92d44fb
send ChangeUrl message from constellation on init
May 19, 2015
02606fa
implement on_address_change handler for cef port
May 19, 2015
a809d6b
remove unused cef imports
May 19, 2015
efc75ef
ignore KEYEVENT_RAWKEYDOWN in cef browser events
May 21, 2015
28aed52
improve cef keyboard handling
May 21, 2015
1e4ceb0
more accurately handle key modifiers in cef
May 21, 2015
cd9dab7
implement cef_load_handler::on_load_start()
May 22, 2015
3481c75
add CompositorMsg::LoadStart, implement cef_load_handler::on_loading_…
May 22, 2015
0d46a3b
add navigation state data to LoadComplete messages, finish cef load s…
May 22, 2015
3f8d8a3
add back/forward/loading members to ServoCefBrowser with related brow…
May 22, 2015
68fc512
add error enum for chromium net errors, create window method for erro…
May 26, 2015
8e78feb
make cef_errorcode_t a typedef for net::NetError
May 26, 2015
14a6390
add embedding method for load_handler::on_load_error
May 26, 2015
90169e8
force resize after sending cef_browser::on_after_created() callback
May 26, 2015
aef3218
Revert "temp re-set default url for cef while I figure out wtf is goi…
May 26, 2015
64ff2c4
handle early LoadURL messages without panicking by sending initial ur…
May 26, 2015
45116dc
break out cef app wakeup code into separate pub function
May 27, 2015
fcf4495
handle case of deleted pipeline when preparing to send load_end const…
May 27, 2015
b1ae5e7
make Opts.url an Option<> type, only emit initial url load if url exists
May 27, 2015
81eb426
when creating a cef browser, setup the url to load but don't load it
May 27, 2015
ca1f49a
spawn a task for cef async browser creation to kick the main loop awake
May 27, 2015
8c278d3
fix glutin headless compile errors
May 27, 2015
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -384,7 +384,11 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.scroll_fragment_to_point(pipeline_id, layer_id, point);
}

(Msg::LoadComplete, ShutdownState::NotShuttingDown) => {
(Msg::LoadStart(back, forward), ShutdownState::NotShuttingDown) => {
self.window.load_start(back, forward);
}

(Msg::LoadComplete(back, forward), ShutdownState::NotShuttingDown) => {
self.got_load_complete_message = true;

// If we're painting in headless mode, schedule a recomposite.
@@ -395,7 +399,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
// Inform the embedder that the load has finished.
//
// TODO(pcwalton): Specify which frame's load completed.
self.window.load_end();
self.window.load_end(back, forward);
}

(Msg::ScrollTimeout(timestamp), ShutdownState::NotShuttingDown) => {
@@ -878,14 +882,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn on_load_url_window_event(&mut self, url_string: String) {
debug!("osmain: loading URL `{}`", url_string);
self.got_load_complete_message = false;
let root_pipeline_id = match self.scene.root {
Some(ref layer) => layer.get_pipeline_id(),
None => panic!("Compositor: Received WindowEvent::LoadUrl without initialized compositor \
layers"),
let url = Url::parse(&url_string).unwrap();
self.window.set_page_url(url.clone());
let msg = match self.scene.root {
Some(ref layer) => ConstellationMsg::LoadUrl(layer.get_pipeline_id(), LoadData::new(url)),
None => ConstellationMsg::InitLoadUrl(url)
};

let msg = ConstellationMsg::LoadUrl(root_pipeline_id,
LoadData::new(Url::parse(&url_string).unwrap()));
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(msg).unwrap()
}
@@ -160,8 +160,10 @@ pub enum Msg {
ChangeRunningAnimationsState(PipelineId, AnimationState),
/// Replaces the current frame tree, typically called during main frame navigation.
SetFrameTree(SendableFrameTree, Sender<()>, ConstellationChan),
/// The load of a page has completed.
LoadComplete,
/// The load of a page has begun: (can go back, can go forward).
LoadStart(bool, bool),
/// The load of a page has completed: (can go back, can go forward).
LoadComplete(bool, bool),
/// Indicates that the scrolling timeout with the given starting timestamp has happened and a
/// composite should happen. (See the `scrolling` module.)
ScrollTimeout(u64),
@@ -194,7 +196,8 @@ impl Debug for Msg {
Msg::ChangePageTitle(..) => write!(f, "ChangePageTitle"),
Msg::ChangePageUrl(..) => write!(f, "ChangePageUrl"),
Msg::SetFrameTree(..) => write!(f, "SetFrameTree"),
Msg::LoadComplete => write!(f, "LoadComplete"),
Msg::LoadComplete(..) => write!(f, "LoadComplete"),
Msg::LoadStart(..) => write!(f, "LoadStart"),
Msg::ScrollTimeout(..) => write!(f, "ScrollTimeout"),
Msg::RecompositeAfterScroll => write!(f, "RecompositeAfterScroll"),
Msg::KeyEvent(..) => write!(f, "KeyEvent"),
@@ -391,9 +391,9 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
// A page loaded through one of several methods above has completed all parsing,
// script, and reflow messages have been sent.
ConstellationMsg::LoadComplete => {
ConstellationMsg::LoadComplete(pipeline_id) => {
debug!("constellation got load complete message");
self.handle_load_complete_msg()
self.handle_load_complete_msg(&pipeline_id)
}
// Handle a forward or back request
ConstellationMsg::Navigate(pipeline_info, direction) => {
@@ -519,8 +519,10 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
fn handle_init_load(&mut self, url: Url) {
let window_rect = Rect(Point2D::zero(), self.window_size.visible_viewport);
let root_pipeline_id =
self.new_pipeline(None, Some(window_rect), None, LoadData::new(url));
self.new_pipeline(None, Some(window_rect), None, LoadData::new(url.clone()));
self.handle_load_start_msg(&root_pipeline_id);
self.push_pending_frame(root_pipeline_id, None);
self.compositor_proxy.send(CompositorMsg::ChangePageUrl(root_pipeline_id, url));
}

fn handle_frame_rect_msg(&mut self, containing_pipeline_id: PipelineId, subpage_id: SubpageId,
@@ -629,6 +631,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
// requested change so it can update its internal state.
match self.pipeline(source_id).parent_info {
Some((parent_pipeline_id, subpage_id)) => {
self.handle_load_start_msg(&source_id);
// Message the constellation to find the script task for this iframe
// and issue an iframe load through there.
let parent_pipeline = self.pipeline(parent_pipeline_id);
@@ -646,6 +649,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}

self.handle_load_start_msg(&source_id);
// Being here means either there are no pending frames, or none of the pending
// changes would be overridden by changing the subframe associated with source_id.

@@ -661,8 +665,31 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
}
}

fn handle_load_complete_msg(&mut self) {
self.compositor_proxy.send(CompositorMsg::LoadComplete);
fn handle_load_start_msg(&mut self, pipeline_id: &PipelineId) {
let mut back;
let mut forward;
let frameid = self.pipeline_to_frame_map.get(pipeline_id);
match frameid {
Some(frame_id) => {
forward = if !self.frame(*frame_id).next.is_empty() { true }
else { false };
back = if !self.frame(*frame_id).prev.is_empty() { true }
else { false };
},
None => return
};
self.compositor_proxy.send(CompositorMsg::LoadStart(back, forward));
}

fn handle_load_complete_msg(&mut self, pipeline_id: &PipelineId) {
let frame_id = match self.pipeline_to_frame_map.get(pipeline_id) {
Some(frame) => *frame,
None => return
};

let forward = !self.mut_frame(frame_id).next.is_empty();
let back = !self.mut_frame(frame_id).prev.is_empty();
self.compositor_proxy.send(CompositorMsg::LoadComplete(back, forward));
if let Some(ref reply_chan) = self.webdriver.load_channel {
reply_chan.send(webdriver_traits::LoadComplete).unwrap();
}
@@ -97,7 +97,8 @@ impl CompositorEventListener for NullCompositor {
Msg::AssignPaintedBuffers(..) |
Msg::ChangeRunningAnimationsState(..) |
Msg::ScrollFragmentPoint(..) |
Msg::LoadComplete |
Msg::LoadStart(..) |
Msg::LoadComplete(..) |
Msg::ScrollTimeout(..) |
Msg::RecompositeAfterScroll |
Msg::ChangePageTitle(..) |
@@ -12,6 +12,7 @@ use geom::size::TypedSize2D;
use layers::geometry::DevicePixel;
use layers::platform::surface::NativeGraphicsMetadata;
use msg::constellation_msg::{Key, KeyState, KeyModifiers};
use net::net_error_list::NetError;
use script_traits::MouseButton;
use url::Url;
use util::cursor::Cursor;
@@ -103,8 +104,12 @@ pub trait WindowMethods {
fn set_page_title(&self, title: Option<String>);
/// Sets the load data for the current page.
fn set_page_url(&self, url: Url);
/// Called when the browser has started loading a frame.
fn load_start(&self, back: bool, forward: bool);
/// Called when the browser is done loading a frame.
fn load_end(&self);
fn load_end(&self, back: bool, forward: bool);
/// Called when the browser encounters an error while loading a URL
fn load_error(&self, code: NetError, url: String);

/// Returns the hidpi factor of the monitor.
fn hidpi_factor(&self) -> ScaleFactor<ScreenPx, DevicePixel, f32>;
@@ -211,7 +211,7 @@ pub enum Msg {
Exit,
Failure(Failure),
InitLoadUrl(Url),
LoadComplete,
LoadComplete(PipelineId),
FrameRect(PipelineId, SubpageId, Rect<f32>),
LoadUrl(PipelineId, LoadData),
ScriptLoadedURLInIFrame(Url, PipelineId, SubpageId, Option<SubpageId>, IFrameSandboxState),
@@ -39,6 +39,7 @@ pub mod data_loader;
pub mod cookie;
pub mod cookie_storage;
pub mod image_cache_task;
pub mod net_error_list;
pub mod pub_domains;
pub mod resource_task;
pub mod storage_task;
@@ -0,0 +1,203 @@
/* 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/. */

// see https://github.com/adobe/chromium/blob/master/net/base/net_error_list.h
#[allow(dead_code, non_camel_case_types)]
pub enum NetError {
IO_PENDING = 1,
FAILED = 2,
ABORTED = 3,
INVALID_ARGUMENT = 4,
INVALID_HANDLE = 5,
FILE_NOT_FOUND = 6,
TIMED_OUT = 7,
FILE_TOO_BIG = 8,
UNEXPECTED = 9,
ACCESS_DENIED = 10,
NOT_IMPLEMENTED = 11,
INSUFFICIENT_RESOURCES = 12,
OUT_OF_MEMORY = 13,
UPLOAD_FILE_CHANGED = 14,
SOCKET_NOT_CONNECTED = 15,
FILE_EXISTS = 16,
FILE_PATH_TOO_LONG = 17,
FILE_NO_SPACE = 18,
FILE_VIRUS_INFECTED = 19,
BLOCKED_BY_CLIENT = 20,
NETWORK_CHANGED = 21,
BLOCKED_BY_ADMINISTRATOR = 22,
SOCKET_IS_CONNECTED = 23,
BLOCKED_ENROLLMENT_CHECK_PENDING = 24,
UPLOAD_STREAM_REWIND_NOT_SUPPORTED = 25,
CONNECTION_CLOSED = 100,
CONNECTION_RESET = 101,
CONNECTION_REFUSED = 102,
CONNECTION_ABORTED = 103,
CONNECTION_FAILED = 104,
NAME_NOT_RESOLVED = 105,
INTERNET_DISCONNECTED = 106,
SSL_PROTOCOL_ERROR = 107,
ADDRESS_INVALID = 108,
ADDRESS_UNREACHABLE = 109,
SSL_CLIENT_AUTH_CERT_NEEDED = 110,
TUNNEL_CONNECTION_FAILED = 111,
NO_SSL_VERSIONS_ENABLED = 112,
SSL_VERSION_OR_CIPHER_MISMATCH = 113,
SSL_RENEGOTIATION_REQUESTED = 114,
PROXY_AUTH_UNSUPPORTED = 115,
CERT_ERROR_IN_SSL_RENEGOTIATION = 116,
BAD_SSL_CLIENT_AUTH_CERT = 117,
CONNECTION_TIMED_OUT = 118,
HOST_RESOLVER_QUEUE_TOO_LARGE = 119,
SOCKS_CONNECTION_FAILED = 120,
SOCKS_CONNECTION_HOST_UNREACHABLE = 121,
NPN_NEGOTIATION_FAILED = 122,
SSL_NO_RENEGOTIATION = 123,
WINSOCK_UNEXPECTED_WRITTEN_BYTES = 124,
SSL_DECOMPRESSION_FAILURE_ALERT = 125,
SSL_BAD_RECORD_MAC_ALERT = 126,
PROXY_AUTH_REQUESTED = 127,
SSL_UNSAFE_NEGOTIATION = 128,
SSL_WEAK_SERVER_EPHEMERAL_DH_KEY = 129,
PROXY_CONNECTION_FAILED = 130,
MANDATORY_PROXY_CONFIGURATION_FAILED = 131,
PRECONNECT_MAX_SOCKET_LIMIT = 133,
SSL_CLIENT_AUTH_PRIVATE_KEY_ACCESS_DENIED = 134,
SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY = 135,
PROXY_CERTIFICATE_INVALID = 136,
NAME_RESOLUTION_FAILED = 137,
NETWORK_ACCESS_DENIED = 138,
TEMPORARILY_THROTTLED = 139,
HTTPS_PROXY_TUNNEL_RESPONSE = 140,
SSL_CLIENT_AUTH_SIGNATURE_FAILED = 141,
MSG_TOO_BIG = 142,
SPDY_SESSION_ALREADY_EXISTS = 143,
WS_PROTOCOL_ERROR = 145,
ADDRESS_IN_USE = 147,
SSL_HANDSHAKE_NOT_COMPLETED = 148,
SSL_BAD_PEER_PUBLIC_KEY = 149,
SSL_PINNED_KEY_NOT_IN_CERT_CHAIN = 150,
CLIENT_AUTH_CERT_TYPE_UNSUPPORTED = 151,
ORIGIN_BOUND_CERT_GENERATION_TYPE_MISMATCH = 152,
SSL_DECRYPT_ERROR_ALERT = 153,
WS_THROTTLE_QUEUE_TOO_LARGE = 154,
SSL_SERVER_CERT_CHANGED = 156,
SSL_INAPPROPRIATE_FALLBACK = 157,
CT_NO_SCTS_VERIFIED_OK = 158,
SSL_UNRECOGNIZED_NAME_ALERT = 159,
SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR = 160,
SOCKET_SET_SEND_BUFFER_SIZE_ERROR = 161,
SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE = 162,
SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE = 163,
SSL_CLIENT_AUTH_CERT_BAD_FORMAT = 164,
SSL_FALLBACK_BEYOND_MINIMUM_VERSION = 165,
CERT_COMMON_NAME_INVALID = 200,
CERT_DATE_INVALID = 201,
CERT_AUTHORITY_INVALID = 202,
CERT_CONTAINS_ERRORS = 203,
CERT_NO_REVOCATION_MECHANISM = 204,
CERT_UNABLE_TO_CHECK_REVOCATION = 205,
CERT_REVOKED = 206,
CERT_INVALID = 207,
CERT_WEAK_SIGNATURE_ALGORITHM = 208,
CERT_NON_UNIQUE_NAME = 210,
CERT_WEAK_KEY = 211,
CERT_NAME_CONSTRAINT_VIOLATION = 212,
CERT_VALIDITY_TOO_LONG = 213,
CERT_END = 214,
INVALID_URL = 300,
DISALLOWED_URL_SCHEME = 301,
UNKNOWN_URL_SCHEME = 302,
TOO_MANY_REDIRECTS = 310,
UNSAFE_REDIRECT = 311,
UNSAFE_PORT = 312,
INVALID_RESPONSE = 320,
INVALID_CHUNKED_ENCODING = 321,
METHOD_NOT_SUPPORTED = 322,
UNEXPECTED_PROXY_AUTH = 323,
EMPTY_RESPONSE = 324,
RESPONSE_HEADERS_TOO_BIG = 325,
PAC_STATUS_NOT_OK = 326,
PAC_SCRIPT_FAILED = 327,
REQUEST_RANGE_NOT_SATISFIABLE = 328,
MALFORMED_IDENTITY = 329,
CONTENT_DECODING_FAILED = 330,
NETWORK_IO_SUSPENDED = 331,
SYN_REPLY_NOT_RECEIVED = 332,
ENCODING_CONVERSION_FAILED = 333,
UNRECOGNIZED_FTP_DIRECTORY_LISTING_FORMAT = 334,
INVALID_SPDY_STREAM = 335,
NO_SUPPORTED_PROXIES = 336,
SPDY_PROTOCOL_ERROR = 337,
INVALID_AUTH_CREDENTIALS = 338,
UNSUPPORTED_AUTH_SCHEME = 339,
ENCODING_DETECTION_FAILED = 340,
MISSING_AUTH_CREDENTIALS = 341,
UNEXPECTED_SECURITY_LIBRARY_STATUS = 342,
MISCONFIGURED_AUTH_ENVIRONMENT = 343,
UNDOCUMENTED_SECURITY_LIBRARY_STATUS = 344,
RESPONSE_BODY_TOO_BIG_TO_DRAIN = 345,
RESPONSE_HEADERS_MULTIPLE_CONTENT_LENGTH = 346,
INCOMPLETE_SPDY_HEADERS = 347,
PAC_NOT_IN_DHCP = 348,
RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION = 349,
RESPONSE_HEADERS_MULTIPLE_LOCATION = 350,
SPDY_SERVER_REFUSED_STREAM = 351,
SPDY_PING_FAILED = 352,
CONTENT_LENGTH_MISMATCH = 354,
INCOMPLETE_CHUNKED_ENCODING = 355,
QUIC_PROTOCOL_ERROR = 356,
RESPONSE_HEADERS_TRUNCATED = 357,
QUIC_HANDSHAKE_FAILED = 358,
REQUEST_FOR_SECURE_RESOURCE_OVER_INSECURE_QUIC = 359,
SPDY_INADEQUATE_TRANSPORT_SECURITY = 360,
SPDY_FLOW_CONTROL_ERROR = 361,
SPDY_FRAME_SIZE_ERROR = 362,
SPDY_COMPRESSION_ERROR = 363,
PROXY_AUTH_REQUESTED_WITH_NO_CONNECTION = 364,
HTTP_1_1_REQUIRED = 365,
PROXY_HTTP_1_1_REQUIRED = 366,
CACHE_MISS = 400,
CACHE_READ_FAILURE = 401,
CACHE_WRITE_FAILURE = 402,
CACHE_OPERATION_NOT_SUPPORTED = 403,
CACHE_OPEN_FAILURE = 404,
CACHE_CREATE_FAILURE = 405,
CACHE_RACE = 406,
CACHE_CHECKSUM_READ_FAILURE = 407,
CACHE_CHECKSUM_MISMATCH = 408,
CACHE_LOCK_TIMEOUT = 409,
INSECURE_RESPONSE = 501,
NO_PRIVATE_KEY_FOR_CERT = 502,
ADD_USER_CERT_FAILED = 503,
FTP_FAILED = 601,
FTP_SERVICE_UNAVAILABLE = 602,
FTP_TRANSFER_ABORTED = 603,
FTP_FILE_BUSY = 604,
FTP_SYNTAX_ERROR = 605,
FTP_COMMAND_NOT_SUPPORTED = 606,
FTP_BAD_COMMAND_SEQUENCE = 607,
PKCS12_IMPORT_BAD_PASSWORD = 701,
PKCS12_IMPORT_FAILED = 702,
IMPORT_CA_CERT_NOT_CA = 703,
IMPORT_CERT_ALREADY_EXISTS = 704,
IMPORT_CA_CERT_FAILED = 705,
IMPORT_SERVER_CERT_FAILED = 706,
PKCS12_IMPORT_INVALID_MAC = 707,
PKCS12_IMPORT_INVALID_FILE = 708,
PKCS12_IMPORT_UNSUPPORTED = 709,
KEY_GENERATION_FAILED = 710,
ORIGIN_BOUND_CERT_GENERATION_FAILED = 711,
PRIVATE_KEY_EXPORT_FAILED = 712,
SELF_SIGNED_CERT_GENERATION_FAILED = 713,
CERT_DATABASE_CHANGED = 714,
CHANNEL_ID_IMPORT_FAILED = 715,
DNS_MALFORMED_RESPONSE = 800,
DNS_SERVER_REQUIRES_TCP = 801,
DNS_SERVER_FAILED = 802,
DNS_TIMED_OUT = 803,
DNS_CACHE_MISS = 804,
DNS_SEARCH_EMPTY = 805,
DNS_SORT_ERROR = 806,
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.