Changeset 247184 in webkit


Ignore:
Timestamp:
Jul 5, 2019 4:19:34 PM (5 years ago)
Author:
timothy@apple.com
Message:

Mail's use of punchOutWhiteBackgroundsInDarkMode not working on iOS.
https://bugs.webkit.org/show_bug.cgi?id=199534
rdar://problem/52586836

Reviewed by Simon Fraser.

Tests: css3/color-filters/punch-out-white-backgrounds.html

  • dom/Document.cpp:

(WebCore::Document::compositeOperatorForBackgroundColor const): Added.
Use CompositeDestinationOut for transparent frames, otherwise CompositeDestinationIn.

  • dom/Document.h:
  • rendering/InlineFlowBox.cpp:

(WebCore::InlineFlowBox::paintBoxDecorations): Use compositeOperatorForBackgroundColor.

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::paintRootBoxFillLayers): Ditto.
(WebCore::RenderBox::paintBackground): Ditto.

  • rendering/RenderTableCell.cpp:

(WebCore::RenderTableCell::paintBackgroundsBehindCell): Ditto.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247182 r247184  
     12019-07-05  Timothy Hatcher  <timothy@apple.com>
     2
     3        Mail's use of punchOutWhiteBackgroundsInDarkMode not working on iOS.
     4        https://bugs.webkit.org/show_bug.cgi?id=199534
     5        rdar://problem/52586836
     6
     7        Reviewed by Simon Fraser.
     8
     9        Tests: css3/color-filters/punch-out-white-backgrounds.html
     10
     11        * dom/Document.cpp:
     12        (WebCore::Document::compositeOperatorForBackgroundColor const): Added.
     13        Use CompositeDestinationOut for transparent frames, otherwise CompositeDestinationIn.
     14        * dom/Document.h:
     15        * rendering/InlineFlowBox.cpp:
     16        (WebCore::InlineFlowBox::paintBoxDecorations): Use compositeOperatorForBackgroundColor.
     17        * rendering/RenderBox.cpp:
     18        (WebCore::RenderBox::paintRootBoxFillLayers): Ditto.
     19        (WebCore::RenderBox::paintBackground): Ditto.
     20        * rendering/RenderTableCell.cpp:
     21        (WebCore::RenderTableCell::paintBackgroundsBehindCell): Ditto.
     22
    1232019-07-05  Jer Noble  <jer.noble@apple.com>
    224
  • trunk/Source/WebCore/dom/Document.cpp

    r247148 r247184  
    69786978}
    69796979
     6980CompositeOperator Document::compositeOperatorForBackgroundColor(const Color& color, const RenderObject& renderer) const
     6981{
     6982    if (LIKELY(!settings().punchOutWhiteBackgroundsInDarkMode() || !Color::isWhiteColor(color) || !renderer.useDarkAppearance()))
     6983        return CompositeSourceOver;
     6984
     6985    auto* frameView = view();
     6986    if (!frameView)
     6987        return CompositeSourceOver;
     6988
     6989    // Mail on macOS uses a transparent view, and on iOS it is an opaque view. We need to
     6990    // use different composite modes to get the right results in this case.
     6991    return frameView->isTransparent() ? CompositeDestinationOut : CompositeDestinationIn;
     6992}
     6993
    69806994void Document::didAssociateFormControl(Element& element)
    69816995{
  • trunk/Source/WebCore/dom/Document.h

    r247148 r247184  
    4040#include "FrameDestructionObserver.h"
    4141#include "GenericTaskQueue.h"
     42#include "GraphicsTypes.h"
    4243#include "MediaProducer.h"
    4344#include "MutationObserver.h"
     
    569570
    570571    OptionSet<StyleColor::Options> styleColorOptions(const RenderStyle*) const;
     572    CompositeOperator compositeOperatorForBackgroundColor(const Color&, const RenderObject&) const;
    571573
    572574    WEBCORE_EXPORT Ref<Range> createRange();
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r245543 r247184  
    13701370        paintBoxShadow(paintInfo, lineStyle, Normal, paintRect);
    13711371
    1372     Color color = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
    1373 
    1374     CompositeOperator compositeOp = CompositeSourceOver;
    1375     if (renderer().document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && renderer().useDarkAppearance())
    1376         compositeOp = CompositeDestinationOut;
     1372    auto color = lineStyle.visitedDependentColor(CSSPropertyBackgroundColor);
     1373    auto compositeOp = renderer().document().compositeOperatorForBackgroundColor(color, renderer());
    13771374
    13781375    color = lineStyle.colorByApplyingColorFilter(color);
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r246432 r247184  
    12581258
    12591259    auto& style = rootBackgroundRenderer->style();
    1260 
    12611260    auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
    1262 
    1263     CompositeOperator compositeOp = CompositeSourceOver;
    1264     if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && useDarkAppearance())
    1265         compositeOp = CompositeDestinationOut;
     1261    auto compositeOp = document().compositeOperatorForBackgroundColor(color, *this);
    12661262
    12671263    paintFillLayers(paintInfo, style.colorByApplyingColorFilter(color), style.backgroundLayers(), view().backgroundRect(), BackgroundBleedNone, compositeOp, rootBackgroundRenderer);
     
    13941390        return;
    13951391
    1396     Color backgroundColor = style().visitedDependentColor(CSSPropertyBackgroundColor);
    1397 
    1398     CompositeOperator compositeOp = CompositeSourceOver;
    1399     if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(backgroundColor) && useDarkAppearance())
    1400         compositeOp = CompositeDestinationOut;
     1392    auto backgroundColor = style().visitedDependentColor(CSSPropertyBackgroundColor);
     1393    auto compositeOp = document().compositeOperatorForBackgroundColor(backgroundColor, *this);
    14011394
    14021395    paintFillLayers(paintInfo, style().colorByApplyingColorFilter(backgroundColor), style().backgroundLayers(), paintRect, bleedAvoidance, compositeOp);
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r245543 r247184  
    12881288    auto& bgLayer = style.backgroundLayers();
    12891289
    1290     CompositeOperator compositeOp = CompositeSourceOver;
    1291     Color color = style.visitedDependentColor(CSSPropertyBackgroundColor);
    1292     if (document().settings().punchOutWhiteBackgroundsInDarkMode() && Color::isWhiteColor(color) && useDarkAppearance())
    1293         compositeOp = CompositeDestinationOut;
     1290    auto color = style.visitedDependentColor(CSSPropertyBackgroundColor);
     1291    auto compositeOp = document().compositeOperatorForBackgroundColor(color, *this);
    12941292
    12951293    color = style.colorByApplyingColorFilter(color);
Note: See TracChangeset for help on using the changeset viewer.