- Revision
- 181654
- Author
- [email protected]
- Date
- 2015-03-17 11:58:59 -0700 (Tue, 17 Mar 2015)
Log Message
Move some code from LogicalSelectionOffsetCaches into RenderElement
https://bugs.webkit.org/show_bug.cgi?id=142758
Reviewed by Myles C. Maxfield.
LogicalSelectionOffsetCaches had some useful code regarding containing blocks etc
that should be used in more places, so move it into RenderElement.
No behavior change.
* rendering/LogicalSelectionOffsetCaches.h:
(WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):
(WebCore::isContainingBlockCandidateForAbsolutelyPositionedObject): Deleted.
(WebCore::isNonRenderBlockInline): Deleted.
(WebCore::containingBlockForFixedPosition): Deleted.
(WebCore::containingBlockForAbsolutePosition): Deleted.
(WebCore::containingBlockForObjectInFlow): Deleted.
* rendering/RenderBlock.cpp: No need to initialize static data.
(WebCore::RenderBlock::positionedObjects): nullptr
* rendering/RenderElement.cpp:
(WebCore::RenderElement::containingBlockForFixedPosition):
(WebCore::RenderElement::containingBlockForAbsolutePosition):
(WebCore::isNonRenderBlockInline):
(WebCore::RenderElement::containingBlockForObjectInFlow):
* rendering/RenderElement.h:
(WebCore::RenderElement::canContainAbsolutelyPositionedObjects):
* rendering/RenderLayer.cpp:
(WebCore::isContainerForPositioned):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::containingBlock):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (181653 => 181654)
--- trunk/Source/WebCore/ChangeLog 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/ChangeLog 2015-03-17 18:58:59 UTC (rev 181654)
@@ -1,3 +1,36 @@
+2015-03-17 Simon Fraser <[email protected]>
+
+ Move some code from LogicalSelectionOffsetCaches into RenderElement
+ https://bugs.webkit.org/show_bug.cgi?id=142758
+
+ Reviewed by Myles C. Maxfield.
+
+ LogicalSelectionOffsetCaches had some useful code regarding containing blocks etc
+ that should be used in more places, so move it into RenderElement.
+
+ No behavior change.
+
+ * rendering/LogicalSelectionOffsetCaches.h:
+ (WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches):
+ (WebCore::isContainingBlockCandidateForAbsolutelyPositionedObject): Deleted.
+ (WebCore::isNonRenderBlockInline): Deleted.
+ (WebCore::containingBlockForFixedPosition): Deleted.
+ (WebCore::containingBlockForAbsolutePosition): Deleted.
+ (WebCore::containingBlockForObjectInFlow): Deleted.
+ * rendering/RenderBlock.cpp: No need to initialize static data.
+ (WebCore::RenderBlock::positionedObjects): nullptr
+ * rendering/RenderElement.cpp:
+ (WebCore::RenderElement::containingBlockForFixedPosition):
+ (WebCore::RenderElement::containingBlockForAbsolutePosition):
+ (WebCore::isNonRenderBlockInline):
+ (WebCore::RenderElement::containingBlockForObjectInFlow):
+ * rendering/RenderElement.h:
+ (WebCore::RenderElement::canContainAbsolutelyPositionedObjects):
+ * rendering/RenderLayer.cpp:
+ (WebCore::isContainerForPositioned):
+ * rendering/RenderObject.cpp:
+ (WebCore::RenderObject::containingBlock):
+
2015-03-17 Alex Christensen <[email protected]>
[WinCairo] Unreviewed build fix after r181640.
Modified: trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h (181653 => 181654)
--- trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h 2015-03-17 18:58:59 UTC (rev 181654)
@@ -25,58 +25,6 @@
namespace WebCore {
-// FIXME: share code with RenderObject::container().
-static inline bool isContainingBlockCandidateForAbsolutelyPositionedObject(RenderElement& object)
-{
- // FIXME: hasTransformRelatedProperty() includes preserves3D() check, but this may need to change: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27566
- return object.style().position() != StaticPosition
- || (object.isRenderBlock() && object.hasTransformRelatedProperty())
- || object.isSVGForeignObject()
- || object.isRenderView();
-}
-
-static inline bool isNonRenderBlockInline(RenderElement& object)
-{
- return (object.isInline() && !object.isReplaced()) || !object.isRenderBlock();
-}
-
-// FIXME: share code with RenderObject::container().
-static inline RenderBlock* containingBlockForFixedPosition(RenderElement* parent)
-{
- RenderElement* object = parent;
- while (object && !object->canContainFixedPositionObjects())
- object = object->parent();
- ASSERT(!object || !object->isAnonymousBlock());
- return downcast<RenderBlock>(object);
-}
-
-static inline RenderBlock* containingBlockForAbsolutePosition(RenderElement* parent)
-{
- RenderElement* object = parent;
- while (object && !isContainingBlockCandidateForAbsolutelyPositionedObject(*object))
- object = object->parent();
-
- // For a relatively positioned inline, return its nearest non-anonymous containing block,
- // not the inline itself, to avoid having a positioned objects list in all RenderInlines
- // and use RenderBlock* as RenderElement::containingBlock's return type.
- // Use RenderBlock::container() to obtain the inline.
- if (object && !is<RenderBlock>(*object))
- object = object->containingBlock();
-
- while (object && object->isAnonymousBlock())
- object = object->containingBlock();
-
- return downcast<RenderBlock>(object);
-}
-
-static inline RenderBlock* containingBlockForObjectInFlow(RenderElement* parent)
-{
- RenderElement* object = parent;
- while (object && isNonRenderBlockInline(*object))
- object = object->parent();
- return downcast<RenderBlock>(object);
-}
-
class LogicalSelectionOffsetCaches {
public:
class ContainingBlockInfo {
@@ -144,9 +92,9 @@
auto parent = rootBlock.parent();
// LogicalSelectionOffsetCaches should not be used on an orphaned tree.
- m_containingBlockForFixedPosition.setBlock(containingBlockForFixedPosition(parent), 0);
- m_containingBlockForAbsolutePosition.setBlock(containingBlockForAbsolutePosition(parent), 0);
- m_containingBlockForInflowPosition.setBlock(containingBlockForObjectInFlow(parent), 0);
+ m_containingBlockForFixedPosition.setBlock(parent->containingBlockForFixedPosition(), nullptr);
+ m_containingBlockForAbsolutePosition.setBlock(parent->containingBlockForAbsolutePosition(), nullptr);
+ m_containingBlockForInflowPosition.setBlock(parent->containingBlockForObjectInFlow(), nullptr);
}
LogicalSelectionOffsetCaches(RenderBlock& block, const LogicalSelectionOffsetCaches& cache)
@@ -156,7 +104,7 @@
if (block.canContainFixedPositionObjects())
m_containingBlockForFixedPosition.setBlock(&block, &cache);
- if (isContainingBlockCandidateForAbsolutelyPositionedObject(block) && !block.isRenderInline() && !block.isAnonymousBlock())
+ if (block.canContainAbsolutelyPositionedObjects() && !block.isRenderInline() && !block.isAnonymousBlock())
m_containingBlockForFixedPosition.setBlock(&block, &cache);
m_containingBlockForInflowPosition.setBlock(&block, &cache);
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (181653 => 181654)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2015-03-17 18:58:59 UTC (rev 181654)
@@ -90,11 +90,11 @@
COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock_should_stay_small);
-static TrackedDescendantsMap* gPositionedDescendantsMap = 0;
-static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0;
+static TrackedDescendantsMap* gPositionedDescendantsMap;
+static TrackedDescendantsMap* gPercentHeightDescendantsMap;
-static TrackedContainerMap* gPositionedContainerMap = 0;
-static TrackedContainerMap* gPercentHeightContainerMap = 0;
+static TrackedContainerMap* gPositionedContainerMap;
+static TrackedContainerMap* gPercentHeightContainerMap;
typedef HashMap<RenderBlock*, std::unique_ptr<ListHashSet<RenderInline*>>> ContinuationOutlineTableMap;
@@ -2144,7 +2144,7 @@
{
if (gPositionedDescendantsMap)
return gPositionedDescendantsMap->get(this);
- return 0;
+ return nullptr;
}
void RenderBlock::insertPositionedObject(RenderBox& o)
Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (181653 => 181654)
--- trunk/Source/WebCore/rendering/RenderElement.cpp 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp 2015-03-17 18:58:59 UTC (rev 181654)
@@ -37,6 +37,7 @@
#include "HTMLHtmlElement.h"
#include "HTMLNames.h"
#include "FlowThreadController.h"
+#include "RenderBlock.h"
#include "RenderCounter.h"
#include "RenderDeprecatedFlexibleBox.h"
#include "RenderFlexibleBox.h"
@@ -1496,6 +1497,48 @@
return document().ensureStyleResolver().pseudoStyleForElement(element(), pseudoStyleRequest, parentStyle);
}
+RenderBlock* RenderElement::containingBlockForFixedPosition() const
+{
+ const RenderElement* object = this;
+ while (object && !object->canContainFixedPositionObjects())
+ object = object->parent();
+
+ ASSERT(!object || !object->isAnonymousBlock());
+ return const_cast<RenderBlock*>(downcast<RenderBlock>(object));
+}
+
+RenderBlock* RenderElement::containingBlockForAbsolutePosition() const
+{
+ const RenderElement* object = this;
+ while (object && !object->canContainAbsolutelyPositionedObjects())
+ object = object->parent();
+
+ // For a relatively positioned inline, return its nearest non-anonymous containing block,
+ // not the inline itself, to avoid having a positioned objects list in all RenderInlines
+ // and use RenderBlock* as RenderElement::containingBlock's return type.
+ // Use RenderBlock::container() to obtain the inline.
+ if (object && !is<RenderBlock>(*object))
+ object = object->containingBlock();
+
+ while (object && object->isAnonymousBlock())
+ object = object->containingBlock();
+
+ return const_cast<RenderBlock*>(downcast<RenderBlock>(object));
+}
+
+static inline bool isNonRenderBlockInline(const RenderElement& object)
+{
+ return (object.isInline() && !object.isReplaced()) || !object.isRenderBlock();
+}
+
+RenderBlock* RenderElement::containingBlockForObjectInFlow() const
+{
+ const RenderElement* object = this;
+ while (object && isNonRenderBlockInline(*object))
+ object = object->parent();
+ return const_cast<RenderBlock*>(downcast<RenderBlock>(object));
+}
+
Color RenderElement::selectionColor(int colorProperty) const
{
// If the element is unselectable, or we are only painting the selection,
Modified: trunk/Source/WebCore/rendering/RenderElement.h (181653 => 181654)
--- trunk/Source/WebCore/rendering/RenderElement.h 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2015-03-17 18:58:59 UTC (rev 181654)
@@ -29,6 +29,7 @@
namespace WebCore {
class ControlStates;
+class RenderBlock;
class RenderElement : public RenderObject {
public:
@@ -63,7 +64,12 @@
virtual bool isEmpty() const override { return !firstChild(); }
bool canContainFixedPositionObjects() const;
+ bool canContainAbsolutelyPositionedObjects() const;
+ RenderBlock* containingBlockForFixedPosition() const;
+ RenderBlock* containingBlockForAbsolutePosition() const;
+ RenderBlock* containingBlockForObjectInFlow() const;
+
Color selectionColor(int colorProperty) const;
PassRefPtr<RenderStyle> selectionPseudoStyle() const;
@@ -393,6 +399,14 @@
|| isOutOfFlowRenderFlowThread();
}
+inline bool RenderElement::canContainAbsolutelyPositionedObjects() const
+{
+ return style().position() != StaticPosition
+ || (isRenderBlock() && hasTransformRelatedProperty())
+ || isSVGForeignObject()
+ || isRenderView();
+}
+
inline bool RenderObject::isRenderLayerModelObject() const
{
return is<RenderElement>(*this) && downcast<RenderElement>(*this).isRenderLayerModelObject();
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (181653 => 181654)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2015-03-17 18:58:59 UTC (rev 181654)
@@ -77,7 +77,6 @@
#include "HitTestRequest.h"
#include "HitTestResult.h"
#include "InspectorInstrumentation.h"
-#include "LogicalSelectionOffsetCaches.h"
#include "OverflowEvent.h"
#include "OverlapTestRequestClient.h"
#include "Page.h"
@@ -1434,7 +1433,7 @@
return layer.renderer().canContainFixedPositionObjects();
case AbsolutePosition:
- return isContainingBlockCandidateForAbsolutelyPositionedObject(layer.renderer());
+ return layer.renderer().canContainAbsolutelyPositionedObjects();
default:
ASSERT_NOT_REACHED();
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (181653 => 181654)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2015-03-17 18:02:56 UTC (rev 181653)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2015-03-17 18:58:59 UTC (rev 181654)
@@ -693,11 +693,11 @@
const RenderStyle& style = this->style();
if (!is<RenderText>(*this) && style.position() == FixedPosition)
- parent = containingBlockForFixedPosition(parent);
+ parent = parent->containingBlockForFixedPosition();
else if (!is<RenderText>(*this) && style.position() == AbsolutePosition)
- parent = containingBlockForAbsolutePosition(parent);
+ parent = parent->containingBlockForAbsolutePosition();
else
- parent = containingBlockForObjectInFlow(parent);
+ parent = parent->containingBlockForObjectInFlow();
if (!is<RenderBlock>(parent))
return nullptr; // This can still happen in case of an orphaned tree