diff options
Diffstat (limited to 'Source/WebCore/rendering/RenderFrameSet.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderFrameSet.cpp | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/Source/WebCore/rendering/RenderFrameSet.cpp b/Source/WebCore/rendering/RenderFrameSet.cpp index 26d66db26..052a32c7c 100644 --- a/Source/WebCore/rendering/RenderFrameSet.cpp +++ b/Source/WebCore/rendering/RenderFrameSet.cpp @@ -2,7 +2,7 @@ * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 2000 Simon Hausmann <hausmann@kde.org> * (C) 2000 Stefan Schimanski (1Stein@gmx.de) - * Copyright (C) 2004, 2005, 2006, 2013 Apple Computer, Inc. + * Copyright (C) 2004, 2005, 2006, 2013 Apple Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -45,8 +45,8 @@ namespace WebCore { -RenderFrameSet::RenderFrameSet(HTMLFrameSetElement& frameSet, PassRef<RenderStyle> style) - : RenderBox(frameSet, std::move(style), 0) +RenderFrameSet::RenderFrameSet(HTMLFrameSetElement& frameSet, RenderStyle&& style) + : RenderBox(frameSet, WTFMove(style), 0) , m_isResizing(false) , m_isChildResizing(false) { @@ -59,7 +59,7 @@ RenderFrameSet::~RenderFrameSet() HTMLFrameSetElement& RenderFrameSet::frameSetElement() const { - return toHTMLFrameSetElement(nodeForNonAnonymous()); + return downcast<HTMLFrameSetElement>(nodeForNonAnonymous()); } RenderFrameSet::GridAxis::GridAxis() @@ -67,19 +67,22 @@ RenderFrameSet::GridAxis::GridAxis() { } -static Color borderStartEdgeColor() +static const Color& borderStartEdgeColor() { - return Color(170, 170, 170); + static NeverDestroyed<Color> color(170, 170, 170); + return color; } -static Color borderEndEdgeColor() +static const Color& borderEndEdgeColor() { - return Color::black; + static NeverDestroyed<Color> color = Color::black; + return color; } -static Color borderFillColor() +static const Color& borderFillColor() { - return Color(208, 208, 208); + static NeverDestroyed<Color> color(208, 208, 208); + return color; } void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect& borderRect) @@ -90,15 +93,14 @@ void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect // 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, frameSetElement().hasBorderColor() ? style().visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor(), colorSpace); + GraphicsContext& context = paintInfo.context(); + context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColor(CSSPropertyBorderLeftColor) : 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.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); + context.fillRect(IntRect(borderRect.location(), IntSize(1, height())), borderStartEdgeColor()); + context.fillRect(IntRect(IntPoint(borderRect.maxX() - 1, borderRect.y()), IntSize(1, height())), borderEndEdgeColor()); } } @@ -110,15 +112,14 @@ void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& b // 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, frameSetElement().hasBorderColor() ? style().visitedDependentColor(CSSPropertyBorderLeftColor) : borderFillColor(), colorSpace); + GraphicsContext& context = paintInfo.context(); + context.fillRect(borderRect, frameSetElement().hasBorderColor() ? style().visitedDependentColor(CSSPropertyBorderLeftColor) : 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.location(), IntSize(width(), 1)), borderStartEdgeColor(), colorSpace); - context->fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), IntSize(width(), 1)), borderEndEdgeColor(), colorSpace); + context.fillRect(IntRect(borderRect.location(), IntSize(width(), 1)), borderStartEdgeColor()); + context.fillRect(IntRect(IntPoint(borderRect.x(), borderRect.maxY() - 1), IntSize(width(), 1)), borderEndEdgeColor()); } } @@ -141,10 +142,10 @@ void RenderFrameSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) for (size_t r = 0; r < rows; r++) { LayoutUnit xPos = 0; for (size_t c = 0; c < cols; c++) { - toRenderElement(child)->paint(paintInfo, adjustedPaintOffset); + downcast<RenderElement>(*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()))); + paintColumnBorder(paintInfo, snappedIntRect(LayoutRect(adjustedPaintOffset.x() + xPos, adjustedPaintOffset.y() + yPos, borderThickness, height()))); xPos += borderThickness; } child = child->nextSibling(); @@ -153,7 +154,7 @@ void RenderFrameSet::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset) } 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))); + paintRowBorder(paintInfo, snappedIntRect(LayoutRect(adjustedPaintOffset.x(), adjustedPaintOffset.y() + yPos, width(), borderThickness))); yPos += borderThickness; } } @@ -206,7 +207,7 @@ void RenderFrameSet::layOutAxis(GridAxis& axis, const Length* grid, int availabl // Count the total percentage of all of the percentage columns/rows -> totalPercent // Count the number of columns/rows which are percentages -> countPercent - if (grid[i].isPercent()) { + if (grid[i].isPercentOrCalculated()) { gridLayout[i] = std::max(intValueForLength(grid[i], availableLen), 0); totalPercent += gridLayout[i]; countPercent++; @@ -244,7 +245,7 @@ void RenderFrameSet::layOutAxis(GridAxis& axis, const Length* grid, int availabl int remainingPercent = remainingLen; for (int i = 0; i < gridLen; ++i) { - if (grid[i].isPercent()) { + if (grid[i].isPercentOrCalculated()) { gridLayout[i] = (gridLayout[i] * remainingPercent) / totalPercent; remainingLen -= gridLayout[i]; } @@ -288,7 +289,7 @@ void RenderFrameSet::layOutAxis(GridAxis& axis, const Length* grid, int availabl int changePercent = 0; for (int i = 0; i < gridLen; ++i) { - if (grid[i].isPercent()) { + if (grid[i].isPercentOrCalculated()) { changePercent = (remainingPercent * gridLayout[i]) / totalPercent; gridLayout[i] += changePercent; remainingLen -= changePercent; @@ -320,7 +321,7 @@ void RenderFrameSet::layOutAxis(GridAxis& axis, const Length* grid, int availabl int changePercent = 0; for (int i = 0; i < gridLen; ++i) { - if (grid[i].isPercent()) { + if (grid[i].isPercentOrCalculated()) { changePercent = remainingPercent / countPercent; gridLayout[i] += changePercent; remainingLen -= changePercent; @@ -409,10 +410,10 @@ void RenderFrameSet::computeEdgeInfo() for (size_t r = 0; r < rows; ++r) { for (size_t c = 0; c < cols; ++c) { FrameEdgeInfo edgeInfo; - if (child->isFrameSet()) - edgeInfo = toRenderFrameSet(child)->edgeInfo(); + if (is<RenderFrameSet>(*child)) + edgeInfo = downcast<RenderFrameSet>(*child).edgeInfo(); else - edgeInfo = toRenderFrame(child)->edgeInfo(); + edgeInfo = downcast<RenderFrame>(*child).edgeInfo(); fillFromEdgeInfo(edgeInfo, r, c); child = child->nextSibling(); if (!child) @@ -483,10 +484,10 @@ void RenderFrameSet::layout() updateLayerTransform(); if (doFullRepaint) { - repaintUsingContainer(repaintContainer, pixelSnappedIntRect(oldBounds)); + repaintUsingContainer(repaintContainer, snappedIntRect(oldBounds)); LayoutRect newBounds = clippedOverflowRectForRepaint(repaintContainer); if (newBounds != oldBounds) - repaintUsingContainer(repaintContainer, pixelSnappedIntRect(newBounds)); + repaintUsingContainer(repaintContainer, snappedIntRect(newBounds)); } clearNeedsLayout(); @@ -533,10 +534,10 @@ void RenderFrameSet::positionFrames() } // all the remaining frames are hidden to avoid ugly spurious unflowed frames - for (; child; child = child->nextSiblingBox()) { - child->setWidth(0); - child->setHeight(0); - child->clearNeedsLayout(); + for (auto* descendant = child; descendant; descendant = downcast<RenderBox>(RenderObjectTraversal::next(*descendant, this))) { + descendant->setWidth(0); + descendant->setHeight(0); + descendant->clearNeedsLayout(); } } @@ -554,12 +555,12 @@ void RenderFrameSet::positionFramesWithFlattening() // calculate frameset height based on actual content height to eliminate scrolling bool out = false; - for (int r = 0; r < rows && !out; r++) { + 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()); + for (int c = 0; c < cols; ++c) { + IntRect oldFrameRect = snappedIntRect(child->frameRect()); int width = m_cols.m_sizes[c]; @@ -575,10 +576,10 @@ void RenderFrameSet::positionFramesWithFlattening() child->setNeedsLayout(); - if (child->isFrameSet()) - toRenderFrameSet(child)->layout(); + if (is<RenderFrameSet>(*child)) + downcast<RenderFrameSet>(*child).layout(); else - toRenderFrame(child)->layoutWithFlattening(fixedWidth, fixedHeight); + downcast<RenderFrame>(*child).layoutWithFlattening(fixedWidth, fixedHeight); if (child->height() > m_rows.m_sizes[r]) m_rows.m_sizes[r] = child->height(); @@ -603,11 +604,11 @@ void RenderFrameSet::positionFramesWithFlattening() int yPos = 0; out = false; child = firstChildBox(); - for (int r = 0; r < rows && !out; r++) { + for (int r = 0; r < rows && !out; ++r) { xPos = 0; - for (int c = 0; c < cols; c++) { + for (int c = 0; c < cols; ++c) { // ensure the rows and columns are filled - IntRect oldRect = pixelSnappedIntRect(child->frameRect()); + IntRect oldRect = snappedIntRect(child->frameRect()); child->setLocation(IntPoint(xPos, yPos)); child->setHeight(m_rows.m_sizes[r]); @@ -618,10 +619,10 @@ void RenderFrameSet::positionFramesWithFlattening() // update to final size child->setNeedsLayout(); - if (child->isFrameSet()) - toRenderFrameSet(child)->layout(); + if (is<RenderFrameSet>(*child)) + downcast<RenderFrameSet>(*child).layout(); else - toRenderFrame(child)->layoutWithFlattening(true, true); + downcast<RenderFrame>(*child).layoutWithFlattening(true, true); } xPos += m_cols.m_sizes[c] + borderThickness; @@ -650,7 +651,7 @@ void RenderFrameSet::positionFramesWithFlattening() bool RenderFrameSet::flattenFrameSet() const { - return frame().settings().frameFlatteningEnabled(); + return settings().frameFlatteningEnabled(); } void RenderFrameSet::startResizing(GridAxis& axis, int position) @@ -679,7 +680,7 @@ void RenderFrameSet::continueResizing(GridAxis& axis, int position) setNeedsLayout(); } -bool RenderFrameSet::userResize(MouseEvent* evt) +bool RenderFrameSet::userResize(MouseEvent& event) { if (flattenFrameSet()) return false; @@ -687,8 +688,8 @@ bool RenderFrameSet::userResize(MouseEvent* evt) if (!m_isResizing) { if (needsLayout()) return false; - if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftButton) { - FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTransforms); + if (event.type() == eventNames().mousedownEvent && event.button() == LeftButton) { + FloatPoint localPos = absoluteToLocal(event.absoluteLocation(), UseTransforms); startResizing(m_cols, localPos.x()); startResizing(m_rows, localPos.y()); if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) { @@ -697,11 +698,11 @@ bool RenderFrameSet::userResize(MouseEvent* evt) } } } else { - if (evt->type() == eventNames().mousemoveEvent || (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton)) { - FloatPoint localPos = absoluteToLocal(evt->absoluteLocation(), UseTransforms); + if (event.type() == eventNames().mousemoveEvent || (event.type() == eventNames().mouseupEvent && event.button() == LeftButton)) { + FloatPoint localPos = absoluteToLocal(event.absoluteLocation(), UseTransforms); continueResizing(m_cols, localPos.x()); continueResizing(m_rows, localPos.y()); - if (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton) { + if (event.type() == eventNames().mouseupEvent && event.button() == LeftButton) { setIsResizing(false); return true; } |