本文整理汇总了C++中InlineTextBox::end方法的典型用法代码示例。如果您正苦于以下问题:C++ InlineTextBox::end方法的具体用法?C++ InlineTextBox::end怎么用?C++ InlineTextBox::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InlineTextBox
的用法示例。
在下文中一共展示了InlineTextBox::end方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: localQuadForTextBox
static FloatRect localQuadForTextBox(const InlineTextBox& box, unsigned start, unsigned end, bool useSelectionHeight)
{
unsigned realEnd = std::min(box.end() + 1, end);
LayoutRect boxSelectionRect = box.localSelectionRect(start, realEnd);
if (!boxSelectionRect.height())
return FloatRect();
if (useSelectionHeight)
return boxSelectionRect;
// Change the height and y position (or width and x for vertical text)
// because selectionRect uses selection-specific values.
if (box.isHorizontal()) {
boxSelectionRect.setHeight(box.height());
boxSelectionRect.setY(box.y());
} else {
boxSelectionRect.setWidth(box.width());
boxSelectionRect.setX(box.x());
}
return boxSelectionRect;
}
示例2: recursiveBuildTextChunks
void SVGTextChunkLayoutInfo::recursiveBuildTextChunks(InlineFlowBox* start)
{
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " -> buildTextChunks(start=%p)\n", start);
#endif
for (InlineBox* curr = start->firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->renderer()->isText()) {
InlineTextBox* textBox = static_cast<InlineTextBox*>(curr);
unsigned length = textBox->len();
ASSERT(length > 0);
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " -> Handle inline text box (%p) with %i characters (start: %i, end: %i), handlingTextPath=%i\n",
textBox, length, textBox->start(), textBox->end(), (int) m_handlingTextPath);
#endif
RenderText* text = textBox->textRenderer();
ASSERT(text);
ASSERT(text->node());
SVGTextContentElement* textContent = 0;
Node* node = text->node()->parent();
while (node && node->isSVGElement() && !textContent) {
if (static_cast<SVGElement*>(node)->isTextContent())
textContent = static_cast<SVGTextContentElement*>(node);
else
node = node->parentNode();
}
ASSERT(textContent);
// Start new character range for the first chunk
bool isFirstCharacter = m_svgTextChunks.isEmpty() && m_chunk.start == m_charsIt && m_chunk.start == m_chunk.end;
if (isFirstCharacter) {
ASSERT(m_chunk.boxes.isEmpty());
m_chunk.boxes.append(SVGInlineBoxCharacterRange());
} else
ASSERT(!m_chunk.boxes.isEmpty());
// Walk string to find out new chunk positions, if existent
for (unsigned i = 0; i < length; ++i) {
ASSERT(m_charsIt != m_charsEnd);
SVGInlineBoxCharacterRange& range = m_chunk.boxes.last();
if (range.isOpen()) {
range.box = curr;
range.startOffset = !i ? 0 : i - 1;
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " | -> Range is open! box=%p, startOffset=%i\n", range.box, range.startOffset);
#endif
}
// If a new (or the first) chunk has been started, record it's text-anchor and writing mode.
if (m_assignChunkProperties) {
m_assignChunkProperties = false;
m_chunk.isVerticalText = isVerticalWritingMode(text->style()->svgStyle());
m_chunk.isTextPath = m_handlingTextPath;
m_chunk.anchor = text->style()->svgStyle()->textAnchor();
m_chunk.textLength = textContent->textLength().value(textContent);
m_chunk.lengthAdjust = (ELengthAdjust) textContent->lengthAdjust();
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " | -> Assign chunk properties, isVerticalText=%i, anchor=%i\n", m_chunk.isVerticalText, m_chunk.anchor);
#endif
}
if (i > 0 && !isFirstCharacter && m_charsIt->newTextChunk) {
// Close mid chunk & character range
ASSERT(!range.isOpen());
ASSERT(!range.isClosed());
range.endOffset = i;
closeTextChunk();
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " | -> Close mid-text chunk, at endOffset: %i and starting new mid chunk!\n", range.endOffset);
#endif
// Prepare for next chunk, if we're not at the end
startTextChunk();
if (i + 1 == length) {
#if DEBUG_CHUNK_BUILDING > 1
fprintf(stderr, " | -> Record last chunk of inline text box!\n");
#endif
startTextChunk();
SVGInlineBoxCharacterRange& range = m_chunk.boxes.last();
m_assignChunkProperties = false;
m_chunk.isVerticalText = isVerticalWritingMode(text->style()->svgStyle());
m_chunk.isTextPath = m_handlingTextPath;
m_chunk.anchor = text->style()->svgStyle()->textAnchor();
m_chunk.textLength = textContent->textLength().value(textContent);
m_chunk.lengthAdjust = (ELengthAdjust) textContent->lengthAdjust();
range.box = curr;
range.startOffset = i;
//.........这里部分代码省略.........
示例3: textForRenderer
static gchar* textForRenderer(RenderObject* renderer)
{
GString* resultText = g_string_new(0);
if (!renderer)
return g_string_free(resultText, FALSE);
// For RenderBlocks, piece together the text from the RenderText objects they contain.
for (RenderObject* object = renderer->firstChild(); object; object = object->nextSibling()) {
if (object->isBR()) {
g_string_append(resultText, "\n");
continue;
}
RenderText* renderText;
if (object->isText())
renderText = toRenderText(object);
else {
// List item's markers will be treated in an special way
// later on this function, so ignore them here.
if (object->isReplaced() && !renderer->isListItem())
g_string_append_unichar(resultText, objectReplacementCharacter);
// We need to check children, if any, to consider when
// current object is not a text object but some of its
// children are, in order not to miss those portions of
// text by not properly handling those situations
if (object->firstChild())
g_string_append(resultText, textForRenderer(object));
continue;
}
InlineTextBox* box = renderText ? renderText->firstTextBox() : 0;
while (box) {
// WebCore introduces line breaks in the text that do not reflect
// the layout you see on the screen, replace them with spaces.
String text = String(renderText->characters(), renderText->textLength()).replace("\n", " ");
g_string_append(resultText, text.substring(box->start(), box->end() - box->start() + 1).utf8().data());
// Newline chars in the source result in separate text boxes, so check
// before adding a newline in the layout. See bug 25415 comment #78.
// If the next sibling is a BR, we'll add the newline when we examine that child.
if (!box->nextOnLineExists() && !(object->nextSibling() && object->nextSibling()->isBR())) {
// If there was a '\n' in the last position of the
// current text box, it would have been converted to a
// space in String::replace(), so remove it first.
if (renderText->characters()[box->end()] == '\n')
g_string_erase(resultText, resultText->len - 1, -1);
g_string_append(resultText, "\n");
}
box = box->nextTextBox();
}
}
// Insert the text of the marker for list item in the right place, if present
if (renderer->isListItem()) {
String markerText = toRenderListItem(renderer)->markerTextWithSuffix();
if (renderer->style()->direction() == LTR)
g_string_prepend(resultText, markerText.utf8().data());
else
g_string_append(resultText, markerText.utf8().data());
}
return g_string_free(resultText, FALSE);
}
示例4: downstream
Position Position::downstream(EStayInBlock stayInBlock) const
{
Position start = equivalentDeepPosition();
NodeImpl *startNode = start.node();
if (!startNode)
return Position();
NodeImpl *block = startNode->enclosingBlockFlowOrTableElement();
Position lastVisible;
PositionIterator it(start);
for (; !it.atEnd(); it.next()) {
NodeImpl *currentNode = it.current().node();
if (stayInBlock) {
NodeImpl *currentBlock = currentNode->enclosingBlockFlowOrTableElement();
if (block != currentBlock)
return it.previous();
}
RenderObject *renderer = currentNode->renderer();
if (!renderer)
continue;
if (renderer->style()->visibility() != VISIBLE)
continue;
lastVisible = it.current();
if (currentNode != startNode && renderer->isBlockFlow()) {
if (it.current().offset() == 0) {
// If no first child, or first visible child is a not a block, return; otherwise continue.
if (!currentNode->firstChild())
return Position(currentNode, 0);
for (NodeImpl *child = currentNode->firstChild(); child; child = child->nextSibling()) {
RenderObject *r = child->renderer();
if (r && r->style()->visibility() == VISIBLE) {
if (r->isBlockFlow())
break; // break causes continue code below to run.
else
return Position(child, 0);
}
}
continue;
}
}
if (renderer->isReplaced() || renderer->isBR()) {
if (it.current().offset() <= renderer->caretMinOffset())
return Position(currentNode, renderer->caretMinOffset());
else
continue;
}
if (renderer->isText() && static_cast<RenderText *>(renderer)->firstTextBox()) {
if (currentNode != start.node())
return Position(currentNode, renderer->caretMinOffset());
if (it.current().offset() < 0)
continue;
uint textOffset = it.current().offset();
RenderText *textRenderer = static_cast<RenderText *>(renderer);
for (InlineTextBox *box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
if (textOffset >= box->start() && textOffset <= box->end())
return it.current();
else if (box != textRenderer->lastTextBox() &&
!box->nextOnLine() &&
textOffset == box->start() + box->len())
return it.current();
}
}
}
return lastVisible.isNotNull() ? lastVisible : *this;
}
示例5: downstream
// P.downstream() returns the end of the range of positions that map to the same VisiblePosition as P.
Position Position::downstream() const
{
Node* startNode = node();
if (!startNode)
return Position();
// iterate forward from there, looking for a qualified position
Node* block = enclosingBlock(startNode);
PositionIterator lastVisible = *this;
PositionIterator currentPos = lastVisible;
Node* originalRoot = node()->rootEditableElement();
for (; !currentPos.atEnd(); currentPos.increment()) {
Node* currentNode = currentPos.node();
if (currentNode->rootEditableElement() != originalRoot)
break;
// stop before going above the body, up into the head
// return the last visible streamer position
if (currentNode->hasTagName(bodyTag) && currentPos.atEndOfNode())
break;
// Do not enter a new enclosing block flow or table element, and don't leave the original one.
if (block != enclosingBlock(currentNode))
return lastVisible;
// skip position in unrendered or invisible node
RenderObject* renderer = currentNode->renderer();
if (!renderer || renderer->style()->visibility() != VISIBLE)
continue;
// track last visible streamer position
if (isStreamer(currentPos))
lastVisible = currentPos;
// Return position before brs, tables, and nodes which have content that can be ignored.
if (editingIgnoresContent(currentNode) || renderer->isBR() || isTableElement(currentNode)) {
if (currentPos.offsetInLeafNode() <= renderer->caretMinOffset())
return Position(currentNode, renderer->caretMinOffset());
continue;
}
// return current position if it is in rendered text
if (renderer->isText() && static_cast<RenderText*>(renderer)->firstTextBox()) {
if (currentNode != startNode) {
ASSERT(currentPos.atStartOfNode());
return Position(currentNode, renderer->caretMinOffset());
}
unsigned textOffset = currentPos.offsetInLeafNode();
RenderText* textRenderer = static_cast<RenderText*>(renderer);
for (InlineTextBox* box = textRenderer->firstTextBox(); box; box = box->nextTextBox()) {
if (textOffset >= box->start() && textOffset <= box->end())
return currentPos;
if (box != textRenderer->lastTextBox() &&
!box->nextOnLine() &&
textOffset == box->start() + box->len()) {
return currentPos;
}
}
}
}
return lastVisible;
}
示例6: placePositionedBoxesHorizontally
static int placePositionedBoxesHorizontally(InlineFlowBox* flow, int x, int& leftPosition, int& rightPosition, int& leftAlign, int& rightAlign, bool& needsWordSpacing, int xPos, bool positioned)
{
int mn = INT_MAX;
int mx = INT_MIN;
int amn = INT_MAX;
int amx = INT_MIN;
int startx = x;
bool seenPositionedElement = false;
flow->setXPos(x);
for (InlineBox* curr = flow->firstChild(); curr; curr = curr->nextOnLine()) {
if (curr->object()->isText()) {
mn = min(mn, x);
amn = min(amn, x);
InlineTextBox* text = static_cast<InlineTextBox*>(curr);
RenderText* rt = static_cast<RenderText*>(text->object());
if (rt->textLength()) {
if (needsWordSpacing && DeprecatedChar(rt->characters()[text->start()]).isSpace())
x += rt->style(flow->isFirstLineStyle())->font().wordSpacing();
needsWordSpacing = !DeprecatedChar(rt->characters()[text->end()]).isSpace();
}
text->setXPos(x);
x += text->width();
mx = max(mx, x);
amx = max(amx, x);
} else if (curr->object()->isInlineFlow()) {
InlineFlowBox* flow = static_cast<InlineFlowBox*>(curr);
if (flow->object()->element()->hasTagName(aTag)) {
x = placePositionedBoxesHorizontally(flow, x, mn, mx, amn, amx, needsWordSpacing, xPos, false);
} else {
SVGTextPositioningElement* text = static_cast<SVGTextPositioningElement*>(flow->object()->element());
x += (int)(text->dx()->getFirst().value());
if (text->x()->numberOfItems() > 0)
x = (int)(text->x()->getFirst().value() - xPos);
if (text->x()->numberOfItems() > 0 || text->y()->numberOfItems() > 0 ||
text->dx()->numberOfItems() > 0 || text->dy()->numberOfItems() > 0) {
seenPositionedElement = true;
needsWordSpacing = false;
int ignoreX, ignoreY;
x = placePositionedBoxesHorizontally(flow, x, mn, mx, ignoreX, ignoreY, needsWordSpacing, xPos, true);
} else if (seenPositionedElement) {
int ignoreX, ignoreY;
x = placePositionedBoxesHorizontally(flow, x, mn, mx, ignoreX, ignoreY, needsWordSpacing, xPos, false);
} else
x = placePositionedBoxesHorizontally(flow, x, mn, mx, amn, amx, needsWordSpacing, xPos, false);
}
}
}
if (mn > mx)
mn = mx = startx;
if (amn > amx)
amn = amx = startx;
int width = mx - mn;
flow->setWidth(width);
int awidth = amx - amn;
int dx = 0;
if (positioned) {
switch (flow->object()->style()->svgStyle()->textAnchor()) {
case TA_MIDDLE:
translateBox(flow, dx = -awidth / 2, 0, true);
break;
case TA_END:
translateBox(flow, dx = -awidth, 0, true);
break;
case TA_START:
default:
break;
}
if (dx) {
x += dx;
mn += dx;
mx += dx;
}
}
leftPosition = min(leftPosition, mn);
rightPosition = max(rightPosition, mx);
leftAlign = min(leftAlign, amn);
rightAlign = max(rightAlign, amx);
return x;
}
示例7: getPangoLayoutForAtk
static PangoLayout* getPangoLayoutForAtk(AtkText* textObject)
{
AccessibilityObject* coreObject = core(textObject);
HostWindow* hostWindow = coreObject->document()->view()->hostWindow();
if (!hostWindow)
return 0;
PlatformPageClient webView = hostWindow->platformPageClient();
if (!webView)
return 0;
GString* str = g_string_new(NULL);
AccessibilityRenderObject* accObject = static_cast<AccessibilityRenderObject*>(coreObject);
if (!accObject)
return 0;
RenderText* renderText = toRenderText(accObject->renderer());
if (!renderText)
return 0;
// Create a string with the layout as it appears on the screen
InlineTextBox* box = renderText->firstTextBox();
while (box) {
gchar *text = convertUniCharToUTF8(renderText->characters(), renderText->textLength(), box->start(), box->end());
g_string_append(str, text);
g_string_append(str, "\n");
box = box->nextTextBox();
}
PangoLayout* layout = gtk_widget_create_pango_layout(static_cast<GtkWidget*>(webView), g_string_free(str, FALSE));
g_object_set_data_full(G_OBJECT(textObject), "webkit-accessible-pango-layout", layout, g_object_unref);
return layout;
}