Commit 4b9e01ed authored by Mason Freed's avatar Mason Freed Committed by Commit Bot

Change word-break to break-all for the view-source table

Previously, the view-source table used the UA stylesheet value for
word-break, which was break-word. This, combined with the prior
quirks-mode view source document, was a very slow Layout path.
With this change, the view-source table is set to break-all, which
should be faster. Long lines are now broken at the edge of the
page, rather than on word boundaries. So the display is different
than before. However, the content is the same, so this should
be ok.

Bug: 920571
Change-Id: Ic045c4dc5f6f467ef1bfb3a6317d6c9020968370
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424038
Commit-Queue: Mason Freed <masonfreed@chromium.org>
Auto-Submit: Mason Freed <masonfreed@chromium.org>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810052}
parent 326c62c4
......@@ -24,6 +24,7 @@
#include "third_party/blink/renderer/core/html/html_view_source_document.h"
#include "third_party/blink/renderer/core/css/css_value_id_mappings.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_base_element.h"
......@@ -38,6 +39,7 @@
#include "third_party/blink/renderer/core/html/html_table_row_element.h"
#include "third_party/blink/renderer/core/html/html_table_section_element.h"
#include "third_party/blink/renderer/core/html/parser/html_view_source_parser.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink {
......@@ -68,6 +70,8 @@ void HTMLViewSourceDocument::CreateContainingTable() {
body->ParserAppendChild(div);
auto* table = MakeGarbageCollected<HTMLTableElement>(*this);
table->SetInlineStyleProperty(CSSPropertyID::kWordBreak,
PlatformEnumToCSSValueID(EWordBreak::kKeepAll));
body->ParserAppendChild(table);
tbody_ = MakeGarbageCollected<HTMLTableSectionElement>(html_names::kTbodyTag,
*this);
......
......@@ -38,7 +38,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource1) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -91,7 +92,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource2) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -143,7 +145,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource3) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -208,7 +211,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource4) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -276,7 +280,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource5) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"><br></td></tr><tr><td "
......@@ -308,7 +313,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource6) {
LoadMainResource((many_spaces + std::string(" <b>A</b> ")).c_str());
std::string expected_beginning(
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td class=\"line-content\"> "
" ");
std::string expected_ending(
......@@ -324,7 +330,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource7) {
LoadMainResource("1234567");
EXPECT_EQ(GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\">1234567<span "
"class=\"html-end-of-file\"></span></td></tr></tbody></table></"
......@@ -346,7 +353,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource8) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -413,7 +421,8 @@ TEST_F(HTMLViewSourceDocumentTest, ViewSource9) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> <span "
......@@ -444,7 +453,8 @@ TEST_F(HTMLViewSourceDocumentTest, IncompleteToken) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td "
"class=\"line-content\"><br></td></tr><tr><td class=\"line-number\" "
"value=\"2\"></td><td class=\"line-content\"> Incomplete token "
......@@ -466,7 +476,8 @@ TEST_F(HTMLViewSourceDocumentTest, UnfinishedTextarea) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td class=\"line-content\"><span "
"class=\"html-tag\">&lt;textarea&gt;</span>foobar in "
"textarea</td></tr><tr><td class=\"line-number\" value=\"2\"></td><td "
......@@ -481,7 +492,8 @@ TEST_F(HTMLViewSourceDocumentTest, UnfinishedScript) {
EXPECT_EQ(
GetDocument().documentElement()->outerHTML(),
"<html><head></head><body><div "
"class=\"line-gutter-backdrop\"></div><table><tbody><tr><td "
"class=\"line-gutter-backdrop\"></div><table style=\"word-break: "
"keep-all;\"><tbody><tr><td "
"class=\"line-number\" value=\"1\"></td><td class=\"line-content\"><span "
"class=\"html-tag\">&lt;script&gt;</span>foobar in "
"script</td></tr><tr><td class=\"line-number\" value=\"2\"></td><td "
......
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