summaryrefslogtreecommitdiffstats
path: root/layout/generic/nsTextFrame.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-05-14 10:50:01 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-05-14 10:50:01 +0200
commite9dd029f5d00590e1a53e63b0ab805110a10b54c (patch)
tree1126ca5dda925a62be3dc12c99c90e953d08afcf /layout/generic/nsTextFrame.cpp
parent9d6a7ae25d7f5da855a8f8df884de483b4e2a538 (diff)
parent36b8fd734f590eb726ca2e50f8d1ff9cc968b8e1 (diff)
downloadUXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar
UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.gz
UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.lz
UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.xz
UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.zip
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'layout/generic/nsTextFrame.cpp')
-rw-r--r--layout/generic/nsTextFrame.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp
index 00c0016fd..fa31443fd 100644
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2936,22 +2936,40 @@ nsTextFrame::GetTrimmedOffsets(const nsTextFragment* aFrag,
return offsets;
}
-static bool IsJustifiableCharacter(const nsTextFragment* aFrag, int32_t aPos,
+static bool IsJustifiableCharacter(const nsStyleText* aTextStyle,
+ const nsTextFragment* aFrag, int32_t aPos,
bool aLangIsCJ)
{
NS_ASSERTION(aPos >= 0, "negative position?!");
+
+ StyleTextJustify justifyStyle = aTextStyle->mTextJustify;
+ if (justifyStyle == StyleTextJustify::None) {
+ return false;
+ }
+
char16_t ch = aFrag->CharAt(aPos);
- if (ch == '\n' || ch == '\t' || ch == '\r')
+ if (ch == '\n' || ch == '\t' || ch == '\r') {
return true;
+ }
if (ch == ' ' || ch == CH_NBSP) {
// Don't justify spaces that are combined with diacriticals
- if (!aFrag->Is2b())
+ if (!aFrag->Is2b()) {
return true;
+ }
return !nsTextFrameUtils::IsSpaceCombiningSequenceTail(
- aFrag->Get2b() + aPos + 1, aFrag->GetLength() - (aPos + 1));
+ aFrag->Get2b() + aPos + 1, aFrag->GetLength() - (aPos + 1));
}
- if (ch < 0x2150u)
+
+ if (justifyStyle == StyleTextJustify::InterCharacter) {
+ return true;
+ } else if (justifyStyle == StyleTextJustify::InterWord) {
+ return false;
+ }
+
+ // text-justify: auto
+ if (ch < 0x2150u) {
return false;
+ }
if (aLangIsCJ) {
if ((0x2150u <= ch && ch <= 0x22ffu) || // Number Forms, Arrows, Mathematical Operators
(0x2460u <= ch && ch <= 0x24ffu) || // Enclosed Alphanumerics
@@ -3279,7 +3297,7 @@ PropertyProvider::ComputeJustification(
gfxSkipCharsIterator iter = run.GetPos();
for (uint32_t i = 0; i < length; ++i) {
uint32_t offset = originalOffset + i;
- if (!IsJustifiableCharacter(mFrag, offset, isCJ)) {
+ if (!IsJustifiableCharacter(mTextStyle, mFrag, offset, isCJ)) {
continue;
}