https://bugs.webkit.org/show_bug.cgi?id=72095
Patch by Robin Cao <robin.cao@torchmobile.com.cn> on 2011-11-17
Reviewed by Adam Barth.
Source/WebCore:
drawComplexText() should respect the 'from' and 'to' arguments.
Drawing the whole text run may result in text overlapping.
Test: platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html
* platform/graphics/chromium/ComplexTextControllerLinux.cpp:
(WebCore::ComplexTextController::glyphsForRange):
* platform/graphics/chromium/ComplexTextControllerLinux.h:
* platform/graphics/chromium/FontLinux.cpp:
(WebCore::Font::drawComplexText):
LayoutTests:
* platform/chromium-linux/fast/text/international/draw-complex-text-from-to-expected.png: Added.
* platform/chromium-linux/fast/text/international/draw-complex-text-from-to-expected.txt: Added.
* platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@100718
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-11-17 Robin Cao <robin.cao@torchmobile.com.cn>
+
+ [chromium] Font::drawComplexText can not draw a segment of text run
+ https://bugs.webkit.org/show_bug.cgi?id=72095
+
+ Reviewed by Adam Barth.
+
+ * platform/chromium-linux/fast/text/international/draw-complex-text-from-to-expected.png: Added.
+ * platform/chromium-linux/fast/text/international/draw-complex-text-from-to-expected.txt: Added.
+ * platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html: Added.
+
2011-11-17 Peter Kasting <pkasting@google.com>
[chromium] Fix broken expectation.
--- /dev/null
+The text and ellipsis should not overlap.
+
+هذا هو الاختبار
--- /dev/null
+<style>
+ div {
+ font-size:36pt;
+ width:100px;
+ white-space:nowrap;
+ overflow:hidden;
+ text-overflow:ellipsis;
+ direction:rtl;
+ }
+</style>
+ <script>
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText(true);
+</script>
+
+<p>The text and ellipsis should not overlap.</p>
+<div>هذا هو الاختبار</div>
+
+2011-11-17 Robin Cao <robin.cao@torchmobile.com.cn>
+
+ [chromium] Font::drawComplexText can not draw a segment of text run
+ https://bugs.webkit.org/show_bug.cgi?id=72095
+
+ Reviewed by Adam Barth.
+
+ drawComplexText() should respect the 'from' and 'to' arguments.
+ Drawing the whole text run may result in text overlapping.
+
+ Test: platform/chromium-linux/fast/text/international/draw-complex-text-from-to.html
+
+ * platform/graphics/chromium/ComplexTextControllerLinux.cpp:
+ (WebCore::ComplexTextController::glyphsForRange):
+ * platform/graphics/chromium/ComplexTextControllerLinux.h:
+ * platform/graphics/chromium/FontLinux.cpp:
+ (WebCore::Font::drawComplexText):
+
2011-11-17 Adam Barth <abarth@webkit.org>
Unique SecurityOrigins shouldn't remember their old schemes and hosts
return FloatRect(point.x() + toX, point.y(), fromX - toX, height);
}
+void ComplexTextController::glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength)
+{
+ // Character offsets within the current run. THESE MAY NOT BE IN RANGE and may
+ // be negative, etc. The code below handles this.
+ int fromChar = from - m_item.item.pos;
+ int toChar = to - m_item.item.pos;
+
+ // See if there are any characters in the current run.
+ if (!numCodePoints() || fromChar >= static_cast<int>(numCodePoints()) || toChar <= 0) {
+ fromGlyph = -1;
+ glyphLength = 0;
+ return;
+ }
+
+ // Compute the starting glyph within this span. |from| and |to| are
+ // global offsets that may intersect arbitrarily with our local run.
+ fromGlyph = m_item.log_clusters[fromChar < 0 ? 0 : fromChar];
+ if (toChar >= static_cast<int>(numCodePoints()))
+ glyphLength = length() - fromGlyph;
+ else
+ glyphLength = m_item.log_clusters[toChar] - fromGlyph;
+}
+
} // namespace WebCore
bool rtl() const { return m_run.rtl(); }
const uint16_t* glyphs() const { return m_glyphs16; }
+ // Return the start index and length of glyphs for the range [from, to) in the current script run.
+ void glyphsForRange(int from, int to, int& fromGlyph, int& glyphLength);
+
// Return the length of the array returned by |glyphs|
const unsigned length() const { return m_item.num_glyphs; }
controller.setupForRTL();
while (controller.nextScriptRun()) {
+ // Check if there is any glyph found in the current script run.
+ int fromGlyph, glyphLength;
+ controller.glyphsForRange(from, to, fromGlyph, glyphLength);
+ if (fromGlyph < 0 || glyphLength <= 0)
+ continue;
+
if (fill) {
controller.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
adjustTextRenderMode(&fillPaint, gc->platformContext());
- canvas->drawPosText(controller.glyphs(), controller.length() << 1, controller.positions(), fillPaint);
+ canvas->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, fillPaint);
}
if (stroke) {
controller.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
adjustTextRenderMode(&strokePaint, gc->platformContext());
- canvas->drawPosText(controller.glyphs(), controller.length() << 1, controller.positions(), strokePaint);
+ canvas->drawPosText(controller.glyphs() + fromGlyph, glyphLength << 1, controller.positions() + fromGlyph, strokePaint);
}
}
}