Skip to content
Permalink
Browse files

Auto merge of #23002 - paulrouget:padding, r=jdm

Fix bleeding in FxR by adding Padding support to ServoSurface

Not ready for review, just need to make sure the CI is happy for now.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23002)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Mar 14, 2019
2 parents 85ed181 + 5296fb1 commit c58718a0b34af38fb8b88e1e09ffa0bbe950a3cb
Showing with 458 additions and 259 deletions.
  1. +155 −101 Cargo.lock
  2. +2 −2 components/canvas/webgl_mode/inprocess.rs
  3. +1 −1 components/compositing/Cargo.toml
  4. +22 −10 components/compositing/compositor.rs
  5. +5 −5 components/compositing/gl.rs
  6. +4 −2 components/compositing/windowing.rs
  7. +2 −3 components/geometry/lib.rs
  8. +1 −1 components/gfx/Cargo.toml
  9. +2 −1 components/gfx/platform/freetype/font_template.rs
  10. +2 −1 components/gfx/platform/windows/font.rs
  11. +0 −5 components/gfx/platform/windows/font_list.rs
  12. +11 −5 components/gfx/platform/windows/font_template.rs
  13. +1 −0 components/layout/display_list/builder.rs
  14. +16 −8 components/layout/display_list/webrender_helpers.rs
  15. +13 −11 components/layout_thread/lib.rs
  16. +1 −1 components/net_traits/Cargo.toml
  17. +1 −1 components/script/Cargo.toml
  18. +1 −0 components/servo/lib.rs
  19. +1 −1 components/webdriver_server/Cargo.toml
  20. +40 −21 ports/libsimpleservo/api/src/lib.rs
  21. +13 −7 ports/libsimpleservo/capi/src/lib.rs
  22. +42 −17 ports/libsimpleservo/jniapi/src/lib.rs
  23. +3 −1 ports/servo/Cargo.toml
  24. +3 −3 ports/servo/glutin_app/keyutils.rs
  25. +59 −39 ports/servo/glutin_app/window.rs
  26. +11 −3 support/android/apk/servoview/src/main/java/org/mozilla/servoview/JNIServo.java
  27. +3 −2 support/android/apk/servoview/src/main/java/org/mozilla/servoview/Servo.java
  28. +25 −4 support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoSurface.java
  29. +16 −3 support/android/apk/servoview/src/main/java/org/mozilla/servoview/ServoView.java
  30. +2 −0 tests/wpt/mozilla/meta/gfx-rs-gecko/1035611-1.html.ini

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -151,7 +151,7 @@ impl webrender::OutputImageHandler for OutputHandler {
fn lock(
&mut self,
id: webrender_api::PipelineId,
) -> Option<(u32, webrender_api::DeviceIntSize)> {
) -> Option<(u32, webrender_api::FramebufferIntSize)> {
// Insert a fence in the WR command queue
let gl_sync = self
.webrender_gl
@@ -164,7 +164,7 @@ impl webrender::OutputImageHandler for OutputHandler {
self.lock_channel.1.recv().unwrap().map(|(tex_id, size)| {
(
tex_id,
webrender_api::DeviceIntSize::new(size.width, size.height),
webrender_api::FramebufferIntSize::new(size.width, size.height),
)
})
}
@@ -21,7 +21,7 @@ embedder_traits = {path = "../embedder_traits"}
euclid = "0.19"
gfx_traits = {path = "../gfx_traits"}
gleam = {version = "0.6", optional = true}
image = "0.20"
image = "0.21"
ipc-channel = "0.11"
libc = "0.2"
keyboard-types = "0.4.3"
@@ -41,7 +41,10 @@ use std::rc::Rc;
use style_traits::viewport::ViewportConstraints;
use style_traits::{CSSPixel, DevicePixel, PinchZoomFactor};
use time::{now, precise_time_ns, precise_time_s};
use webrender_api::{self, DeviceIntPoint, DevicePoint, HitTestFlags, HitTestResult};
use webrender_api::{
self, DeviceIntPoint, DevicePoint, FramebufferIntRect, FramebufferIntSize, HitTestFlags,
HitTestResult,
};
use webrender_api::{LayoutVector2D, ScrollLocation};
use webvr_traits::WebVRMainThreadHeartbeat;

@@ -575,10 +578,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
fn send_window_size(&self, size_type: WindowSizeType) {
let dppx = self.page_zoom * self.embedder_coordinates.hidpi_factor;

self.webrender_api.set_window_parameters(
let flipped_viewport = {
let fb_height = self.embedder_coordinates.framebuffer.height;
let mut view = self.embedder_coordinates.viewport.clone();
view.origin.y = fb_height - view.origin.y - view.size.height;
FramebufferIntRect::from_untyped(&view.to_untyped())
};

self.webrender_api.set_document_view(
self.webrender_document,
self.embedder_coordinates.framebuffer,
self.embedder_coordinates.viewport,
flipped_viewport,
self.embedder_coordinates.hidpi_factor.get(),
);

@@ -612,9 +621,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
self.update_zoom_transform();
}

if self.embedder_coordinates.viewport == old_coords.viewport &&
self.embedder_coordinates.framebuffer == old_coords.framebuffer
{
if self.embedder_coordinates.viewport == old_coords.viewport {
return;
}

@@ -1203,11 +1210,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|| {
debug!("compositor: compositing");

let size = FramebufferIntSize::from_untyped(
&self.embedder_coordinates.framebuffer.to_untyped(),
);

self.window.gl().clear_color(0.0, 0.0, 0.0, 0.0);
self.window.gl().clear(gleam::gl::COLOR_BUFFER_BIT);

// Paint the scene.
// TODO(gw): Take notice of any errors the renderer returns!
self.webrender
.render(self.embedder_coordinates.framebuffer)
.ok();
self.webrender.render(size).ok();
},
);

@@ -4,7 +4,7 @@

use gleam::gl;
use image::RgbImage;
use servo_geometry::DeviceUintLength;
use servo_geometry::FramebufferUintLength;

#[derive(Default)]
pub struct RenderTargetInfo {
@@ -15,8 +15,8 @@ pub struct RenderTargetInfo {

pub fn initialize_png(
gl: &dyn gl::Gl,
width: DeviceUintLength,
height: DeviceUintLength,
width: FramebufferUintLength,
height: FramebufferUintLength,
) -> RenderTargetInfo {
let framebuffer_ids = gl.gen_framebuffers(1);
gl.bind_framebuffer(gl::FRAMEBUFFER, framebuffer_ids[0]);
@@ -82,8 +82,8 @@ pub fn initialize_png(
pub fn draw_img(
gl: &dyn gl::Gl,
render_target_info: RenderTargetInfo,
width: DeviceUintLength,
height: DeviceUintLength,
width: FramebufferUintLength,
height: FramebufferUintLength,
) -> RgbImage {
let width = width.get() as usize;
let height = height.get() as usize;
@@ -17,7 +17,9 @@ use std::fmt::{Debug, Error, Formatter};
#[cfg(feature = "gl")]
use std::rc::Rc;
use style_traits::DevicePixel;
use webrender_api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, ScrollLocation};
use webrender_api::{
DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePoint, FramebufferIntSize, ScrollLocation,
};
use webvr::VRServiceManager;
use webvr_traits::WebVRMainThreadHeartbeat;

@@ -167,7 +169,7 @@ pub struct EmbedderCoordinates {
/// Size of the native window.
pub window: (DeviceIntSize, DeviceIntPoint),
/// Size of the GL buffer in the window.
pub framebuffer: DeviceIntSize,
pub framebuffer: FramebufferIntSize,
/// Coordinates of the document within the framebuffer.
pub viewport: DeviceIntRect,
}
@@ -8,12 +8,11 @@ extern crate malloc_size_of_derive;
use app_units::{Au, MAX_AU, MIN_AU};
use euclid::{Length, Point2D, Rect, Size2D};
use std::f32;
use style_traits::DevicePixel;
use webrender_api::{LayoutPoint, LayoutRect, LayoutSize};
use webrender_api::{FramebufferPixel, LayoutPoint, LayoutRect, LayoutSize};

// Units for use with euclid::length and euclid::scale_factor.

pub type DeviceUintLength = Length<u32, DevicePixel>;
pub type FramebufferUintLength = Length<u32, FramebufferPixel>;

/// A normalized "pixel" at the default resolution for the display.
///
@@ -63,5 +63,5 @@ servo-fontconfig = "0.2.1"
xml5ever = {version = "0.12"}

[target.'cfg(target_os = "windows")'.dependencies]
dwrote = "0.7"
dwrote = "0.8"
truetype = "0.26"
@@ -6,6 +6,7 @@ use servo_atoms::Atom;
use std::fmt;
use std::fs::File;
use std::io::{Error, Read};
use std::path::PathBuf;
use webrender_api::NativeFontHandle;

/// Platform specific font representation for Linux.
@@ -61,7 +62,7 @@ impl FontTemplateData {
pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(NativeFontHandle {
pathname: String::from(&*self.identifier),
path: PathBuf::from(&*self.identifier),
index: 0,
})
} else {
@@ -280,7 +280,8 @@ impl FontHandleMethods for FontHandle {

let face = font_file
.unwrap()
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE);
.create_face(0, dwrote::DWRITE_FONT_SIMULATIONS_NONE)
.map_err(|_| ())?;
let info = FontInfo::new_from_face(&face)?;
(info, face)
} else {
@@ -64,11 +64,6 @@ where
}
}

pub fn descriptor_from_atom(ident: &Atom) -> FontDescriptor {
let fonts = FONT_ATOM_MAP.lock().unwrap();
fonts.get(ident).unwrap().clone()
}

pub fn font_from_atom(ident: &Atom) -> Font {
let fonts = FONT_ATOM_MAP.lock().unwrap();
FontCollection::system()
@@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

use crate::platform::windows::font_list::{descriptor_from_atom, font_from_atom};
use crate::platform::windows::font_list::font_from_atom;
use servo_atoms::Atom;
use std::fmt;
use std::io;
@@ -59,10 +59,16 @@ impl FontTemplateData {
}

pub fn native_font(&self) -> Option<NativeFontHandle> {
if self.bytes.is_none() {
Some(descriptor_from_atom(&self.identifier))
} else {
None
if self.bytes.is_some() {
return None;
}
let font = font_from_atom(&self.identifier);
let face = font.create_font_face();
let files = face.get_files();
let path = files.iter().next()?.get_font_file_path()?;
Some(NativeFontHandle {
path,
index: face.get_index(),
})
}
}
@@ -2012,6 +2012,7 @@ impl Fragment {
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
color: self.style.resolve_color(shadow.color).to_layout(),
blur_radius: shadow.blur.px(),
should_inflate: true,
},
},
)));
@@ -10,8 +10,10 @@
use crate::display_list::items::{ClipScrollNode, ClipScrollNodeType};
use crate::display_list::items::{DisplayItem, DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId;
use webrender_api::{self, ClipId, DisplayListBuilder, RasterSpace, SpaceAndClipInfo, SpatialId};
use webrender_api::{LayoutPoint, SpecificDisplayItem};
use webrender_api::{
self, ClipId, DisplayListBuilder, RasterSpace, ReferenceFrameKind, SpaceAndClipInfo, SpatialId,
};
use webrender_api::{LayoutPoint, PropertyBinding, SpecificDisplayItem};

pub trait WebRenderDisplayListConverter {
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
@@ -204,17 +206,20 @@ impl WebRenderDisplayItemConverter for DisplayItem {
let mut info = webrender_api::LayoutPrimitiveInfo::new(stacking_context.bounds);
let spatial_id =
if let Some(frame_index) = stacking_context.established_reference_frame {
debug_assert!(
stacking_context.transform.is_some() ||
stacking_context.perspective.is_some()
);
let transform =
match (stacking_context.transform, stacking_context.perspective) {
(None, Some(p)) => p,
(Some(t), None) => t,
(Some(t), Some(p)) => t.pre_mul(&p),
(None, None) => unreachable!(),
};

let spatial_id = builder.push_reference_frame(
&stacking_context.bounds,
state.active_spatial_id,
stacking_context.transform_style,
stacking_context.transform.map(Into::into),
stacking_context.perspective,
PropertyBinding::Value(transform),
ReferenceFrameKind::Transform,
);
state.spatial_ids[frame_index.to_index()] = Some(spatial_id);
state.clip_ids[frame_index.to_index()] = Some(cur_clip_id);
@@ -233,7 +238,9 @@ impl WebRenderDisplayItemConverter for DisplayItem {
stacking_context.transform_style,
stacking_context.mix_blend_mode,
&stacking_context.filters,
&[],
RasterSpace::Screen,
/* cache_tiles = */ false,
);
},
DisplayItem::PopStackingContext(_) => builder.pop_stacking_context(),
@@ -273,6 +280,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
node.clip.complex.clone(),
None,
scroll_sensitivity,
webrender_api::LayoutVector2D::zero(),
);

state.clip_ids[item.node_index.to_index()] = Some(space_clip_info.clip_id);
@@ -1861,11 +1861,8 @@ impl ProfilerMetadataFactory for LayoutThread {
// http://dev.w3.org/csswg/css-backgrounds/#background-color). However, we
// need to propagate the background color from the root HTML/Body
// element (http://dev.w3.org/csswg/css-backgrounds/#special-backgrounds) if
// it is non-transparent. The phrase in the spec "If the canvas background
// is not opaque, what shows through is UA-dependent." is handled by rust-layers
// clearing the frame buffer to white. This ensures that setting a background
// color on an iframe element, while the iframe content itself has a default
// transparent background color is handled correctly.
// it is non-transparent. The spec says "If the canvas background is not opaque,
// what shows through is UA-dependent.". Here we fallback to white.
fn get_root_flow_background_color(flow: &mut dyn Flow) -> webrender_api::ColorF {
let transparent = webrender_api::ColorF {
r: 0.0,
@@ -1894,12 +1891,17 @@ fn get_root_flow_background_color(flow: &mut dyn Flow) -> webrender_api::ColorF
.get_background()
.background_color,
);
webrender_api::ColorF::new(
color.red_f32(),
color.green_f32(),
color.blue_f32(),
color.alpha_f32(),
)

if color.alpha == 0 {
webrender_api::ColorF::WHITE
} else {
webrender_api::ColorF::new(
color.red_f32(),
color.green_f32(),
color.blue_f32(),
color.alpha_f32(),
)
}
}

fn get_ua_stylesheets() -> Result<UserAgentStylesheets, &'static str> {
@@ -20,7 +20,7 @@ headers-ext = "0.0.3"
http = "0.1"
hyper = "0.12"
hyper_serde = "0.9"
piston_image = {package = "image", version = "0.20"}
piston_image = {package = "image", version = "0.21"}
ipc-channel = "0.11"
lazy_static = "1"
log = "0.4"
@@ -58,7 +58,7 @@ html5ever = "0.22"
http = "0.1"
hyper = "0.12"
hyper_serde = "0.9"
image = "0.20"
image = "0.21"
indexmap = "1.0.2"
ipc-channel = "0.11"
itertools = "0.8"
@@ -242,6 +242,7 @@ where
},
renderer_kind: renderer_kind,
enable_subpixel_aa: opts.enable_subpixel_text_antialiasing,
clear_color: None,
..Default::default()
},
None,
@@ -16,7 +16,7 @@ cookie = "0.11"
crossbeam-channel = "0.3"
euclid = "0.19"
hyper = "0.12"
image = "0.20"
image = "0.21"
ipc-channel = "0.11"
keyboard-types = "0.4.3"
log = "0.4"
Oops, something went wrong.

0 comments on commit c58718a

Please sign in to comment.
You can’t perform that action at this time.