- Revision
- 201201
- Author
- [email protected]
- Date
- 2016-05-19 16:54:32 -0700 (Thu, 19 May 2016)
Log Message
Cleanup RenderObject::container()
https://bugs.webkit.org/show_bug.cgi?id=157914
Reviewed by David Hyatt.
1. Now we have a dedicated method for the optional, repaintContainerSkipped branch. The container finding
logic is moved to a static inline function so the compiler can optimize out the repaintContainerSkipped branches, when
container() is called instead of container(repaintContainer, isRepaintContainerSkipped).
2. Use helper functions like canContainAbsolutelyPositionedObjects()
3. Remove stale comments.
No behaviour change.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::mapLocalToContainer):
(WebCore::RenderBox::pushMappingToContainer):
(WebCore::RenderBox::computeRectForRepaint):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::computeRectForRepaint):
(WebCore::RenderInline::mapLocalToContainer):
(WebCore::RenderInline::pushMappingToContainer):
* rendering/RenderObject.cpp:
(WebCore::containerForElement):
(WebCore::RenderObject::container):
* rendering/RenderObject.h:
* rendering/RenderText.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (201200 => 201201)
--- trunk/Source/WebCore/ChangeLog 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/ChangeLog 2016-05-19 23:54:32 UTC (rev 201201)
@@ -1,3 +1,32 @@
+2016-05-19 Zalan Bujtas <[email protected]>
+
+ Cleanup RenderObject::container()
+ https://bugs.webkit.org/show_bug.cgi?id=157914
+
+ Reviewed by David Hyatt.
+
+ 1. Now we have a dedicated method for the optional, repaintContainerSkipped branch. The container finding
+ logic is moved to a static inline function so the compiler can optimize out the repaintContainerSkipped branches, when
+ container() is called instead of container(repaintContainer, isRepaintContainerSkipped).
+ 2. Use helper functions like canContainAbsolutelyPositionedObjects()
+ 3. Remove stale comments.
+
+ No behaviour change.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::mapLocalToContainer):
+ (WebCore::RenderBox::pushMappingToContainer):
+ (WebCore::RenderBox::computeRectForRepaint):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::computeRectForRepaint):
+ (WebCore::RenderInline::mapLocalToContainer):
+ (WebCore::RenderInline::pushMappingToContainer):
+ * rendering/RenderObject.cpp:
+ (WebCore::containerForElement):
+ (WebCore::RenderObject::container):
+ * rendering/RenderObject.h:
+ * rendering/RenderText.h:
+
2016-05-16 Enrica Casucci <[email protected]>
No candidate punctuation when typing punctuation in WK2 text field.
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (201200 => 201201)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2016-05-19 23:54:32 UTC (rev 201201)
@@ -2004,7 +2004,7 @@
}
bool containerSkipped;
- RenderElement* container = this->container(repaintContainer, &containerSkipped);
+ RenderElement* container = this->container(repaintContainer, containerSkipped);
if (!container)
return;
@@ -2052,7 +2052,7 @@
ASSERT(ancestorToStopAt != this);
bool ancestorSkipped;
- RenderElement* container = this->container(ancestorToStopAt, &ancestorSkipped);
+ RenderElement* container = this->container(ancestorToStopAt, ancestorSkipped);
if (!container)
return nullptr;
@@ -2241,7 +2241,7 @@
}
bool containerSkipped;
- auto* renderer = container(repaintContainer, &containerSkipped);
+ auto* renderer = container(repaintContainer, containerSkipped);
if (!renderer)
return adjustedRect;
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (201200 => 201201)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2016-05-19 23:54:32 UTC (rev 201201)
@@ -1278,7 +1278,7 @@
return adjustedRect;
bool containerSkipped;
- RenderElement* container = this->container(repaintContainer, &containerSkipped);
+ RenderElement* container = this->container(repaintContainer, containerSkipped);
if (!container)
return adjustedRect;
@@ -1342,7 +1342,7 @@
}
bool containerSkipped;
- RenderElement* container = this->container(repaintContainer, &containerSkipped);
+ RenderElement* container = this->container(repaintContainer, containerSkipped);
if (!container)
return;
@@ -1380,7 +1380,7 @@
ASSERT(ancestorToStopAt != this);
bool ancestorSkipped;
- RenderElement* container = this->container(ancestorToStopAt, &ancestorSkipped);
+ RenderElement* container = this->container(ancestorToStopAt, ancestorSkipped);
if (!container)
return nullptr;
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (201200 => 201201)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2016-05-19 23:54:32 UTC (rev 201201)
@@ -1396,71 +1396,36 @@
return style().hasEntirelyFixedBackground();
}
-RenderElement* RenderObject::container(const RenderLayerModelObject* repaintContainer, bool* repaintContainerSkipped) const
+static inline RenderElement* containerForElement(const RenderObject& renderer, const RenderLayerModelObject* repaintContainer, bool* repaintContainerSkipped)
{
- if (repaintContainerSkipped)
- *repaintContainerSkipped = false;
-
// This method is extremely similar to containingBlock(), but with a few notable
// exceptions.
- // (1) It can be used on orphaned subtrees, i.e., it can be called safely even when
- // the object is not part of the primary document subtree yet.
- // (2) For normal flow elements, it just returns the parent.
- // (3) For absolute positioned elements, it will return a relative positioned inline.
- // containingBlock() simply skips relpositioned inlines and lets an enclosing block handle
- // the layout of the positioned object. This does mean that computePositionedLogicalWidth and
- // computePositionedLogicalHeight have to use container().
- auto o = parent();
-
- if (isText())
- return o;
-
- EPosition pos = style().position();
- if (pos == FixedPosition) {
- // container() can be called on an object that is not in the
- // tree yet. We don't call view() since it will assert if it
- // can't get back to the canvas. Instead we just walk as high up
- // as we can. If we're in the tree, we'll get the root. If we
- // aren't we'll get the root of our little subtree (most likely
- // we'll just return nullptr).
- // FIXME: The definition of view() has changed to not crawl up the render tree. It might
- // be safe now to use it.
- // FIXME: share code with containingBlockForFixedPosition().
- while (o && o->parent() && !(o->hasTransform() && o->isRenderBlock())) {
- // foreignObject is the containing block for its contents.
- if (o->isSVGForeignObject())
- break;
-
- // The render flow thread is the top most containing block
- // for the fixed positioned elements.
- if (o->isOutOfFlowRenderFlowThread())
- break;
-
- if (repaintContainerSkipped && o == repaintContainer)
- *repaintContainerSkipped = true;
-
- o = o->parent();
- }
- } else if (pos == AbsolutePosition) {
- // Same goes here. We technically just want our containing block, but
- // we may not have one if we're part of an uninstalled subtree. We'll
- // climb as high as we can though.
- // FIXME: share code with isContainingBlockCandidateForAbsolutelyPositionedObject().
- // FIXME: hasTransformRelatedProperty() includes preserves3D() check, but this may need to change: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27566
- while (o && o->style().position() == StaticPosition && !o->isRenderView() && !(o->hasTransformRelatedProperty() && o->isRenderBlock())) {
- if (o->isSVGForeignObject()) // foreignObject is the containing block for contents inside it
- break;
-
- if (repaintContainerSkipped && o == repaintContainer)
- *repaintContainerSkipped = true;
-
- o = o->parent();
- }
+ // (1) For normal flow elements, it just returns the parent.
+ // (2) For absolute positioned elements, it will return a relative positioned inline, while
+ // containingBlock() skips to the non-anonymous containing block.
+ // This does mean that computePositionedLogicalWidth and computePositionedLogicalHeight have to use container().
+ EPosition pos = renderer.style().position();
+ auto* parent = renderer.parent();
+ if (is<RenderText>(renderer) || (pos != FixedPosition && pos != AbsolutePosition))
+ return parent;
+ for (; parent && (pos == AbsolutePosition ? !parent->canContainAbsolutelyPositionedObjects() : !parent->canContainFixedPositionObjects()); parent = parent->parent()) {
+ if (repaintContainerSkipped && repaintContainer == parent)
+ *repaintContainerSkipped = true;
}
+ return parent;
+}
- return o;
+RenderElement* RenderObject::container() const
+{
+ return containerForElement(*this, nullptr, nullptr);
}
+RenderElement* RenderObject::container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const
+{
+ repaintContainerSkipped = false;
+ return containerForElement(*this, repaintContainer, &repaintContainerSkipped);
+}
+
bool RenderObject::isSelectionBorder() const
{
SelectionState st = selectionState();
Modified: trunk/Source/WebCore/rendering/RenderObject.h (201200 => 201201)
--- trunk/Source/WebCore/rendering/RenderObject.h 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2016-05-19 23:54:32 UTC (rev 201201)
@@ -571,7 +571,8 @@
// Returns the object containing this one. Can be different from parent for positioned elements.
// If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
// is true if the renderer returned is an ancestor of repaintContainer.
- RenderElement* container(const RenderLayerModelObject* repaintContainer = nullptr, bool* repaintContainerSkipped = nullptr) const;
+ RenderElement* container() const;
+ RenderElement* container(const RenderLayerModelObject* repaintContainer, bool& repaintContainerSkipped) const;
RenderBoxModelObject* offsetParent() const;
Modified: trunk/Source/WebCore/rendering/RenderText.h (201200 => 201201)
--- trunk/Source/WebCore/rendering/RenderText.h 2016-05-19 23:48:01 UTC (rev 201200)
+++ trunk/Source/WebCore/rendering/RenderText.h 2016-05-19 23:54:32 UTC (rev 201201)
@@ -205,6 +205,8 @@
LayoutRect collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector<LayoutRect>*);
void node() const = delete;
+ void container() const = delete; // Use parent() instead.
+ void container(const RenderLayerModelObject&, bool&) const = delete; // Use parent() instead.
// We put the bitfield first to minimize padding on 64-bit.
unsigned m_hasBreakableChar : 1; // Whether or not we can be broken into multiple lines.