bool RenderFrameSet::userResize(MouseEvent* evt) { if (!m_isResizing) { if (needsLayout()) return false; if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftButton) { FloatPoint pos = localToAbsolute(); startResizing(m_cols, evt->absoluteLocation().x() - pos.x()); startResizing(m_rows, evt->absoluteLocation().y() - pos.y()); if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) { setIsResizing(true); return true; } } } else { if (evt->type() == eventNames().mousemoveEvent || (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton)) { FloatPoint pos = localToAbsolute(); continueResizing(m_cols, evt->absoluteLocation().x() - pos.x()); continueResizing(m_rows, evt->absoluteLocation().y() - pos.y()); if (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton) { setIsResizing(false); return true; } } } return false; }
LayoutUnit LayoutMedia::computePanelWidth(const LayoutRect& mediaRect) const { // TODO(mlamouri): we don't know if the main frame has an horizontal scrollbar // if it is out of process. See https://crbug.com/662480 if (document().page()->mainFrame()->isRemoteFrame()) return mediaRect.width(); FrameHost* frameHost = document().frameHost(); LocalFrame* mainFrame = document().page()->deprecatedLocalMainFrame(); FrameView* pageView = mainFrame ? mainFrame->view() : nullptr; if (!frameHost || !mainFrame || !pageView) return mediaRect.width(); if (pageView->horizontalScrollbarMode() != ScrollbarAlwaysOff) return mediaRect.width(); // On desktop, this will include scrollbars when they stay visible. const LayoutUnit visibleWidth(frameHost->visualViewport().visibleWidth()); const LayoutUnit absoluteXOffset( localToAbsolute( FloatPoint(mediaRect.location()), UseTransforms | ApplyContainerFlip | TraverseDocumentBoundaries) .x()); DCHECK_GE(visibleWidth - absoluteXOffset, 0); return std::min(mediaRect.width(), visibleWidth - absoluteXOffset); }
void RenderWidget::updateWidgetPosition() { if (!m_widget) return; // FIXME: This doesn't work correctly with transforms. FloatPoint absPos = localToAbsolute(); absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); int w = width() - borderLeft() - borderRight() - paddingLeft() - paddingRight(); int h = height() - borderTop() - borderBottom() - paddingTop() - paddingBottom(); IntRect newBounds(absPos.x(), absPos.y(), w, h); IntRect oldBounds(m_widget->frameRect()); bool boundsChanged = newBounds != oldBounds; if (boundsChanged) { RenderArena* arena = ref(); node()->ref(); m_widget->setFrameRect(newBounds); node()->deref(); deref(arena); } // if the frame bounds got changed, or if view needs layout (possibly indicating // content size is wrong) we have to do a layout to set the right widget size if (m_widget->isFrameView()) { FrameView* frameView = static_cast<FrameView*>(m_widget.get()); if (boundsChanged || frameView->needsLayout()) frameView->layout(); } }
void RenderWidget::updateWidgetPosition() { if (!m_widget) return; // FIXME: This doesn't work correctly with transforms. FloatPoint absPos = localToAbsolute(); absPos.move(borderLeft() + paddingLeft(), borderTop() + paddingTop()); int w = width() - borderLeft() - borderRight() - paddingLeft() - paddingRight(); int h = height() - borderTop() - borderBottom() - paddingTop() - paddingBottom(); IntRect newBounds(absPos.x(), absPos.y(), w, h); IntRect oldBounds(m_widget->frameRect()); if (newBounds != oldBounds) { // The widget changed positions. Update the frame geometry. if (checkForRepaintDuringLayout()) { RenderView* v = view(); if (!v->printing()) { // FIXME: do container-relative repaint v->repaintRectangleInViewAndCompositedLayers(oldBounds); v->repaintRectangleInViewAndCompositedLayers(newBounds); } } RenderArena* arena = ref(); element()->ref(); m_widget->setFrameRect(newBounds); element()->deref(); deref(arena); } }
void RenderContainer::addLineBoxRects(Vector<IntRect>& rects, unsigned start, unsigned end, bool) { if (!children()->firstChild() && (isInline() || isAnonymousBlock())) { FloatPoint absPos = localToAbsolute(FloatPoint()); absoluteRects(rects, absPos.x(), absPos.y()); return; } if (!children()->firstChild()) return; unsigned offset = start; for (RenderObject* child = childAt(start); child && offset < end; child = child->nextSibling(), ++offset) { if (child->isText() || child->isInline() || child->isAnonymousBlock()) { FloatPoint absPos = child->localToAbsolute(FloatPoint()); child->absoluteRects(rects, absPos.x(), absPos.y()); } } }