- Revision
- 242561
- Author
- [email protected]
- Date
- 2019-03-06 12:18:00 -0800 (Wed, 06 Mar 2019)
Log Message
Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
https://bugs.webkit.org/show_bug.cgi?id=195300
Reviewed by Simon Fraser.
Source/WebCore:
Move isTransparentOrFullyClippedRespectingParentFrames() from RenderObject to RenderLayer, since this function
asks questions about RenderLayers rather than their renderers. No change in behavior.
* rendering/RenderLayer.cpp:
(WebCore::enclosingFrameRenderLayer):
(WebCore::parentLayerCrossFrame):
Some static helpers currently in RenderObject that walk up the layer hierarchy through subframes are redundant
with static helpers in RenderLayer. Now that isTransparentOrFullyClippedRespectingParentFrames exists in
RenderLayer, simply use this existing helper instead and split logic to grab the enclosing layer around the
owner element of a frame into a separate helper.
* rendering/RenderLayer.h:
* rendering/RenderObject.cpp:
(WebCore::enclosingFrameRenderLayer): Deleted.
(WebCore::parentLayerCrossingFrameBoundaries): Deleted.
(WebCore::RenderObject::isTransparentOrFullyClippedRespectingParentFrames const): Deleted.
Moved from RenderObject.
* rendering/RenderObject.h:
Source/WebKit:
Refactor some logic to use isTransparentOrFullyClippedRespectingParentFrames on RenderLayer rather than
RenderObject; introduce a helper method to ask whether the enclosing layer of a renderer is transparent or
clipped.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::enclosingLayerIsTransparentOrFullyClipped):
(WebKit::WebPage::platformEditorState const):
(WebKit::WebPage::requestEvasionRectsAboveSelection):
(WebKit::WebPage::getFocusedElementInformation):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (242560 => 242561)
--- trunk/Source/WebCore/ChangeLog 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebCore/ChangeLog 2019-03-06 20:18:00 UTC (rev 242561)
@@ -1,3 +1,32 @@
+2019-03-06 Wenson Hsieh <[email protected]>
+
+ Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
+ https://bugs.webkit.org/show_bug.cgi?id=195300
+
+ Reviewed by Simon Fraser.
+
+ Move isTransparentOrFullyClippedRespectingParentFrames() from RenderObject to RenderLayer, since this function
+ asks questions about RenderLayers rather than their renderers. No change in behavior.
+
+ * rendering/RenderLayer.cpp:
+ (WebCore::enclosingFrameRenderLayer):
+ (WebCore::parentLayerCrossFrame):
+
+ Some static helpers currently in RenderObject that walk up the layer hierarchy through subframes are redundant
+ with static helpers in RenderLayer. Now that isTransparentOrFullyClippedRespectingParentFrames exists in
+ RenderLayer, simply use this existing helper instead and split logic to grab the enclosing layer around the
+ owner element of a frame into a separate helper.
+
+ * rendering/RenderLayer.h:
+ * rendering/RenderObject.cpp:
+ (WebCore::enclosingFrameRenderLayer): Deleted.
+ (WebCore::parentLayerCrossingFrameBoundaries): Deleted.
+ (WebCore::RenderObject::isTransparentOrFullyClippedRespectingParentFrames const): Deleted.
+
+ Moved from RenderObject.
+
+ * rendering/RenderObject.h:
+
2019-03-06 Sihui Liu <[email protected]>
Assertion Failed: m_databaseQueue.isKilled() in UniqueIDBDatabase::~UniqueIDBDatabase()
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (242560 => 242561)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2019-03-06 20:18:00 UTC (rev 242561)
@@ -1652,16 +1652,13 @@
return curr;
}
-static RenderLayer* parentLayerCrossFrame(const RenderLayer& layer)
+static RenderLayer* enclosingFrameRenderLayer(const RenderLayer& layer)
{
- if (layer.parent())
- return layer.parent();
-
- HTMLFrameOwnerElement* ownerElement = layer.renderer().document().ownerElement();
+ auto* ownerElement = layer.renderer().document().ownerElement();
if (!ownerElement)
return nullptr;
- RenderElement* ownerRenderer = ownerElement->renderer();
+ auto* ownerRenderer = ownerElement->renderer();
if (!ownerRenderer)
return nullptr;
@@ -1668,6 +1665,14 @@
return ownerRenderer->enclosingLayer();
}
+static RenderLayer* parentLayerCrossFrame(const RenderLayer& layer)
+{
+ if (auto* parent = layer.parent())
+ return parent;
+
+ return enclosingFrameRenderLayer(layer);
+}
+
RenderLayer* RenderLayer::enclosingScrollableLayer() const
{
for (RenderLayer* nextLayer = parentLayerCrossFrame(*this); nextLayer; nextLayer = parentLayerCrossFrame(*nextLayer)) {
@@ -6594,6 +6599,25 @@
renderer().repaint();
}
+bool RenderLayer::isTransparentOrFullyClippedRespectingParentFrames() const
+{
+ static const double minimumVisibleOpacity = 0.01;
+
+ float currentOpacity = 1;
+ for (auto* layer = this; layer; layer = parentLayerCrossFrame(*layer)) {
+ currentOpacity *= layer->renderer().style().opacity();
+ if (currentOpacity < minimumVisibleOpacity)
+ return true;
+ }
+
+ for (auto* layer = this; layer; layer = enclosingFrameRenderLayer(*layer)) {
+ if (layer->selfClipRect().isEmpty())
+ return true;
+ }
+
+ return false;
+}
+
TextStream& operator<<(TextStream& ts, const RenderLayer& layer)
{
ts << "RenderLayer " << &layer << " " << layer.size();
Modified: trunk/Source/WebCore/rendering/RenderLayer.h (242560 => 242561)
--- trunk/Source/WebCore/rendering/RenderLayer.h 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebCore/rendering/RenderLayer.h 2019-03-06 20:18:00 UTC (rev 242561)
@@ -857,6 +857,8 @@
void simulateFrequentPaint() { SinglePaintFrequencyTracking { m_paintFrequencyTracker }; }
bool paintingFrequently() const { return m_paintFrequencyTracker.paintingFrequently(); }
+ WEBCORE_EXPORT bool isTransparentOrFullyClippedRespectingParentFrames() const;
+
private:
void setNextSibling(RenderLayer* next) { m_next = next; }
Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (242560 => 242561)
--- trunk/Source/WebCore/rendering/RenderObject.cpp 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp 2019-03-06 20:18:00 UTC (rev 242561)
@@ -1527,43 +1527,6 @@
delete this;
}
-static RenderLayer* enclosingFrameRenderLayer(RenderObject& renderObject)
-{
- auto* owner = renderObject.frame().ownerElement();
- if (!owner)
- return nullptr;
-
- auto* frameOwnerRenderer = owner->renderer();
- return frameOwnerRenderer ? frameOwnerRenderer->enclosingLayer() : nullptr;
-}
-
-static RenderLayer* parentLayerCrossingFrameBoundaries(RenderLayer& layer)
-{
- if (auto* parentLayer = layer.parent())
- return parentLayer;
-
- return enclosingFrameRenderLayer(layer.renderer());
-}
-
-bool RenderObject::isTransparentOrFullyClippedRespectingParentFrames() const
-{
- static const double minimumVisibleOpacity = 0.01;
-
- float currentOpacity = 1;
- for (auto* layer = enclosingLayer(); layer; layer = parentLayerCrossingFrameBoundaries(*layer)) {
- currentOpacity *= layer->renderer().style().opacity();
- if (currentOpacity < minimumVisibleOpacity)
- return true;
- }
-
- for (auto* layer = enclosingLayer(); layer; layer = enclosingFrameRenderLayer(layer->renderer())) {
- if (layer->selfClipRect().isEmpty())
- return true;
- }
-
- return false;
-}
-
Position RenderObject::positionForPoint(const LayoutPoint& point)
{
// FIXME: This should just create a Position object instead (webkit.org/b/168566).
Modified: trunk/Source/WebCore/rendering/RenderObject.h (242560 => 242561)
--- trunk/Source/WebCore/rendering/RenderObject.h 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebCore/rendering/RenderObject.h 2019-03-06 20:18:00 UTC (rev 242561)
@@ -798,8 +798,6 @@
void initializeFragmentedFlowStateOnInsertion();
virtual void insertedIntoTree();
- WEBCORE_EXPORT bool isTransparentOrFullyClippedRespectingParentFrames() const;
-
protected:
//////////////////////////////////////////
// Helper functions. Dangerous to use!
Modified: trunk/Source/WebKit/ChangeLog (242560 => 242561)
--- trunk/Source/WebKit/ChangeLog 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebKit/ChangeLog 2019-03-06 20:18:00 UTC (rev 242561)
@@ -1,3 +1,20 @@
+2019-03-06 Wenson Hsieh <[email protected]>
+
+ Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
+ https://bugs.webkit.org/show_bug.cgi?id=195300
+
+ Reviewed by Simon Fraser.
+
+ Refactor some logic to use isTransparentOrFullyClippedRespectingParentFrames on RenderLayer rather than
+ RenderObject; introduce a helper method to ask whether the enclosing layer of a renderer is transparent or
+ clipped.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::enclosingLayerIsTransparentOrFullyClipped):
+ (WebKit::WebPage::platformEditorState const):
+ (WebKit::WebPage::requestEvasionRectsAboveSelection):
+ (WebKit::WebPage::getFocusedElementInformation):
+
2019-03-06 Chris Dumez <[email protected]>
REGRESSION (r238490): YouTube.com: Returning PiP to Safari after sleeping device loses page
Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (242560 => 242561)
--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-03-06 20:16:35 UTC (rev 242560)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2019-03-06 20:18:00 UTC (rev 242561)
@@ -179,6 +179,12 @@
data.hasPlainText = data.hasContent && hasAnyPlainText(Range::create(root->document(), VisiblePosition { startInEditableRoot }, VisiblePosition { lastPositionInNode(root) }));
}
+static bool enclosingLayerIsTransparentOrFullyClipped(const RenderObject& renderer)
+{
+ auto* enclosingLayer = renderer.enclosingLayer();
+ return enclosingLayer && enclosingLayer->isTransparentOrFullyClippedRespectingParentFrames();
+}
+
void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint shouldIncludePostLayoutData) const
{
if (frame.editor().hasComposition()) {
@@ -246,9 +252,10 @@
postLayoutData.insideFixedPosition = startNodeIsInsideFixedPosition || endNodeIsInsideFixedPosition;
if (!selection.isNone()) {
if (m_focusedElement && m_focusedElement->renderer()) {
- postLayoutData.focusedElementRect = view->contentsToRootView(m_focusedElement->renderer()->absoluteBoundingBoxRect());
- postLayoutData.caretColor = m_focusedElement->renderer()->style().caretColor();
- postLayoutData.elementIsTransparentOrFullyClipped = m_focusedElement->renderer()->isTransparentOrFullyClippedRespectingParentFrames();
+ auto& renderer = *m_focusedElement->renderer();
+ postLayoutData.focusedElementRect = view->contentsToRootView(renderer.absoluteBoundingBoxRect());
+ postLayoutData.caretColor = renderer.style().caretColor();
+ postLayoutData.elementIsTransparentOrFullyClipped = enclosingLayerIsTransparentOrFullyClipped(renderer);
}
computeEditableRootHasContentAndPlainText(selection, postLayoutData);
}
@@ -1523,7 +1530,7 @@
return;
}
- if (!m_focusedElement || !m_focusedElement->renderer() || m_focusedElement->renderer()->isTransparentOrFullyClippedRespectingParentFrames()) {
+ if (!m_focusedElement || !m_focusedElement->renderer() || enclosingLayerIsTransparentOrFullyClipped(*m_focusedElement->renderer())) {
reply({ });
return;
}
@@ -2489,7 +2496,7 @@
auto& elementFrame = m_page->focusController().focusedOrMainFrame();
information.elementRect = elementRectInRootViewCoordinates(*m_focusedElement, elementFrame);
information.nodeFontSize = renderer->style().fontDescription().computedSize();
- information.elementIsTransparentOrFullyClipped = renderer->isTransparentOrFullyClippedRespectingParentFrames();
+ information.elementIsTransparentOrFullyClipped = enclosingLayerIsTransparentOrFullyClipped(*renderer);
bool inFixed = false;
renderer->localToContainerPoint(FloatPoint(), nullptr, UseTransforms, &inFixed);