本文整理汇总了C++中DocumentMarker::shiftOffsets方法的典型用法代码示例。如果您正苦于以下问题:C++ DocumentMarker::shiftOffsets方法的具体用法?C++ DocumentMarker::shiftOffsets怎么用?C++ DocumentMarker::shiftOffsets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentMarker
的用法示例。
在下文中一共展示了DocumentMarker::shiftOffsets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: copyMarkers
// copies markers from srcNode to dstNode, applying the specified shift delta to the copies. The shift is
// useful if, e.g., the caller has created the dstNode from a non-prefix substring of the srcNode.
void DocumentMarkerController::copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta)
{
if (length <= 0)
return;
if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
return;
ASSERT(!m_markers.isEmpty());
MarkerLists* markers = m_markers.get(srcNode);
if (!markers)
return;
bool docDirty = false;
for (size_t markerListIndex = 0; markerListIndex < DocumentMarker::MarkerTypeIndexesCount; ++markerListIndex) {
OwnPtr<MarkerList>& list = (*markers)[markerListIndex];
if (!list)
continue;
unsigned endOffset = startOffset + length - 1;
MarkerList::iterator startPos = std::lower_bound(list->begin(), list->end(), startOffset, doesNotInclude);
for (MarkerList::iterator i = startPos; i != list->end(); ++i) {
DocumentMarker* marker = i->get();
// stop if we are now past the specified range
if (marker->startOffset() > endOffset)
break;
// pin the marker to the specified range and apply the shift delta
docDirty = true;
if (marker->startOffset() < startOffset)
marker->setStartOffset(startOffset);
if (marker->endOffset() > endOffset)
marker->setEndOffset(endOffset);
marker->shiftOffsets(delta);
addMarker(dstNode, *marker);
}
}
// repaint the affected node
if (docDirty && dstNode->renderer())
dstNode->renderer()->doNotUseInvalidatePaintForWholeRendererSynchronously();
}
示例2: copyMarkers
// copies markers from srcNode to dstNode, applying the specified shift delta to the copies. The shift is
// useful if, e.g., the caller has created the dstNode from a non-prefix substring of the srcNode.
void DocumentMarkerController::copyMarkers(Node* srcNode, unsigned startOffset, int length, Node* dstNode, int delta)
{
if (length <= 0)
return;
if (!possiblyHasMarkers(DocumentMarker::AllMarkers()))
return;
ASSERT(!m_markers.isEmpty());
MarkerList* list = m_markers.get(srcNode);
if (!list)
return;
bool docDirty = false;
unsigned endOffset = startOffset + length - 1;
for (size_t i = 0; i != list->size(); ++i) {
DocumentMarker marker = list->at(i);
// stop if we are now past the specified range
if (marker.startOffset() > endOffset)
break;
// skip marker that is before the specified range or is the wrong type
if (marker.endOffset() < startOffset)
continue;
// pin the marker to the specified range and apply the shift delta
docDirty = true;
if (marker.startOffset() < startOffset)
marker.setStartOffset(startOffset);
if (marker.endOffset() > endOffset)
marker.setEndOffset(endOffset);
marker.shiftOffsets(delta);
addMarker(dstNode, marker);
}
// repaint the affected node
if (docDirty && dstNode->renderer())
dstNode->renderer()->repaint();
}