about summary refs log tree commit diff
path: root/src/librustdoc/html/static
diff options
context:
space:
mode:
authorJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-01-20 14:47:26 -0800
committerJacob Hoffman-Andrews <github@hoffman-andrews.com>2022-01-20 15:53:08 -0800
commit9d178e5e8d7943da8f1b4b645911f300178f5070 (patch)
tree63f1545058ae83e71f66a97882bbbbedc88da6ee /src/librustdoc/html/static
parent74fbbefea8d13683cca5eee62e4740706cb3144a (diff)
downloadrust-9d178e5e8d7943da8f1b4b645911f300178f5070.tar.gz
rust-9d178e5e8d7943da8f1b4b645911f300178f5070.zip
rustdoc: fix overflow-wrap for table layouts
For all table layouts, set overflow-wrap: break-word.
Diffstat (limited to 'src/librustdoc/html/static')
-rw-r--r--src/librustdoc/html/static/css/rustdoc.css30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css
index 44a9a571fa1..a6bc719d6a1 100644
--- a/src/librustdoc/html/static/css/rustdoc.css
+++ b/src/librustdoc/html/static/css/rustdoc.css
@@ -675,7 +675,6 @@ nav.sub {
 	margin: .5em 0;
 	width: calc(100% - 2px);
 	overflow-x: auto;
-	overflow-wrap: normal;
 	display: block;
 }
 
@@ -862,6 +861,31 @@ h2.small-section-header > .anchor {
 
 .block a.current.crate { font-weight: 500; }
 
+/*  In most contexts we use `overflow-wrap: anywhere` to ensure that we can wrap
+	as much as needed on mobile (see
+	src/test/rustdoc-gui/type-declaration-overflow.goml for an example of why
+	this matters). The `anywhere` value means:
+
+	"Soft wrap opportunities introduced by the word break are considered when
+	 calculating min-content intrinsic sizes."
+
+	https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap#values
+
+	For table layouts, that becomes a problem: the browser tries to make each
+	column as narrow as possible, and `overflow-wrap: anywhere` means it can do
+	so by breaking words - even if some other column could be shrunk without
+	breaking words! This shows up, for instance, in the `Structs` / `Modules` /
+	`Functions` (etcetera) sections of a module page, and when a docblock
+	contains a table.
+
+	So, for table layouts, override the default with break-word, which does
+	_not_ affect min-content intrinsic sizes.
+*/
+table,
+.item-table {
+	overflow-wrap: break-word;
+}
+
 .item-table {
 	display: table;
 }
@@ -2040,10 +2064,6 @@ details.rustdoc-toggle[open] > summary.hideme::after {
 		overflow-wrap: anywhere;
 	}
 
-	.docblock table code {
-		overflow-wrap: normal;
-	}
-
 	.sub-container {
 		flex-direction: column;
 	}