From 2c5e08f648224ea785775a8db48fba018ffd2455 Mon Sep 17 00:00:00 2001 From: JohnAlbin Date: Sun, 10 Feb 2013 12:18:17 +0800 Subject: [PATCH] Issue #1924430: Add drupal.base library for base CSS styles. --- core/includes/theme.maintenance.inc | 5 +- core/misc/drupal.base-rtl.css | 20 +++++++ core/misc/drupal.base.css | 83 ++++++++++++++++++++++++++++++ core/modules/overlay/overlay-child-rtl.css | 4 -- core/modules/system/system.base.css | 32 ------------ core/modules/system/system.module | 16 +++++- core/modules/system/system.theme-rtl.css | 13 ----- core/modules/system/system.theme.css | 43 ---------------- 8 files changed, 121 insertions(+), 95 deletions(-) create mode 100644 core/misc/drupal.base-rtl.css create mode 100644 core/misc/drupal.base.css diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index cda4109..2559ca3 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -90,8 +90,9 @@ function _drupal_maintenance_theme() { } _drupal_theme_initialize($themes[$theme], array_reverse($base_theme), '_theme_load_offline_registry'); - // These are usually added from system_init() -except maintenance.css. - // When the database is inactive it's not called so we add it here. + // These are usually added from system_page_build(), except maintenance.css. + // When the database is inactive, it's not called so we add them here. + drupal_add_library('system', 'drupal.base'); $path = drupal_get_path('module', 'system'); drupal_add_css($path . '/system.base.css'); drupal_add_css($path . '/system.admin.css'); diff --git a/core/misc/drupal.base-rtl.css b/core/misc/drupal.base-rtl.css new file mode 100644 index 0000000..f4ad6d5 --- /dev/null +++ b/core/misc/drupal.base-rtl.css @@ -0,0 +1,20 @@ +/** + * @file + * Provides RTL base styling for HTML elements in Drupal. + */ + +html { + direction: rtl; +} + +/** + * Table elements. + */ +caption { + text-align: right; +} +th { + padding-left: 1em; + padding-right: 0; + text-align: right; +} diff --git a/core/misc/drupal.base.css b/core/misc/drupal.base.css new file mode 100644 index 0000000..4e3c7ff --- /dev/null +++ b/core/misc/drupal.base.css @@ -0,0 +1,83 @@ +/** + * @file + * Provides a base styling for HTML elements in Drupal. + */ + +/** + * Block-level HTML5 display definition. + * + * Provides display values for browsers that don't recognize the new elements + * and therefore display them inline by default. + */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * Form elements. + */ +form { + margin: 0; + padding: 0; +} +fieldset { + border: 1px solid #ccc; + margin: 1em 0; + padding: 0.5em; +} +label { + display: block; + font-weight: bold; +} +input { + /* Keep form elements from overflowing their containers. */ + max-width: 100%; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +/** + * Table elements. + */ +table { + border-collapse: collapse; + width: 100%; +} +caption { + text-align: left; /* LTR */ +} +th { + padding-right: 1em; /* LTR */ + text-align: left; /* LTR */ +} +thead > tr { + border-bottom: 1px solid #000; +} +tr { + border-bottom: 1px solid #ccc; + padding: 0.1em 0.6em; +} + +/** + * Miscellaneous elements. + */ +hr { + border: 1px solid gray; + height: 1px; +} +img { + border: 0; +} diff --git a/core/modules/overlay/overlay-child-rtl.css b/core/modules/overlay/overlay-child-rtl.css index 0751b56..e595d11 100644 --- a/core/modules/overlay/overlay-child-rtl.css +++ b/core/modules/overlay/overlay-child-rtl.css @@ -3,10 +3,6 @@ * RTL styling for Overlay child pages. */ -html { - direction: rtl; -} - #overlay-title { float: right; left: auto; diff --git a/core/modules/system/system.base.css b/core/modules/system/system.base.css index a0b66e6..3797b3f 100644 --- a/core/modules/system/system.base.css +++ b/core/modules/system/system.base.css @@ -175,16 +175,6 @@ tr .ajax-progress-throbber .throbber { } /** - * Keep form elements from overflowing their containers. - */ -input { - max-width: 100%; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; -} - -/** * Inline items. */ .container-inline div, @@ -273,25 +263,3 @@ input { display: table; clear: both; } - -/** - * Block-level HTML5 display definition. - * - * Provides display values for browsers that don't recognize the new elements - * and therefore display them inline by default. - */ -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -main, -menu, -nav, -section, -summary { - display: block; -} diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 70b8dab..c975b0f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1581,7 +1581,19 @@ function system_library_info() { 'css' => array( 'core/misc/normalize/normalize.css' => array( 'every_page' => TRUE, - 'weight' => -10, + 'weight' => CSS_BASE - 20, + ), + ), + ); + + // Drupal's base CSS. + $libraries['drupal.base'] = array( + 'title' => 'Drupal base CSS', + 'version' => VERSION, + 'css' => array( + 'core/misc/drupal.base.css' => array( + 'every_page' => TRUE, + 'weight' => CSS_BASE - 10, ), ), ); @@ -2562,6 +2574,8 @@ function system_init() { * Implements hook_page_build(). */ function system_page_build(&$page) { + // Note: ensure the same CSS is loaded in _drupal_maintenance_theme(). + $page['#attached']['library'][] = array('system', 'drupal.base'); $path = drupal_get_path('module', 'system'); // Use the CSS_AGGREGATE_SYSTEM group to load these early. $page['#attached']['css'][$path . '/system.base.css'] = array('group' => CSS_AGGREGATE_SYSTEM, 'every_page' => TRUE); diff --git a/core/modules/system/system.theme-rtl.css b/core/modules/system/system.theme-rtl.css index b2ee453..f5de071 100644 --- a/core/modules/system/system.theme-rtl.css +++ b/core/modules/system/system.theme-rtl.css @@ -1,22 +1,9 @@ - /** * @file * RTL styles for common markup. */ /** - * HTML elements. - */ -th { - text-align: right; - padding-left: 1em; - padding-right: 0; -} -caption { - text-align: right; -} - -/** * Markup generated by theme_item_list(). */ .item-list ul li { diff --git a/core/modules/system/system.theme.css b/core/modules/system/system.theme.css index 680d15e..0b4a730 100644 --- a/core/modules/system/system.theme.css +++ b/core/modules/system/system.theme.css @@ -1,48 +1,9 @@ - /** * @file * Basic styling for common markup. */ /** - * HTML elements. - */ -fieldset { - border: 1px solid #ccc; - margin: 1em 0; - padding: 0.5em; -} -form { - margin: 0; - padding: 0; -} -hr { - border: 1px solid gray; - height: 1px; -} -img { - border: 0; -} -table { - border-collapse: collapse; - width: 100%; -} -th { - padding-right: 1em; /* LTR */ - text-align: left; /* LTR */ -} -thead > tr { - border-bottom: 1px solid #000; -} -tr { - border-bottom: 1px solid #ccc; - padding: 0.1em 0.6em; -} -caption { - text-align: left; /* LTR */ -} - -/** * Publishing status. */ .unpublished { @@ -94,10 +55,6 @@ tr.even .form-item { .form-item .description { font-size: 0.85em; } -label { - display: block; - font-weight: bold; -} label.option { display: inline; font-weight: normal; -- 1.8.2.1