本文整理汇总了C++中RenderTextControl类的典型用法代码示例。如果您正苦于以下问题:C++ RenderTextControl类的具体用法?C++ RenderTextControl怎么用?C++ RenderTextControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderTextControl类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: visibleSelectionForRangeInputElement
VisibleSelection visibleSelectionForRangeInputElement(Element* element, int start, int end)
{
if (DOMSupport::toTextControlElement(element)) {
RenderTextControl* textRender = toRenderTextControl(element->renderer());
if (!textRender)
return VisibleSelection();
VisiblePosition startPosition = textRender->visiblePositionForIndex(start);
VisiblePosition endPosition;
if (start == end)
endPosition = startPosition;
else
endPosition = textRender->visiblePositionForIndex(end);
return VisibleSelection(startPosition, endPosition);
}
// Must be content editable, generate the range.
RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(element, start, end - start);
if (start == end)
return VisibleSelection(selectionRange.get()->startPosition(), DOWNSTREAM);
VisiblePosition visibleStart(selectionRange->startPosition(), DOWNSTREAM);
VisiblePosition visibleEnd(selectionRange->endPosition(), SEL_DEFAULT_AFFINITY);
return VisibleSelection(visibleStart, visibleEnd);
}
示例2: visibleSelectionForFocusedBlock
VisibleSelection visibleSelectionForFocusedBlock(Element* element)
{
int textLength = inputElementText(element).length();
if (DOMSupport::toTextControlElement(element)) {
RenderTextControl* textRender = toRenderTextControl(element->renderer());
if (!textRender)
return VisibleSelection();
VisiblePosition startPosition = textRender->visiblePositionForIndex(0);
VisiblePosition endPosition;
if (textLength)
endPosition = textRender->visiblePositionForIndex(textLength);
else
endPosition = startPosition;
return VisibleSelection(startPosition, endPosition);
}
// Must be content editable, generate the range.
RefPtr<Range> selectionRange = TextIterator::rangeFromLocationAndLength(element, 0, textLength);
if (!selectionRange)
return VisibleSelection();
if (!textLength)
return VisibleSelection(selectionRange->startPosition(), DOWNSTREAM);
return VisibleSelection(selectionRange->startPosition(), selectionRange->endPosition());
}
示例3: toRenderTextControl
bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool)
{
if (name().isEmpty())
return false;
// FIXME: It's not acceptable to ignore the HardWrap setting when there is no renderer.
// While we have no evidence this has ever been a practical problem, it would be best to fix it some day.
RenderTextControl* control = toRenderTextControl(renderer());
const String& text = (m_wrap == HardWrap && control) ? control->textWithHardLineBreaks() : value();
encoding.appendData(name(), text);
return true;
}
示例4: contentsPoint
VisiblePosition RenderTextControlInnerBlock::positionForPoint(const LayoutPoint& point)
{
LayoutPoint contentsPoint(point);
// Multiline text controls have the scroll on shadowAncestorNode, so we need to take that
// into account here.
if (m_multiLine) {
RenderTextControl* renderer = toRenderTextControl(node()->shadowAncestorNode()->renderer());
if (renderer->hasOverflowClip())
contentsPoint += renderer->scrolledContentOffset();
}
return RenderBlock::positionForPoint(contentsPoint);
}
示例5: positionForPoint
VisiblePosition RenderTextControlInnerBlock::positionForPoint(const IntPoint& point)
{
int contentsX = point.x();
int contentsY = point.y();
// Multiline text controls have the scroll on shadowAncestorNode, so we need to take that
// into account here.
if (m_multiLine) {
RenderTextControl* renderer = static_cast<RenderTextControl*>(node()->shadowAncestorNode()->renderer());
if (renderer->hasOverflowClip())
renderer->layer()->addScrolledContentOffset(contentsX, contentsY);
}
return RenderBlock::positionForPoint(IntPoint(contentsX, contentsY));
}
示例6: document
void HTMLTextFormControlElement::setSelectionRange(int start, int end, TextFieldSelectionDirection direction)
{
document()->updateLayoutIgnorePendingStylesheets();
if (!renderer() || !renderer()->isTextControl())
return;
end = max(end, 0);
start = min(max(start, 0), end);
RenderTextControl* control = toRenderTextControl(renderer());
if (!hasVisibleTextArea(control, innerTextElement())) {
cacheSelection(start, end, direction);
return;
}
VisiblePosition startPosition = control->visiblePositionForIndex(start);
VisiblePosition endPosition;
if (start == end)
endPosition = startPosition;
else
endPosition = control->visiblePositionForIndex(end);
// startPosition and endPosition can be null position for example when
// "-webkit-user-select: none" style attribute is specified.
if (startPosition.isNotNull() && endPosition.isNotNull()) {
ASSERT(startPosition.deepEquivalent().deprecatedNode()->shadowHost() == this
&& endPosition.deepEquivalent().deprecatedNode()->shadowHost() == this);
}
VisibleSelection newSelection;
if (direction == SelectionHasBackwardDirection)
newSelection = VisibleSelection(endPosition, startPosition);
else
newSelection = VisibleSelection(startPosition, endPosition);
newSelection.setIsDirectional(direction != SelectionHasNoDirection);
if (Frame* frame = document()->frame())
frame->selection()->setSelection(newSelection);
}
示例7: nodeAtPoint
bool RenderTextControlInnerBlock::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction hitTestAction)
{
RenderTextControl* renderer = static_cast<RenderTextControl*>(node()->shadowAncestorNode()->renderer());
return RenderBlock::nodeAtPoint(request, result, x, y, tx, ty, renderer->placeholderIsVisible() ? HitTestBlockBackground : hitTestAction);
}