Reviewed by Dan Bernstein.
ComplexTextController incorrectly conflates string length and range of indexes
https://bugs.webkit.org/show_bug.cgi?id=52760
* fast/text/offsetForPosition-complex-fallback-expected.txt: Added.
* fast/text/offsetForPosition-complex-fallback.html: Added.
2011-01-25 Ned Holbrook <nholbrook@apple.com>
Reviewed by Dan Bernstein.
ComplexTextController incorrectly conflates string length and range of indexes
https://bugs.webkit.org/show_bug.cgi?id=52760
Test: fast/text/offsetForPosition-complex-fallback.html
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::offsetForPosition):
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
(WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
(WebCore::ComplexTextController::advance):
* platform/graphics/mac/ComplexTextController.h:
(WebCore::ComplexTextController::ComplexTextRun::create):
(WebCore::ComplexTextController::ComplexTextRun::indexEnd):
* platform/graphics/mac/ComplexTextControllerATSUI.cpp:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
* platform/graphics/mac/ComplexTextControllerCoreText.cpp:
(WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76674
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-01-25 Ned Holbrook <nholbrook@apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ ComplexTextController incorrectly conflates string length and range of indexes
+ https://bugs.webkit.org/show_bug.cgi?id=52760
+
+ * fast/text/offsetForPosition-complex-fallback-expected.txt: Added.
+ * fast/text/offsetForPosition-complex-fallback.html: Added.
+
2011-01-25 Sam Weinig <sam@webkit.org>
Make this test a bit more robust agains different scrollbar widths.
--- /dev/null
+Test offset for position computation across complex runs with font fallbacks, in this case due to a font (Arial) lacking a newline glyph.
+
+PASS
+
+Justification should be used sparingly and cautiously on Web pages.
--- /dev/null
+<p>
+ Test offset for position computation across complex runs with font
+ fallbacks, in this case due to a font (Arial) lacking a newline glyph.
+</p>
+<p id="result">
+ Test did not run.
+</p>
+<div id="target" style="display: inline; font-family: Arial; text-rendering: optimizeLegibility;">
+Jus­ti­fi­ca­tion
+should
+be used sparingly and cautiously on Web pages.
+</div>
+<script>
+ if (window.layoutTestController) {
+ layoutTestController.dumpAsText();
+
+ var target = document.getElementById("target");
+ var result = document.getElementById("result");
+ var x = target.offsetLeft + target.offsetWidth / 2;
+ var y = target.offsetTop + target.offsetHeight / 2;
+
+ eventSender.leapForward(1000);
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.leapForward(1);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ eventSender.leapForward(1000);
+
+ var selectedText = getSelection().toString();
+ if (selectedText == "sparingly")
+ result.innerText = "PASS";
+ else
+ result.innerText = "FAIL: Selected text is \"" + selectedText + "\"";
+ }
+</script>
+2011-01-25 Ned Holbrook <nholbrook@apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ ComplexTextController incorrectly conflates string length and range of indexes
+ https://bugs.webkit.org/show_bug.cgi?id=52760
+
+ Test: fast/text/offsetForPosition-complex-fallback.html
+
+ * platform/graphics/mac/ComplexTextController.cpp:
+ (WebCore::ComplexTextController::offsetForPosition):
+ (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+ (WebCore::ComplexTextController::ComplexTextRun::setIsNonMonotonic):
+ (WebCore::ComplexTextController::advance):
+ * platform/graphics/mac/ComplexTextController.h:
+ (WebCore::ComplexTextController::ComplexTextRun::create):
+ (WebCore::ComplexTextController::ComplexTextRun::indexEnd):
+ * platform/graphics/mac/ComplexTextControllerATSUI.cpp:
+ (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+ * platform/graphics/mac/ComplexTextControllerCoreText.cpp:
+ (WebCore::ComplexTextController::ComplexTextRun::ComplexTextRun):
+ (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText):
+
2011-01-25 Sam Weinig <sam@webkit.org>
Reviewed by David Hyatt.
CFIndex hitGlyphStart = complexTextRun.indexAt(j);
CFIndex hitGlyphEnd;
if (m_run.ltr())
- hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.stringLength()));
+ hitGlyphEnd = max<CFIndex>(hitGlyphStart, j + 1 < complexTextRun.glyphCount() ? complexTextRun.indexAt(j + 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
else
- hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.stringLength()));
+ hitGlyphEnd = max<CFIndex>(hitGlyphStart, j > 0 ? complexTextRun.indexAt(j - 1) : static_cast<CFIndex>(complexTextRun.indexEnd()));
// FIXME: Instead of dividing the glyph's advance equally between the characters, this
// could use the glyph's "ligature carets". However, there is no Core Text API to get the
, m_characters(characters)
, m_stringLocation(stringLocation)
, m_stringLength(stringLength)
+ , m_indexEnd(stringLocation + stringLength)
, m_isMonotonic(true)
{
#if USE(CORE_TEXT) && USE(ATSUI)
m_glyphEndOffsets.grow(m_glyphCount);
for (size_t i = 0; i < m_glyphCount; ++i) {
- CFIndex nextMappedIndex = m_stringLength;
+ CFIndex nextMappedIndex = m_indexEnd;
for (size_t j = indexAt(i) + 1; j < m_stringLength; ++j) {
if (mappedIndices[j]) {
nextMappedIndex = j;
unsigned glyphEndOffset;
if (complexTextRun.isMonotonic()) {
if (ltr)
- glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? static_cast<unsigned>(complexTextRun.indexAt(g + 1)) : complexTextRun.stringLength());
+ glyphEndOffset = max<unsigned>(glyphStartOffset, g + 1 < glyphCount ? static_cast<unsigned>(complexTextRun.indexAt(g + 1)) : complexTextRun.indexEnd());
else
- glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? static_cast<unsigned>(complexTextRun.indexAt(g - 1)) : complexTextRun.stringLength());
+ glyphEndOffset = max<unsigned>(glyphStartOffset, g > 0 ? static_cast<unsigned>(complexTextRun.indexAt(g - 1)) : complexTextRun.indexEnd());
} else
glyphEndOffset = complexTextRun.endOffsetAt(g);
unsigned oldCharacterInCurrentGlyph = m_characterInCurrentGlyph;
m_characterInCurrentGlyph = min(m_currentCharacter - complexTextRun.stringLocation(), glyphEndOffset) - glyphStartOffset;
- // FIXME: Instead of dividing the glyph's advance equially between the characters, this
+ // FIXME: Instead of dividing the glyph's advance equally between the characters, this
// could use the glyph's "ligature carets". However, there is no Core Text API to get the
// ligature carets.
if (glyphStartOffset == glyphEndOffset) {
class ComplexTextRun : public RefCounted<ComplexTextRun> {
public:
#if USE(CORE_TEXT)
- static PassRefPtr<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
+ static PassRefPtr<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
{
- return adoptRef(new ComplexTextRun(ctRun, fontData, characters, stringLocation, stringLength));
+ return adoptRef(new ComplexTextRun(ctRun, fontData, characters, stringLocation, stringLength, runRange));
}
#endif
#if USE(ATSUI)
unsigned stringLocation() const { return m_stringLocation; }
size_t stringLength() const { return m_stringLength; }
ALWAYS_INLINE CFIndex indexAt(size_t i) const;
+ CFIndex indexEnd() const { return m_indexEnd; }
CFIndex endOffsetAt(size_t i) const { ASSERT(!m_isMonotonic); return m_glyphEndOffsets[i]; }
const CGGlyph* glyphs() const { return m_glyphs; }
const CGSize* advances() const { return m_advances; }
private:
#if USE(CORE_TEXT)
- ComplexTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength);
+ ComplexTextRun(CTRunRef, const SimpleFontData*, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange);
void createTextRunFromFontDataCoreText(bool ltr);
#endif
#if USE(ATSUI)
#if USE(ATSUI)
Vector<CFIndex, 64> m_atsuiIndices;
#endif
+ CFIndex m_indexEnd;
Vector<CFIndex, 64> m_glyphEndOffsets;
Vector<CGGlyph, 64> m_glyphsVector;
const CGGlyph* m_glyphs;
, m_characters(characters)
, m_stringLocation(stringLocation)
, m_stringLength(stringLength)
+ , m_indexEnd(stringLocation + stringLength)
, m_directionalOverride(directionalOverride)
, m_isMonotonic(true)
{
namespace WebCore {
-ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength)
+ComplexTextController::ComplexTextRun::ComplexTextRun(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)
: m_coreTextRun(ctRun)
, m_fontData(fontData)
, m_characters(characters)
, m_stringLocation(stringLocation)
, m_stringLength(stringLength)
+ , m_indexEnd(runRange.location + runRange.length)
, m_isMonotonic(true)
{
m_glyphCount = CTRunGetGlyphCount(m_coreTextRun.get());
for (CFIndex r = 0; r < runCount; r++) {
CTRunRef ctRun = static_cast<CTRunRef>(CFArrayGetValueAtIndex(runArray, r));
ASSERT(CFGetTypeID(ctRun) == CTRunGetTypeID());
- m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length));
+ CFRange runRange = CTRunGetStringRange(ctRun);
+ m_complexTextRuns.append(ComplexTextRun::create(ctRun, fontData, cp, stringLocation, length, runRange));
}
}