https://bugs.webkit.org/show_bug.cgi?id=132164
Reviewed by Darin Adler.
Inline text selection painting now snaps to device pixels. It uses the same rounding logic as
other painting functions.
Source/WebCore:
Test: fast/inline/hidpi-select-inline-on-subpixel-position.html
* rendering/EllipsisBox.cpp:
(WebCore::EllipsisBox::paintSelection):
* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::paintSelection):
(WebCore::alignSelectionRectToDevicePixels): Deleted.
* rendering/InlineTextBox.h:
LayoutTests:
* fast/inline/hidpi-select-inline-on-subpixel-position-expected.html: Added.
* fast/inline/hidpi-select-inline-on-subpixel-position.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168095
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-05-01 Zalan Bujtas <zalan@apple.com>
+
+ Subpixel rendering: Inline text selection painting should not snap to integral CSS pixel position.
+ https://bugs.webkit.org/show_bug.cgi?id=132164
+
+ Reviewed by Darin Adler.
+
+ Inline text selection painting now snaps to device pixels. It uses the same rounding logic as
+ other painting functions.
+
+ * fast/inline/hidpi-select-inline-on-subpixel-position-expected.html: Added.
+ * fast/inline/hidpi-select-inline-on-subpixel-position.html: Added.
+
2014-05-01 Rik Cabanier <cabanier@adobe.com>
Calling createPattern with a broken image must throw an invalidstate error
2014-05-01 Rik Cabanier <cabanier@adobe.com>
Calling createPattern with a broken image must throw an invalidstate error
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that inline text selection can paint to subpixel position.</title>
+<style>
+ div {
+ font-size: 16px;
+ width: 21px;
+ height: 18px;
+ position: fixed;
+ background: rgba(255, 0, 0, 0.9);
+ }
+</style>
+</head>
+<body>
+<p id="container"></p>
+<script>
+ var container = document.getElementById("container");
+ adjustment = 0.1;
+ for (i = 0; i < 10; ++i) {
+ adjustment+=0.1;
+ for (j = 0; j < 10; ++j) {
+ var e = document.createElement("div");
+ e.style.top = (30 * i + j * adjustment) + "px";
+ e.style.left = (30 * j + i * adjustment) + "px";
+ e.innerHTML = "foo";
+ container.appendChild(e);
+ }
+ }
+</script>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that inline text selection can paint to subpixel position.</title>
+<style>
+ ::selection {
+ background: rgba(255, 0, 0, 0.9);
+ }
+
+ div {
+ font-size: 16px;
+ height: 10px;
+ width: 1px;
+ height: 1px;
+ position: fixed;
+ }
+
+</style>
+</head>
+<body>
+<p id="container"></p>
+<script>
+ var container = document.getElementById("container");
+ adjustment = 0.1;
+ for (i = 0; i < 10; ++i) {
+ adjustment+=0.1;
+ for (j = 0; j < 10; ++j) {
+ var e = document.createElement("div");
+ e.style.top = (30 * i + j * adjustment) + "px";
+ e.style.left = (30 * j + i * adjustment) + "px";
+ e.innerHTML = "foo";
+ container.appendChild(e);
+ }
+ }
+
+ var range = document.createRange();
+ range.selectNode(document.getElementById("container"));
+ window.getSelection().addRange(range);
+</script>
+</body>
+</html>
+2014-05-01 Zalan Bujtas <zalan@apple.com>
+
+ Subpixel rendering: Inline text selection painting should not snap to integral CSS pixel position.
+ https://bugs.webkit.org/show_bug.cgi?id=132164
+
+ Reviewed by Darin Adler.
+
+ Inline text selection painting now snaps to device pixels. It uses the same rounding logic as
+ other painting functions.
+
+ Test: fast/inline/hidpi-select-inline-on-subpixel-position.html
+
+ * rendering/EllipsisBox.cpp:
+ (WebCore::EllipsisBox::paintSelection):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::paintSelection):
+ (WebCore::alignSelectionRectToDevicePixels): Deleted.
+ * rendering/InlineTextBox.h:
+
2014-05-01 Ryuan Choi <ryuan.choi@samsung.com>
[EFL] There are many warnings with software backend
2014-05-01 Ryuan Choi <ryuan.choi@samsung.com>
[EFL] There are many warnings with software backend
const RootInlineBox& rootBox = root();
LayoutUnit top = rootBox.selectionTop();
LayoutUnit h = rootBox.selectionHeight();
const RootInlineBox& rootBox = root();
LayoutUnit top = rootBox.selectionTop();
LayoutUnit h = rootBox.selectionHeight();
- FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h);
- alignSelectionRectToDevicePixels(clipRect);
GraphicsContextStateSaver stateSaver(*context);
GraphicsContextStateSaver stateSaver(*context);
- context->clip(clipRect);
+ float deviceScaleFactor = renderer().document().deviceScaleFactor();
+ context->clip(pixelSnappedForPainting(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWidth, h, renderer().document().deviceScaleFactor()));
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
- context->drawHighlightForText(font, RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style.colorSpace());
+ FloatPoint localOrigin = roundedForPainting(LayoutPoint(x() + paintOffset.x(), y() + paintOffset.y() + top), deviceScaleFactor);
+ context->drawHighlightForText(font, RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, TextRun::AllowTrailingExpansion), localOrigin, h, c, style.colorSpace());
}
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
}
bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
ePos = std::min(endPos - m_start, (int)m_len);
}
ePos = std::min(endPos - m_start, (int)m_len);
}
-void alignSelectionRectToDevicePixels(FloatRect& rect)
-{
- float maxX = floorf(rect.maxX());
- rect.setX(floorf(rect.x()));
- rect.setWidth(roundf(maxX - rect.x()));
-}
-
void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
{
#if ENABLE(TEXT_SELECTION)
void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor)
{
#if ENABLE(TEXT_SELECTION)
LayoutUnit selectionBottom = rootBox.selectionBottom();
LayoutUnit selectionTop = rootBox.selectionTopAdjustedForPrecedingBlock();
LayoutUnit selectionBottom = rootBox.selectionBottom();
LayoutUnit selectionTop = rootBox.selectionTopAdjustedForPrecedingBlock();
- int deltaY = roundToInt(renderer().style().isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop);
- int selHeight = std::max(0, roundToInt(selectionBottom - selectionTop));
-
- FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
- FloatRect clipRect(localOrigin, FloatSize(m_logicalWidth, selHeight));
- alignSelectionRectToDevicePixels(clipRect);
-
- context->clip(clipRect);
+ LayoutUnit deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom - logicalBottom() : logicalTop() - selectionTop;
+ LayoutUnit selectionHeight = std::max<LayoutUnit>(0, selectionBottom - selectionTop);
- context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style.colorSpace(), sPos, ePos);
+ float deviceScaleFactor = renderer().document().deviceScaleFactor();
+ FloatPoint localOrigin = roundedForPainting(LayoutPoint(boxOrigin.x(), boxOrigin.y() - deltaY), deviceScaleFactor);
+ context->clip(pixelSnappedForPainting(LayoutRect(LayoutPoint(localOrigin), LayoutSize(m_logicalWidth, selectionHeight)), deviceScaleFactor));
+ context->drawHighlightForText(font, textRun, localOrigin, selectionHeight, c, style.colorSpace(), sPos, ePos);
#else
UNUSED_PARAM(context);
UNUSED_PARAM(boxOrigin);
#else
UNUSED_PARAM(context);
UNUSED_PARAM(boxOrigin);
INLINE_BOX_OBJECT_TYPE_CASTS(InlineTextBox, isInlineTextBox())
INLINE_BOX_OBJECT_TYPE_CASTS(InlineTextBox, isInlineTextBox())
-void alignSelectionRectToDevicePixels(FloatRect&);
-
} // namespace WebCore
#endif // InlineTextBox_h
} // namespace WebCore
#endif // InlineTextBox_h