Bug 1611711 - Remove kCursorKTable. r=jwatt

(And while at it, format the end of the other keyword tables so that
cleanup_ktables.py works).

It seems `Window.setCursor` is only used once in our code, maybe
we should remove it...

Differential Revision: https://phabricator.services.mozilla.com/D61090

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-01-26 20:17:41 +00:00
Родитель 64099dcf90
Коммит 6bfbf10f25
9 изменённых файлов: 30 добавлений и 162 удалений

Просмотреть файл

@ -6718,7 +6718,7 @@ already_AddRefed<nsWindowRoot> nsGlobalWindowInner::GetWindowRoot(
FORWARD_TO_OUTER_OR_THROW(GetWindowRootOuter, (), aError, nullptr); FORWARD_TO_OUTER_OR_THROW(GetWindowRootOuter, (), aError, nullptr);
} }
void nsGlobalWindowInner::SetCursor(const nsAString& aCursor, void nsGlobalWindowInner::SetCursor(const nsACString& aCursor,
ErrorResult& aError) { ErrorResult& aError) {
FORWARD_TO_OUTER_OR_THROW(SetCursorOuter, (aCursor, aError), aError, ); FORWARD_TO_OUTER_OR_THROW(SetCursorOuter, (aCursor, aError), aError, );
} }

Просмотреть файл

@ -894,7 +894,7 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget,
void GetAttention(mozilla::ErrorResult& aError); void GetAttention(mozilla::ErrorResult& aError);
void GetAttentionWithCycleCount(int32_t aCycleCount, void GetAttentionWithCycleCount(int32_t aCycleCount,
mozilla::ErrorResult& aError); mozilla::ErrorResult& aError);
void SetCursor(const nsAString& aCursor, mozilla::ErrorResult& aError); void SetCursor(const nsACString& aCursor, mozilla::ErrorResult& aError);
void Maximize(); void Maximize();
void Minimize(); void Minimize();
void Restore(); void Restore();

Просмотреть файл

@ -7343,20 +7343,13 @@ nsIDOMWindowUtils* nsGlobalWindowOuter::WindowUtils() {
// Note: This call will lock the cursor, it will not change as it moves. // Note: This call will lock the cursor, it will not change as it moves.
// To unlock, the cursor must be set back to Auto. // To unlock, the cursor must be set back to Auto.
void nsGlobalWindowOuter::SetCursorOuter(const nsAString& aCursor, void nsGlobalWindowOuter::SetCursorOuter(const nsACString& aCursor,
ErrorResult& aError) { ErrorResult& aError) {
StyleCursorKind cursor; auto cursor = StyleCursorKind::Auto;
if (!Servo_CursorKind_Parse(&aCursor, &cursor)) {
if (aCursor.EqualsLiteral("auto")) { // FIXME: It's a bit weird that this doesn't throw but stuff below does, but
cursor = StyleCursorKind::Auto; // matches previous behavior so...
} else { return;
// TODO(emilio): Use Servo for this instead.
nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(aCursor);
int32_t c;
if (!nsCSSProps::FindKeyword(keyword, nsCSSProps::kCursorKTable, c)) {
return;
}
cursor = static_cast<StyleCursorKind>(c);
} }
RefPtr<nsPresContext> presContext; RefPtr<nsPresContext> presContext;

Просмотреть файл

@ -662,7 +662,7 @@ class nsGlobalWindowOuter final : public mozilla::dom::EventTarget,
// fact chrome. // fact chrome.
nsIBrowserDOMWindow* GetBrowserDOMWindowOuter(); nsIBrowserDOMWindow* GetBrowserDOMWindowOuter();
void SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow); void SetBrowserDOMWindowOuter(nsIBrowserDOMWindow* aBrowserWindow);
void SetCursorOuter(const nsAString& aCursor, mozilla::ErrorResult& aError); void SetCursorOuter(const nsACString& aCursor, mozilla::ErrorResult& aError);
void GetReturnValueOuter(JSContext* aCx, void GetReturnValueOuter(JSContext* aCx,
JS::MutableHandle<JS::Value> aReturnValue, JS::MutableHandle<JS::Value> aReturnValue,

Просмотреть файл

@ -609,7 +609,7 @@ partial interface Window {
void getAttentionWithCycleCount(long aCycleCount); void getAttentionWithCycleCount(long aCycleCount);
[Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"] [Throws, Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
void setCursor(DOMString cursor); void setCursor(UTF8String cursor);
[Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"] [Func="nsGlobalWindowInner::IsPrivilegedChromeWindow"]
void maximize(); void maximize();

Просмотреть файл

@ -37,124 +37,30 @@
// MACRO_NAME=CSS_KEY // MACRO_NAME=CSS_KEY
CSS_KEY(-moz-available, _moz_available) CSS_KEY(-moz-available, _moz_available)
CSS_KEY(-moz-box, _moz_box)
CSS_KEY(-moz-center, _moz_center) CSS_KEY(-moz-center, _moz_center)
CSS_KEY(-moz-block-height, _moz_block_height) CSS_KEY(-moz-block-height, _moz_block_height)
CSS_KEY(-moz-deck, _moz_deck)
CSS_KEY(-moz-fit-content, _moz_fit_content) CSS_KEY(-moz-fit-content, _moz_fit_content)
CSS_KEY(-moz-grabbing, _moz_grabbing)
CSS_KEY(-moz-grab, _moz_grab)
CSS_KEY(-moz-grid-group, _moz_grid_group)
CSS_KEY(-moz-grid-line, _moz_grid_line)
CSS_KEY(-moz-grid, _moz_grid)
CSS_KEY(-moz-groupbox, _moz_groupbox)
CSS_KEY(-moz-inline-box, _moz_inline_box)
CSS_KEY(-moz-left, _moz_left) CSS_KEY(-moz-left, _moz_left)
CSS_KEY(-moz-none, _moz_none) CSS_KEY(-moz-none, _moz_none)
CSS_KEY(-moz-popup, _moz_popup)
CSS_KEY(-moz-right, _moz_right) CSS_KEY(-moz-right, _moz_right)
CSS_KEY(-moz-zoom-in, _moz_zoom_in)
CSS_KEY(-moz-zoom-out, _moz_zoom_out)
CSS_KEY(-webkit-box, _webkit_box)
CSS_KEY(-webkit-flex, _webkit_flex)
CSS_KEY(-webkit-inline-box, _webkit_inline_box)
CSS_KEY(-webkit-inline-flex, _webkit_inline_flex)
CSS_KEY(alias, alias)
CSS_KEY(all-scroll, all_scroll)
CSS_KEY(auto, auto) CSS_KEY(auto, auto)
CSS_KEY(baseline, baseline)
CSS_KEY(block, block)
CSS_KEY(cell, cell)
CSS_KEY(center, center) CSS_KEY(center, center)
CSS_KEY(circle, circle)
CSS_KEY(col-resize, col_resize)
CSS_KEY(column, column)
CSS_KEY(contents, contents)
CSS_KEY(context-menu, context_menu)
CSS_KEY(copy, copy)
CSS_KEY(crosshair, crosshair)
CSS_KEY(dashed, dashed) CSS_KEY(dashed, dashed)
CSS_KEY(dense, dense)
CSS_KEY(default, default)
CSS_KEY(dot, dot)
CSS_KEY(dotted, dotted) CSS_KEY(dotted, dotted)
CSS_KEY(double, double) CSS_KEY(double, double)
CSS_KEY(double-circle, double_circle)
CSS_KEY(e-resize, e_resize)
CSS_KEY(end, end) CSS_KEY(end, end)
CSS_KEY(ew-resize, ew_resize)
CSS_KEY(flex, flex)
CSS_KEY(flex-end, flex_end)
CSS_KEY(flex-start, flex_start)
CSS_KEY(flow-root, flow_root)
CSS_KEY(grab, grab)
CSS_KEY(grabbing, grabbing)
CSS_KEY(grayscale, grayscale) CSS_KEY(grayscale, grayscale)
CSS_KEY(grid, grid)
CSS_KEY(help, help)
CSS_KEY(inline, inline)
CSS_KEY(inline-block, inline_block)
CSS_KEY(inline-flex, inline_flex)
CSS_KEY(inline-grid, inline_grid)
CSS_KEY(inline-table, inline_table)
CSS_KEY(inset, inset)
CSS_KEY(justify, justify) CSS_KEY(justify, justify)
CSS_KEY(last baseline, last_baseline) // only used for DevTools auto-completion
CSS_KEY(left, left) CSS_KEY(left, left)
CSS_KEY(list-item, list_item)
CSS_KEY(max-content, max_content) CSS_KEY(max-content, max_content)
CSS_KEY(min-content, min_content) CSS_KEY(min-content, min_content)
CSS_KEY(move, move)
CSS_KEY(n-resize, n_resize)
CSS_KEY(ne-resize, ne_resize)
CSS_KEY(nesw-resize, nesw_resize)
CSS_KEY(no-drop, no_drop)
CSS_KEY(none, none) CSS_KEY(none, none)
CSS_KEY(normal, normal) CSS_KEY(normal, normal)
CSS_KEY(not-allowed, not_allowed)
CSS_KEY(ns-resize, ns_resize)
CSS_KEY(nw-resize, nw_resize)
CSS_KEY(nwse-resize, nwse_resize)
CSS_KEY(pointer, pointer)
CSS_KEY(progress, progress)
CSS_KEY(right, right) CSS_KEY(right, right)
CSS_KEY(row, row)
CSS_KEY(row-resize, row_resize)
CSS_KEY(ruby, ruby)
CSS_KEY(ruby-base, ruby_base)
CSS_KEY(ruby-base-container, ruby_base_container)
CSS_KEY(ruby-text, ruby_text)
CSS_KEY(ruby-text-container, ruby_text_container)
CSS_KEY(s-resize, s_resize)
CSS_KEY(se-resize, se_resize)
CSS_KEY(self-end, self_end)
CSS_KEY(self-start, self_start)
CSS_KEY(sesame, sesame)
CSS_KEY(solid, solid) CSS_KEY(solid, solid)
CSS_KEY(space-around, space_around)
CSS_KEY(space-between, space_between)
CSS_KEY(space-evenly, space_evenly)
CSS_KEY(start, start) CSS_KEY(start, start)
CSS_KEY(stretch, stretch)
CSS_KEY(subgrid, subgrid) CSS_KEY(subgrid, subgrid)
CSS_KEY(sw-resize, sw_resize)
CSS_KEY(table, table)
CSS_KEY(table-caption, table_caption)
CSS_KEY(table-cell, table_cell)
CSS_KEY(table-column, table_column)
CSS_KEY(table-column-group, table_column_group)
CSS_KEY(table-footer-group, table_footer_group)
CSS_KEY(table-header-group, table_header_group)
CSS_KEY(table-row, table_row)
CSS_KEY(table-row-group, table_row_group)
CSS_KEY(text, text)
CSS_KEY(triangle, triangle)
CSS_KEY(vertical-text, vertical_text)
CSS_KEY(w-resize, w_resize)
CSS_KEY(wait, wait)
CSS_KEY(wavy, wavy) CSS_KEY(wavy, wavy)
CSS_KEY(zoom-in, zoom_in)
CSS_KEY(zoom-out, zoom_out)
// Appearance keywords for widget styles // Appearance keywords for widget styles
//CSS_KEY(start, start) //CSS_KEY(start, start)

Просмотреть файл

@ -166,57 +166,11 @@ const nsCString& nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDesc) {
/***************************************************************************/ /***************************************************************************/
const KTableEntry nsCSSProps::kCursorKTable[] = {
// CSS 2.0
{eCSSKeyword_auto, StyleCursorKind::Auto},
{eCSSKeyword_crosshair, StyleCursorKind::Crosshair},
{eCSSKeyword_default, StyleCursorKind::Default},
{eCSSKeyword_pointer, StyleCursorKind::Pointer},
{eCSSKeyword_move, StyleCursorKind::Move},
{eCSSKeyword_e_resize, StyleCursorKind::EResize},
{eCSSKeyword_ne_resize, StyleCursorKind::NeResize},
{eCSSKeyword_nw_resize, StyleCursorKind::NwResize},
{eCSSKeyword_n_resize, StyleCursorKind::NResize},
{eCSSKeyword_se_resize, StyleCursorKind::SeResize},
{eCSSKeyword_sw_resize, StyleCursorKind::SwResize},
{eCSSKeyword_s_resize, StyleCursorKind::SResize},
{eCSSKeyword_w_resize, StyleCursorKind::WResize},
{eCSSKeyword_text, StyleCursorKind::Text},
{eCSSKeyword_wait, StyleCursorKind::Wait},
{eCSSKeyword_help, StyleCursorKind::Help},
// CSS 2.1
{eCSSKeyword_progress, StyleCursorKind::Progress},
// CSS3 basic user interface module
{eCSSKeyword_copy, StyleCursorKind::Copy},
{eCSSKeyword_alias, StyleCursorKind::Alias},
{eCSSKeyword_context_menu, StyleCursorKind::ContextMenu},
{eCSSKeyword_cell, StyleCursorKind::Cell},
{eCSSKeyword_not_allowed, StyleCursorKind::NotAllowed},
{eCSSKeyword_col_resize, StyleCursorKind::ColResize},
{eCSSKeyword_row_resize, StyleCursorKind::RowResize},
{eCSSKeyword_no_drop, StyleCursorKind::NoDrop},
{eCSSKeyword_vertical_text, StyleCursorKind::VerticalText},
{eCSSKeyword_all_scroll, StyleCursorKind::AllScroll},
{eCSSKeyword_nesw_resize, StyleCursorKind::NeswResize},
{eCSSKeyword_nwse_resize, StyleCursorKind::NwseResize},
{eCSSKeyword_ns_resize, StyleCursorKind::NsResize},
{eCSSKeyword_ew_resize, StyleCursorKind::EwResize},
{eCSSKeyword_none, StyleCursorKind::None},
{eCSSKeyword_grab, StyleCursorKind::Grab},
{eCSSKeyword_grabbing, StyleCursorKind::Grabbing},
{eCSSKeyword_zoom_in, StyleCursorKind::ZoomIn},
{eCSSKeyword_zoom_out, StyleCursorKind::ZoomOut},
// -moz- prefixed vendor specific
{eCSSKeyword__moz_grab, StyleCursorKind::Grab},
{eCSSKeyword__moz_grabbing, StyleCursorKind::Grabbing},
{eCSSKeyword__moz_zoom_in, StyleCursorKind::ZoomIn},
{eCSSKeyword__moz_zoom_out, StyleCursorKind::ZoomOut},
{eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE}};
const KTableEntry nsCSSProps::kFontSmoothingKTable[] = { const KTableEntry nsCSSProps::kFontSmoothingKTable[] = {
{eCSSKeyword_auto, NS_FONT_SMOOTHING_AUTO}, {eCSSKeyword_auto, NS_FONT_SMOOTHING_AUTO},
{eCSSKeyword_grayscale, NS_FONT_SMOOTHING_GRAYSCALE}, {eCSSKeyword_grayscale, NS_FONT_SMOOTHING_GRAYSCALE},
{eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE}}; {eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE},
};
const KTableEntry nsCSSProps::kTextAlignKTable[] = { const KTableEntry nsCSSProps::kTextAlignKTable[] = {
{eCSSKeyword_left, NS_STYLE_TEXT_ALIGN_LEFT}, {eCSSKeyword_left, NS_STYLE_TEXT_ALIGN_LEFT},
@ -228,7 +182,8 @@ const KTableEntry nsCSSProps::kTextAlignKTable[] = {
{eCSSKeyword__moz_left, NS_STYLE_TEXT_ALIGN_MOZ_LEFT}, {eCSSKeyword__moz_left, NS_STYLE_TEXT_ALIGN_MOZ_LEFT},
{eCSSKeyword_start, NS_STYLE_TEXT_ALIGN_START}, {eCSSKeyword_start, NS_STYLE_TEXT_ALIGN_START},
{eCSSKeyword_end, NS_STYLE_TEXT_ALIGN_END}, {eCSSKeyword_end, NS_STYLE_TEXT_ALIGN_END},
{eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE}}; {eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE},
};
const KTableEntry nsCSSProps::kTextDecorationStyleKTable[] = { const KTableEntry nsCSSProps::kTextDecorationStyleKTable[] = {
{eCSSKeyword__moz_none, NS_STYLE_TEXT_DECORATION_STYLE_NONE}, {eCSSKeyword__moz_none, NS_STYLE_TEXT_DECORATION_STYLE_NONE},
@ -237,7 +192,8 @@ const KTableEntry nsCSSProps::kTextDecorationStyleKTable[] = {
{eCSSKeyword_dotted, NS_STYLE_TEXT_DECORATION_STYLE_DOTTED}, {eCSSKeyword_dotted, NS_STYLE_TEXT_DECORATION_STYLE_DOTTED},
{eCSSKeyword_dashed, NS_STYLE_TEXT_DECORATION_STYLE_DASHED}, {eCSSKeyword_dashed, NS_STYLE_TEXT_DECORATION_STYLE_DASHED},
{eCSSKeyword_wavy, NS_STYLE_TEXT_DECORATION_STYLE_WAVY}, {eCSSKeyword_wavy, NS_STYLE_TEXT_DECORATION_STYLE_WAVY},
{eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE}}; {eCSSKeyword_UNKNOWN, nsCSSKTableEntry::SENTINEL_VALUE},
};
int32_t nsCSSProps::FindIndexOfKeyword(nsCSSKeyword aKeyword, int32_t nsCSSProps::FindIndexOfKeyword(nsCSSKeyword aKeyword,
const KTableEntry aTable[]) { const KTableEntry aTable[]) {

Просмотреть файл

@ -278,7 +278,6 @@ class nsCSSProps {
if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState)es_)) if (nsCSSProps::IsEnabled(*it_, (mozilla::CSSEnabledState)es_))
// Keyword/Enum value tables // Keyword/Enum value tables
static const KTableEntry kCursorKTable[];
static const KTableEntry kFontSmoothingKTable[]; static const KTableEntry kFontSmoothingKTable[];
static const KTableEntry kTextAlignKTable[]; static const KTableEntry kTextAlignKTable[];
static const KTableEntry kTextDecorationStyleKTable[]; static const KTableEntry kTextDecorationStyleKTable[];

Просмотреть файл

@ -6860,3 +6860,17 @@ pub extern "C" fn Servo_LengthPercentage_ToCss(
) { ) {
lp.to_css(&mut CssWriter::new(result)).unwrap(); lp.to_css(&mut CssWriter::new(result)).unwrap();
} }
#[no_mangle]
pub unsafe extern "C" fn Servo_CursorKind_Parse(
cursor: &nsACString,
result: &mut computed::ui::CursorKind,
) -> bool {
match computed::ui::CursorKind::from_ident(cursor.as_str_unchecked()) {
Ok(c) => {
*result = c;
true
}
Err(..) => false,
}
}