Commit 2ce5631f authored by Mason Freed's avatar Mason Freed Committed by Chromium LUCI CQ

Fix the width of the "Line wrap" control bar on View-Source

The previous bar had a 100% width, which made the right edge
visible if the window was scrolled. With this implementation,
the control is the first row in the table, so the width is
max-content. (Simply making <body> max-width doesn't work,
because then when trying to line-wrap, the table is too
wide and doesn't wrap anything.)

Fixed: 1154219
Change-Id: I8d35eb632c59f7dc8c8e8c76c3575018669d82da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582636
Commit-Queue: Koji Ishii <kojii@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835517}
parent aca14864
...@@ -54,6 +54,10 @@ table { ...@@ -54,6 +54,10 @@ table {
align-items: center; align-items: center;
} }
.line-wrap-cell {
white-space: normal;
}
td { td {
padding: 0 !important; padding: 0 !important;
vertical-align: baseline vertical-align: baseline
......
...@@ -93,6 +93,20 @@ void HTMLViewSourceDocument::CreateContainingTable() { ...@@ -93,6 +93,20 @@ void HTMLViewSourceDocument::CreateContainingTable() {
auto* body = MakeGarbageCollected<HTMLBodyElement>(*this); auto* body = MakeGarbageCollected<HTMLBodyElement>(*this);
html->ParserAppendChild(body); html->ParserAppendChild(body);
// Create a line gutter div that can be used to make sure the gutter extends
// down the height of the whole document.
auto* div = MakeGarbageCollected<HTMLDivElement>(*this);
div->setAttribute(html_names::kClassAttr, "line-gutter-backdrop");
body->ParserAppendChild(div);
auto* table = MakeGarbageCollected<HTMLTableElement>(*this);
body->ParserAppendChild(table);
tbody_ = MakeGarbageCollected<HTMLTableSectionElement>(html_names::kTbodyTag,
*this);
table->ParserAppendChild(tbody_);
current_ = tbody_;
line_number_ = 0;
// Create a checkbox to control line wrapping. // Create a checkbox to control line wrapping.
auto* line_wrap_div = MakeGarbageCollected<HTMLDivElement>(*this); auto* line_wrap_div = MakeGarbageCollected<HTMLDivElement>(*this);
line_wrap_div->setAttribute(html_names::kClassAttr, "line-wrap-control"); line_wrap_div->setAttribute(html_names::kClassAttr, "line-wrap-control");
...@@ -107,21 +121,14 @@ void HTMLViewSourceDocument::CreateContainingTable() { ...@@ -107,21 +121,14 @@ void HTMLViewSourceDocument::CreateContainingTable() {
Text::Create(*this, WTF::AtomicString(Locale::DefaultLocale().QueryString( Text::Create(*this, WTF::AtomicString(Locale::DefaultLocale().QueryString(
IDS_VIEW_SOURCE_LINE_WRAP)))); IDS_VIEW_SOURCE_LINE_WRAP))));
line_wrap_div->ParserAppendChild(label); line_wrap_div->ParserAppendChild(label);
body->ParserAppendChild(line_wrap_div); auto* tr = MakeGarbageCollected<HTMLTableRowElement>(*this);
auto* td =
// Create a line gutter div that can be used to make sure the gutter extends MakeGarbageCollected<HTMLTableCellElement>(html_names::kTdTag, *this);
// down the height of the whole document. td->setAttribute(html_names::kColspanAttr, "2");
auto* div = MakeGarbageCollected<HTMLDivElement>(*this); td->setAttribute(html_names::kClassAttr, "line-wrap-cell");
div->setAttribute(html_names::kClassAttr, "line-gutter-backdrop"); td->ParserAppendChild(line_wrap_div);
body->ParserAppendChild(div); tr->ParserAppendChild(td);
tbody_->ParserAppendChild(tr);
auto* table = MakeGarbageCollected<HTMLTableElement>(*this);
body->ParserAppendChild(table);
tbody_ = MakeGarbageCollected<HTMLTableSectionElement>(html_names::kTbodyTag,
*this);
table->ParserAppendChild(tbody_);
current_ = tbody_;
line_number_ = 0;
auto* listener = auto* listener =
MakeGarbageCollected<ViewSourceEventListener>(table, checkbox); MakeGarbageCollected<ViewSourceEventListener>(table, checkbox);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment