diff options
Diffstat (limited to 'Source/WebCore/rendering/RenderText.cpp')
| -rw-r--r-- | Source/WebCore/rendering/RenderText.cpp | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/Source/WebCore/rendering/RenderText.cpp b/Source/WebCore/rendering/RenderText.cpp index 6aeb4d92d..9a077bf30 100644 --- a/Source/WebCore/rendering/RenderText.cpp +++ b/Source/WebCore/rendering/RenderText.cpp @@ -58,7 +58,7 @@ struct SameSizeAsRenderText : public RenderObject { uint32_t bitfields : 16; float widths[4]; String text; - void* pointers[2]; + void* pointers[3]; }; COMPILE_ASSERT(sizeof(RenderText) == sizeof(SameSizeAsRenderText), RenderText_should_stay_small); @@ -151,6 +151,11 @@ RenderText::RenderText(Node* node, PassRefPtr<StringImpl> str) { ASSERT(m_text); + m_is8Bit = m_text.is8Bit(); + if (is8Bit()) + m_data.characters8 = m_text.characters8(); + else + m_data.characters16 = m_text.characters16(); m_isAllASCII = m_text.containsOnlyASCII(); m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath(); setIsText(); @@ -365,12 +370,12 @@ void RenderText::absoluteRectsForRange(Vector<IntRect>& rects, unsigned start, u r.setX(selectionRect.x()); } } - rects.append(localToAbsoluteQuad(r, false, wasFixed).enclosingBoundingBox()); + rects.append(localToAbsoluteQuad(r, SnapOffsetForTransforms, wasFixed).enclosingBoundingBox()); } else { // FIXME: This code is wrong. It's converting local to absolute twice. http://webkit.org/b/65722 FloatRect rect = localQuadForTextBox(box, start, end, useSelectionHeight); if (!rect.isZero()) - rects.append(localToAbsoluteQuad(rect, false, wasFixed).enclosingBoundingBox()); + rects.append(localToAbsoluteQuad(rect, SnapOffsetForTransforms, wasFixed).enclosingBoundingBox()); } } } @@ -413,7 +418,7 @@ void RenderText::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed, Clippin else boundaries.setHeight(ellipsisRect.maxY() - boundaries.y()); } - quads.append(localToAbsoluteQuad(boundaries, false, wasFixed)); + quads.append(localToAbsoluteQuad(boundaries, SnapOffsetForTransforms, wasFixed)); } } @@ -448,11 +453,11 @@ void RenderText::absoluteQuadsForRange(Vector<FloatQuad>& quads, unsigned start, r.setX(selectionRect.x()); } } - quads.append(localToAbsoluteQuad(r, false, wasFixed)); + quads.append(localToAbsoluteQuad(r, SnapOffsetForTransforms, wasFixed)); } else { FloatRect rect = localQuadForTextBox(box, start, end, useSelectionHeight); if (!rect.isZero()) - quads.append(localToAbsoluteQuad(rect, false, wasFixed)); + quads.append(localToAbsoluteQuad(rect, SnapOffsetForTransforms, wasFixed)); } } } @@ -755,7 +760,7 @@ ALWAYS_INLINE float RenderText::widthFromCache(const Font& f, int start, int len return w; } - TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + start, len, style()); + TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, this, start, len, style()); run.setCharactersLength(textLength() - start); ASSERT(run.charactersLength() >= run.length()); @@ -954,8 +959,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si const Font& f = styleToUse->font(); // FIXME: This ignores first-line. float wordSpacing = styleToUse->wordSpacing(); int len = textLength(); - const UChar* txt = characters(); - LazyLineBreakIterator breakIterator(txt, len, styleToUse->locale()); + LazyLineBreakIterator breakIterator(m_text, styleToUse->locale()); bool needsWordSpacing = false; bool ignoringSpaces = false; bool isSpace = false; @@ -992,7 +996,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si bool breakAll = (styleToUse->wordBreak() == BreakAllWordBreak || styleToUse->wordBreak() == BreakWordBreak) && styleToUse->autoWrap(); for (int i = 0; i < len; i++) { - UChar c = txt[i]; + UChar c = characterAt(i); bool previousCharacterIsSpace = isSpace; @@ -1044,8 +1048,8 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si j++; if (j == len) break; - c = txt[j]; - if (isBreakable(breakIterator, j, nextBreakable, breakNBSP) && txt[j - 1] != softHyphen) + c = characterAt(j); + if (isBreakable(breakIterator, j, nextBreakable, breakNBSP) && characterAt(j - 1) != softHyphen) break; if (breakAll) { betweenWords = false; @@ -1067,7 +1071,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si if (w > maxWordWidth) { int suffixStart; - float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, txt + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart); + float maxFragmentWidth = maxWordFragmentWidth(this, styleToUse, f, characters() + i, wordLen, minimumPrefixLength, minimumSuffixLength, suffixStart); if (suffixStart) { float suffixWidth; @@ -1142,7 +1146,7 @@ void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const Si m_maxWidth = currMaxWidth; currMaxWidth = 0; } else { - TextRun run = RenderBlock::constructTextRun(this, f, txt + i, 1, styleToUse); + TextRun run = RenderBlock::constructTextRun(this, f, this, i, 1, styleToUse); run.setCharactersLength(len - i); ASSERT(run.charactersLength() >= run.length()); run.setTabSize(!style()->collapseWhiteSpace(), style()->tabSize()); @@ -1256,6 +1260,9 @@ void RenderText::setSelectionState(SelectionState state) void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset, unsigned len, bool force) { + if (!force && equal(m_text.impl(), text.get())) + return; + unsigned oldLen = textLength(); unsigned newLen = text->length(); int delta = newLen - oldLen; @@ -1328,7 +1335,7 @@ void RenderText::setTextWithOffset(PassRefPtr<StringImpl> text, unsigned offset, } m_linesDirty = dirtiedLines; - setText(text, force); + setText(text, force || dirtiedLines); } void RenderText::transformText() @@ -1415,6 +1422,11 @@ void RenderText::setTextInternal(PassRefPtr<StringImpl> text) ASSERT(m_text); ASSERT(!isBR() || (textLength() == 1 && m_text[0] == '\n')); + m_is8Bit = m_text.is8Bit(); + if (is8Bit()) + m_data.characters8 = m_text.characters8(); + else + m_data.characters16 = m_text.characters16(); m_isAllASCII = m_text.containsOnlyASCII(); m_canUseSimpleFontCodePath = computeCanUseSimpleFontCodePath(); } @@ -1537,7 +1549,7 @@ float RenderText::width(unsigned from, unsigned len, float xPos, bool firstLine, float RenderText::width(unsigned from, unsigned len, const Font& f, float xPos, HashSet<const SimpleFontData*>* fallbackFonts, GlyphOverflow* glyphOverflow) const { ASSERT(from + len <= textLength()); - if (!characters()) + if (!textLength()) return 0; float w; @@ -1556,7 +1568,7 @@ float RenderText::width(unsigned from, unsigned len, const Font& f, float xPos, } else w = widthFromCache(f, from, len, xPos, fallbackFonts, glyphOverflow); } else { - TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + from, len, style()); + TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, this, from, len, style()); run.setCharactersLength(textLength() - from); ASSERT(run.charactersLength() >= run.length()); @@ -1620,7 +1632,7 @@ LayoutRect RenderText::linesVisualOverflowBoundingBox() const return rect; } -LayoutRect RenderText::clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const +LayoutRect RenderText::clippedOverflowRectForRepaint(RenderLayerModelObject* repaintContainer) const { RenderObject* rendererToRepaint = containingBlock(); @@ -1636,7 +1648,7 @@ LayoutRect RenderText::clippedOverflowRectForRepaint(RenderBoxModelObject* repai return rendererToRepaint->clippedOverflowRectForRepaint(repaintContainer); } -LayoutRect RenderText::selectionRectForRepaint(RenderBoxModelObject* repaintContainer, bool clipToVisibleContent) +LayoutRect RenderText::selectionRectForRepaint(RenderLayerModelObject* repaintContainer, bool clipToVisibleContent) { ASSERT(!needsLayout()); |
