- Revision
- 183885
- Author
- hy...@apple.com
- Date
- 2015-05-06 13:40:53 -0700 (Wed, 06 May 2015)
Log Message
Optimize topLeftLocationOffset() addition in updateLayerPosition
https://bugs.webkit.org/show_bug.cgi?id=144704
Reviewed by Dean Jackson.
* page/FrameView.cpp:
(WebCore::FrameView::FrameView):
* page/FrameView.h:
Move the hasFlippedBlocks bit to FrameView instead of RenderView. Works better for inlining
the check in any renderer header, and it also makes more sense conceptually, since the RenderView
itself could be a flipped block.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::layoutOverflowRectForPropagation):
Change over to the FrameView bit.
* rendering/RenderBox.h:
(WebCore::RenderBox::applyTopLeftLocationOffset):
Add a new inlined function that can apply the top left location offset to a point without
multiple LayoutSize creations and copies. It invokes a helper for flipping that is not
inlined only in the case where actual flipped blocks exist in the render tree.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::updateFromStyle):
Set the bit on the FrameView now instead of the RenderView.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateLayerPosition):
Call the new applyTopLeftLocationOffset function so that the point can have offsets added
in without any extra copies.
(WebCore::RenderLayer::calculateClipRects):
* rendering/RenderLineBoxList.cpp:
(WebCore::RenderLineBoxList::rangeIntersectsRect):
Switch over to the bit on the FrameView.
* rendering/RenderView.cpp:
(WebCore::RenderView::RenderView):
* rendering/RenderView.h:
Get rid of the bit on the RenderView.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (183884 => 183885)
--- trunk/Source/WebCore/ChangeLog 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/ChangeLog 2015-05-06 20:40:53 UTC (rev 183885)
@@ -1,3 +1,46 @@
+2015-05-06 David Hyatt <hy...@apple.com>
+
+ Optimize topLeftLocationOffset() addition in updateLayerPosition
+ https://bugs.webkit.org/show_bug.cgi?id=144704
+
+ Reviewed by Dean Jackson.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::FrameView):
+ * page/FrameView.h:
+ Move the hasFlippedBlocks bit to FrameView instead of RenderView. Works better for inlining
+ the check in any renderer header, and it also makes more sense conceptually, since the RenderView
+ itself could be a flipped block.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::layoutOverflowRectForPropagation):
+ Change over to the FrameView bit.
+
+ * rendering/RenderBox.h:
+ (WebCore::RenderBox::applyTopLeftLocationOffset):
+ Add a new inlined function that can apply the top left location offset to a point without
+ multiple LayoutSize creations and copies. It invokes a helper for flipping that is not
+ inlined only in the case where actual flipped blocks exist in the render tree.
+
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::updateFromStyle):
+ Set the bit on the FrameView now instead of the RenderView.
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::updateLayerPosition):
+ Call the new applyTopLeftLocationOffset function so that the point can have offsets added
+ in without any extra copies.
+
+ (WebCore::RenderLayer::calculateClipRects):
+ * rendering/RenderLineBoxList.cpp:
+ (WebCore::RenderLineBoxList::rangeIntersectsRect):
+ Switch over to the bit on the FrameView.
+
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::RenderView):
+ * rendering/RenderView.h:
+ Get rid of the bit on the RenderView.
+
2015-05-05 Myles C. Maxfield <mmaxfi...@apple.com>
Introducing the Platform Abstraction Layer (PAL)
Modified: trunk/Source/WebCore/page/FrameView.cpp (183884 => 183885)
--- trunk/Source/WebCore/page/FrameView.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/page/FrameView.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -200,6 +200,7 @@
, m_footerHeight(0)
, m_milestonesPendingPaint(0)
, m_visualUpdatesAllowedByClient(true)
+ , m_hasFlippedBlockRenderers(false)
, m_scrollPinningBehavior(DoNotPin)
{
init();
Modified: trunk/Source/WebCore/page/FrameView.h (183884 => 183885)
--- trunk/Source/WebCore/page/FrameView.h 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/page/FrameView.h 2015-05-06 20:40:53 UTC (rev 183885)
@@ -511,6 +511,9 @@
ScrollBehaviorForFixedElements scrollBehaviorForFixedElements() const;
+ bool hasFlippedBlockRenderers() const { return m_hasFlippedBlockRenderers; }
+ void setHasFlippedBlockRenderers(bool b) { m_hasFlippedBlockRenderers = b; }
+
void updateWidgetPositions();
void didAddWidgetToRenderTree(Widget&);
void willRemoveWidgetFromRenderTree(Widget&);
@@ -790,7 +793,8 @@
#endif
bool m_visualUpdatesAllowedByClient;
-
+ bool m_hasFlippedBlockRenderers;
+
ScrollPinningBehavior m_scrollPinningBehavior;
IntRect* m_cachedWindowClipRect { nullptr };
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -4831,7 +4831,7 @@
LayoutPoint RenderBox::topLeftLocation() const
{
- if (!view().hasFlippedBlockDescendants())
+ if (!view().frameView().hasFlippedBlockRenderers())
return location();
RenderBlock* containerBlock = containingBlock();
@@ -4842,8 +4842,8 @@
LayoutSize RenderBox::topLeftLocationOffset() const
{
- if (!view().hasFlippedBlockDescendants())
- return LayoutSize(m_frameRect.x(), m_frameRect.y());
+ if (!view().frameView().hasFlippedBlockRenderers())
+ return locationOffset();
RenderBlock* containerBlock = containingBlock();
if (!containerBlock || containerBlock == this)
@@ -4854,6 +4854,19 @@
return LayoutSize(rect.x(), rect.y());
}
+void RenderBox::applyTopLeftLocationOffsetWithFlipping(LayoutPoint& point) const
+{
+ RenderBlock* containerBlock = containingBlock();
+ if (!containerBlock || containerBlock == this) {
+ point.move(m_frameRect.x(), m_frameRect.y());
+ return;
+ }
+
+ LayoutRect rect(frameRect());
+ containerBlock->flipForWritingMode(rect); // FIXME: This is wrong if we are an absolutely positioned object enclosed by a relative-positioned inline.
+ point.move(rect.x(), rect.y());
+}
+
bool RenderBox::hasRelativeDimensions() const
{
return style().height().isPercent() || style().width().isPercent()
Modified: trunk/Source/WebCore/rendering/RenderBox.h (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderBox.h 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2015-05-06 20:40:53 UTC (rev 183885)
@@ -23,6 +23,7 @@
#ifndef RenderBox_h
#define RenderBox_h
+#include "FrameView.h"
#include "RenderBoxModelObject.h"
#include "RenderOverflow.h"
#include "ScrollTypes.h"
@@ -553,6 +554,14 @@
// In layout related methods you almost always want the logical location (e.g. x() and y()).
LayoutPoint topLeftLocation() const;
LayoutSize topLeftLocationOffset() const;
+ void applyTopLeftLocationOffset(LayoutPoint& point) const
+ {
+ // This is inlined for speed, since it is used by updateLayerPosition() during scrolling.
+ if (!document().view()->hasFlippedBlockRenderers())
+ point.move(m_frameRect.x(), m_frameRect.y());
+ else
+ applyTopLeftLocationOffsetWithFlipping(point);
+ }
LayoutRect logicalVisualOverflowRectForPropagation(RenderStyle*) const;
LayoutRect visualOverflowRectForPropagation(RenderStyle*) const;
@@ -709,6 +718,8 @@
virtual void computePreferredLogicalWidths() { setPreferredLogicalWidthsDirty(false); }
virtual LayoutRect frameRectForStickyPositioning() const override final { return frameRect(); }
+
+ void applyTopLeftLocationOffsetWithFlipping(LayoutPoint&) const;
private:
// The width/height of the contents + borders + padding. The x/y location is relative to our container (which is not always our parent).
Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -220,7 +220,7 @@
setPositionState(styleToUse.position());
setHorizontalWritingMode(styleToUse.isHorizontalWritingMode());
if (styleToUse.isFlippedBlocksWritingMode())
- view().setHasFlippedBlockDescendants(true);
+ view().frameView().setHasFlippedBlockRenderers(true);
}
static LayoutSize accumulateInFlowPositionOffsets(const RenderObject* child)
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -1317,7 +1317,7 @@
} else if (RenderBox* box = renderBox()) {
// FIXME: Is snapping the size really needed here for the RenderBox case?
setSize(box->pixelSnappedSize());
- localPoint += box->topLeftLocationOffset();
+ box->applyTopLeftLocationOffset(localPoint);
}
RenderElement* ancestor;
@@ -5819,7 +5819,7 @@
LayoutRect RenderLayer::boundingBox(const RenderLayer* ancestorLayer, const LayoutSize& offsetFromRoot, CalculateLayerBoundsFlags flags) const
{
LayoutRect result = localBoundingBox(flags);
- if (renderer().view().hasFlippedBlockDescendants()) {
+ if (renderer().view().frameView().hasFlippedBlockRenderers()) {
if (renderer().isBox())
renderBox()->flipForWritingMode(result);
else
@@ -5901,7 +5901,7 @@
LayoutRect boundingBoxRect = localBoundingBox(flags);
- if (renderer().view().hasFlippedBlockDescendants()) {
+ if (renderer().view().frameView().hasFlippedBlockRenderers()) {
if (is<RenderBox>(renderer()))
downcast<RenderBox>(renderer()).flipForWritingMode(boundingBoxRect);
else
Modified: trunk/Source/WebCore/rendering/RenderLineBoxList.cpp (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderLineBoxList.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -154,7 +154,7 @@
{
LayoutUnit physicalStart = logicalTop;
LayoutUnit physicalEnd = logicalBottom;
- if (renderer->view().hasFlippedBlockDescendants()) {
+ if (renderer->view().frameView().hasFlippedBlockRenderers()) {
RenderBox* block;
if (is<RenderBox>(*renderer))
block = downcast<RenderBox>(renderer);
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2015-05-06 20:40:53 UTC (rev 183885)
@@ -111,7 +111,6 @@
, m_renderCounterCount(0)
, m_selectionWasCaret(false)
, m_hasSoftwareFilters(false)
- , m_hasFlippedBlockDescendants(false)
#if ENABLE(SERVICE_CONTROLS)
, m_selectionRectGatherer(*this)
#endif
Modified: trunk/Source/WebCore/rendering/RenderView.h (183884 => 183885)
--- trunk/Source/WebCore/rendering/RenderView.h 2015-05-06 20:34:51 UTC (rev 183884)
+++ trunk/Source/WebCore/rendering/RenderView.h 2015-05-06 20:40:53 UTC (rev 183885)
@@ -103,9 +103,6 @@
LayoutRect viewRect() const;
- bool hasFlippedBlockDescendants() const { return m_hasFlippedBlockDescendants; }
- void setHasFlippedBlockDescendants(bool b) { m_hasFlippedBlockDescendants = b; }
-
// layoutDelta is used transiently during layout to store how far an object has moved from its
// last layout location, in order to repaint correctly.
// If we're doing a full repaint m_layoutState will be 0, but in that case layoutDelta doesn't matter.
@@ -363,7 +360,6 @@
bool m_selectionWasCaret;
bool m_hasSoftwareFilters;
- bool m_hasFlippedBlockDescendants;
HashSet<RenderElement*> m_renderersWithPausedImageAnimation;
Vector<RefPtr<RenderWidget>> m_protectedRenderWidgets;