From 7db19361b48909f7cab3995f05703f5b2dd10f8f Mon Sep 17 00:00:00 2001 From: Fedor Date: Wed, 14 Oct 2020 01:52:48 +0300 Subject: [PATCH] Implement overflow-wrap: anywhere. --- devtools/shared/css/generated/properties-db.js | 2 ++ layout/generic/nsTextFrame.cpp | 5 +++-- layout/style/nsCSSKeywordList.h | 1 + layout/style/nsCSSProps.cpp | 1 + layout/style/nsStyleConsts.h | 1 + layout/style/nsStyleStruct.h | 7 +++++-- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index 25d9e2d33..316352771 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -7857,6 +7857,7 @@ exports.CSS_PROPERTIES = { ], "supports": [], "values": [ + "anywhere", "break-word", "inherit", "initial", @@ -9317,6 +9318,7 @@ exports.CSS_PROPERTIES = { ], "supports": [], "values": [ + "anywhere", "break-word", "inherit", "initial", diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index cb9b5da16..e6af1e485 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -8244,8 +8244,9 @@ nsTextFrame::AddInlineMinISizeForFlow(nsRenderingContext *aRenderingContext, return; } - // If overflow-wrap is break-word, we can wrap everywhere. - if (textStyle->WordCanWrap(this)) { + // If overflow-wrap is 'anywhere', we can wrap everywhere. + if (textStyle->mOverflowWrap == NS_STYLE_OVERFLOWWRAP_ANYWHERE && + textStyle->WordCanWrap(this)) { aData->OptionallyBreak(); aData->mCurrentLine += textRun->GetMinAdvanceWidth(Range(start, flowEndInTextRun)); diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 9045da9ff..86ba59142 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -144,6 +144,7 @@ CSS_KEY(alternate, alternate) CSS_KEY(alternate-reverse, alternate_reverse) CSS_KEY(always, always) CSS_KEY(annotation, annotation) +CSS_KEY(anywhere, anywhere) CSS_KEY(appworkspace, appworkspace) CSS_KEY(auto, auto) CSS_KEY(auto-fill, auto_fill) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 24c97cf33..e0cda2488 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -2284,6 +2284,7 @@ const KTableEntry nsCSSProps::kWordBreakKTable[] = { const KTableEntry nsCSSProps::kOverflowWrapKTable[] = { { eCSSKeyword_normal, NS_STYLE_OVERFLOWWRAP_NORMAL }, { eCSSKeyword_break_word, NS_STYLE_OVERFLOWWRAP_BREAK_WORD }, + { eCSSKeyword_anywhere, NS_STYLE_OVERFLOWWRAP_ANYWHERE }, { eCSSKeyword_UNKNOWN, -1 } }; diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index f54387aa8..e6a0cc65a 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -997,6 +997,7 @@ enum class StyleDisplay : uint8_t { // See nsStyleText #define NS_STYLE_OVERFLOWWRAP_NORMAL 0 #define NS_STYLE_OVERFLOWWRAP_BREAK_WORD 1 +#define NS_STYLE_OVERFLOWWRAP_ANYWHERE 2 // See nsStyleText #define NS_STYLE_HYPHENS_NONE 0 diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index f49cdc43e..cca7bb8d4 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2134,8 +2134,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText } bool WordCanWrapStyle() const { - return WhiteSpaceCanWrapStyle() && - mOverflowWrap == NS_STYLE_OVERFLOWWRAP_BREAK_WORD; + if (!WhiteSpaceCanWrapStyle()) { + return false; + } + return (mOverflowWrap == NS_STYLE_OVERFLOWWRAP_BREAK_WORD || + mOverflowWrap == NS_STYLE_OVERFLOWWRAP_ANYWHERE); } bool HasTextEmphasis() const {