+2007-12-01 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler.
+
+ - fold FontStyle into TextRun
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/Font.cpp:
+ (WebCore::WidthIterator::WidthIterator):
+ (WebCore::WidthIterator::advance):
+ (WebCore::Font::width):
+ (WebCore::Font::drawSimpleText):
+ (WebCore::Font::drawGlyphBuffer):
+ (WebCore::Font::drawText):
+ (WebCore::Font::floatWidth):
+ (WebCore::Font::floatWidthForSimpleText):
+ (WebCore::Font::selectionRectForText):
+ (WebCore::Font::selectionRectForSimpleText):
+ (WebCore::Font::offsetForPosition):
+ (WebCore::Font::offsetForPositionForSimpleText):
+ * platform/graphics/Font.h:
+ (WebCore::TextRun::TextRun):
+ (WebCore::TextRun::setText):
+ (WebCore::TextRun::allowTabs):
+ (WebCore::TextRun::xPos):
+ (WebCore::TextRun::padding):
+ (WebCore::TextRun::rtl):
+ (WebCore::TextRun::ltr):
+ (WebCore::TextRun::directionalOverride):
+ (WebCore::TextRun::applyRunRounding):
+ (WebCore::TextRun::applyWordRounding):
+ (WebCore::TextRun::spacingDisabled):
+ (WebCore::TextRun::disableSpacing):
+ (WebCore::TextRun::disableRoundingHacks):
+ (WebCore::TextRun::setRTL):
+ (WebCore::TextRun::setDirectionalOverride):
+ * platform/graphics/FontStyle.h: Removed.
+ * platform/graphics/GraphicsContext.cpp:
+ (WebCore::GraphicsContext::drawText):
+ (WebCore::GraphicsContext::drawBidiText):
+ (WebCore::GraphicsContext::drawHighlightForText):
+ * platform/graphics/GraphicsContext.h:
+ * platform/graphics/StringTruncator.cpp:
+ (WebCore::stringWidth):
+ * platform/graphics/gtk/FontGtk.cpp:
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForComplexText):
+ (WebCore::Font::offsetForPositionForComplexText):
+ (WebCore::Font::selectionRectForComplexText):
+ * platform/graphics/mac/FontMac.mm:
+ (WebCore::ATSULayoutParameters::ATSULayoutParameters):
+ (WebCore::addDirectionalOverride):
+ (WebCore::overrideLayoutOperation):
+ (WebCore::ATSULayoutParameters::initialize):
+ (WebCore::Font::selectionRectForComplexText):
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForComplexText):
+ (WebCore::Font::offsetForPositionForComplexText):
+ * platform/graphics/qt/FontQt.cpp:
+ (WebCore::generateComponents):
+ (WebCore::Font::drawText):
+ (WebCore::Font::width):
+ (WebCore::Font::offsetForPosition):
+ (WebCore::cursorToX):
+ (WebCore::Font::selectionRectForText):
+ * platform/graphics/win/FontWin.cpp:
+ (WebCore::Font::selectionRectForComplexText):
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForComplexText):
+ (WebCore::Font::offsetForPositionForComplexText):
+ * platform/graphics/wx/FontWx.cpp:
+ (WebCore::Font::selectionRectForComplexText):
+ (WebCore::Font::drawComplexText):
+ (WebCore::Font::floatWidthForComplexText):
+ (WebCore::Font::offsetForPositionForComplexText):
+ * platform/mac/WebCoreTextRenderer.mm:
+ (WebCoreDrawTextAtPoint):
+ (WebCoreTextFloatWidth):
+ * platform/win/PopupMenuWin.cpp:
+ (WebCore::PopupMenu::paint):
+ * platform/win/UniscribeController.cpp:
+ (WebCore::UniscribeController::UniscribeController):
+ (WebCore::UniscribeController::offsetForPosition):
+ (WebCore::UniscribeController::advance):
+ (WebCore::UniscribeController::itemizeShapeAndPlace):
+ (WebCore::UniscribeController::resetControlAndState):
+ (WebCore::UniscribeController::shapeAndPlaceItem):
+ * platform/win/UniscribeController.h:
+ * platform/win/WebCoreTextRenderer.cpp:
+ (WebCore::doDrawTextAtPoint):
+ * rendering/EllipsisBox.cpp:
+ (WebCore::EllipsisBox::paint):
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::selectionRect):
+ (WebCore::InlineTextBox::paint):
+ (WebCore::InlineTextBox::paintSelection):
+ (WebCore::InlineTextBox::paintCompositionBackground):
+ (WebCore::InlineTextBox::paintSpellingOrGrammarMarker):
+ (WebCore::InlineTextBox::paintTextMatchMarker):
+ (WebCore::InlineTextBox::offsetForPosition):
+ (WebCore::InlineTextBox::positionForOffset):
+ * rendering/RenderFileUploadControl.cpp:
+ (WebCore::RenderFileUploadControl::paintObject):
+ (WebCore::RenderFileUploadControl::calcPrefWidths):
+ * rendering/RenderImage.cpp:
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::updateFromElement):
+ (WebCore::RenderListBox::paintItemForeground):
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::updateOptionsWidth):
+ * rendering/RenderText.cpp:
+ (WebCore::RenderText::widthFromCache):
+ (WebCore::RenderText::calcPrefWidths):
+ (WebCore::RenderText::width):
+ * rendering/RenderText.h:
+ (WebCore::RenderText::allowTabs):
+ * rendering/RenderTextControl.cpp:
+ (WebCore::RenderTextControl::calcPrefWidths):
+ * rendering/SVGInlineTextBox.cpp:
+ (WebCore::SVGInlineTextBox::calculateGlyphWidth):
+ (WebCore::SVGInlineTextBox::paintCharacters):
+ (WebCore::SVGInlineTextBox::paintSelection):
+ * rendering/SVGRootInlineBox.cpp:
+ (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback):
+ (WebCore::cummulatedWidthOfInlineBoxCharacterRange):
+ (WebCore::svgTextRunForInlineTextBox):
+ * rendering/SVGRootInlineBox.h:
+
2007-12-01 Adam Treat <treat@kde.org>
Reviewed by Simon.
B24055650B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055630B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h */; };
B24055660B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */; };
B25DFAAF0B2E2929000E6510 /* JSSVGMatrixCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B25DFAAE0B2E2929000E6510 /* JSSVGMatrixCustom.cpp */; };
- B25E96BE0D00975100CFD296 /* FontStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = B25E96BD0D00975100CFD296 /* FontStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
B26554EA0B80D74900A50EC3 /* RenderSVGTextPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B26554E80B80D74900A50EC3 /* RenderSVGTextPath.cpp */; };
B26554EB0B80D74900A50EC3 /* RenderSVGTextPath.h in Headers */ = {isa = PBXBuildFile; fileRef = B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */; };
B266CD4D0C3AEC6500EB08D2 /* JSSVGException.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B266CD4B0C3AEC6500EB08D2 /* JSSVGException.cpp */; };
B24055630B5BE640002A28C0 /* DOMSVGElementInstanceInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceInternal.h; sourceTree = "<group>"; };
B24055640B5BE640002A28C0 /* DOMSVGElementInstanceListInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMSVGElementInstanceListInternal.h; sourceTree = "<group>"; };
B25DFAAE0B2E2929000E6510 /* JSSVGMatrixCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGMatrixCustom.cpp; sourceTree = "<group>"; };
- B25E96BD0D00975100CFD296 /* FontStyle.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FontStyle.h; sourceTree = "<group>"; };
B26554E80B80D74900A50EC3 /* RenderSVGTextPath.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGTextPath.cpp; sourceTree = "<group>"; };
B26554E90B80D74900A50EC3 /* RenderSVGTextPath.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = RenderSVGTextPath.h; sourceTree = "<group>"; };
B266CD4B0C3AEC6500EB08D2 /* JSSVGException.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGException.cpp; sourceTree = "<group>"; };
B2A015910AF6CD53006BCE0E /* graphics */ = {
isa = PBXGroup;
children = (
- B25E96BD0D00975100CFD296 /* FontStyle.h */,
B23540F00D00782E002382FA /* StringTruncator.cpp */,
B23540F10D00782E002382FA /* StringTruncator.h */,
B2C3DA4F0D006CD600EF6F26 /* Font.cpp */,
B2C3DA6E0D006CD600EF6F26 /* GlyphPageTreeNode.h in Headers */,
B2C3DA700D006CD600EF6F26 /* GlyphWidthMap.h in Headers */,
B23540F30D00782E002382FA /* StringTruncator.h in Headers */,
- B25E96BE0D00975100CFD296 /* FontStyle.h in Headers */,
B2AFFC7E0D00A5C10030074D /* FontCustomPlatformData.h in Headers */,
B2AFFC810D00A5C10030074D /* FontPlatformData.h in Headers */,
B2AFFC940D00A5DF0030074D /* ShapeArabic.h in Headers */,
#include "FontFallbackList.h"
#include "IntPoint.h"
#include "GlyphBuffer.h"
-#include "FontStyle.h"
#include <wtf/unicode/Unicode.h>
#include <wtf/MathExtras.h>
Font::CodePath Font::codePath = Auto;
struct WidthIterator {
- WidthIterator(const Font* font, const TextRun& run, const FontStyle& style);
+ WidthIterator(const Font* font, const TextRun& run);
void advance(int to, GlyphBuffer* glyphBuffer = 0);
bool advanceOneCharacter(float& width, GlyphBuffer* glyphBuffer = 0);
const TextRun& m_run;
int m_end;
- const FontStyle& m_style;
-
unsigned m_currentCharacter;
float m_runWidthSoFar;
float m_padding;
UChar32 normalizeVoicingMarks(int currentCharacter);
};
-WidthIterator::WidthIterator(const Font* font, const TextRun& run, const FontStyle& style)
+WidthIterator::WidthIterator(const Font* font, const TextRun& run)
: m_font(font)
, m_run(run)
, m_end(run.length())
- , m_style(style)
, m_currentCharacter(0)
, m_runWidthSoFar(0)
, m_finalRoundingWidth(0)
{
// If the padding is non-zero, count the number of spaces in the run
// and divide that by the padding for per space addition.
- m_padding = m_style.padding();
+ m_padding = m_run.padding();
if (!m_padding)
m_padPerSpace = 0;
else {
if (numSpaces == 0)
m_padPerSpace = 0;
else
- m_padPerSpace = ceilf(m_style.padding() / numSpaces);
+ m_padPerSpace = ceilf(m_run.padding() / numSpaces);
}
}
int currentCharacter = m_currentCharacter;
const UChar* cp = m_run.data(currentCharacter);
- bool rtl = m_style.rtl();
+ bool rtl = m_run.rtl();
bool hasExtraSpacing = m_font->letterSpacing() || m_font->wordSpacing() || m_padding;
float runWidthSoFar = m_runWidthSoFar;
// Now that we have a glyph and font data, get its width.
float width;
- if (c == '\t' && m_style.allowTabs()) {
+ if (c == '\t' && m_run.allowTabs()) {
float tabWidth = m_font->tabWidth();
- width = tabWidth - fmodf(m_style.xPos() + runWidthSoFar, tabWidth);
+ width = tabWidth - fmodf(m_run.xPos() + runWidthSoFar, tabWidth);
} else {
width = fontData->widthForGlyph(glyph);
// We special case spaces in two ways when applying word rounding.
// First, we round spaces to an adjusted width in all fonts.
// Second, in fixed-pitch fonts we ensure that all characters that
// match the width of the space character have the same width as the space character.
- if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_style.applyWordRounding())
+ if (width == fontData->m_spaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) && m_run.applyWordRounding())
width = fontData->m_adjustedSpaceWidth;
}
- if (hasExtraSpacing && !m_style.spacingDisabled()) {
+ if (hasExtraSpacing && !m_run.spacingDisabled()) {
// Account for letter-spacing.
if (width && m_font->letterSpacing())
width += m_font->letterSpacing();
// Force characters that are used to determine word boundaries for the rounding hack
// to be integer width, so following words will start on an integer boundary.
- if (m_style.applyWordRounding() && Font::isRoundingHackCharacter(c))
+ if (m_run.applyWordRounding() && Font::isRoundingHackCharacter(c))
width = ceilf(width);
// Check to see if the next character is a "rounding hack character", if so, adjust
// width so that the total run width will be on an integer boundary.
- if ((m_style.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
- || (m_style.applyRunRounding() && currentCharacter >= m_end)) {
+ if ((m_run.applyWordRounding() && currentCharacter < m_run.length() && Font::isRoundingHackCharacter(*cp))
+ || (m_run.applyRunRounding() && currentCharacter >= m_end)) {
float totalWidth = runWidthSoFar + width;
width += ceilf(totalWidth) - totalWidth;
}
int Font::width(const TextRun& run) const
{
- return width(run, FontStyle());
-}
-
-int Font::width(const TextRun& run, const FontStyle& style) const
-{
- return lroundf(floatWidth(run, style));
+ return lroundf(floatWidth(run));
}
int Font::ascent() const
}
-void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
+void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// This glyph buffer holds our glyphs+advances+font data for each glyph.
GlyphBuffer glyphBuffer;
float startX = point.x();
- WidthIterator it(this, run, style);
+ WidthIterator it(this, run);
it.advance(from);
float beforeWidth = it.m_runWidthSoFar;
it.advance(to, &glyphBuffer);
float afterWidth = it.m_runWidthSoFar;
- if (style.rtl()) {
+ if (run.rtl()) {
float finalRoundingWidth = it.m_finalRoundingWidth;
it.advance(run.length());
startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
startX += beforeWidth;
// Swap the order of the glyphs if right-to-left.
- if (style.rtl())
+ if (run.rtl())
for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
glyphBuffer.swap(i, end);
// Calculate the starting point of the glyphs to be displayed by adding
// all the advances up to the first glyph.
FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, style, startPoint);
+ drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuffer,
- const TextRun& run, const FontStyle& style, const FloatPoint& point) const
+ const TextRun& run, const FloatPoint& point) const
{
// Draw each contiguous run of glyphs that use the same font data.
const FontData* fontData = glyphBuffer.fontDataAt(0);
drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
}
-void Font::drawText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
+void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// Don't draw anything while we are using custom fonts that are in the process of loading.
if (m_fontList && m_fontList->loadingCustomFonts())
to = (to == -1 ? run.length() : to);
if (canUseGlyphCache(run))
- drawSimpleText(context, run, style, point, from, to);
+ drawSimpleText(context, run, point, from, to);
else
- drawComplexText(context, run, style, point, from, to);
+ drawComplexText(context, run, point, from, to);
}
-float Font::floatWidth(const TextRun& run, const FontStyle& style) const
+float Font::floatWidth(const TextRun& run) const
{
if (canUseGlyphCache(run))
- return floatWidthForSimpleText(run, style, 0);
- return floatWidthForComplexText(run, style);
+ return floatWidthForSimpleText(run, 0);
+ return floatWidthForComplexText(run);
}
-float Font::floatWidthForSimpleText(const TextRun& run, const FontStyle& style, GlyphBuffer* glyphBuffer) const
+float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer) const
{
- WidthIterator it(this, run, style);
+ WidthIterator it(this, run);
it.advance(run.length(), glyphBuffer);
return it.m_runWidthSoFar;
}
-FloatRect Font::selectionRectForText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
+FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
{
to = (to == -1 ? run.length() : to);
if (canUseGlyphCache(run))
- return selectionRectForSimpleText(run, style, point, h, from, to);
- return selectionRectForComplexText(run, style, point, h, from, to);
+ return selectionRectForSimpleText(run, point, h, from, to);
+ return selectionRectForComplexText(run, point, h, from, to);
}
-FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
+FloatRect Font::selectionRectForSimpleText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
{
- WidthIterator it(this, run, style);
+ WidthIterator it(this, run);
it.advance(from);
float beforeWidth = it.m_runWidthSoFar;
it.advance(to);
float afterWidth = it.m_runWidthSoFar;
// Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (style.rtl()) {
+ if (run.rtl()) {
it.advance(run.length());
float totalWidth = it.m_runWidthSoFar;
return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
}
}
-int Font::offsetForPosition(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPosition(const TextRun& run, int x, bool includePartialGlyphs) const
{
if (canUseGlyphCache(run))
- return offsetForPositionForSimpleText(run, style, x, includePartialGlyphs);
- return offsetForPositionForComplexText(run, style, x, includePartialGlyphs);
+ return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
+ return offsetForPositionForComplexText(run, x, includePartialGlyphs);
}
-int Font::offsetForPositionForSimpleText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForSimpleText(const TextRun& run, int x, bool includePartialGlyphs) const
{
float delta = (float)x;
- WidthIterator it(this, run, style);
+ WidthIterator it(this, run);
GlyphBuffer localGlyphBuffer;
unsigned offset;
- if (style.rtl()) {
- delta -= floatWidthForSimpleText(run, style, 0);
+ if (run.rtl()) {
+ delta -= floatWidthForSimpleText(run, 0);
while (1) {
offset = it.m_currentCharacter;
float w;
class GlyphPageTreeNode;
class GraphicsContext;
class IntPoint;
-class FontStyle;
struct GlyphData;
class TextRun {
public:
- TextRun(const UChar* c, int len)
- :m_characters(c), m_len(len)
- {}
+ TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
+ bool applyRunRounding = true, bool applyWordRounding = true)
+ : m_characters(c)
+ , m_len(len)
+ , m_allowTabs(allowTabs)
+ , m_xpos(xpos)
+ , m_padding(padding)
+ , m_rtl(rtl)
+ , m_directionalOverride(directionalOverride)
+ , m_applyRunRounding(applyRunRounding)
+ , m_applyWordRounding(applyWordRounding)
+ , m_disableSpacing(false)
+ {
+ }
- TextRun(const String& s)
- :m_characters(s.characters()), m_len(s.length())
- {}
+ TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
+ bool applyRunRounding = true, bool applyWordRounding = true)
+ : m_characters(s.characters())
+ , m_len(s.length())
+ , m_allowTabs(allowTabs)
+ , m_xpos(xpos)
+ , m_padding(padding)
+ , m_rtl(rtl)
+ , m_directionalOverride(directionalOverride)
+ , m_applyRunRounding(applyRunRounding)
+ , m_applyWordRounding(applyWordRounding)
+ , m_disableSpacing(false)
+ {
+ }
const UChar operator[](int i) const { return m_characters[i]; }
const UChar* data(int i) const { return &m_characters[i]; }
const UChar* characters() const { return m_characters; }
int length() const { return m_len; }
-
+
+ void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
+
+ bool allowTabs() const { return m_allowTabs; }
+ int xPos() const { return m_xpos; }
+ int padding() const { return m_padding; }
+ bool rtl() const { return m_rtl; }
+ bool ltr() const { return !m_rtl; }
+ bool directionalOverride() const { return m_directionalOverride; }
+ bool applyRunRounding() const { return m_applyRunRounding; }
+ bool applyWordRounding() const { return m_applyWordRounding; }
+ bool spacingDisabled() const { return m_disableSpacing; }
+
+ void disableSpacing() { m_disableSpacing = true; }
+ void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
+ void setRTL(bool b) { m_rtl = b; }
+ void setDirectionalOverride(bool override) { m_directionalOverride = override; }
+
private:
const UChar* m_characters;
int m_len;
+
+ bool m_allowTabs;
+ int m_xpos;
+ int m_padding;
+ bool m_rtl;
+ bool m_directionalOverride;
+ bool m_applyRunRounding;
+ bool m_applyWordRounding;
+ bool m_disableSpacing;
};
class Font {
void update(PassRefPtr<FontSelector>) const;
- void drawText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from = 0, int to = -1) const;
+ void drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1) const;
- int width(const TextRun&, const FontStyle&) const;
int width(const TextRun&) const;
- float floatWidth(const TextRun&, const FontStyle&) const;
float floatWidth(const TextRun&) const;
- int offsetForPosition(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
- FloatRect selectionRectForText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from = 0, int to = -1) const;
+ int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
+ FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const;
bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
private:
bool canUseGlyphCache(const TextRun&) const;
- void drawSimpleText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const;
+ void drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
void drawGlyphs(GraphicsContext*, const FontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
- void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FontStyle&, const FloatPoint&) const;
- void drawComplexText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const;
- float floatWidthForSimpleText(const TextRun&, const FontStyle&, GlyphBuffer*) const;
- float floatWidthForComplexText(const TextRun&, const FontStyle&) const;
- int offsetForPositionForSimpleText(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
- int offsetForPositionForComplexText(const TextRun&, const FontStyle&, int position, bool includePartialGlyphs) const;
- FloatRect selectionRectForSimpleText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from, int to) const;
- FloatRect selectionRectForComplexText(const TextRun&, const FontStyle&, const IntPoint&, int h, int from, int to) const;
+ void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const TextRun&, const FloatPoint&) const;
+ void drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
+ float floatWidthForSimpleText(const TextRun&, GlyphBuffer*) const;
+ float floatWidthForComplexText(const TextRun&) const;
+ int offsetForPositionForSimpleText(const TextRun&, int position, bool includePartialGlyphs) const;
+ int offsetForPositionForComplexText(const TextRun&, int position, bool includePartialGlyphs) const;
+ FloatRect selectionRectForSimpleText(const TextRun&, const IntPoint&, int h, int from, int to) const;
+ FloatRect selectionRectForComplexText(const TextRun&, const IntPoint&, int h, int from, int to) const;
#endif
friend struct WidthIterator;
+++ /dev/null
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef FontStyle_h
-#define FontStyle_h
-
-namespace WebCore {
-
-class FontStyle {
-public:
- FontStyle(bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false,
- bool applyRunRounding = true, bool applyWordRounding = true)
- : m_allowTabs(allowTabs)
- , m_xpos(xpos)
- , m_padding(padding)
- , m_rtl(rtl)
- , m_directionalOverride(directionalOverride)
- , m_applyRunRounding(applyRunRounding)
- , m_applyWordRounding(applyWordRounding)
- , m_disableSpacing(false)
- {
- }
-
- bool allowTabs() const { return m_allowTabs; }
- int xPos() const { return m_xpos; }
- int padding() const { return m_padding; }
- bool rtl() const { return m_rtl; }
- bool ltr() const { return !m_rtl; }
- bool directionalOverride() const { return m_directionalOverride; }
- bool applyRunRounding() const { return m_applyRunRounding; }
- bool applyWordRounding() const { return m_applyWordRounding; }
- bool spacingDisabled() const { return m_disableSpacing; }
-
- void disableSpacing() { m_disableSpacing = true; }
- void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; }
- void setRTL(bool b) { m_rtl = b; }
- void setDirectionalOverride(bool override) { m_directionalOverride = override; }
-
-private:
- bool m_allowTabs;
- int m_xpos;
- int m_padding;
- bool m_rtl;
- bool m_directionalOverride;
- bool m_applyRunRounding;
- bool m_applyWordRounding;
- bool m_disableSpacing;
-};
-
-}
-
-#endif
#include "BidiResolver.h"
#include "Font.h"
-#include "FontStyle.h"
using namespace std;
}
void GraphicsContext::drawText(const TextRun& run, const IntPoint& point, int from, int to)
-{
- drawText(run, point, FontStyle(), from, to);
-}
-
-void GraphicsContext::drawText(const TextRun& run, const IntPoint& point, const FontStyle& style, int from, int to)
{
if (paintingDisabled())
return;
- font().drawText(this, run, style, point, from, to);
+ font().drawText(this, run, point, from, to);
}
-void GraphicsContext::drawBidiText(const TextRun& run, const IntPoint& point, const FontStyle& style)
+void GraphicsContext::drawBidiText(const TextRun& run, const IntPoint& point)
{
if (paintingDisabled())
return;
BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
- WTF::Unicode::Direction paragraphDirection = style.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
+ WTF::Unicode::Direction paragraphDirection = run.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
- bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(style.ltr() ? 0 : 1, paragraphDirection, style.directionalOverride())));
+ bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(run.ltr() ? 0 : 1, paragraphDirection, run.directionalOverride())));
bidiResolver.createBidiRunsForLine(TextRunIterator(&run, 0), TextRunIterator(&run, run.length()));
FloatPoint currPoint = point;
BidiCharacterRun* bidiRun = bidiResolver.firstRun();
while (bidiRun) {
- FontStyle subrunStyle(style);
- subrunStyle.setRTL(bidiRun->level() % 2);
- subrunStyle.setDirectionalOverride(bidiRun->dirOverride(false));
- TextRun subrun(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
+ TextRun subrun = run;
+ subrun.setText(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
+ subrun.setRTL(bidiRun->level() % 2);
+ subrun.setDirectionalOverride(bidiRun->dirOverride(false));
- font().drawText(this, subrun, subrunStyle, currPoint);
+ font().drawText(this, subrun, currPoint);
bidiRun = bidiRun->next();
// FIXME: Have Font::drawText return the width of what it drew so that we don't have to re-measure here.
if (bidiRun)
- currPoint.move(font().floatWidth(subrun, subrunStyle), 0.f);
+ currPoint.move(font().floatWidth(subrun), 0.f);
}
bidiResolver.deleteRuns();
}
-void GraphicsContext::drawHighlightForText(const TextRun& run, const IntPoint& point, int h, const FontStyle& style, const Color& backgroundColor, int from, int to)
+void GraphicsContext::drawHighlightForText(const TextRun& run, const IntPoint& point, int h, const Color& backgroundColor, int from, int to)
{
if (paintingDisabled())
return;
- fillRect(font().selectionRectForText(run, style, point, h, from, to), backgroundColor);
+ fillRect(font().selectionRectForText(run, point, h, from, to), backgroundColor);
}
void GraphicsContext::initFocusRing(int width, int offset)
class KURL;
class Path;
class TextRun;
- class FontStyle;
// These bits can be ORed together for a total of 8 possible text drawing modes.
const int cTextInvisible = 0;
void setTextDrawingMode(int);
void drawText(const TextRun&, const IntPoint&, int from = 0, int to = -1);
- void drawText(const TextRun&, const IntPoint&, const FontStyle&, int from = 0, int to = -1);
- void drawBidiText(const TextRun&, const IntPoint&, const FontStyle&);
- void drawHighlightForText(const TextRun&, const IntPoint&, int h, const FontStyle&, const Color& backgroundColor, int from = 0, int to = -1);
+ void drawBidiText(const TextRun&, const IntPoint&);
+ void drawHighlightForText(const TextRun&, const IntPoint&, int h, const Color& backgroundColor, int from = 0, int to = -1);
FloatRect roundToDevicePixels(const FloatRect&);
#include "Font.h"
#include "FontPlatformData.h"
#include "TextBreakIterator.h"
-#include "FontStyle.h"
#include <wtf/Assertions.h>
#include <wtf/Vector.h>
static float stringWidth(const Font& renderer, const UChar* characters, unsigned length, bool disableRoundingHacks)
{
TextRun run(characters, length);
- FontStyle style;
if (disableRoundingHacks)
- style.disableRoundingHacks();
- return renderer.floatWidth(run, style);
+ run.disableRoundingHacks();
+ return renderer.floatWidth(run);
}
static String truncateString(const String& string, float maxWidth, const Font& font, TruncationFunction truncateToBuffer, bool disableRoundingHacks)
cairo_show_glyphs(context, glyphs, numGlyphs);
}
-void Font::drawComplexText(GraphicsContext*, const TextRun&, const FontStyle&, const FloatPoint&, int from, int to) const
+void Font::drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const
{
notImplemented();
}
-float Font::floatWidthForComplexText(const TextRun&, const FontStyle&) const
+float Font::floatWidthForComplexText(const TextRun&) const
{
notImplemented();
return 0.0f;
}
-int Font::offsetForPositionForComplexText(const TextRun&, const FontStyle&, int, bool) const
+int Font::offsetForPositionForComplexText(const TextRun&, int, bool) const
{
notImplemented();
return 0;
}
-FloatRect Font::selectionRectForComplexText(const TextRun&, const FontStyle&, const IntPoint&, int, int, int) const
+FloatRect Font::selectionRectForComplexText(const TextRun&, const IntPoint&, int, int, int) const
{
notImplemented();
return FloatRect();
#import "GraphicsContext.h"
#import "IntRect.h"
#import "Logging.h"
-#import "FontStyle.h"
#import "WebCoreSystemInterface.h"
#import "WebCoreTextRenderer.h"
#import "ShapeArabic.h"
struct ATSULayoutParameters
{
- ATSULayoutParameters(const TextRun& run, const FontStyle& style)
+ ATSULayoutParameters(const TextRun& run)
: m_run(run)
- , m_style(style)
, m_font(0)
, m_fonts(0)
, m_charBuffer(0)
void initialize(const Font*, const GraphicsContext* = 0);
const TextRun& m_run;
- const FontStyle& m_style;
const Font* m_font;
memcpy(&charactersWithOverride[1], run.data(0), sizeof(UChar) * run.length());
charactersWithOverride[run.length() + 1] = popDirectionalFormatting;
- return TextRun(charactersWithOverride, run.length() + 2);
+ TextRun result = run;
+ result.setText(charactersWithOverride, run.length() + 2);
+ return result;
}
static void initializeATSUStyle(const FontData* fontData)
ItemCount count;
ATSLayoutRecord *layoutRecords;
- if (params->m_style.applyWordRounding()) {
+ if (params->m_run.applyWordRounding()) {
status = ATSUDirectGetLayoutDataArrayPtrFromLineRef(iLineRef, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, true, (void **)&layoutRecords, &count);
if (status != noErr) {
*oCallbackStatus = kATSULayoutOperationCallbackStatusContinue;
bool syntheticBoldPass = params->m_syntheticBoldPass;
Fixed syntheticBoldOffset = 0;
ATSGlyphRef spaceGlyph = 0;
- bool hasExtraSpacing = params->m_font->letterSpacing() || params->m_font->wordSpacing() | params->m_style.padding();
- float padding = params->m_style.padding();
+ bool hasExtraSpacing = params->m_font->letterSpacing() || params->m_font->wordSpacing() | params->m_run.padding();
+ float padding = params->m_run.padding();
// In the CoreGraphics code path, the rounding hack is applied in logical order.
// Here it is applied in visual left-to-right order, which may be better.
ItemCount lastRoundingChar = 0;
if (width && params->m_font->letterSpacing())
width +=params->m_font->letterSpacing();
if (Font::treatAsSpace(nextCh)) {
- if (params->m_style.padding()) {
+ if (params->m_run.padding()) {
if (padding < params->m_padPerSpace) {
width += padding;
padding = 0;
if (Font::isRoundingHackCharacter(ch))
width = ceilf(width);
lastAdjustedPos = lastAdjustedPos + width;
- if (Font::isRoundingHackCharacter(nextCh) && (!isLastChar || params->m_style.applyRunRounding())){
- if (params->m_style.ltr())
+ if (Font::isRoundingHackCharacter(nextCh) && (!isLastChar || params->m_run.applyRunRounding())){
+ if (params->m_run.ltr())
lastAdjustedPos = ceilf(lastAdjustedPos);
else {
float roundingWidth = ceilf(lastAdjustedPos) - lastAdjustedPos;
CGContextRef cgContext = graphicsContext ? graphicsContext->platformContext() : (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
ATSLineLayoutOptions lineLayoutOptions = kATSLineKeepSpacesOutOfMargin | kATSLineHasNoHangers;
- Boolean rtl = m_style.rtl();
+ Boolean rtl = m_run.rtl();
overrideSpecifier.operationSelector = kATSULayoutOperationPostLayoutAdjustment;
overrideSpecifier.overrideUPP = overrideLayoutOperation;
ATSUAttributeTag tags[] = { kATSUCGContextTag, kATSULineLayoutOptionsTag, kATSULineDirectionTag, kATSULayoutOperationOverrideTag };
ByteCount sizes[] = { sizeof(CGContextRef), sizeof(ATSLineLayoutOptions), sizeof(Boolean), sizeof(ATSULayoutOperationOverrideSpecifier) };
ATSUAttributeValuePtr values[] = { &cgContext, &lineLayoutOptions, &rtl, &overrideSpecifier };
- status = ATSUSetLayoutControls(layout, (m_style.applyWordRounding() ? 4 : 3), tags, sizes, values);
+ status = ATSUSetLayoutControls(layout, (m_run.applyWordRounding() ? 4 : 3), tags, sizes, values);
if (status != noErr)
LOG_ERROR("ATSUSetLayoutControls failed(%d)", status);
}
shapeArabic(m_run.characters(), m_charBuffer, runLength, i);
}
- if (m_style.rtl() && !r->m_ATSUMirrors) {
+ if (m_run.rtl() && !r->m_ATSUMirrors) {
UChar mirroredChar = u_charMirror(m_run[i]);
if (mirroredChar != m_run[i]) {
if (!m_charBuffer) {
}
substituteOffset += substituteLength;
}
- if (m_style.padding()) {
+ if (m_run.padding()) {
float numSpaces = 0;
unsigned k;
for (k = 0; k < runLength; k++)
if (numSpaces == 0)
m_padPerSpace = 0;
else
- m_padPerSpace = ceilf(m_style.padding() / numSpaces);
+ m_padPerSpace = ceilf(m_run.padding() / numSpaces);
} else
m_padPerSpace = 0;
}
delete []params->m_fonts;
}
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
{
- TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
- if (style.directionalOverride()) {
+ TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
+ if (run.directionalOverride()) {
from++;
to++;
}
- ATSULayoutParameters params(adjustedRun, style);
+ ATSULayoutParameters params(adjustedRun);
params.initialize(this);
ATSTrapezoid firstGlyphBounds;
FloatRect rect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
- if (style.directionalOverride())
+ if (run.directionalOverride())
delete []adjustedRun.characters();
return rect;
}
-void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
+void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
{
OSStatus status;
int drawPortionLength = to - from;
- TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
- if (style.directionalOverride())
+ TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
+ if (run.directionalOverride())
from++;
- ATSULayoutParameters params(TextRun(adjustedRun.characters(), adjustedRun.length()), style);
+ ATSULayoutParameters params(TextRun(adjustedRun.characters(), adjustedRun.length()));
params.initialize(this, graphicsContext);
// ATSUI can't draw beyond -32768 to +32767 so we translate the CTM and tell ATSUI to draw at (0, 0).
disposeATSULayoutParameters(¶ms);
- if (style.directionalOverride())
+ if (run.directionalOverride())
delete []adjustedRun.characters();
}
-float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
+float Font::floatWidthForComplexText(const TextRun& run) const
{
if (run.length() == 0)
return 0;
- ATSULayoutParameters params(run, style);
+ ATSULayoutParameters params(run);
params.initialize(this);
OSStatus status;
MIN(FixedToFloat(firstGlyphBounds.upperLeft.x), FixedToFloat(firstGlyphBounds.lowerLeft.x));
}
-int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
{
- TextRun adjustedRun = style.directionalOverride() ? addDirectionalOverride(run, style.rtl()) : run;
+ TextRun adjustedRun = run.directionalOverride() ? addDirectionalOverride(run, run.rtl()) : run;
- ATSULayoutParameters params(adjustedRun, style);
+ ATSULayoutParameters params(adjustedRun);
params.initialize(this);
UniCharArrayOffset primaryOffset = 0;
unsigned offset;
if (status == noErr) {
offset = (unsigned)primaryOffset;
- if (style.directionalOverride() && offset > 0)
+ if (run.directionalOverride() && offset > 0)
offset--;
} else
// Failed to find offset! Return 0 offset.
disposeATSULayoutParameters(¶ms);
- if (style.directionalOverride())
+ if (run.directionalOverride())
delete []adjustedRun.characters();
return offset;
#include "Font.h"
#include "FontDescription.h"
#include "FontSelector.h"
-#include "FontStyle.h"
#include "GraphicsContext.h"
#include <QTextLayout>
// don't think we need this
}
-static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run, const FontStyle &style)
+static int generateComponents(Vector<TextRunComponent, 1024>* components, const Font &font, const TextRun &run)
{
// qDebug() << "generateComponents" << QString((const QChar *)run.characters(), run.length());
int letterSpacing = font.letterSpacing();
int wordSpacing = font.wordSpacing();
bool smallCaps = font.fontDescription().smallCaps();
- int padding = style.padding();
+ int padding = run.padding();
int numSpaces = 0;
if (padding) {
for (int i = 0; i < run.length(); i++)
padding -= add;
--numSpaces;
}
- components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
offset += add + letterSpacing + components->last().width;
start = 1;
// qDebug() << "space at 0" << offset;
// qDebug() << " treatAsSpace:" << i << start;
if (i - start > 0) {
components->append(TextRunComponent(run.characters() + start, i - start,
- style.rtl(),
+ run.rtl(),
f, offset, f == &font.scFont()));
offset += components->last().width + letterSpacing;
// qDebug() << " appending(1) " << components->last().string << components->last().width;
padding -= add;
--numSpaces;
}
- components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
offset += wordSpacing + add + components->last().width + letterSpacing;
start = i + 1;
continue;
}
if (i - start > 0) {
components->append(TextRunComponent(run.characters() + start, i - start,
- style.rtl(),
+ run.rtl(),
f, offset, f == &font.scFont()));
offset += components->last().width + letterSpacing;
// qDebug() << " appending(2) " << components->last().string << components->last().width;
}
if (run.length() - start > 0) {
components->append(TextRunComponent(run.characters() + start, run.length() - start,
- style.rtl(),
+ run.rtl(),
f, offset, f == &font.scFont()));
offset += components->last().width;
// qDebug() << " appending(3) " << components->last().string << components->last().width;
if (Font::treatAsSpace(run[i])) {
if (i - start > 0) {
components->append(TextRunComponent(run.characters() + start, i - start,
- style.rtl(),
+ run.rtl(),
f, offset));
offset += components->last().width;
}
padding -= add;
--numSpaces;
}
- components->append(TextRunComponent(1, style.rtl(), &font.font(), offset));
+ components->append(TextRunComponent(1, run.rtl(), &font.font(), offset));
offset += add + components->last().width;
if (i)
offset += wordSpacing;
}
if (run.length() - start > 0) {
components->append(TextRunComponent(run.characters() + start, run.length() - start,
- style.rtl(),
+ run.rtl(),
f, offset));
offset += components->last().width;
}
return offset;
}
-void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
+void Font::drawText(GraphicsContext* ctx, const TextRun& run, const FloatPoint& point, int from, int to) const
{
if (to < 0)
to = run.length();
p->setPen(QColor(color));
Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run, style);
+ int w = generateComponents(&components, *this, run);
if (from > 0 || to < run.length()) {
- FloatRect clip = selectionRectForText(run, style,
+ FloatRect clip = selectionRectForText(run,
IntPoint(qRound(point.x()), qRound(point.y())),
QFontMetrics(m_font).height(), from, to);
QRectF rect(clip.x(), clip.y() - ascent(), clip.width(), clip.height());
p->setClipRect(rect.toRect());
}
- if (style.rtl()) {
+ if (run.rtl()) {
for (int i = 0; i < components.size(); ++i) {
if (!components.at(i).isSpace()) {
p->setFont(*components.at(i).font);
p->restore();
}
-int Font::width(const TextRun& run, const FontStyle& style) const
+int Font::width(const TextRun& run) const
{
Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run, style);
+ int w = generateComponents(&components, *this, run);
// qDebug() << " width=" << w;
return w;
}
-int Font::width(const TextRun& run) const
-{
- return width(run, FontStyle());
-}
-
-float Font::floatWidth(const TextRun& run, const FontStyle& style) const
-{
- return width(run, style);
-}
-
float Font::floatWidth(const TextRun& run) const
{
return width(run);
}
-int Font::offsetForPosition(const TextRun& run, const FontStyle& style, int position, bool includePartialGlyphs) const
+int Font::offsetForPosition(const TextRun& run, int position, bool includePartialGlyphs) const
{
Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run, style);
+ int w = generateComponents(&components, *this, run);
int offset = 0;
- if (style.rtl()) {
+ if (run.rtl()) {
for (int i = 0; i < components.size(); ++i) {
int xe = w - components.at(i).offset;
int xs = xe - components.at(i).width;
return run.length();
}
-static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width,
- const FontStyle& style, int cursor)
+static float cursorToX(const Vector<TextRunComponent, 1024>& components, int width, bool rtl, int cursor)
{
int start = 0;
for (int i = 0; i < components.size(); ++i) {
continue;
}
int xs = components.at(i).offset;
- if (style.rtl())
+ if (rtl)
xs = width - xs - components.at(i).width;
QTextLayout layout(components.at(i).string, *components.at(i).font);
layout.beginLayout();
return width;
}
-FloatRect Font::selectionRectForText(const TextRun& run, const FontStyle& style, const IntPoint& pt,
+FloatRect Font::selectionRectForText(const TextRun& run, const IntPoint& pt,
int h, int from, int to) const
{
Vector<TextRunComponent, 1024> components;
- int w = generateComponents(&components, *this, run, style);
+ int w = generateComponents(&components, *this, run);
if (from == 0 && to == run.length())
return FloatRect(pt.x(), pt.y(), w, h);
- float x1 = cursorToX(components, w, style, from);
- float x2 = cursorToX(components, w, style, to);
+ float x1 = cursorToX(components, w, run.rtl(), from);
+ float x2 = cursorToX(components, w, run.rtl(), to);
if (x2 < x1)
qSwap(x1, x2);
#include "GraphicsContext.h"
#include "IntRect.h"
#include "NotImplemented.h"
-#include "FontStyle.h"
#include "UniscribeController.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
wkRestoreFontSmoothingStyle(cgContext, oldFontSmoothingStyle);
}
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h,
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h,
int from, int to) const
{
- UniscribeController it(this, run, style);
+ UniscribeController it(this, run);
it.advance(from);
float beforeWidth = it.runWidthSoFar();
it.advance(to);
float afterWidth = it.runWidthSoFar();
// Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
- if (style.rtl()) {
+ if (run.rtl()) {
it.advance(run.length());
float totalWidth = it.runWidthSoFar();
return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
}
-void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FontStyle& style, const FloatPoint& point,
+void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
int from, int to) const
{
// This glyph buffer holds our glyphs + advances + font data for each glyph.
GlyphBuffer glyphBuffer;
float startX = point.x();
- UniscribeController controller(this, run, style);
+ UniscribeController controller(this, run);
controller.advance(from);
float beforeWidth = controller.runWidthSoFar();
controller.advance(to, &glyphBuffer);
float afterWidth = controller.runWidthSoFar();
- if (style.rtl()) {
+ if (run.rtl()) {
controller.advance(run.length());
startX += controller.runWidthSoFar() - afterWidth;
} else
// Draw the glyph buffer now at the starting point returned in startX.
FloatPoint startPoint(startX, point.y());
- drawGlyphBuffer(context, glyphBuffer, run, style, startPoint);
+ drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
-float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
+float Font::floatWidthForComplexText(const TextRun& run) const
{
- UniscribeController controller(this, run, style);
+ UniscribeController controller(this, run);
controller.advance(run.length());
return controller.runWidthSoFar();
}
-int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
{
- UniscribeController controller(this, run, style);
+ UniscribeController controller(this, run);
return controller.offsetForPosition(x, includePartialGlyphs);
}
dc->DrawText(text, (wxCoord)point.x(), ypoint);
}
-FloatRect Font::selectionRectForComplexText(const TextRun& run, const FontStyle& style, const IntPoint& point, int h, int from, int to) const
+FloatRect Font::selectionRectForComplexText(const TextRun& run, const IntPoint& point, int h, int from, int to) const
{
notImplemented();
return FloatRect();
}
-void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FontStyle& style, const FloatPoint& point, int from, int to) const
+void Font::drawComplexText(GraphicsContext* graphicsContext, const TextRun& run, const FloatPoint& point, int from, int to) const
{
notImplemented();
}
-float Font::floatWidthForComplexText(const TextRun& run, const FontStyle& style) const
+float Font::floatWidthForComplexText(const TextRun& run) const
{
notImplemented();
return 0;
}
-int Font::offsetForPositionForComplexText(const TextRun& run, const FontStyle& style, int x, bool includePartialGlyphs) const
+int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
{
notImplemented();
return 0;
#import "FontData.h"
#import "GraphicsContext.h"
#import "IntPoint.h"
-#import "FontStyle.h"
#import "WebFontCache.h"
using namespace WebCore;
FontPlatformData f(font);
Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
TextRun run(buffer, length);
- FontStyle style;
- style.disableRoundingHacks();
+ run.disableRoundingHacks();
CGFloat red, green, blue, alpha;
[[textColor colorUsingColorSpaceName:NSDeviceRGBColorSpace] getRed:&red green:&green blue:&blue alpha:&alpha];
graphicsContext.setFillColor(makeRGBA((int)(red * 255), (int)(green * 255), (int)(blue * 255), (int)(alpha * 255)));
- renderer.drawText(&graphicsContext, run, style, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y))));
+ renderer.drawText(&graphicsContext, run, FloatPoint(point.x, (flipped ? point.y : (-1.0f * point.y))));
if (!flipped)
CGContextScaleCTM(cgContext, 1.0f, -1.0f);
}
FontPlatformData f(font);
Font renderer(f, ![[NSGraphicsContext currentContext] isDrawingToScreen]);
TextRun run(buffer, length);
- FontStyle style;
- style.disableRoundingHacks();
- return renderer.floatWidth(run, style);
+ run.disableRoundingHacks();
+ return renderer.floatWidth(run);
}
static bool gShouldUseFontSmoothing = true;
#include "PlatformScrollBar.h"
#include "RenderTheme.h"
#include "RenderView.h"
-#include "FontStyle.h"
#include <tchar.h>
#include <windows.h>
unsigned length = itemText.length();
const UChar* string = itemText.characters();
- FontStyle fontStyle(0, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
- TextRun textRun(string, length);
+ TextRun textRun(string, length, false, 0, 0, itemText.defaultWritingDirection() == WTF::Unicode::RightToLeft);
context.setFillColor(optionTextColor);
if (itemStyle->visibility() != HIDDEN) {
int textX = max(0, client()->clientPaddingLeft() - client()->clientInsetLeft());
int textY = itemRect.y() + itemFont.ascent() + (itemRect.height() - itemFont.height()) / 2;
- context.drawBidiText(textRun, IntPoint(textX, textY), fontStyle);
+ context.drawBidiText(textRun, IntPoint(textX, textY));
}
}
#include "UniscribeController.h"
#include "Font.h"
#include "FontData.h"
-#include "FontStyle.h"
#include <wtf/MathExtras.h>
namespace WebCore {
// that does stuff in that method instead of doing everything in the constructor. Have advance()
// take the GlyphBuffer as an arg so that we don't have to populate the glyph buffer when
// measuring.
-UniscribeController::UniscribeController(const Font* font, const TextRun& run, const FontStyle& style)
+UniscribeController::UniscribeController(const Font* font, const TextRun& run)
: m_font(*font)
, m_run(run)
-, m_style(style)
, m_end(run.length())
, m_currentCharacter(0)
, m_runWidthSoFar(0)
, m_offsetX(0)
, m_offsetPosition(0)
{
- m_padding = m_style.padding();
+ m_padding = m_run.padding();
if (!m_padding)
m_padPerSpace = 0;
else {
if (numSpaces == 0)
m_padPerSpace = 0;
else
- m_padPerSpace = ceilf(m_style.padding() / numSpaces);
+ m_padPerSpace = ceilf(m_run.padding() / numSpaces);
}
// Null out our uniscribe structs
advance(m_run.length());
if (m_computingOffsetPosition) {
// The point is to the left or to the right of the entire run.
- if (m_offsetX >= m_runWidthSoFar && m_style.ltr() || m_offsetX < 0 && m_style.rtl())
+ if (m_offsetX >= m_runWidthSoFar && m_run.ltr() || m_offsetX < 0 && m_run.rtl())
m_offsetPosition = m_end;
}
m_computingOffsetPosition = false;
Vector<UChar> smallCapsBuffer(length);
memcpy(smallCapsBuffer.data(), cp, length * sizeof(UChar));
bool isSmallCaps = false;
- unsigned indexOfCaseShift = m_style.rtl() ? length - 1 : 0;
- const UChar* curr = m_style.rtl() ? cp + length - 1: cp;
- const UChar* end = m_style.rtl() ? cp - 1: cp + length;
+ unsigned indexOfCaseShift = m_run.rtl() ? length - 1 : 0;
+ const UChar* curr = m_run.rtl() ? cp + length - 1: cp;
+ const UChar* end = m_run.rtl() ? cp - 1: cp + length;
while (curr != end) {
int index = curr - cp;
UChar c = smallCapsBuffer[index];
UChar newC;
- curr = m_style.rtl() ? curr - 1 : curr + 1;
+ curr = m_run.rtl() ? curr - 1 : curr + 1;
if (U_GET_GC_MASK(c) & U_GC_M_MASK)
continue;
if (!u_isUUppercase(c) && (newC = u_toupper(c)) != c) {
smallCapsBuffer[index] = newC;
if (!isSmallCaps) {
isSmallCaps = true;
- int itemStart = m_style.rtl() ? index : indexOfCaseShift;
- int itemLength = m_style.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
+ int itemStart = m_run.rtl() ? index : indexOfCaseShift;
+ int itemLength = m_run.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, false, glyphBuffer);
indexOfCaseShift = index;
}
} else if (isSmallCaps) {
isSmallCaps = false;
- int itemStart = m_style.rtl() ? index : indexOfCaseShift;
- int itemLength = m_style.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
+ int itemStart = m_run.rtl() ? index : indexOfCaseShift;
+ int itemLength = m_run.rtl() ? indexOfCaseShift - index : index - indexOfCaseShift;
itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, true, glyphBuffer);
indexOfCaseShift = index;
}
}
- int itemLength = m_style.rtl() ? indexOfCaseShift + 1 : length - indexOfCaseShift;
+ int itemLength = m_run.rtl() ? indexOfCaseShift + 1 : length - indexOfCaseShift;
if (itemLength) {
- int itemStart = m_style.rtl() ? 0 : indexOfCaseShift;
+ int itemStart = m_run.rtl() ? 0 : indexOfCaseShift;
itemizeShapeAndPlace(smallCapsBuffer.data() + itemStart, itemLength, isSmallCaps, glyphBuffer);
}
} else
}
m_items.resize(numItems + 1);
- if (m_style.rtl()) {
+ if (m_run.rtl()) {
for (int i = m_items.size() - 2; i >= 0; i--) {
if (!shapeAndPlaceItem(cp, i, smallCaps, glyphBuffer))
return;
memset(&m_state, 0, sizeof(SCRIPT_STATE));
// Set up the correct direction for the run.
- m_state.uBidiLevel = m_style.rtl();
+ m_state.uBidiLevel = m_run.rtl();
// Lock the correct directional override.
- m_state.fOverrideDirection = m_style.directionalOverride();
+ m_state.fOverrideDirection = m_run.directionalOverride();
}
bool UniscribeController::shapeAndPlaceItem(const UChar* cp, unsigned i, bool smallCaps, GlyphBuffer* glyphBuffer)
// Second, in fixed-pitch fonts we ensure that all glyphs that
// match the width of the space glyph have the same width as the space glyph.
if (roundedAdvance == roundedSpaceWidth && (fontData->m_treatAsFixedPitch || glyph == fontData->m_spaceGlyph) &&
- m_style.applyWordRounding())
+ m_run.applyWordRounding())
advance = fontData->m_adjustedSpaceWidth;
if (hasExtraSpacing) {
// Force characters that are used to determine word boundaries for the rounding hack
// to be integer width, so the following words will start on an integer boundary.
int roundingHackIndex = roundingHackCharacters[k];
- if (m_style.applyWordRounding() && roundingHackIndex != -1)
+ if (m_run.applyWordRounding() && roundingHackIndex != -1)
advance = ceilf(advance);
// Check to see if the next character is a "rounding hack character", if so, adjust the
// width so that the total run width will be on an integer boundary.
int position = m_currentCharacter + len;
- bool lastGlyph = (k == glyphs.size() - 1) && (m_style.rtl() ? i == 0 : i == m_items.size() - 2) && (position >= m_end);
- if ((m_style.applyWordRounding() && roundingHackWordBoundaries[k] != -1) ||
- (m_style.applyRunRounding() && lastGlyph)) {
+ bool lastGlyph = (k == glyphs.size() - 1) && (m_run.rtl() ? i == 0 : i == m_items.size() - 2) && (position >= m_end);
+ if ((m_run.applyWordRounding() && roundingHackWordBoundaries[k] != -1) ||
+ (m_run.applyRunRounding() && lastGlyph)) {
float totalWidth = m_runWidthSoFar + advance;
advance += ceilf(totalWidth) - totalWidth;
}
advances.data(), &item.a, &m_offsetPosition, &trailing);
if (trailing && m_includePartialGlyphs && m_offsetPosition < len - 1) {
m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
- m_offsetX += m_style.rtl() ? -trailing : trailing;
+ m_offsetX += m_run.rtl() ? -trailing : trailing;
} else {
m_computingOffsetPosition = false;
m_offsetPosition += m_currentCharacter + m_items[i].iCharPos;
class UniscribeController {
public:
- UniscribeController(const Font*, const TextRun&, const FontStyle&);
+ UniscribeController(const Font*, const TextRun&);
// Advance and measure/place up to the specified character.
void advance(unsigned to, GlyphBuffer* = 0);
const Font& m_font;
const TextRun& m_run;
- const FontStyle& m_style;
SCRIPT_CONTROL m_control;
SCRIPT_STATE m_state;
#include "FontDescription.h"
#include "GraphicsContext.h"
#include "StringTruncator.h"
-#include "FontStyle.h"
#include <wtf/unicode/Unicode.h>
namespace WebCore {
static void doDrawTextAtPoint(GraphicsContext& context, const String& text, const IntPoint& point, const Font& font, const Color& color, int underlinedIndex)
{
TextRun run(text.characters(), text.length());
- FontStyle style;
context.setFillColor(color);
if (isOneLeftToRightRun(run))
- font.drawText(&context, run, style, point);
+ font.drawText(&context, run, point);
else {
context.setFont(font);
- context.drawBidiText(run, point, style);
+ context.drawBidiText(run, point);
}
if (underlinedIndex >= 0) {
int beforeWidth;
if (underlinedIndex > 0) {
TextRun beforeRun(text.characters(), underlinedIndex);
- beforeWidth = font.width(beforeRun, style);
+ beforeWidth = font.width(beforeRun);
} else
beforeWidth = 0;
TextRun underlinedRun(text.characters() + underlinedIndex, 1);
- int underlinedWidth = font.width(underlinedRun, style);
+ int underlinedWidth = font.width(underlinedRun);
IntPoint underlinePoint(point);
underlinePoint.move(beforeWidth, 1);
#include "Document.h"
#include "GraphicsContext.h"
#include "HitTestResult.h"
-#include "FontStyle.h"
namespace WebCore {
}
const String& str = m_str;
- FontStyle fontStyle(0, 0, 0, false, style->visuallyOrdered());
- context->drawText(TextRun(str.characters(), str.length()), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
+ context->drawText(TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + m_baseline));
if (setShadow)
context->clearShadow();
#include "RenderBlock.h"
#include "RenderTheme.h"
#include "Text.h"
-#include "FontStyle.h"
#include "break_lines.h"
#include <wtf/AlwaysInline.h>
int selHeight = selectionHeight();
const Font& f = textObj->style(m_firstLine)->font();
- IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len),
- FontStyle(textObj->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
+ IntRect r = enclosingIntRect(f.selectionRectForText(TextRun(textObj->text()->characters() + m_start, m_len, textObj->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
IntPoint(tx + m_x, ty + selTop), selHeight, sPos, ePos));
if (r.x() > tx + m_x + m_width)
r.setWidth(0);
StringImpl* textStr = textObject()->text();
- FontStyle fontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered());
-
if (!paintSelectedTextOnly && !paintSelectedTextSeparately) {
// paint all the text
// FIXME: Handle RTL direction, handle reversed strings. For now truncation can only be turned on
int endPoint = m_len;
if (m_truncation != cNoTruncation)
endPoint = m_truncation;
- paintInfo.context->drawText(TextRun(textStr->characters() + m_start, endPoint), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
+ paintInfo.context->drawText(TextRun(textStr->characters() + m_start, endPoint, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
+ IntPoint(m_x + tx, m_y + ty + m_baseline));
} else {
int sPos, ePos;
selectionStartEnd(sPos, ePos);
if (paintSelectedTextSeparately) {
// paint only the text that is not selected
if (sPos >= ePos)
- paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle);
+ paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
+ IntPoint(m_x + tx, m_y + ty + m_baseline));
else {
if (sPos - 1 >= 0)
- paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle, 0, sPos);
+ paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
+ IntPoint(m_x + tx, m_y + ty + m_baseline), 0, sPos);
if (ePos < m_start + m_len)
- paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle, ePos);
+ paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
+ IntPoint(m_x + tx, m_y + ty + m_baseline), ePos);
}
}
if (selectionTextShadow)
paintInfo.context->setShadow(IntSize(selectionTextShadow->x, selectionTextShadow->y),
selectionTextShadow->blur, selectionTextShadow->color);
- paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len), IntPoint(m_x + tx, m_y + ty + m_baseline), fontStyle, sPos, ePos);
+ paintInfo.context->drawText(TextRun(textStr->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || styleToUse->visuallyOrdered()),
+ IntPoint(m_x + tx, m_y + ty + m_baseline), sPos, ePos);
if (selectionTextShadow)
paintInfo.context->clearShadow();
int y = selectionTop();
int h = selectionHeight();
p->clip(IntRect(m_x + tx, y + ty, m_width, h));
- p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len), IntPoint(m_x + tx, y + ty), h,
- FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()), c,
- sPos, ePos);
+ p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
+ IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
p->restore();
}
int y = selectionTop();
int h = selectionHeight();
- p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len),
- IntPoint(m_x + tx, y + ty), h,
- FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()), c, sPos, ePos);
+ p->drawHighlightForText(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
+ IntPoint(m_x + tx, y + ty), h, c, sPos, ePos);
p->restore();
}
if (grammar) {
int y = selectionTop();
IntPoint startPoint = IntPoint(m_x + tx, y + ty);
- FontStyle fontStyle = FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
int startPosition = max(marker.startOffset - m_start, (unsigned)0);
int endPosition = min(marker.endOffset - m_start, (unsigned)m_len);
- TextRun run = TextRun(textObject()->text()->characters() + m_start, m_len);
- IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, fontStyle, startPoint, selectionHeight(), startPosition, endPosition));
+ TextRun run(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
+ IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, startPoint, selectionHeight(), startPosition, endPosition));
object()->document()->setRenderedRectForMarker(object()->node(), marker, markerRect);
}
int sPos = max(marker.startOffset - m_start, (unsigned)0);
int ePos = min(marker.endOffset - m_start, (unsigned)m_len);
- TextRun run = TextRun(textObject()->text()->characters() + m_start, m_len);
- FontStyle renderStyle = FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
+ TextRun run(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered());
IntPoint startPoint = IntPoint(m_x + tx, y + ty);
// Always compute and store the rect associated with this marker
- IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, renderStyle, startPoint, h, sPos, ePos));
+ IntRect markerRect = enclosingIntRect(f->selectionRectForText(run, startPoint, h, sPos, ePos));
object()->document()->setRenderedRectForMarker(object()->node(), marker, markerRect);
// Optionally highlight the text
pt->save();
updateGraphicsContext(pt, color, color, 0); // Don't draw text at all!
pt->clip(IntRect(tx + m_x, ty + y, m_width, h));
- pt->drawHighlightForText(run, startPoint, h, renderStyle, color, sPos, ePos);
+ pt->drawHighlightForText(run, startPoint, h, color, sPos, ePos);
pt->restore();
}
}
RenderText* text = static_cast<RenderText*>(m_object);
RenderStyle *style = text->style(m_firstLine);
const Font* f = &style->font();
- return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len),
- FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
+ return f->offsetForPosition(TextRun(textObject()->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride || style->visuallyOrdered()),
_x - m_x, includePartialGlyphs);
}
int from = m_reversed ? offset - m_start : 0;
int to = m_reversed ? m_len : offset - m_start;
// FIXME: Do we need to add rightBearing here?
- return enclosingIntRect(f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len),
- FontStyle(textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
+ return enclosingIntRect(f.selectionRectForText(TextRun(text->text()->characters() + m_start, m_len, textObject()->allowTabs(), textPos(), m_toAdd, m_reversed, m_dirOverride),
IntPoint(m_x, 0), 0, from, to)).right();
}
#include "RenderText.h"
#include "RenderTheme.h"
#include "RenderView.h"
-#include "FontStyle.h"
#include <math.h>
using namespace std;
const String& displayedFilename = m_fileChooser->basenameForWidth(style()->font(), maxFilenameWidth());
unsigned length = displayedFilename.length();
const UChar* string = displayedFilename.characters();
- FontStyle fontStyle(0, 0, 0, style()->direction() == RTL, style()->unicodeBidi() == Override);
- TextRun textRun(string, length);
+ TextRun textRun(string, length, false, 0, 0, style()->direction() == RTL, style()->unicodeBidi() == Override);
// Determine where the filename should be placed
int contentLeft = tx + borderLeft() + paddingLeft();
paintInfo.context->setFillColor(style()->color());
// Draw the filename
- paintInfo.context->drawBidiText(textRun, IntPoint(textX, textY), fontStyle);
+ paintInfo.context->drawBidiText(textRun, IntPoint(textX, textY));
if (m_fileChooser->icon()) {
// Determine where the icon should be placed
// Figure out how big the filename space needs to be for a given number of characters
// (using "0" as the nominal character).
const UChar ch = '0';
- float charWidth = style()->font().floatWidth(TextRun(&ch, 1), FontStyle(0, 0, 0, false, false, false));
+ float charWidth = style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
m_maxPrefWidth = (int)ceilf(charWidth * defaultWidthNumChars);
}
#include "HitTestResult.h"
#include "Page.h"
#include "RenderView.h"
-#include "FontStyle.h"
using namespace std;
#include "PlatformScrollBar.h"
#include "RenderTheme.h"
#include "RenderView.h"
-#include "FontStyle.h"
#include <math.h>
using namespace std;
int size = numItems();
float width = 0;
- FontStyle fontStyle(0, 0, 0, false, false, false, false);
for (int i = 0; i < size; ++i) {
HTMLElement* element = listItems[i];
String text;
}
if (!text.isEmpty()) {
- float textWidth = itemFont.floatWidth(TextRun(text.impl()), fontStyle);
+ float textWidth = itemFont.floatWidth(TextRun(text.impl(), 0, 0, 0, false, false, false, false));
width = max(width, textWidth);
}
}
unsigned length = itemText.length();
const UChar* string = itemText.characters();
- FontStyle fontStyle(0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
- TextRun textRun(string, length);
+ TextRun textRun(string, length, 0, 0, 0, itemStyle->direction() == RTL, itemStyle->unicodeBidi() == Override, false, false);
// Draw the item text
if (itemStyle->visibility() != HIDDEN)
- paintInfo.context->drawBidiText(textRun, r.location(), fontStyle);
+ paintInfo.context->drawBidiText(textRun, r.location());
}
void RenderListBox::paintItemBackground(PaintInfo& paintInfo, int tx, int ty, int listIndex)
#include "RenderBR.h"
#include "RenderText.h"
#include "RenderTheme.h"
-#include "FontStyle.h"
#include <math.h>
using namespace std;
if (element->hasTagName(optionTag)) {
String text = static_cast<HTMLOptionElement*>(element)->optionText();
if (!text.isEmpty())
- maxOptionWidth = max(maxOptionWidth, style()->font().floatWidth(text, FontStyle()));
+ maxOptionWidth = max(maxOptionWidth, style()->font().floatWidth(text));
}
}
#include "RenderLayer.h"
#include "Text.h"
#include "TextBreakIterator.h"
-#include "FontStyle.h"
#include "break_lines.h"
#include <wtf/AlwaysInline.h>
return w;
}
- return f.width(TextRun(text()->characters() + start, len), FontStyle(allowTabs(), xPos));
+ return f.width(TextRun(text()->characters() + start, len, allowTabs(), xPos));
}
void RenderText::trimmedPrefWidths(int leadWidth,
m_maxWidth = currMaxWidth;
currMaxWidth = 0;
} else {
- currMaxWidth += f.width(TextRun(txt + i, 1), FontStyle(allowTabs(), leadWidth + currMaxWidth));
+ currMaxWidth += f.width(TextRun(txt + i, 1, allowTabs(), leadWidth + currMaxWidth));
needsWordSpacing = isSpace && !previousCharacterIsSpace && i == len - 1;
}
ASSERT(lastWordBoundary == i);
else
w = widthFromCache(f, from, len, xPos);
} else
- w = f.width(TextRun(text()->characters() + from, len), FontStyle(allowTabs(), xPos));
+ w = f.width(TextRun(text()->characters() + from, len, allowTabs(), xPos));
return w;
}
InlineTextBox* findNextInlineTextBox(int offset, int& pos) const;
- int allowTabs() const { return !style()->collapseWhiteSpace(); }
+ bool allowTabs() const { return !style()->collapseWhiteSpace(); }
void checkConsistency() const;
#include "Settings.h"
#include "Text.h"
#include "TextIterator.h"
-#include "FontStyle.h"
#include "htmlediting.h"
#include "visible_units.h"
#include <math.h>
// Figure out how big a text control needs to be for a given number of characters
// (using "0" as the nominal character).
const UChar ch = '0';
- float charWidth = style()->font().floatWidth(TextRun(&ch, 1), FontStyle(0, 0, 0, false, false, false));
+ float charWidth = style()->font().floatWidth(TextRun(&ch, 1, false, 0, 0, false, false, false));
int factor;
int scrollbarSize = 0;
if (m_multiLine) {
#include "SVGPaintServer.h"
#include "SVGRootInlineBox.h"
#include "Text.h"
-#include "FontStyle.h"
#include <float.h>
float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset) const
{
- return style->font().floatWidth(TextRun(textObject()->text()->characters() + offset, 1), svgFontStyleForInlineTextBox(style, this, 0));
+ return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0));
}
float SVGInlineTextBox::calculateGlyphHeight(RenderStyle* style, int offset) const
}
IntPoint origin((int) svgChar.x, (int) svgChar.y);
- TextRun run(chars, length);
- FontStyle style = svgFontStyleForInlineTextBox(styleToUse, this, svgChar.x);
+ TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
- paintInfo.context->drawText(run, origin, style);
+ paintInfo.context->drawText(run, origin);
if (paintInfo.phase != PaintPhaseSelection) {
paintDocumentMarkers(paintInfo.context, tx, ty, styleToUse, font, false);
p->save();
int adjust = startPos >= boxStartOffset ? boxStartOffset : 0;
- p->drawHighlightForText(TextRun(textObject()->text()->characters() + start() + boxStartOffset, length),
- IntPoint((int) svgChar.x, (int) svgChar.y - f->ascent()), f->ascent() + f->descent(),
- svgFontStyleForInlineTextBox(style, this, svgChar.x), color,
- startPos - adjust, endPos - adjust);
+ p->drawHighlightForText(svgTextRunForInlineTextBox(textObject()->text()->characters() + start() + boxStartOffset, length, style, this, svgChar.x),
+ IntPoint((int) svgChar.x, (int) svgChar.y - f->ascent()),
+ f->ascent() + f->descent(), color, startPos - adjust, endPos - adjust);
p->restore();
}
#include "SVGTextPositioningElement.h"
#include "SVGURIReference.h"
#include "Text.h"
-#include "FontStyle.h"
#include "UnicodeRange.h"
#include <float.h>
// Paint decorations, that have to be drawn before the text gets drawn
if (textDecorations != TDNONE && m_paintInfo.phase != PaintPhaseSelection) {
- textWidth = styleToUse->font().width(TextRun(stringStart, stringLength), styleToUse);
+ textWidth = styleToUse->font().width(svgTextRunForInlineTextBox(stringStart, stringLength, styleToUse, textBox, (*it).x));
decorationOrigin = IntPoint((int) (*it).x, (int) (*it).y - styleToUse->font().ascent());
info = m_rootBox->retrievePaintServersForTextDecoration(text);
}
RenderText* text = textBox->textObject();
RenderStyle* style = text->style();
- return style->font().floatWidth(TextRun(text->characters() + textBox->start() + range.startOffset, range.endOffset - range.startOffset), svgFontStyleForInlineTextBox(style, textBox, 0));
+ return style->font().floatWidth(svgTextRunForInlineTextBox(text->characters() + textBox->start() + range.startOffset, range.endOffset - range.startOffset, style, textBox, 0));
}
float cummulatedHeightOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range)
return (range.endOffset - range.startOffset) * (font.ascent() + font.descent());
}
-FontStyle svgFontStyleForInlineTextBox(RenderStyle* style, const InlineTextBox* textBox, float xPos)
+TextRun svgTextRunForInlineTextBox(const UChar* c, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos)
{
ASSERT(textBox);
ASSERT(style);
- FontStyle fontStyle(false, static_cast<int>(xPos), textBox->toAdd(), textBox->m_reversed, textBox->m_dirOverride || style->visuallyOrdered());
+ TextRun run(c, len, false, static_cast<int>(xPos), textBox->toAdd(), textBox->m_reversed, textBox->m_dirOverride || style->visuallyOrdered());
// We handle letter & word spacing ourselves
- fontStyle.disableSpacing();
- return fontStyle;
+ run.disableSpacing();
+ return run;
}
static float cummulatedWidthOrHeightOfTextChunk(SVGTextChunk& chunk, bool calcWidthOnly)
};
// Shared with SVGRenderTreeAsText / SVGInlineTextBox
-FontStyle svgFontStyleForInlineTextBox(RenderStyle* style, const InlineTextBox* textBox, float xPos);
+TextRun svgTextRunForInlineTextBox(const UChar*, int len, RenderStyle* style, const InlineTextBox* textBox, float xPos);
FloatPoint topLeftPositionOfCharacterRange(Vector<SVGChar>::iterator start, Vector<SVGChar>::iterator end);
float cummulatedWidthOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);
float cummulatedHeightOfInlineBoxCharacterRange(SVGInlineBoxCharacterRange& range);