void TransformState::translateTransform(const LayoutSize& offset) { if (m_direction == ApplyTransformDirection) m_accumulatedTransform->translateRight(offset.width(), offset.height()); else m_accumulatedTransform->translate(offset.width(), offset.height()); }
bool canScrollInDirection(const LocalFrame* frame, FocusType type) { if (!frame->view()) return false; ScrollbarMode verticalMode; ScrollbarMode horizontalMode; frame->view()->calculateScrollbarModesForLayoutAndSetViewportRenderer(horizontalMode, verticalMode); if ((type == FocusTypeLeft || type == FocusTypeRight) && ScrollbarAlwaysOff == horizontalMode) return false; if ((type == FocusTypeUp || type == FocusTypeDown) && ScrollbarAlwaysOff == verticalMode) return false; LayoutSize size = frame->view()->contentsSize(); LayoutSize offset = frame->view()->scrollOffset(); LayoutRect rect = frame->view()->visibleContentRect(IncludeScrollbars); switch (type) { case FocusTypeLeft: return offset.width() > 0; case FocusTypeUp: return offset.height() > 0; case FocusTypeRight: return rect.width() + offset.width() < size.width(); case FocusTypeDown: return rect.height() + offset.height() < size.height(); default: ASSERT_NOT_REACHED(); return false; } }
IntRect RenderVideo::videoBox() const { if (m_cachedImageSize.isEmpty() && videoElement()->shouldDisplayPosterImage()) return IntRect(); LayoutSize elementSize; if (videoElement()->shouldDisplayPosterImage()) elementSize = m_cachedImageSize; else elementSize = intrinsicSize(); IntRect contentRect = pixelSnappedIntRect(contentBoxRect()); if (elementSize.isEmpty() || contentRect.isEmpty()) return IntRect(); LayoutRect renderBox = contentRect; LayoutUnit ratio = renderBox.width() * elementSize.height() - renderBox.height() * elementSize.width(); if (ratio > 0) { LayoutUnit newWidth = renderBox.height() * elementSize.width() / elementSize.height(); // Just fill the whole area if the difference is one pixel or less (in both sides) if (renderBox.width() - newWidth > 2) renderBox.setWidth(newWidth); renderBox.move((contentRect.width() - renderBox.width()) / 2, 0); } else if (ratio < 0) { LayoutUnit newHeight = renderBox.width() * elementSize.height() / elementSize.width(); if (renderBox.height() - newHeight > 2) renderBox.setHeight(newHeight); renderBox.move(0, (contentRect.height() - renderBox.height()) / 2); } return pixelSnappedIntRect(renderBox); }
bool canScrollInDirection(const Frame* frame, FocusDirection direction) { if (!frame->view()) return false; ScrollbarMode verticalMode; ScrollbarMode horizontalMode; frame->view()->calculateScrollbarModesForLayout(horizontalMode, verticalMode); if ((direction == FocusDirectionLeft || direction == FocusDirectionRight) && ScrollbarAlwaysOff == horizontalMode) return false; if ((direction == FocusDirectionUp || direction == FocusDirectionDown) && ScrollbarAlwaysOff == verticalMode) return false; LayoutSize size = frame->view()->totalContentsSize(); LayoutSize offset = frame->view()->scrollOffset(); LayoutRect rect = frame->view()->visibleContentRectIncludingScrollbars(); switch (direction) { case FocusDirectionLeft: return offset.width() > 0; case FocusDirectionUp: return offset.height() > 0; case FocusDirectionRight: return rect.width() + offset.width() < size.width(); case FocusDirectionDown: return rect.height() + offset.height() < size.height(); default: ASSERT_NOT_REACHED(); return false; } }
LayoutSize ImageResource::imageSizeForLayoutObject(const LayoutObject* layoutObject, float multiplier, SizeType sizeType) { ASSERT(!isPurgeable()); if (!m_image) return LayoutSize(); LayoutSize imageSize; if (m_image->isBitmapImage() && (layoutObject && layoutObject->shouldRespectImageOrientation() == RespectImageOrientation)) imageSize = LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrientation()); else if (m_image->isSVGImage() && sizeType == NormalSize) imageSize = LayoutSize(svgImageSizeForLayoutObject(layoutObject)); else imageSize = LayoutSize(m_image->size()); if (multiplier == 1.0f) return imageSize; // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); imageSize.scale(widthScale, heightScale); imageSize.clampToMinimumSize(minimumSize); ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); return imageSize; }
LayoutSize CachedImage::imageSizeForRenderer(const RenderObject* renderer, float multiplier, SizeType sizeType) { if (!m_image) return LayoutSize(); LayoutSize imageSize; if (is<BitmapImage>(*m_image) && renderer && renderer->shouldRespectImageOrientation() == RespectImageOrientation) imageSize = LayoutSize(downcast<BitmapImage>(*m_image).sizeRespectingOrientation()); else if (is<SVGImage>(*m_image) && sizeType == UsedSize) imageSize = LayoutSize(m_svgImageCache->imageSizeForRenderer(renderer)); else imageSize = LayoutSize(m_image->size()); if (multiplier == 1.0f) return imageSize; // Don't let images that have a width/height >= 1 shrink below 1 when zoomed. float widthScale = m_image->hasRelativeWidth() ? 1.0f : multiplier; float heightScale = m_image->hasRelativeHeight() ? 1.0f : multiplier; LayoutSize minimumSize(imageSize.width() > 0 ? 1 : 0, imageSize.height() > 0 ? 1 : 0); imageSize.scale(widthScale, heightScale); imageSize.clampToMinimumSize(minimumSize); ASSERT(multiplier != 1.0f || (imageSize.width().fraction() == 0.0f && imageSize.height().fraction() == 0.0f)); return imageSize; }
LayoutSize LayoutSize::constrainedBetween(const LayoutSize& min, const LayoutSize& max) const { return { std::max(min.width(), std::min(max.width(), m_width)), std::max(min.height(), std::min(max.height(), m_height)) }; }
LayoutBoxExtent NinePieceImage::computeSlices(const LayoutSize& size, const LengthBox& lengths, int scaleFactor) { LayoutUnit top = std::min<LayoutUnit>(size.height(), valueForLength(lengths.top(), size.height())) * scaleFactor; LayoutUnit right = std::min<LayoutUnit>(size.width(), valueForLength(lengths.right(), size.width())) * scaleFactor; LayoutUnit bottom = std::min<LayoutUnit>(size.height(), valueForLength(lengths.bottom(), size.height())) * scaleFactor; LayoutUnit left = std::min<LayoutUnit>(size.width(), valueForLength(lengths.left(), size.width())) * scaleFactor; return LayoutBoxExtent(top, right, bottom, left); }
PassOwnPtr<Shape> Shape::createShape(const LayoutSize& logicalSize, const LayoutSize& logicalRadii, WritingMode writingMode, Length margin, Length padding) { FloatRect rect(0, 0, logicalSize.width(), logicalSize.height()); FloatSize radii(logicalRadii.width(), logicalRadii.height()); FloatRoundedRect bounds(rect, radii, radii, radii, radii); OwnPtr<Shape> shape = createBoxShape(bounds); shape->m_writingMode = writingMode; shape->m_margin = floatValueForLength(margin, 0); shape->m_padding = floatValueForLength(padding, 0); return shape.release(); }
bool ImageDocument::imageFitsInWindow() { if (!m_imageElement) return true; FrameView* view = this->view(); if (!view) return true; LayoutSize imageSize = this->imageSize(); LayoutSize windowSize = LayoutSize(view->width(), view->height()); return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height(); }
int RenderListBox::listIndexAtOffset(const LayoutSize& offset) { if (!numItems()) return -1; if (offset.height() < borderTop() + paddingTop() || offset.height() > height() - paddingBottom() - borderBottom()) return -1; LayoutUnit scrollbarWidth = m_vBar ? m_vBar->width() : LayoutUnit(0); if (offset.width() < borderLeft() + paddingLeft() || offset.width() > width() - borderRight() - paddingRight() - scrollbarWidth) return -1; int newOffset = (offset.height() - borderTop() - paddingTop()) / itemHeight() + m_indexOffset; return newOffset < numItems() ? newOffset : -1; }
void RenderHTMLCanvas::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { GraphicsContext* context = paintInfo.context; LayoutRect contentRect = contentBoxRect(); contentRect.moveBy(paintOffset); LayoutRect paintRect = replacedContentRect(); paintRect.moveBy(paintOffset); bool clip = !contentRect.contains(paintRect); if (clip) { // Not allowed to overflow the content box. paintInfo.context->save(); paintInfo.context->clip(pixelSnappedIntRect(contentRect)); } // FIXME: InterpolationNone should be used if ImageRenderingOptimizeContrast is set. // See bug for more details: crbug.com/353716. InterpolationQuality interpolationQuality = style()->imageRendering() == ImageRenderingOptimizeContrast ? InterpolationLow : CanvasDefaultInterpolationQuality; HTMLCanvasElement* canvas = toHTMLCanvasElement(node()); LayoutSize layoutSize = contentRect.size(); if (style()->imageRendering() == ImageRenderingPixelated && (layoutSize.width() > canvas->width() || layoutSize.height() > canvas->height() || layoutSize == canvas->size())) { interpolationQuality = InterpolationNone; } InterpolationQuality previousInterpolationQuality = context->imageInterpolationQuality(); context->setImageInterpolationQuality(interpolationQuality); canvas->paint(context, paintRect); context->setImageInterpolationQuality(previousInterpolationQuality); if (clip) context->restore(); }
void RenderMultiColumnFlowThread::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const { // First get the transform state's point into the block flow thread's physical coordinate space. parent()->mapAbsoluteToLocalPoint(mode, transformState); LayoutPoint transformPoint = roundedLayoutPoint(transformState.mappedPoint()); // Now walk through each region. const RenderMultiColumnSet* candidateColumnSet = nullptr; LayoutPoint candidatePoint; LayoutSize candidateContainerOffset; for (const auto& columnSet : childrenOfType<RenderMultiColumnSet>(*parent())) { candidateContainerOffset = columnSet.offsetFromContainer(parent(), LayoutPoint()); candidatePoint = transformPoint - candidateContainerOffset; candidateColumnSet = &columnSet; // We really have no clue what to do with overflow. We'll just use the closest region to the point in that case. LayoutUnit pointOffset = isHorizontalWritingMode() ? candidatePoint.y() : candidatePoint.x(); LayoutUnit regionOffset = isHorizontalWritingMode() ? columnSet.topLeftLocation().y() : columnSet.topLeftLocation().x(); if (pointOffset < regionOffset + columnSet.logicalHeight()) break; } // Once we have a good guess as to which region we hit tested through (and yes, this was just a heuristic, but it's // the best we could do), then we can map from the region into the flow thread. LayoutSize translationOffset = physicalTranslationFromRegionToFlow(candidateColumnSet, candidatePoint) + candidateContainerOffset; bool preserve3D = mode & UseTransforms && (parent()->style().preserves3D() || style().preserves3D()); if (mode & UseTransforms && shouldUseTransformFromContainer(parent())) { TransformationMatrix t; getTransformFromContainer(parent(), translationOffset, t); transformState.applyTransform(t, preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); } else transformState.move(translationOffset.width(), translationOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); }
LayoutRect InlineFlowBoxPainter::paintRectForImageStrip(const LayoutPoint& paintOffset, const LayoutSize& frameSize, TextDirection direction) const { // We have a fill/border/mask image that spans multiple lines. // We need to adjust the offset by the width of all previous lines. // Think of background painting on inlines as though you had one long line, a single continuous // strip. Even though that strip has been broken up across multiple lines, you still paint it // as though you had one single line. This means each line has to pick up the background where // the previous line left off. LayoutUnit logicalOffsetOnLine = 0; LayoutUnit totalLogicalWidth; if (direction == LTR) { for (const InlineFlowBox* curr = m_inlineFlowBox.prevLineBox(); curr; curr = curr->prevLineBox()) logicalOffsetOnLine += curr->logicalWidth(); totalLogicalWidth = logicalOffsetOnLine; for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; curr = curr->nextLineBox()) totalLogicalWidth += curr->logicalWidth(); } else { for (const InlineFlowBox* curr = m_inlineFlowBox.nextLineBox(); curr; curr = curr->nextLineBox()) logicalOffsetOnLine += curr->logicalWidth(); totalLogicalWidth = logicalOffsetOnLine; for (const InlineFlowBox* curr = &m_inlineFlowBox; curr; curr = curr->prevLineBox()) totalLogicalWidth += curr->logicalWidth(); } LayoutUnit stripX = paintOffset.x() - (m_inlineFlowBox.isHorizontal() ? logicalOffsetOnLine : LayoutUnit()); LayoutUnit stripY = paintOffset.y() - (m_inlineFlowBox.isHorizontal() ? LayoutUnit() : logicalOffsetOnLine); LayoutUnit stripWidth = m_inlineFlowBox.isHorizontal() ? totalLogicalWidth : frameSize.width(); LayoutUnit stripHeight = m_inlineFlowBox.isHorizontal() ? frameSize.height() : totalLogicalWidth; return LayoutRect(stripX, stripY, stripWidth, stripHeight); }
void RenderReplaced::layout() { StackStats::LayoutCheckPoint layoutCheckPoint; ASSERT(needsLayout()); LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); setHeight(minimumReplacedHeight()); updateLogicalWidth(); updateLogicalHeight(); // Now that we've calculated our preferred layout, we check to see // if we should further constrain sizing to the intrinsic aspect ratio. if (style().aspectRatioType() == AspectRatioFromIntrinsic && !m_intrinsicSize.isEmpty()) { float aspectRatio = m_intrinsicSize.aspectRatio(); LayoutSize frameSize = size(); float frameAspectRatio = frameSize.aspectRatio(); if (frameAspectRatio < aspectRatio) setHeight(computeReplacedLogicalHeightRespectingMinMaxHeight(frameSize.height() * frameAspectRatio / aspectRatio)); else if (frameAspectRatio > aspectRatio) setWidth(computeReplacedLogicalWidthRespectingMinMaxWidth(frameSize.width() * aspectRatio / frameAspectRatio, ComputePreferred)); } clearOverflow(); addVisualEffectOverflow(); updateLayerTransform(); invalidateBackgroundObscurationStatus(); repainter.repaintAfterLayout(); clearNeedsLayout(); }
void MediaPlayerPrivateMediaFoundation::setSize(const IntSize& size) { m_size = size; if (!m_videoDisplay) return; LayoutSize scrollOffset; IntPoint positionInWindow(m_lastPaintRect.location()); FrameView* view = nullptr; if (m_player && m_player->cachedResourceLoader() && m_player->cachedResourceLoader()->document()) view = m_player->cachedResourceLoader()->document()->view(); if (view) { scrollOffset = view->scrollOffsetForFixedPosition(); positionInWindow = view->convertToContainingWindow(IntPoint(m_lastPaintRect.location())); } positionInWindow.move(-scrollOffset.width().toInt(), -scrollOffset.height().toInt()); if (m_hwndVideo && !m_lastPaintRect.isEmpty()) ::MoveWindow(m_hwndVideo, positionInWindow.x(), positionInWindow.y(), m_size.width(), m_size.height(), FALSE); RECT rc = { 0, 0, m_size.width(), m_size.height() }; m_videoDisplay->SetVideoPosition(nullptr, &rc); }
LayoutUnit RootInlineBox::selectionTopAdjustedForPrecedingBlock() const { const RootInlineBox& rootBox = root(); LayoutUnit top = selectionTop(); RenderObject::SelectionState blockSelectionState = rootBox.blockFlow().selectionState(); if (blockSelectionState != RenderObject::SelectionInside && blockSelectionState != RenderObject::SelectionEnd) return top; LayoutSize offsetToBlockBefore; if (RenderBlock* block = rootBox.blockFlow().blockBeforeWithinSelectionRoot(offsetToBlockBefore)) { if (block->isRenderBlockFlow()) { if (RootInlineBox* lastLine = toRenderBlockFlow(block)->lastRootBox()) { RenderObject::SelectionState lastLineSelectionState = lastLine->selectionState(); if (lastLineSelectionState != RenderObject::SelectionInside && lastLineSelectionState != RenderObject::SelectionStart) return top; LayoutUnit lastLineSelectionBottom = lastLine->selectionBottom() + offsetToBlockBefore.height(); top = std::max(top, lastLineSelectionBottom); } } } return top; }
AffineTransform SVGSVGElement::localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const { AffineTransform viewBoxTransform; if (hasAttribute(SVGNames::viewBoxAttr)) { FloatSize size = currentViewportSize(); viewBoxTransform = viewBoxToViewTransform(size.width(), size.height()); } AffineTransform transform; if (!isOutermostSVG()) { SVGLengthContext lengthContext(this); transform.translate(x().value(lengthContext), y().value(lengthContext)); } else if (mode == SVGLocatable::ScreenScope) { if (RenderObject* renderer = this->renderer()) { // Translate in our CSS parent coordinate space // FIXME: This doesn't work correctly with CSS transforms. FloatPoint location = renderer->localToAbsolute(FloatPoint(), false, true); // Be careful here! localToAbsolute() includes the x/y offset coming from the viewBoxToViewTransform(), because // RenderSVGRoot::localToBorderBoxTransform() (called through mapLocalToContainer(), called from localToAbsolute()) // also takes the viewBoxToViewTransform() into account, so we have to subtract it here (original cause of bug #27183) transform.translate(location.x() - viewBoxTransform.e(), location.y() - viewBoxTransform.f()); // Respect scroll offset. if (FrameView* view = document()->view()) { LayoutSize scrollOffset = view->scrollOffset(); transform.translate(-scrollOffset.width(), -scrollOffset.height()); } } } return transform.multiply(viewBoxTransform); }
LayoutRect RenderReplaced::replacedContentRect(const LayoutSize& intrinsicSize) const { LayoutRect contentRect = contentBoxRect(); ObjectFit objectFit = style().objectFit(); if (objectFit == ObjectFitFill) return contentRect; if (!intrinsicSize.width() || !intrinsicSize.height()) return contentRect; LayoutRect finalRect = contentRect; switch (objectFit) { case ObjectFitContain: case ObjectFitScaleDown: case ObjectFitCover: finalRect.setSize(finalRect.size().fitToAspectRatio(intrinsicSize, objectFit == ObjectFitCover ? AspectRatioFitGrow : AspectRatioFitShrink)); if (objectFit != ObjectFitScaleDown || finalRect.width() <= intrinsicSize.width()) break; // fall through case ObjectFitNone: finalRect.setSize(intrinsicSize); break; case ObjectFitFill: ASSERT_NOT_REACHED(); } // FIXME: This is where object-position should be taken into account, but since it's not // implemented yet, assume the initial value of "50% 50%". LayoutUnit xOffset = (contentRect.width() - finalRect.width()) / 2; LayoutUnit yOffset = (contentRect.height() - finalRect.height()) / 2; finalRect.move(xOffset, yOffset); return finalRect; }
void InlineBox::move(const LayoutSize& delta) { m_topLeft.move(delta); if (lineLayoutItem().isReplaced()) toLayoutBox(layoutObject()).move(delta.width(), delta.height()); }
void RenderBoxModelObject::mapAbsoluteToLocalPoint(MapCoordinatesFlags mode, TransformState& transformState) const { RenderObject* o = container(); if (!o) return; if (o->isRenderFlowThread()) transformState.move(o->columnOffset(LayoutPoint(transformState.mappedPoint()))); o->mapAbsoluteToLocalPoint(mode, transformState); LayoutSize containerOffset = offsetFromContainer(o, LayoutPoint()); if (!style()->hasOutOfFlowPosition() && o->hasColumns()) { RenderBlock* block = toRenderBlock(o); LayoutPoint point(roundedLayoutPoint(transformState.mappedPoint())); point -= containerOffset; block->adjustForColumnRect(containerOffset, point); } bool preserve3D = mode & UseTransforms && (o->style()->preserves3D() || style()->preserves3D()); if (mode & UseTransforms && shouldUseTransformFromContainer(o)) { TransformationMatrix t; getTransformFromContainer(o, containerOffset, t); transformState.applyTransform(t, preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); } else transformState.move(containerOffset.width(), containerOffset.height(), preserve3D ? TransformState::AccumulateTransform : TransformState::FlattenTransform); }
LayoutPoint ScrollableArea::constrainScrollPositionForOverhang(const LayoutRect& visibleContentRect, const LayoutSize& totalContentsSize, const LayoutPoint& scrollPosition, const LayoutPoint& scrollOrigin, int headerHeight, int footerHeight) { // The viewport rect that we're scrolling shouldn't be larger than our document. LayoutSize idealScrollRectSize(std::min(visibleContentRect.width(), totalContentsSize.width()), std::min(visibleContentRect.height(), totalContentsSize.height())); LayoutRect scrollRect(scrollPosition + scrollOrigin - LayoutSize(0, headerHeight), idealScrollRectSize); LayoutRect documentRect(LayoutPoint(), LayoutSize(totalContentsSize.width(), totalContentsSize.height() - headerHeight - footerHeight)); // Use intersection to constrain our ideal scroll rect by the document rect. scrollRect.intersect(documentRect); if (scrollRect.size() != idealScrollRectSize) { // If the rect was clipped, restore its size, effectively pushing it "down" from the top left. scrollRect.setSize(idealScrollRectSize); // If we still clip, push our rect "up" from the bottom right. scrollRect.intersect(documentRect); if (scrollRect.width() < idealScrollRectSize.width()) scrollRect.move(-(idealScrollRectSize.width() - scrollRect.width()), 0); if (scrollRect.height() < idealScrollRectSize.height()) scrollRect.move(0, -(idealScrollRectSize.height() - scrollRect.height())); } return scrollRect.location() - toLayoutSize(scrollOrigin); }
void MediaControlPanelElement::continueDrag(const LayoutPoint& eventLocation) { if (!m_isBeingDragged) return; LayoutSize distanceDragged = eventLocation - m_dragStartEventLocation; setPosition(LayoutPoint(distanceDragged.width(), distanceDragged.height())); }
bool ImageDocument::imageFitsInWindow() const { ASSERT(m_shrinkToFitMode == Desktop); if (!m_imageElement || m_imageElement->document() != this) return true; FrameView* view = frame()->view(); if (!view) return true; ASSERT(m_imageElement->cachedImage()); LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this)); LayoutSize windowSize = LayoutSize(view->width(), view->height()); return imageSize.width() <= windowSize.width() && imageSize.height() <= windowSize.height(); }
LayoutPoint RenderTheme::volumeSliderOffsetFromMuteButton(const RenderBox& muteButtonBox, const LayoutSize& size) const { LayoutUnit y = -size.height(); FloatPoint absPoint = muteButtonBox.localToAbsolute(FloatPoint(muteButtonBox.offsetLeft(), y), IsFixed | UseTransforms); if (absPoint.y() < 0) y = muteButtonBox.height(); return LayoutPoint(0, y); }
LayoutSize LayoutImageResource::imageSize(float multiplier) const { if (!m_cachedImage) return LayoutSize(); LayoutSize size = m_cachedImage->imageSize(LayoutObject::shouldRespectImageOrientation(m_layoutObject), multiplier); if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && size.height()) size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio()); return size; }
float ImageDocument::scale() const { if (!m_imageElement || m_imageElement->document() != this) return 1.0f; FrameView* view = frame()->view(); if (!view) return 1; ASSERT(m_imageElement->cachedImage()); LayoutSize imageSize = m_imageElement->cachedImage()->imageSizeForLayoutObject(m_imageElement->layoutObject(), pageZoomFactor(this)); LayoutSize windowSize = LayoutSize(view->width(), view->height()); float widthScale = windowSize.width().toFloat() / imageSize.width().toFloat(); float heightScale = windowSize.height().toFloat() / imageSize.height().toFloat(); return min(widthScale, heightScale); }
bool ShapeInsideInfo::updateSegmentsForLine(LayoutSize lineOffset, LayoutUnit lineHeight) { bool result = updateSegmentsForLine(lineOffset.height(), lineHeight); for (size_t i = 0; i < m_segments.size(); i++) { m_segments[i].logicalLeft -= lineOffset.width(); m_segments[i].logicalRight -= lineOffset.width(); } return result; }
static bool areRectsMoreThanFullScreenApart(FocusType type, const LayoutRect& curRect, const LayoutRect& targetRect, const LayoutSize& viewSize) { ASSERT(isRectInDirection(type, curRect, targetRect)); switch (type) { case FocusTypeLeft: return curRect.x() - targetRect.maxX() > viewSize.width(); case FocusTypeRight: return targetRect.x() - curRect.maxX() > viewSize.width(); case FocusTypeUp: return curRect.y() - targetRect.maxY() > viewSize.height(); case FocusTypeDown: return targetRect.y() - curRect.maxY() > viewSize.height(); default: ASSERT_NOT_REACHED(); return true; } }
LayoutSize LayoutImageResource::getImageSize(float multiplier, ImageResource::SizeType type) const { if (!m_cachedImage) return LayoutSize(); LayoutSize size = m_cachedImage->imageSizeForLayoutObject(m_layoutObject, multiplier, type); if (m_layoutObject && m_layoutObject->isLayoutImage() && size.width() && size.height()) size.scale(toLayoutImage(m_layoutObject)->imageDevicePixelRatio()); return size; }