Ruby overhang uses ints instead of floats
https://bugs.webkit.org/show_bug.cgi?id=139624
Reviewed by Dave Hyatt.
Source/WebCore:
Simply change the type.
Updated existing tests.
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlockFlow::setMarginsForRubyRun):
* rendering/RenderRubyRun.cpp:
(WebCore::RenderRubyRun::getOverhang):
* rendering/RenderRubyRun.h:
* rendering/line/LineWidth.cpp:
(WebCore::LineWidth::applyOverhang):
LayoutTests:
Updating tests.
* fast/ruby/overhang-horizontal-expected.png:
* fast/ruby/overhang-horizontal-expected.txt:
* fast/ruby/overhang-vertical-expected.png:
* fast/ruby/overhang-vertical-expected.txt:
* platform/mac/fast/ruby/ruby-beforeafter-expected.png:
* platform/mac/fast/ruby/ruby-beforeafter-expected.txt:
* platform/mac/fast/ruby/ruby-length-expected.png:
* platform/mac/fast/ruby/ruby-length-expected.txt:
* platform/mac/fast/ruby/ruby-run-break-expected.png:
* platform/mac/fast/ruby/ruby-run-break-expected.txt:
* platform/mac/fast/ruby/ruby-runs-expected.png:
* platform/mac/fast/ruby/ruby-runs-expected.txt:
* platform/mac/fast/ruby/ruby-runs-spans-expected.png:
* platform/mac/fast/ruby/ruby-runs-spans-expected.txt:
* platform/mac/fast/ruby/ruby-trailing-expected.png:
* platform/mac/fast/ruby/ruby-trailing-expected.txt:
* platform/mac/fast/ruby/rubyDOM-insert-rt-expected.png:
* platform/mac/fast/ruby/rubyDOM-insert-rt-expected.txt:
* platform/mac/fast/ruby/rubyDOM-insert-text1-expected.png:
* platform/mac/fast/ruby/rubyDOM-insert-text1-expected.txt:
* platform/mac/fast/ruby/rubyDOM-insert-text2-expected.png:
* platform/mac/fast/ruby/rubyDOM-insert-text2-expected.txt:
* platform/mac/fast/ruby/rubyDOM-insert-text3-expected.png:
* platform/mac/fast/ruby/rubyDOM-insert-text3-expected.txt:
* platform/mac/fast/ruby/rubyDOM-remove-rt1-expected.png:
* platform/mac/fast/ruby/rubyDOM-remove-rt1-expected.txt:
* platform/mac/fast/ruby/rubyDOM-remove-rt2-expected.png:
* platform/mac/fast/ruby/rubyDOM-remove-rt2-expected.txt:
* platform/mac/fast/ruby/rubyDOM-remove-text1-expected.png:
* platform/mac/fast/ruby/rubyDOM-remove-text1-expected.txt:
* platform/mac/fast/writing-mode/Kusa-Makura-background-canvas-expected.png:
* platform/mac/fast/writing-mode/Kusa-Makura-background-canvas-expected.txt:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@177398 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 3078e46..ff9324e 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
+2014-12-16 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Ruby overhang uses ints instead of floats
+ https://bugs.webkit.org/show_bug.cgi?id=139624
+
+ Reviewed by Dave Hyatt.
+
+ Simply change the type.
+
+ Updated existing tests.
+
+ * rendering/RenderBlockLineLayout.cpp:
+ (WebCore::RenderBlockFlow::setMarginsForRubyRun):
+ * rendering/RenderRubyRun.cpp:
+ (WebCore::RenderRubyRun::getOverhang):
+ * rendering/RenderRubyRun.h:
+ * rendering/line/LineWidth.cpp:
+ (WebCore::LineWidth::applyOverhang):
+
2014-12-16 Gavin Barraclough <barraclough@apple.com>
Move Mac process suppression from WebCore to WebKit2
diff --git a/Source/WebCore/rendering/RenderBlockLineLayout.cpp b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
index 7f8b856..0ae96cf 100644
--- a/Source/WebCore/rendering/RenderBlockLineLayout.cpp
+++ b/Source/WebCore/rendering/RenderBlockLineLayout.cpp
@@ -441,8 +441,8 @@
void RenderBlockFlow::setMarginsForRubyRun(BidiRun* run, RenderRubyRun& renderer, RenderObject* previousObject, const LineInfo& lineInfo)
{
- int startOverhang;
- int endOverhang;
+ float startOverhang;
+ float endOverhang;
RenderObject* nextObject = 0;
for (BidiRun* runWithNextObject = run->next(); runWithNextObject; runWithNextObject = runWithNextObject->next()) {
if (!runWithNextObject->renderer().isOutOfFlowPositioned() && !runWithNextObject->box()->isLineBreak()) {
diff --git a/Source/WebCore/rendering/RenderRubyRun.cpp b/Source/WebCore/rendering/RenderRubyRun.cpp
index ef45a7f..a9114fd 100644
--- a/Source/WebCore/rendering/RenderRubyRun.cpp
+++ b/Source/WebCore/rendering/RenderRubyRun.cpp
@@ -306,7 +306,7 @@
return style.fontSize() <= rubyBaseStyle.fontSize();
}
-void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, int& startOverhang, int& endOverhang) const
+void RenderRubyRun::getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, float& startOverhang, float& endOverhang) const
{
ASSERT(!needsLayout());
@@ -322,12 +322,12 @@
if (!rubyBase->firstRootBox())
return;
- int logicalWidth = this->logicalWidth();
- int logicalLeftOverhang = std::numeric_limits<int>::max();
- int logicalRightOverhang = std::numeric_limits<int>::max();
+ LayoutUnit logicalWidth = this->logicalWidth();
+ float logicalLeftOverhang = std::numeric_limits<float>::max();
+ float logicalRightOverhang = std::numeric_limits<float>::max();
for (RootInlineBox* rootInlineBox = rubyBase->firstRootBox(); rootInlineBox; rootInlineBox = rootInlineBox->nextRootBox()) {
- logicalLeftOverhang = std::min<int>(logicalLeftOverhang, rootInlineBox->logicalLeft());
- logicalRightOverhang = std::min<int>(logicalRightOverhang, logicalWidth - rootInlineBox->logicalRight());
+ logicalLeftOverhang = std::min<float>(logicalLeftOverhang, rootInlineBox->logicalLeft());
+ logicalRightOverhang = std::min<float>(logicalRightOverhang, logicalWidth - rootInlineBox->logicalRight());
}
startOverhang = style().isLeftToRightDirection() ? logicalLeftOverhang : logicalRightOverhang;
@@ -342,11 +342,11 @@
// We can overhang the ruby by no more than half the width of the neighboring text
// and no more than half the font size.
const RenderStyle& rubyTextStyle = firstLine ? rubyText->firstLineStyle() : rubyText->style();
- int halfWidthOfFontSize = rubyTextStyle.fontSize() / 2;
+ float halfWidthOfFontSize = rubyTextStyle.fontSize() / 2.;
if (startOverhang)
- startOverhang = std::min<int>(startOverhang, std::min<int>(downcast<RenderText>(*startRenderer).minLogicalWidth(), halfWidthOfFontSize));
+ startOverhang = std::min(startOverhang, std::min(downcast<RenderText>(*startRenderer).minLogicalWidth(), halfWidthOfFontSize));
if (endOverhang)
- endOverhang = std::min<int>(endOverhang, std::min<int>(downcast<RenderText>(*endRenderer).minLogicalWidth(), halfWidthOfFontSize));
+ endOverhang = std::min(endOverhang, std::min(downcast<RenderText>(*endRenderer).minLogicalWidth(), halfWidthOfFontSize));
}
} // namespace WebCore
diff --git a/Source/WebCore/rendering/RenderRubyRun.h b/Source/WebCore/rendering/RenderRubyRun.h
index a7734c0..df2ad0f 100644
--- a/Source/WebCore/rendering/RenderRubyRun.h
+++ b/Source/WebCore/rendering/RenderRubyRun.h
@@ -63,7 +63,7 @@
virtual RenderBlock* firstLineBlock() const override;
virtual void updateFirstLetter() override;
- void getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, int& startOverhang, int& endOverhang) const;
+ void getOverhang(bool firstLine, RenderObject* startRenderer, RenderObject* endRenderer, float& startOverhang, float& endOverhang) const;
static RenderRubyRun* staticCreateRubyRun(const RenderObject* parentRuby);
diff --git a/Source/WebCore/rendering/line/LineWidth.cpp b/Source/WebCore/rendering/line/LineWidth.cpp
index e62ae99..a601f9a 100644
--- a/Source/WebCore/rendering/line/LineWidth.cpp
+++ b/Source/WebCore/rendering/line/LineWidth.cpp
@@ -129,14 +129,14 @@
void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRenderer, RenderObject* endRenderer)
{
- int startOverhang;
- int endOverhang;
+ float startOverhang;
+ float endOverhang;
rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhang, endOverhang);
- startOverhang = std::min<int>(startOverhang, m_committedWidth);
+ startOverhang = std::min(startOverhang, m_committedWidth);
m_availableWidth += startOverhang;
- endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - currentWidth()), 0);
+ endOverhang = std::max(std::min(endOverhang, m_availableWidth - currentWidth()), 0.0f);
m_availableWidth += endOverhang;
m_overhangWidth += startOverhang + endOverhang;
}