Title: [196782] trunk
- Revision
- 196782
- Author
- [email protected]
- Date
- 2016-02-18 15:48:19 -0800 (Thu, 18 Feb 2016)
Log Message
Soft hyphen is not shown when it is placed at the end of an inline element
https://bugs.webkit.org/show_bug.cgi?id=153980
Reviewed by David Hyatt.
This patch handles the case when the character at the breaking position does not fit the
line and soft-hyphen, as the first breaking opportunity, is followed by this overflowing character.
(foo­bar where b overflows the line).
In such cases we don't yet have an item in the breaking history so we need to take a look at
the current context instead.
Source/WebCore:
Test: fast/text/soft-hyphen-as-first-breaking-opportunity.html
* rendering/line/BreakingContext.h:
(WebCore::BreakingContext::InlineIteratorHistory::nextBreakablePosition):
(WebCore::BreakingContext::handleText):
LayoutTests:
* fast/text/soft-hyphen-as-first-breaking-opportunity-expected.html: Added.
* fast/text/soft-hyphen-as-first-breaking-opportunity.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (196781 => 196782)
--- trunk/LayoutTests/ChangeLog 2016-02-18 23:43:57 UTC (rev 196781)
+++ trunk/LayoutTests/ChangeLog 2016-02-18 23:48:19 UTC (rev 196782)
@@ -1,3 +1,19 @@
+2016-02-18 Zalan Bujtas <[email protected]>
+
+ Soft hyphen is not shown when it is placed at the end of an inline element
+ https://bugs.webkit.org/show_bug.cgi?id=153980
+
+ Reviewed by David Hyatt.
+
+ This patch handles the case when the character at the breaking position does not fit the
+ line and soft-hyphen, as the first breaking opportunity, is followed by this overflowing character.
+ (foo­bar where b overflows the line).
+ In such cases we don't yet have an item in the breaking history so we need to take a look at
+ the current context instead.
+
+ * fast/text/soft-hyphen-as-first-breaking-opportunity-expected.html: Added.
+ * fast/text/soft-hyphen-as-first-breaking-opportunity.html: Added.
+
2016-02-18 Ryan Haddad <[email protected]>
Rebaseline imported/w3c/web-platform-tests/html/dom/interfaces.html for ios-simulator after r196770
Added: trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity-expected.html (0 => 196782)
--- trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity-expected.html (rev 0)
+++ trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity-expected.html 2016-02-18 23:48:19 UTC (rev 196782)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>This tests that soft-hyphen is placed correctly when it is the first breaking opportunity.</title>
+<style>
+.wrap {
+ width: 200px;
+ border: 1px solid;
+}
+.soft-hyphen {
+ color: red;
+}
+</style>
+</head>
+<body>
+<h2>No extra element.</h2>
+<div class="wrap">mmmmmmmmmmmmmm-mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen inside a styled span.</h2>
+<div class="wrap">mmmmmmmmmmmmmm<span class="soft-hyphen">-</span>mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen at the end of a styled span with text in it.</h2>
+<div class="wrap">mmmmmmmmmmmmm<span class="soft-hyphen">m-</span>mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen at the start of a styled span with text in it.</h2>
+<div class="wrap">mmmmmmmmmmmmmm<span class="soft-hyphen">-m</span>mmmmmmmmmmmmm
+</div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity.html (0 => 196782)
--- trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity.html (rev 0)
+++ trunk/LayoutTests/fast/text/soft-hyphen-as-first-breaking-opportunity.html 2016-02-18 23:48:19 UTC (rev 196782)
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>This tests that soft-hyphen is placed correctly when it is the first breaking opportunity.</title>
+<style>
+.wrap {
+ width: 200px;
+ border: 1px solid;
+}
+.soft-hyphen {
+ color: red;
+}
+</style>
+</head>
+<body>
+<h2>No extra element.</h2>
+<div class="wrap">mmmmmmmmmmmmmm­mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen inside a styled span.</h2>
+<div class="wrap">mmmmmmmmmmmmmm<span class="soft-hyphen">­</span>mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen at the end of a styled span with text in it.</h2>
+<div class="wrap">mmmmmmmmmmmmm<span class="soft-hyphen">m­</span>mmmmmmmmmmmmmm
+</div>
+<h2>Soft hyphen at the start of a styled span with text in it.</h2>
+<div class="wrap">mmmmmmmmmmmmmm<span class="soft-hyphen">­m</span>mmmmmmmmmmmmm
+</div>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (196781 => 196782)
--- trunk/Source/WebCore/ChangeLog 2016-02-18 23:43:57 UTC (rev 196781)
+++ trunk/Source/WebCore/ChangeLog 2016-02-18 23:48:19 UTC (rev 196782)
@@ -1,3 +1,22 @@
+2016-02-18 Zalan Bujtas <[email protected]>
+
+ Soft hyphen is not shown when it is placed at the end of an inline element
+ https://bugs.webkit.org/show_bug.cgi?id=153980
+
+ Reviewed by David Hyatt.
+
+ This patch handles the case when the character at the breaking position does not fit the
+ line and soft-hyphen, as the first breaking opportunity, is followed by this overflowing character.
+ (foo­bar where b overflows the line).
+ In such cases we don't yet have an item in the breaking history so we need to take a look at
+ the current context instead.
+
+ Test: fast/text/soft-hyphen-as-first-breaking-opportunity.html
+
+ * rendering/line/BreakingContext.h:
+ (WebCore::BreakingContext::InlineIteratorHistory::nextBreakablePosition):
+ (WebCore::BreakingContext::handleText):
+
2016-02-18 Andreas Kling <[email protected]>
Fake memory pressure handler should log detailed memory breakdown.
Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (196781 => 196782)
--- trunk/Source/WebCore/rendering/line/BreakingContext.h 2016-02-18 23:43:57 UTC (rev 196781)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h 2016-02-18 23:48:19 UTC (rev 196782)
@@ -200,6 +200,7 @@
RenderObject* renderer() const { return this->at(0).renderer(); }
unsigned offset() const { return this->at(0).offset(); }
+ int nextBreakablePosition() const { return this->at(0).nextBreakablePosition(); }
bool atTextParagraphSeparator() const { return this->at(0).atTextParagraphSeparator(); }
UChar previousInSameNode() const { return this->at(0).previousInSameNode(); }
const InlineIterator& get(size_t i) const { return this->at(i); };
@@ -776,6 +777,7 @@
// Non-zero only when kerning is enabled and TextLayout isn't used, in which case we measure
// words with their trailing space, then subtract its width.
HashSet<const Font*> fallbackFonts;
+ UChar lastCharacterFromPreviousRenderText = m_renderTextInfo.lineBreakIterator.lastCharacter();
UChar lastCharacter = m_renderTextInfo.lineBreakIterator.lastCharacter();
UChar secondToLastCharacter = m_renderTextInfo.lineBreakIterator.secondToLastCharacter();
WordTrailingSpace wordTrailingSpace(renderText, style, textLayout);
@@ -903,8 +905,33 @@
m_lineInfo.setPreviousLineBrokeCleanly(true);
wordMeasurement.endOffset = m_lineBreakHistory.offset();
}
- if (m_lineBreakHistory.offset() && downcast<RenderText>(m_lineBreakHistory.renderer()) && downcast<RenderText>(*m_lineBreakHistory.renderer()).textLength() && downcast<RenderText>(*m_lineBreakHistory.renderer()).characterAt(m_lineBreakHistory.offset() - 1) == softHyphen && style.hyphens() != HyphensNone)
- hyphenated = true;
+ // Check if the last breaking position is a soft-hyphen.
+ if (!hyphenated && style.hyphens() != HyphensNone) {
+ Optional<int> lastBreakingPositon;
+ const RenderObject* rendererAtBreakingPosition = nullptr;
+ if (m_lineBreakHistory.offset() || m_lineBreakHistory.nextBreakablePosition() > -1) {
+ lastBreakingPositon = m_lineBreakHistory.offset();
+ rendererAtBreakingPosition = m_lineBreakHistory.renderer();
+ } else if (m_current.nextBreakablePosition() > -1 && (unsigned)m_current.nextBreakablePosition() <= m_current.offset()) {
+ // We might just be right after the soft-hyphen
+ lastBreakingPositon = m_current.nextBreakablePosition();
+ rendererAtBreakingPosition = m_current.renderer();
+ }
+ if (lastBreakingPositon) {
+ Optional<UChar> characterBeforeBreakingPosition;
+ // When last breaking position points to the start of the current context, we need to look at the last character from
+ // the previous non-empty text renderer.
+ if (!lastBreakingPositon.value())
+ characterBeforeBreakingPosition = lastCharacterFromPreviousRenderText;
+ else if (is<RenderText>(rendererAtBreakingPosition)) {
+ const auto& textRenderer = downcast<RenderText>(*rendererAtBreakingPosition);
+ ASSERT(textRenderer.textLength() > (unsigned)(lastBreakingPositon.value() - 1));
+ characterBeforeBreakingPosition = textRenderer.characterAt(lastBreakingPositon.value() - 1);
+ }
+ if (characterBeforeBreakingPosition)
+ hyphenated = characterBeforeBreakingPosition.value() == softHyphen;
+ }
+ }
if (m_lineBreakHistory.offset() && m_lineBreakHistory.offset() != (unsigned)wordMeasurement.endOffset && !wordMeasurement.width) {
if (charWidth) {
wordMeasurement.endOffset = m_lineBreakHistory.offset();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes