本文整理汇总了C++中LayoutDeviceIntRect::Union方法的典型用法代码示例。如果您正苦于以下问题:C++ LayoutDeviceIntRect::Union方法的具体用法?C++ LayoutDeviceIntRect::Union怎么用?C++ LayoutDeviceIntRect::Union使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayoutDeviceIntRect
的用法示例。
在下文中一共展示了LayoutDeviceIntRect::Union方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
LayoutDeviceIntRect
ContentCache::TextRectArray::GetUnionRect(uint32_t aOffset,
uint32_t aLength) const
{
LayoutDeviceIntRect rect;
if (!InRange(aOffset, aLength)) {
return rect;
}
for (uint32_t i = 0; i < aLength; i++) {
rect = rect.Union(mRects[aOffset - mStart + i]);
}
return rect;
}
示例2: EndOffset
LayoutDeviceIntRect
ContentCache::TextRectArray::GetUnionRectAsFarAsPossible(
uint32_t aOffset,
uint32_t aLength) const
{
LayoutDeviceIntRect rect;
if (!IsOverlappingWith(aOffset, aLength)) {
return rect;
}
uint32_t startOffset = std::max(aOffset, mStart);
uint32_t endOffset = std::min(aOffset + aLength, EndOffset());
for (uint32_t i = 0; i < endOffset - startOffset; i++) {
rect = rect.Union(mRects[startOffset - mStart + i]);
}
return rect;
}
示例3: GetUnionTextRects
bool
ContentCacheInParent::GetUnionTextRects(
uint32_t aOffset,
uint32_t aLength,
LayoutDeviceIntRect& aUnionTextRect) const
{
MOZ_LOG(sContentCacheLog, LogLevel::Info,
("ContentCacheInParent: 0x%p GetUnionTextRects(aOffset=%u, "
"aLength=%u), mTextRectArray={ mStart=%u, mRects.Length()=%u }, "
"mSelection={ mAnchor=%u, mFocus=%u }",
this, aOffset, aLength, mTextRectArray.mStart,
mTextRectArray.mRects.Length(), mSelection.mAnchor, mSelection.mFocus));
CheckedInt<uint32_t> endOffset =
CheckedInt<uint32_t>(aOffset) + aLength;
if (!endOffset.isValid()) {
return false;
}
if (!mSelection.Collapsed() &&
aOffset == mSelection.StartOffset() && aLength == mSelection.Length()) {
NS_WARN_IF(mSelection.mRect.IsEmpty());
aUnionTextRect = mSelection.mRect;
return !aUnionTextRect.IsEmpty();
}
if (aLength == 1) {
if (!aOffset) {
NS_WARN_IF(mFirstCharRect.IsEmpty());
aUnionTextRect = mFirstCharRect;
return !aUnionTextRect.IsEmpty();
}
if (aOffset == mSelection.mAnchor) {
NS_WARN_IF(mSelection.mAnchorCharRect.IsEmpty());
aUnionTextRect = mSelection.mAnchorCharRect;
return !aUnionTextRect.IsEmpty();
}
if (aOffset == mSelection.mFocus) {
NS_WARN_IF(mSelection.mFocusCharRect.IsEmpty());
aUnionTextRect = mSelection.mFocusCharRect;
return !aUnionTextRect.IsEmpty();
}
}
// Even if some text rects are not cached of the queried range,
// we should return union rect when the first character's rect is cached
// since the first character rect is important and the others are not so
// in most cases.
if (!aOffset && aOffset != mSelection.mAnchor &&
aOffset != mSelection.mFocus && !mTextRectArray.InRange(aOffset)) {
// The first character rect isn't cached.
return false;
}
if (mTextRectArray.IsOverlappingWith(aOffset, aLength)) {
aUnionTextRect =
mTextRectArray.GetUnionRectAsFarAsPossible(aOffset, aLength);
} else {
aUnionTextRect.SetEmpty();
}
if (!aOffset) {
aUnionTextRect = aUnionTextRect.Union(mFirstCharRect);
}
if (aOffset <= mSelection.mAnchor && mSelection.mAnchor < endOffset.value()) {
aUnionTextRect = aUnionTextRect.Union(mSelection.mAnchorCharRect);
}
if (aOffset <= mSelection.mFocus && mSelection.mFocus < endOffset.value()) {
aUnionTextRect = aUnionTextRect.Union(mSelection.mFocusCharRect);
}
return !aUnionTextRect.IsEmpty();
}