Changeset 242561 in webkit


Ignore:
Timestamp:
Mar 6, 2019, 12:18:00 PM (7 years ago)
Author:
Wenson Hsieh
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):

Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r242555 r242561  
     12019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=195300
     5
     6        Reviewed by Simon Fraser.
     7
     8        Move isTransparentOrFullyClippedRespectingParentFrames() from RenderObject to RenderLayer, since this function
     9        asks questions about RenderLayers rather than their renderers. No change in behavior.
     10
     11        * rendering/RenderLayer.cpp:
     12        (WebCore::enclosingFrameRenderLayer):
     13        (WebCore::parentLayerCrossFrame):
     14
     15        Some static helpers currently in RenderObject that walk up the layer hierarchy through subframes are redundant
     16        with static helpers in RenderLayer. Now that isTransparentOrFullyClippedRespectingParentFrames exists in
     17        RenderLayer, simply use this existing helper instead and split logic to grab the enclosing layer around the
     18        owner element of a frame into a separate helper.
     19
     20        * rendering/RenderLayer.h:
     21        * rendering/RenderObject.cpp:
     22        (WebCore::enclosingFrameRenderLayer): Deleted.
     23        (WebCore::parentLayerCrossingFrameBoundaries): Deleted.
     24        (WebCore::RenderObject::isTransparentOrFullyClippedRespectingParentFrames const): Deleted.
     25
     26        Moved from RenderObject.
     27
     28        * rendering/RenderObject.h:
     29
    1302019-03-06  Sihui Liu  <sihui_liu@apple.com>
    231
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r242333 r242561  
    16531653}
    16541654
    1655 static RenderLayer* parentLayerCrossFrame(const RenderLayer& layer)
    1656 {
    1657     if (layer.parent())
    1658         return layer.parent();
    1659 
    1660     HTMLFrameOwnerElement* ownerElement = layer.renderer().document().ownerElement();
     1655static RenderLayer* enclosingFrameRenderLayer(const RenderLayer& layer)
     1656{
     1657    auto* ownerElement = layer.renderer().document().ownerElement();
    16611658    if (!ownerElement)
    16621659        return nullptr;
    16631660
    1664     RenderElement* ownerRenderer = ownerElement->renderer();
     1661    auto* ownerRenderer = ownerElement->renderer();
    16651662    if (!ownerRenderer)
    16661663        return nullptr;
    16671664
    16681665    return ownerRenderer->enclosingLayer();
     1666}
     1667
     1668static RenderLayer* parentLayerCrossFrame(const RenderLayer& layer)
     1669{
     1670    if (auto* parent = layer.parent())
     1671        return parent;
     1672
     1673    return enclosingFrameRenderLayer(layer);
    16691674}
    16701675
     
    65956600}
    65966601
     6602bool RenderLayer::isTransparentOrFullyClippedRespectingParentFrames() const
     6603{
     6604    static const double minimumVisibleOpacity = 0.01;
     6605
     6606    float currentOpacity = 1;
     6607    for (auto* layer = this; layer; layer = parentLayerCrossFrame(*layer)) {
     6608        currentOpacity *= layer->renderer().style().opacity();
     6609        if (currentOpacity < minimumVisibleOpacity)
     6610            return true;
     6611    }
     6612
     6613    for (auto* layer = this; layer; layer = enclosingFrameRenderLayer(*layer)) {
     6614        if (layer->selfClipRect().isEmpty())
     6615            return true;
     6616    }
     6617
     6618    return false;
     6619}
     6620
    65976621TextStream& operator<<(TextStream& ts, const RenderLayer& layer)
    65986622{
  • trunk/Source/WebCore/rendering/RenderLayer.h

    r242333 r242561  
    858858    bool paintingFrequently() const { return m_paintFrequencyTracker.paintingFrequently(); }
    859859
     860    WEBCORE_EXPORT bool isTransparentOrFullyClippedRespectingParentFrames() const;
     861
    860862private:
    861863
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r242401 r242561  
    15281528}
    15291529
    1530 static RenderLayer* enclosingFrameRenderLayer(RenderObject& renderObject)
    1531 {
    1532     auto* owner = renderObject.frame().ownerElement();
    1533     if (!owner)
    1534         return nullptr;
    1535 
    1536     auto* frameOwnerRenderer = owner->renderer();
    1537     return frameOwnerRenderer ? frameOwnerRenderer->enclosingLayer() : nullptr;
    1538 }
    1539 
    1540 static RenderLayer* parentLayerCrossingFrameBoundaries(RenderLayer& layer)
    1541 {
    1542     if (auto* parentLayer = layer.parent())
    1543         return parentLayer;
    1544 
    1545     return enclosingFrameRenderLayer(layer.renderer());
    1546 }
    1547 
    1548 bool RenderObject::isTransparentOrFullyClippedRespectingParentFrames() const
    1549 {
    1550     static const double minimumVisibleOpacity = 0.01;
    1551 
    1552     float currentOpacity = 1;
    1553     for (auto* layer = enclosingLayer(); layer; layer = parentLayerCrossingFrameBoundaries(*layer)) {
    1554         currentOpacity *= layer->renderer().style().opacity();
    1555         if (currentOpacity < minimumVisibleOpacity)
    1556             return true;
    1557     }
    1558 
    1559     for (auto* layer = enclosingLayer(); layer; layer = enclosingFrameRenderLayer(layer->renderer())) {
    1560         if (layer->selfClipRect().isEmpty())
    1561             return true;
    1562     }
    1563 
    1564     return false;
    1565 }
    1566 
    15671530Position RenderObject::positionForPoint(const LayoutPoint& point)
    15681531{
  • trunk/Source/WebCore/rendering/RenderObject.h

    r241183 r242561  
    798798    void initializeFragmentedFlowStateOnInsertion();
    799799    virtual void insertedIntoTree();
    800 
    801     WEBCORE_EXPORT bool isTransparentOrFullyClippedRespectingParentFrames() const;
    802800
    803801protected:
  • trunk/Source/WebKit/ChangeLog

    r242554 r242561  
     12019-03-06  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Move RenderObject::isTransparentOrFullyClippedRespectingParentFrames() to RenderLayer
     4        https://bugs.webkit.org/show_bug.cgi?id=195300
     5
     6        Reviewed by Simon Fraser.
     7
     8        Refactor some logic to use isTransparentOrFullyClippedRespectingParentFrames on RenderLayer rather than
     9        RenderObject; introduce a helper method to ask whether the enclosing layer of a renderer is transparent or
     10        clipped.
     11
     12        * WebProcess/WebPage/ios/WebPageIOS.mm:
     13        (WebKit::enclosingLayerIsTransparentOrFullyClipped):
     14        (WebKit::WebPage::platformEditorState const):
     15        (WebKit::WebPage::requestEvasionRectsAboveSelection):
     16        (WebKit::WebPage::getFocusedElementInformation):
     17
    1182019-03-06  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r242554 r242561  
    180180}
    181181
     182static bool enclosingLayerIsTransparentOrFullyClipped(const RenderObject& renderer)
     183{
     184    auto* enclosingLayer = renderer.enclosingLayer();
     185    return enclosingLayer && enclosingLayer->isTransparentOrFullyClippedRespectingParentFrames();
     186}
     187
    182188void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePostLayoutDataHint shouldIncludePostLayoutData) const
    183189{
     
    247253    if (!selection.isNone()) {
    248254        if (m_focusedElement && m_focusedElement->renderer()) {
    249             postLayoutData.focusedElementRect = view->contentsToRootView(m_focusedElement->renderer()->absoluteBoundingBoxRect());
    250             postLayoutData.caretColor = m_focusedElement->renderer()->style().caretColor();
    251             postLayoutData.elementIsTransparentOrFullyClipped = m_focusedElement->renderer()->isTransparentOrFullyClippedRespectingParentFrames();
     255            auto& renderer = *m_focusedElement->renderer();
     256            postLayoutData.focusedElementRect = view->contentsToRootView(renderer.absoluteBoundingBoxRect());
     257            postLayoutData.caretColor = renderer.style().caretColor();
     258            postLayoutData.elementIsTransparentOrFullyClipped = enclosingLayerIsTransparentOrFullyClipped(renderer);
    252259        }
    253260        computeEditableRootHasContentAndPlainText(selection, postLayoutData);
     
    15241531    }
    15251532
    1526     if (!m_focusedElement || !m_focusedElement->renderer() || m_focusedElement->renderer()->isTransparentOrFullyClippedRespectingParentFrames()) {
     1533    if (!m_focusedElement || !m_focusedElement->renderer() || enclosingLayerIsTransparentOrFullyClipped(*m_focusedElement->renderer())) {
    15271534        reply({ });
    15281535        return;
     
    24902497        information.elementRect = elementRectInRootViewCoordinates(*m_focusedElement, elementFrame);
    24912498        information.nodeFontSize = renderer->style().fontDescription().computedSize();
    2492         information.elementIsTransparentOrFullyClipped = renderer->isTransparentOrFullyClippedRespectingParentFrames();
     2499        information.elementIsTransparentOrFullyClipped = enclosingLayerIsTransparentOrFullyClipped(*renderer);
    24932500
    24942501        bool inFixed = false;
Note: See TracChangeset for help on using the changeset viewer.