summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2011-01-11 16:16:27 -0500
committerLeon Scroggins <scroggo@google.com>2011-01-11 16:16:27 -0500
commit9c4c34ad9aa0989d5732eb69365c6c75cfce259b (patch)
tree986f9e115e6b2d64abf932adc5bb06c069d63d79 /WebCore
parent354a67ba58009fa494d34c28980688a3ee292205 (diff)
downloadexternal_webkit-9c4c34ad9aa0989d5732eb69365c6c75cfce259b.zip
external_webkit-9c4c34ad9aa0989d5732eb69365c6c75cfce259b.tar.gz
external_webkit-9c4c34ad9aa0989d5732eb69365c6c75cfce259b.tar.bz2
Disable rounding hacks.
Bug:3085564 Change-Id: Ie570cbac6a445a337c72466598d5550c84d803ad
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/config.h2
-rw-r--r--WebCore/rendering/InlineTextBox.cpp53
-rw-r--r--WebCore/rendering/InlineTextBox.h10
-rw-r--r--WebCore/rendering/RenderText.cpp17
4 files changed, 82 insertions, 0 deletions
diff --git a/WebCore/config.h b/WebCore/config.h
index 098e3f0..7eaeaef 100644
--- a/WebCore/config.h
+++ b/WebCore/config.h
@@ -148,6 +148,8 @@
#define ANDROID_FIX
+#define ANDROID_DISABLE_ROUNDING_HACKS
+
// Ensure that the fixed elements are always relative to the top document.
#define ANDROID_FIXED_ELEMENTS
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index 575bdf2..2bec8a1 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -158,8 +158,15 @@ IntRect InlineTextBox::selectionRect(int tx, int ty, int startPos, int endPos)
ePos = len;
}
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ TextRun textRun = TextRun(characters, len, textObj->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride);
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+ IntRect r = enclosingIntRect(f.selectionRectForText(textRun, IntPoint(), selHeight, sPos, ePos));
+#else
IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(characters, len, textObj->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride),
IntPoint(), selHeight, sPos, ePos));
+#endif
int logicalWidth = r.width();
if (r.x() > m_logicalWidth)
@@ -555,6 +562,10 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, length);
TextRun textRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || styleToUse->visuallyOrdered());
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+#endif
int sPos = 0;
int ePos = 0;
@@ -689,9 +700,17 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const IntPoint& box
int selHeight = selectionHeight();
IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
context->clip(IntRect(localOrigin, IntSize(m_logicalWidth, selHeight)));
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ TextRun textRun = TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd,
+ !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+ context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+#else
context->drawHighlightForText(font, TextRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd,
!isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+#endif
context->restore();
}
@@ -713,9 +732,17 @@ void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const I
int deltaY = renderer()->style()->isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop();
int selHeight = selectionHeight();
IntPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ TextRun textRun = TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd,
+ !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+ context->drawHighlightForText(font, textRun, localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+#else
context->drawHighlightForText(font, TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd,
!isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
localOrigin, selHeight, c, style->colorSpace(), sPos, ePos);
+#endif
context->restore();
}
@@ -876,6 +903,10 @@ void InlineTextBox::paintSpellingOrGrammarMarker(GraphicsContext* pt, const IntP
int selHeight = selectionHeight();
IntPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY);
TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ if (m_disableRoundingHacks)
+ run.disableRoundingHacks();
+#endif
IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, startPoint, selHeight, startPosition, endPosition));
start = markerRect.x() - startPoint.x();
@@ -920,6 +951,10 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const IntPoint& bo
int sPos = max(marker.startOffset - m_start, (unsigned)0);
int ePos = min(marker.endOffset - m_start, (unsigned)m_len);
TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ if (m_disableRoundingHacks)
+ run.disableRoundingHacks();
+#endif
// Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates.
IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, selectionTop()), selHeight, sPos, ePos));
@@ -948,6 +983,10 @@ void InlineTextBox::computeRectForReplacementMarker(const DocumentMarker& marker
int sPos = max(marker.startOffset - m_start, (unsigned)0);
int ePos = min(marker.endOffset - m_start, (unsigned)m_len);
TextRun run(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ if (m_disableRoundingHacks)
+ run.disableRoundingHacks();
+#endif
IntPoint startPoint = IntPoint(m_x, y);
// Compute and store the rect associated with this marker.
@@ -1099,8 +1138,15 @@ int InlineTextBox::offsetForPosition(int lineOffset, bool includePartialGlyphs)
RenderText* text = toRenderText(renderer());
RenderStyle* style = text->style(m_firstLine);
const Font* f = &style->font();
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ TextRun textRun = TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered());
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+ return f->offsetForPosition(textRun, lineOffset - logicalLeft(), includePartialGlyphs);
+#else
return f->offsetForPosition(TextRun(textRenderer()->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || style->visuallyOrdered()),
lineOffset - logicalLeft(), includePartialGlyphs);
+#endif
}
int InlineTextBox::positionForOffset(int offset) const
@@ -1116,8 +1162,15 @@ int InlineTextBox::positionForOffset(int offset) const
int from = !isLeftToRightDirection() ? offset - m_start : 0;
int to = !isLeftToRightDirection() ? m_len : offset - m_start;
// FIXME: Do we need to add rightBearing here?
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ TextRun textRun = TextRun(text->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride);
+ if (m_disableRoundingHacks)
+ textRun.disableRoundingHacks();
+ return enclosingIntRect(f.selectionRectForText(textRun, IntPoint(logicalLeft(), 0), 0, from, to)).right();
+#else
return enclosingIntRect(f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride),
IntPoint(logicalLeft(), 0), 0, from, to)).right();
+#endif
}
bool InlineTextBox::containsCaretOffset(int offset) const
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index bc2219b..e19da2e 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -39,13 +39,20 @@ Color correctedTextColor(Color textColor, Color backgroundColor);
class InlineTextBox : public InlineBox {
public:
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ InlineTextBox(RenderObject* obj, bool disableRoundingHacks = false)
+#else
InlineTextBox(RenderObject* obj)
+#endif
: InlineBox(obj)
, m_prevTextBox(0)
, m_nextTextBox(0)
, m_start(0)
, m_len(0)
, m_truncation(cNoTruncation)
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ , m_disableRoundingHacks(disableRoundingHacks)
+#endif
{
}
@@ -139,6 +146,9 @@ private:
unsigned short m_truncation; // Where to truncate when text overflow is applied. We use special constants to
// denote no truncation (the whole run paints) and full truncation (nothing paints at all).
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ bool m_disableRoundingHacks;
+#endif
protected:
void paintCompositionBackground(GraphicsContext*, const IntPoint& boxOrigin, RenderStyle*, const Font&, int startPos, int endPos);
diff --git a/WebCore/rendering/RenderText.cpp b/WebCore/rendering/RenderText.cpp
index 7635d07..b1e9413 100644
--- a/WebCore/rendering/RenderText.cpp
+++ b/WebCore/rendering/RenderText.cpp
@@ -1158,10 +1158,27 @@ void RenderText::dirtyLineBoxes(bool fullLayout)
}
m_linesDirty = false;
}
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+static bool disableRoundingHacks(RenderText* renderText)
+{
+ RenderObject* renderer = renderText;
+ while (renderer) {
+ if (renderer->isTextControl()) {
+ return true;
+ }
+ renderer = renderer->parent();
+ }
+ return false;
+}
+#endif
InlineTextBox* RenderText::createTextBox()
{
+#ifdef ANDROID_DISABLE_ROUNDING_HACKS
+ return new (renderArena()) InlineTextBox(this, disableRoundingHacks(this));
+#else
return new (renderArena()) InlineTextBox(this);
+#endif
}
InlineTextBox* RenderText::createInlineTextBox()