Auto merge of #17901 - heycam:rm-empty-variables, r=emilio

style: Remove now-unused empty Variables struct.

<!-- Please describe your changes on the following line: -->

The `Servo_GetEmptyVariables` FFI function no longer has any callers from Gecko, so we can remove it and the code that creates/frees that struct.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [ ] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17901)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-07-28 09:08:24 -05:00 committed by GitHub
commit e95da98f5f
4 changed files with 2 additions and 40 deletions

View file

@ -2866,9 +2866,6 @@ extern "C" {
index: u32, name: *mut nsAString) index: u32, name: *mut nsAString)
-> bool; -> bool;
} }
extern "C" {
pub fn Servo_GetEmptyVariables() -> *const nsStyleVariables;
}
extern "C" { extern "C" {
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet, pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
loader: *mut Loader, uri: *mut nsIURI) loader: *mut Loader, uri: *mut nsIURI)

View file

@ -19,13 +19,11 @@ use gecko_bindings::bindings::Gecko_Construct_Default_${style_struct.gecko_ffi_n
use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name}; use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name}; use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
% endfor % endfor
use gecko_bindings::bindings::Gecko_Construct_nsStyleVariables;
use gecko_bindings::bindings::Gecko_CopyCounterStyle; use gecko_bindings::bindings::Gecko_CopyCounterStyle;
use gecko_bindings::bindings::Gecko_CopyCursorArrayFrom; use gecko_bindings::bindings::Gecko_CopyCursorArrayFrom;
use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom; use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
use gecko_bindings::bindings::Gecko_CopyImageValueFrom; use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom; use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
use gecko_bindings::bindings::Gecko_Destroy_nsStyleVariables;
use gecko_bindings::bindings::Gecko_EnsureImageLayersLength; use gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendGeneric; use gecko_bindings::bindings::Gecko_FontFamilyList_AppendGeneric;
use gecko_bindings::bindings::Gecko_FontFamilyList_AppendNamed; use gecko_bindings::bindings::Gecko_FontFamilyList_AppendNamed;
@ -43,7 +41,6 @@ use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
use gecko_bindings::bindings::RawGeckoPresContextBorrowed; use gecko_bindings::bindings::RawGeckoPresContextBorrowed;
use gecko_bindings::structs; use gecko_bindings::structs;
use gecko_bindings::structs::nsCSSPropertyID; use gecko_bindings::structs::nsCSSPropertyID;
use gecko_bindings::structs::nsStyleVariables;
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut}; use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
use gecko::values::convert_nscolor_to_rgba; use gecko::values::convert_nscolor_to_rgba;
use gecko::values::convert_rgba_to_nscolor; use gecko::values::convert_rgba_to_nscolor;
@ -5030,26 +5027,3 @@ ${impl_style_struct(style_struct)}
<%self:raw_impl_trait style_struct="${style_struct}"></%self:raw_impl_trait> <%self:raw_impl_trait style_struct="${style_struct}"></%self:raw_impl_trait>
% endif % endif
% endfor % endfor
// This is only accessed from the Gecko main thread.
static mut EMPTY_VARIABLES_STRUCT: Option<nsStyleVariables> = None;
#[no_mangle]
#[allow(non_snake_case)]
pub unsafe extern "C" fn Servo_GetEmptyVariables()
-> *const nsStyleVariables {
EMPTY_VARIABLES_STRUCT.as_ref().unwrap()
}
pub fn initialize() {
unsafe {
EMPTY_VARIABLES_STRUCT = Some(zeroed());
Gecko_Construct_nsStyleVariables(EMPTY_VARIABLES_STRUCT.as_mut().unwrap());
}
}
pub fn shutdown() {
unsafe {
EMPTY_VARIABLES_STRUCT.take().as_mut().map(|v| Gecko_Destroy_nsStyleVariables(v));
}
}

View file

@ -90,7 +90,7 @@ use style::gecko_bindings::structs::nsresult;
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI}; use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasFFI, HasArcFFI, HasBoxFFI};
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong}; use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
use style::gecko_bindings::sugar::refptr::RefPtr; use style::gecko_bindings::sugar::refptr::RefPtr;
use style::gecko_properties::{self, style_structs}; use style::gecko_properties::style_structs;
use style::invalidation::element::restyle_hints::{self, RestyleHint}; use style::invalidation::element::restyle_hints::{self, RestyleHint};
use style::media_queries::{MediaList, parse_media_query_list}; use style::media_queries::{MediaList, parse_media_query_list};
use style::parallel; use style::parallel;
@ -158,18 +158,12 @@ pub extern "C" fn Servo_Initialize(dummy_url_data: *mut URLExtraData) {
parser::assert_parsing_mode_match(); parser::assert_parsing_mode_match();
traversal_flags::assert_traversal_flags_match(); traversal_flags::assert_traversal_flags_match();
// Initialize some static data.
gecko_properties::initialize();
// Initialize the dummy url data // Initialize the dummy url data
unsafe { DUMMY_URL_DATA = dummy_url_data; } unsafe { DUMMY_URL_DATA = dummy_url_data; }
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_Shutdown() { pub extern "C" fn Servo_Shutdown() {
// Clear some static data to avoid shutdown leaks.
gecko_properties::shutdown();
// The dummy url will be released after shutdown, so clear the // The dummy url will be released after shutdown, so clear the
// reference to avoid use-after-free. // reference to avoid use-after-free.
unsafe { DUMMY_URL_DATA = ptr::null_mut(); } unsafe { DUMMY_URL_DATA = ptr::null_mut(); }

View file

@ -24,10 +24,7 @@ with open(INPUT_FILE, "r") as bindings, open(OUTPUT_FILE, "w+") as tests:
for line in bindings: for line in bindings:
match = pattern.search(line) match = pattern.search(line)
if match:
# GetStyleVariables is a Servo_* function, but temporarily defined on
# the gecko side
if match and match.group(1) != "GetStyleVariables":
tests.write(TEMPLATE.format(name=match.group(1))) tests.write(TEMPLATE.format(name=match.group(1)))
tests.write("}\n") tests.write("}\n")