void RenderFrameSet::setIsResizing(bool isResizing) { m_isResizing = isResizing; for (RenderObject* p = parent(); p; p = p->parent()) if (p->isFrameSet()) static_cast<RenderFrameSet*>(p)->m_isChildResizing = isResizing; if (Frame* frame = document()->frame()) frame->eventHandler()->setResizingFrameSet(isResizing ? frameSet() : 0); }
void RenderFrameSet::layout() { ASSERT(needsLayout()); bool doFullRepaint = selfNeedsLayout() && checkForRepaintDuringLayout(); IntRect oldBounds; if (doFullRepaint) oldBounds = absoluteClippedOverflowRect(); if (!parent()->isFrameSet() && !document()->printing()) { setWidth(view()->viewWidth()); setHeight(view()->viewHeight()); } size_t cols = frameSet()->totalCols(); size_t rows = frameSet()->totalRows(); if (m_rows.m_sizes.size() != rows || m_cols.m_sizes.size() != cols) { m_rows.resize(rows); m_cols.resize(cols); } int borderThickness = frameSet()->border(); layOutAxis(m_rows, frameSet()->rowLengths(), height() - (rows - 1) * borderThickness); layOutAxis(m_cols, frameSet()->colLengths(), width() - (cols - 1) * borderThickness); if (flattenFrameSet()) positionFramesWithFlattening(); else positionFrames(); RenderBox::layout(); computeEdgeInfo(); if (doFullRepaint) { view()->repaintViewRectangle(oldBounds); IntRect newBounds = absoluteClippedOverflowRect(); if (newBounds != oldBounds) view()->repaintViewRectangle(newBounds); } setNeedsLayout(false); }
FrameEdgeInfo RenderFrameSet::edgeInfo() const { FrameEdgeInfo result(frameSet()->noResize(), true); int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); if (rows && cols) { result.setPreventResize(LeftFrameEdge, m_cols.m_preventResize[0]); result.setAllowBorder(LeftFrameEdge, m_cols.m_allowBorder[0]); result.setPreventResize(RightFrameEdge, m_cols.m_preventResize[cols]); result.setAllowBorder(RightFrameEdge, m_cols.m_allowBorder[cols]); result.setPreventResize(TopFrameEdge, m_rows.m_preventResize[0]); result.setAllowBorder(TopFrameEdge, m_rows.m_allowBorder[0]); result.setPreventResize(BottomFrameEdge, m_rows.m_preventResize[rows]); result.setAllowBorder(BottomFrameEdge, m_rows.m_allowBorder[rows]); } return result; }
void RenderFrameSet::setIsResizing(bool isResizing) { m_isResizing = isResizing; for (RenderObject* ancestor = parent(); ancestor; ancestor = ancestor->parent()) { if (ancestor->isFrameSet()) toRenderFrameSet(ancestor)->m_isChildResizing = isResizing; } if (Frame* frame = this->frame()) frame->eventHandler()->setResizingFrameSet(isResizing ? frameSet() : 0); }
void RenderFrameSet::positionFrames() { RenderBox* child = firstChildBox(); if (!child) return; int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); int yPos = 0; int borderThickness = frameSet()->border(); for (int r = 0; r < rows; r++) { int xPos = 0; int height = m_rows.m_sizes[r]; for (int c = 0; c < cols; c++) { child->setLocation(xPos, yPos); int width = m_cols.m_sizes[c]; // has to be resized and itself resize its contents if (width != child->width() || height != child->height()) { child->setWidth(width); child->setHeight(height); child->setNeedsLayout(true); child->layout(); } xPos += width + borderThickness; child = child->nextSiblingBox(); if (!child) return; } yPos += height + borderThickness; } // all the remaining frames are hidden to avoid ugly spurious unflowed frames for (; child; child = child->nextSiblingBox()) { child->setWidth(0); child->setHeight(0); child->setNeedsLayout(false); } }
void FrameModel::saveFrameSet(const QModelIndex& index) { _FrameSet set(frameSet(index)); QString path(filePath(index) + QDir::separator() + "frameset.info"); QSettings s(path, QSettings::IniFormat); s.setValue("Classification", set.classification); set.signature.save(s); emit dataChanged(index.sibling(index.row(), 0), index.sibling(index.row(), 1)); }
void RenderFrameSet::paint(PaintInfo& paintInfo, int tx, int ty) { if (paintInfo.phase != PaintPhaseForeground) return; RenderObject* child = firstChild(); if (!child) return; // Add in our offsets. tx += x(); ty += y(); int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); int borderThickness = frameSet()->border(); int yPos = 0; for (int r = 0; r < rows; r++) { int xPos = 0; for (int c = 0; c < cols; c++) { child->paint(paintInfo, tx, ty); xPos += m_cols.m_sizes[c]; if (borderThickness && m_cols.m_allowBorder[c + 1]) { paintColumnBorder(paintInfo, IntRect(tx + xPos, ty + yPos, borderThickness, height())); xPos += borderThickness; } child = child->nextSibling(); if (!child) return; } yPos += m_rows.m_sizes[r]; if (borderThickness && m_rows.m_allowBorder[r + 1]) { paintRowBorder(paintInfo, IntRect(tx, ty + yPos, width(), borderThickness)); yPos += borderThickness; } } }
int RenderFrameSet::splitPosition(const GridAxis& axis, int split) const { if (needsLayout()) return 0; int borderThickness = frameSet()->border(); int size = axis.m_sizes.size(); if (!size) return 0; int position = 0; for (int i = 0; i < split && i < size; ++i) position += axis.m_sizes[i] + borderThickness; return position - borderThickness; }
bool RenderFrameSet::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty, HitTestAction action) { if (action != HitTestForeground) return false; bool inside = RenderBox::nodeAtPoint(request, result, x, y, tx, ty, action) || m_isResizing; if (inside && frameSet()->noResize() && !request.readOnly() && !result.innerNode()) { result.setInnerNode(node()); result.setInnerNonSharedNode(node()); } return inside || m_isChildResizing; }
void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& borderRect) { if (!paintInfo.rect.intersects(borderRect)) return; // FIXME: We should do something clever when borders from distinct framesets meet at a join. // Fill first. GraphicsContext* context = paintInfo.context; context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : borderFillColor()); // Now stroke the edges but only if we have enough room to paint both edges with a little // bit of the fill color showing through. if (borderRect.height() >= 3) { context->fillRect(IntRect(borderRect.topLeft(), IntSize(width(), 1)), borderStartEdgeColor()); context->fillRect(IntRect(borderRect.bottomLeft(), IntSize(width(), 1)), borderEndEdgeColor()); } }
void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect& borderRect) { if (!paintInfo.rect.intersects(borderRect)) return; // FIXME: We should do something clever when borders from distinct framesets meet at a join. // Fill first. GraphicsContext* context = paintInfo.context; ColorSpace colorSpace = style()->colorSpace(); context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor(), colorSpace); // Now stroke the edges but only if we have enough room to paint both edges with a little // bit of the fill color showing through. if (borderRect.width() >= 3) { context->fillRect(IntRect(borderRect.location(), IntSize(1, height())), borderStartEdgeColor(), colorSpace); context->fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), IntSize(1, height())), borderEndEdgeColor(), colorSpace); } }
int RenderFrameSet::hitTestSplit(const GridAxis& axis, int position) const { if (needsLayout()) return noSplit; int borderThickness = frameSet()->border(); if (borderThickness <= 0) return noSplit; size_t size = axis.m_sizes.size(); if (!size) return noSplit; int splitPosition = axis.m_sizes[0]; for (size_t i = 1; i < size; ++i) { if (position >= splitPosition && position < splitPosition + borderThickness) return i; splitPosition += borderThickness + axis.m_sizes[i]; } return noSplit; }
void RenderFrameSet::readyWRATHWidgetColumnBorder(PaintedWidgetsOfWRATHHandle& handle, const PaintInfoOfWRATH& paintInfo, const IntRect& borderRect) { if (!paintInfo.rect.intersects(borderRect)) return; RenderFrameSet_ReadyWRATHWidgetColumnBorder *d(RenderFrameSet_ReadyWRATHWidgetColumnBorder::object(this, handle)); ContextOfWRATH::AutoPushNode autoPushRoot(paintInfo.wrath_context, d->m_root_node); if (d->m_edge_stroke_begin.widget()) d->m_edge_stroke_begin.widget()->visible(false); if (d->m_edge_stroke_end.widget()) d->m_edge_stroke_end.widget()->visible(false); // FIXME: We should do something clever when borders from distinct framesets meet at a join. // Fill first. Color color = (frameSet()->hasBorderColor() ? style()->visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor()); d->m_fill.update(paintInfo.wrath_context, borderRect, color, CompositeSourceOver); // Now stroke the edges but only if we have enough room to paint both edges with a little // bit of the fill color showing through. if (borderRect.width() >= 3) { d->m_edge_stroke_begin.update(paintInfo.wrath_context, IntRect(borderRect.location(), IntSize(1, height())), borderStartEdgeColor(), CompositeSourceOver); d->m_edge_stroke_end.update(paintInfo.wrath_context, IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), IntSize(1, height())), borderEndEdgeColor(), CompositeSourceOver); if(d->m_edge_stroke_begin.widget()) { d->m_edge_stroke_begin.widget()->visible(true); } if(d->m_edge_stroke_end.widget()) { d->m_edge_stroke_end.widget()->visible(true); } } }
void RenderFrameSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) { if (paintInfo.phase != PaintPhaseForeground) return; RenderObject* child = firstChild(); if (!child) return; LayoutPoint adjustedPaintOffset = paintOffset + location(); size_t rows = m_rows.m_sizes.size(); size_t cols = m_cols.m_sizes.size(); LayoutUnit borderThickness = frameSet()->border(); LayoutUnit yPos = 0; for (size_t r = 0; r < rows; r++) { LayoutUnit xPos = 0; for (size_t c = 0; c < cols; c++) { child->paint(paintInfo, adjustedPaintOffset); xPos += m_cols.m_sizes[c]; if (borderThickness && m_cols.m_allowBorder[c + 1]) { paintColumnBorder(paintInfo, pixelSnappedIntRect(LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffset.y() + yPos, borderThickness, height()))); xPos += borderThickness; } child = child->nextSibling(); if (!child) return; } yPos += m_rows.m_sizes[r]; if (borderThickness && m_rows.m_allowBorder[r + 1]) { paintRowBorder(paintInfo, pixelSnappedIntRect(LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yPos, width(), borderThickness))); yPos += borderThickness; } } }
void RenderFrameSet::positionFramesWithFlattening() { RenderBox* child = firstChildBox(); if (!child) return; int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); int borderThickness = frameSet()->border(); bool repaintNeeded = false; // calculate frameset height based on actual content height to eliminate scrolling bool out = false; for (int r = 0; r < rows && !out; r++) { int extra = 0; int height = m_rows.m_sizes[r]; for (int c = 0; c < cols; c++) { IntRect oldFrameRect = pixelSnappedIntRect(child->frameRect()); int width = m_cols.m_sizes[c]; bool fixedWidth = frameSet()->colLengths() && frameSet()->colLengths()[c].isFixed(); bool fixedHeight = frameSet()->rowLengths() && frameSet()->rowLengths()[r].isFixed(); // has to be resized and itself resize its contents if (!fixedWidth) child->setWidth(width ? width + extra / (cols - c) : 0); else child->setWidth(width); child->setHeight(height); child->setNeedsLayout(true); if (child->isFrameSet()) toRenderFrameSet(child)->layout(); else toRenderFrame(child)->layoutWithFlattening(fixedWidth, fixedHeight); if (child->height() > m_rows.m_sizes[r]) m_rows.m_sizes[r] = child->height(); if (child->width() > m_cols.m_sizes[c]) m_cols.m_sizes[c] = child->width(); if (child->frameRect() != oldFrameRect) repaintNeeded = true; // difference between calculated frame width and the width it actually decides to have extra += width - m_cols.m_sizes[c]; child = child->nextSiblingBox(); if (!child) { out = true; break; } } } int xPos = 0; int yPos = 0; out = false; child = firstChildBox(); for (int r = 0; r < rows && !out; r++) { xPos = 0; for (int c = 0; c < cols; c++) { // ensure the rows and columns are filled IntRect oldRect = pixelSnappedIntRect(child->frameRect()); child->setLocation(IntPoint(xPos, yPos)); child->setHeight(m_rows.m_sizes[r]); child->setWidth(m_cols.m_sizes[c]); if (child->frameRect() != oldRect) { repaintNeeded = true; // update to final size child->setNeedsLayout(true); if (child->isFrameSet()) toRenderFrameSet(child)->layout(); else toRenderFrame(child)->layoutWithFlattening(true, true); } xPos += m_cols.m_sizes[c] + borderThickness; child = child->nextSiblingBox(); if (!child) { out = true; break; } } yPos += m_rows.m_sizes[r] + borderThickness; } setWidth(xPos - borderThickness); setHeight(yPos - borderThickness); if (repaintNeeded) repaint(); // all the remaining frames are hidden to avoid ugly spurious unflowed frames for (; child; child = child->nextSiblingBox()) { child->setWidth(0); child->setHeight(0); child->setNeedsLayout(false); } }
void RenderFrameSet::readyWRATHWidgets(PaintedWidgetsOfWRATHHandle& handle, PaintInfoOfWRATH& paintInfo, int tx, int ty) { RenderFrameSet_ReadyWRATHWidgets *d(RenderFrameSet_ReadyWRATHWidgets::object(this, handle)); ContextOfWRATH::AutoPushNode autoPushRoot(paintInfo.wrath_context, d->m_root_node); ContextOfWRATH::AutoPushNode autoPushSkip(paintInfo.wrath_context, d->m_skip_node); d->m_skip_node.widget()->visible(false); if (paintInfo.phase != PaintPhaseForeground) return; RenderObject* child = firstChild(); if (!child) return; d->m_skip_node.widget()->visible(true); // Add in our offsets. tx += x(); ty += y(); int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); int borderThickness = frameSet()->border(); d->m_children.hideEachObject(); d->m_column_borders.hideEachObject(); d->m_row_borders.hideEachObject(); int yPos = 0; for (int r = 0; r < rows; r++) { int xPos = 0; for (int c = 0; c < cols; c++) { PaintedWidgetsOfWRATHHandle& ch(d->m_children.getHandle(child)); ch.visible(true); child->readyWRATHWidgets(ch, paintInfo, tx, ty); xPos += m_cols.m_sizes[c]; if (borderThickness && m_cols.m_allowBorder[c + 1]) { PaintedWidgetsOfWRATHHandle& cbh(d->m_column_borders.getHandle(child)); cbh.visible(true); readyWRATHWidgetColumnBorder(cbh, paintInfo, IntRect(tx + xPos, ty + yPos, borderThickness, height())); xPos += borderThickness; } child = child->nextSibling(); if (!child) { d->m_children.removeNonVisibleHandles(); d->m_column_borders.removeNonVisibleHandles(); d->m_row_borders.removeNonVisibleHandles(); return; } } yPos += m_rows.m_sizes[r]; if (borderThickness && m_rows.m_allowBorder[r + 1]) { /* It's not exactly related to the child but it matches the separation */ /* TODO: Improve the explanation. */ PaintedWidgetsOfWRATHHandle& crh(d->m_row_borders.getHandle(child)); crh.visible(true); readyWRATHWidgetRowBorder(crh, paintInfo, IntRect(tx, ty + yPos, width(), borderThickness)); yPos += borderThickness; } } d->m_children.removeNonVisibleHandles(); d->m_column_borders.removeNonVisibleHandles(); d->m_row_borders.removeNonVisibleHandles(); }
void FrameModel::setSignature(const QModelIndex& index, const Signature& sig) { frameSet(index).signature = sig; saveFrameSet(index); }
void FrameModel::setClassification(const QModelIndex& index, const QString& classification) { frameSet(index).classification = classification; saveFrameSet(index); }
Signature FrameModel::signature(const QModelIndex& index) const { return frameSet(index).signature; }
QString FrameModel::classification(const QModelIndex& index) const { return frameSet(index).classification; }
bool FrameModel::hasClassification(const QModelIndex& index) const { return !frameSet(index).classification.isEmpty(); }
void RenderFrameSet::layout() { ASSERT(needsLayout()); bool doFullRepaint = selfNeedsLayout() && checkForRepaintDuringLayout(); IntRect oldBounds; if (doFullRepaint) oldBounds = absoluteClippedOverflowRect(); if (!parent()->isFrameSet() && !document()->printing()) { #ifdef FLATTEN_FRAMESET // Force a grid recalc. m_gridCalculated = false; #endif m_width = view()->viewWidth(); m_height = view()->viewHeight(); } size_t cols = frameSet()->totalCols(); size_t rows = frameSet()->totalRows(); if (m_rows.m_sizes.size() != rows || m_cols.m_sizes.size() != cols) { m_rows.resize(rows); m_cols.resize(cols); #ifdef FLATTEN_FRAMESET m_gridCalculated = false; #endif } #ifdef FLATTEN_FRAMESET if (!m_gridCalculated) { m_gridCalculated = true; // Make all the child framesets recalculate their grid. RenderObject* child = firstChild(); for (; child; child = child->nextSibling()) { if (child->isFrameSet()) static_cast<RenderFrameSet*>(child)->setGridNeedsLayout(); } #endif int borderThickness = frameSet()->border(); layOutAxis(m_rows, frameSet()->rowLengths(), m_height - (rows - 1) * borderThickness); layOutAxis(m_cols, frameSet()->colLengths(), m_width - (cols - 1) * borderThickness); #ifdef FLATTEN_FRAMESET } #endif positionFrames(); RenderContainer::layout(); computeEdgeInfo(); if (doFullRepaint) { view()->repaintViewRectangle(oldBounds); IntRect newBounds = absoluteClippedOverflowRect(); if (newBounds != oldBounds) view()->repaintViewRectangle(newBounds); } setNeedsLayout(false); }
void RenderFrameSet::positionFrames() { RenderObject* child = firstChild(); if (!child) return; int rows = frameSet()->totalRows(); int cols = frameSet()->totalCols(); int yPos = 0; int borderThickness = frameSet()->border(); #ifdef FLATTEN_FRAMESET // Keep track of the maximum width of a row which will become the maximum width of the frameset. int maxWidth = 0; const Length* rowLengths = frameSet()->rowLengths(); const Length* colLengths = frameSet()->colLengths(); for (int r = 0; r < rows && child; r++) { int xPos = 0; int height = m_rows.m_sizes[r]; int rowHeight = -1; if (rowLengths) { Length l = rowLengths[r]; if (l.isFixed()) rowHeight = l.value(); } for (int c = 0; c < cols && child; c++) { child->setPos(xPos, yPos); child->setWidth(m_cols.m_sizes[c]); child->setHeight(height); int colWidth = -1; if (colLengths) { Length l = colLengths[c]; if (l.isFixed()) colWidth = l.value(); } if (colWidth && rowHeight) { child->setNeedsLayout(true); child->layout(); } else { child->layoutIfNeeded(); } ASSERT(child->width() >= m_cols.m_sizes[c]); m_cols.m_sizes[c] = child->width(); height = max(child->height(), height); xPos += child->width() + borderThickness; child = child->nextSibling(); } ASSERT(height >= m_rows.m_sizes[r]); m_rows.m_sizes[r] = height; maxWidth = max(xPos, maxWidth); yPos += height + borderThickness; } // Compute a new width and height according to the positioning of each expanded child frame. // Note: we subtract borderThickness because we only count borders between frames. int newWidth = maxWidth - borderThickness; int newHeight = yPos - borderThickness; // Distribute the extra width and height evenly across the grid. int dWidth = (m_width - newWidth) / cols; int dHeight = (m_height - newHeight) / rows; if (dWidth > 0) { int availableWidth = m_width - (cols - 1) * borderThickness; for (int c = 0; c < cols; c++) availableWidth -= m_cols.m_sizes[c] += dWidth; // If the extra width did not distribute evenly, add the remainder to // the last column. if (availableWidth) m_cols.m_sizes[cols - 1] += availableWidth; } if (dHeight > 0) { int availableHeight = m_height - (rows - 1) * borderThickness; for (int r = 0; r < rows; r++) availableHeight -= m_rows.m_sizes[r] += dHeight; // If the extra height did not distribute evenly, add the remainder to // the last row. if (availableHeight) m_rows.m_sizes[rows - 1] += availableHeight; } // Ensure the rows and columns are filled by falling through to the normal // layout m_height = max(m_height, newHeight); m_width = max(m_width, newWidth); child = firstChild(); yPos = 0; #endif // FLATTEN_FRAMESET for (int r = 0; r < rows; r++) { int xPos = 0; int height = m_rows.m_sizes[r]; for (int c = 0; c < cols; c++) { child->setPos(xPos, yPos); int width = m_cols.m_sizes[c]; // has to be resized and itself resize its contents if (width != child->width() || height != child->height()) { child->setWidth(width); child->setHeight(height); child->setNeedsLayout(true); child->layout(); } xPos += width + borderThickness; child = child->nextSibling(); if (!child) return; } yPos += height + borderThickness; } // all the remaining frames are hidden to avoid ugly spurious unflowed frames for (; child; child = child->nextSibling()) { child->setWidth(0); child->setHeight(0); child->setNeedsLayout(false); } }