<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[167208] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/167208">167208</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2014-04-13 21:28:25 -0700 (Sun, 13 Apr 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Use unique_ptr for FillLayer::m_next
https://bugs.webkit.org/show_bug.cgi?id=75222
Reviewed by Dan Bernstein.
* css/DeprecatedStyleBuilder.cpp:
(WebCore::ApplyPropertyFillLayer::applyInheritValue):
Renamed currChild to just child and prevChild to previousChild.
Changed code to pass ownership of the new FillLayer immediately.
Changed some loops to be for loops.
(WebCore::ApplyPropertyFillLayer::applyInitialValue): Ditto.
(WebCore::ApplyPropertyFillLayer::applyValue): Ditto.
* rendering/RenderBox.cpp:
(WebCore::RenderBox::backgroundHasOpaqueTopLayer): Use reference
instead of pointer.
(WebCore::RenderBox::paintFillLayers): Ditto.
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::paintFillLayerExtended): Ditto.
* rendering/style/FillLayer.cpp:
(WebCore::FillLayer::FillLayer): Removed m_next initializer since it is now an
OwnPtr and initializes automatically. In a couple other places, changed m_next
initializer to use make_unique.
(WebCore::FillLayer::~FillLayer): Wrote loop for deletion of m_next.
(WebCore::FillLayer::operator=): Removed unneeded explicit deletion of m_next.
(WebCore::FillLayer::cullEmptyLayers): Ditto.
(WebCore::clipMax): Marked inline.
(WebCore::FillLayer::computeClipMax): Rewrote to use a loop instead of recursion.
(WebCore::FillLayer::containsImage): Ditto.
(WebCore::FillLayer::imagesAreLoaded): Ditto.
(WebCore::FillLayer::hasOpaqueImage): Rewrote to use && instead of multiple if.
(WebCore::FillLayer::hasImage): Rewrote to use a loop instead of recursion.
(WebCore::FillLayer::hasFixedImage): Ditto.
* rendering/style/FillLayer.h: Changed m_next to be a unique_ptr.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssDeprecatedStyleBuildercpp">trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxcpp">trunk/Source/WebCore/rendering/RenderBox.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayercpp">trunk/Source/WebCore/rendering/style/FillLayer.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingstyleFillLayerh">trunk/Source/WebCore/rendering/style/FillLayer.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/ChangeLog        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2014-04-12 Darin Adler <darin@apple.com>
+
+ Use unique_ptr for FillLayer::m_next
+ https://bugs.webkit.org/show_bug.cgi?id=75222
+
+ Reviewed by Dan Bernstein.
+
+ * css/DeprecatedStyleBuilder.cpp:
+ (WebCore::ApplyPropertyFillLayer::applyInheritValue):
+ Renamed currChild to just child and prevChild to previousChild.
+ Changed code to pass ownership of the new FillLayer immediately.
+ Changed some loops to be for loops.
+ (WebCore::ApplyPropertyFillLayer::applyInitialValue): Ditto.
+ (WebCore::ApplyPropertyFillLayer::applyValue): Ditto.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::backgroundHasOpaqueTopLayer): Use reference
+ instead of pointer.
+ (WebCore::RenderBox::paintFillLayers): Ditto.
+ * rendering/RenderBoxModelObject.cpp:
+ (WebCore::RenderBoxModelObject::paintFillLayerExtended): Ditto.
+
+ * rendering/style/FillLayer.cpp:
+ (WebCore::FillLayer::FillLayer): Removed m_next initializer since it is now an
+ OwnPtr and initializes automatically. In a couple other places, changed m_next
+ initializer to use make_unique.
+ (WebCore::FillLayer::~FillLayer): Wrote loop for deletion of m_next.
+ (WebCore::FillLayer::operator=): Removed unneeded explicit deletion of m_next.
+ (WebCore::FillLayer::cullEmptyLayers): Ditto.
+ (WebCore::clipMax): Marked inline.
+ (WebCore::FillLayer::computeClipMax): Rewrote to use a loop instead of recursion.
+ (WebCore::FillLayer::containsImage): Ditto.
+ (WebCore::FillLayer::imagesAreLoaded): Ditto.
+ (WebCore::FillLayer::hasOpaqueImage): Rewrote to use && instead of multiple if.
+ (WebCore::FillLayer::hasImage): Rewrote to use a loop instead of recursion.
+ (WebCore::FillLayer::hasFixedImage): Ditto.
+
+ * rendering/style/FillLayer.h: Changed m_next to be a unique_ptr.
+
</ins><span class="cx"> 2014-04-13 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> [QuickLook] Move file system-related code into WebKit
</span></span></pre></div>
<a id="trunkSourceWebCorecssDeprecatedStyleBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -520,72 +520,60 @@
</span><span class="cx"> if (*(styleResolver->parentStyle()->*layersFunction)() == *(styleResolver->style()->*layersFunction)())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)();
- FillLayer* prevChild = 0;
- const FillLayer* currParent = (styleResolver->parentStyle()->*layersFunction)();
- while (currParent && (currParent->*testFunction)()) {
- if (!currChild) {
- /* Need to make a new layer.*/
- currChild = new FillLayer(fillLayerType);
- prevChild->setNext(currChild);
</del><ins>+ auto* child = (styleResolver->style()->*accessLayersFunction)();
+ FillLayer* previousChild = nullptr;
+ for (auto* parent = (styleResolver->parentStyle()->*layersFunction)(); parent && (parent->*testFunction)(); parent = parent->next()) {
+ if (!child) {
+ previousChild->setNext(std::make_unique<FillLayer>(fillLayerType));
+ child = previousChild->next();
</ins><span class="cx"> }
</span><del>- (currChild->*setFunction)((currParent->*getFunction)());
- prevChild = currChild;
- currChild = prevChild->next();
- currParent = currParent->next();
</del><ins>+ (child->*setFunction)((parent->*getFunction)());
+ previousChild = child;
+ child = previousChild->next();
</ins><span class="cx"> }
</span><del>-
- while (currChild) {
- /* Reset any remaining layers to not have the property set. */
- (currChild->*clearFunction)();
- currChild = currChild->next();
- }
</del><ins>+ for (; child; child = child->next())
+ (child->*clearFunction)();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
</span><span class="cx"> {
</span><span class="cx"> // Check for (single-layer) no-op before clearing anything.
</span><span class="cx"> const FillLayer& layers = *(styleResolver->style()->*layersFunction)();
</span><del>- bool firstLayerHasValue = (layers.*testFunction)();
- if (!layers.next() && (!firstLayerHasValue || (layers.*getFunction)() == (*initialFunction)(fillLayerType)))
</del><ins>+ if (!layers.next() && (!(layers.*testFunction)() || (layers.*getFunction)() == (*initialFunction)(fillLayerType)))
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)();
- (currChild->*setFunction)((*initialFunction)(fillLayerType));
- for (currChild = currChild->next(); currChild; currChild = currChild->next())
- (currChild->*clearFunction)();
</del><ins>+ FillLayer* child = (styleResolver->style()->*accessLayersFunction)();
+ (child->*setFunction)((*initialFunction)(fillLayerType));
+ for (child = child->next(); child; child = child->next())
+ (child->*clearFunction)();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
</span><span class="cx"> {
</span><del>- FillLayer* currChild = (styleResolver->style()->*accessLayersFunction)();
- FillLayer* prevChild = 0;
</del><ins>+ FillLayer* child = (styleResolver->style()->*accessLayersFunction)();
+ FillLayer* previousChild = nullptr;
</ins><span class="cx"> if (value->isValueList()
</span><span class="cx"> #if ENABLE(CSS_IMAGE_SET)
</span><span class="cx"> && !value->isImageSetValue()
</span><span class="cx"> #endif
</span><span class="cx"> ) {
</span><del>- /* Walk each value and put it into a layer, creating new layers as needed. */
- CSSValueList* valueList = toCSSValueList(value);
- for (unsigned int i = 0; i < valueList->length(); i++) {
- if (!currChild) {
- /* Need to make a new layer to hold this value */
- currChild = new FillLayer(fillLayerType);
- prevChild->setNext(currChild);
</del><ins>+ // Walk each value and put it into a layer, creating new layers as needed.
+ CSSValueList& valueList = toCSSValueList(*value);
+ for (unsigned i = 0; i < valueList.length(); i++) {
+ if (!child) {
+ previousChild->setNext(std::make_unique<FillLayer>(fillLayerType));
+ child = previousChild->next();
</ins><span class="cx"> }
</span><del>- (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, valueList->itemWithoutBoundsCheck(i));
- prevChild = currChild;
- currChild = currChild->next();
</del><ins>+ (styleResolver->styleMap()->*mapFillFunction)(propertyId, child, valueList.itemWithoutBoundsCheck(i));
+ previousChild = child;
+ child = child->next();
</ins><span class="cx"> }
</span><span class="cx"> } else {
</span><del>- (styleResolver->styleMap()->*mapFillFunction)(propertyId, currChild, value);
- currChild = currChild->next();
</del><ins>+ (styleResolver->styleMap()->*mapFillFunction)(propertyId, child, value);
+ child = child->next();
</ins><span class="cx"> }
</span><del>- while (currChild) {
- /* Reset all remaining layers to not have the property set. */
- (currChild->*clearFunction)();
- currChild = currChild->next();
- }
</del><ins>+ for (; child; child = child->next())
+ (child->*clearFunction)();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
</span><span class="lines">@@ -2499,9 +2487,9 @@
</span><span class="cx"> #endif
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitBoxDirection, ApplyPropertyDefault<EBoxDirection, &RenderStyle::boxDirection, EBoxDirection, &RenderStyle::setBoxDirection, EBoxDirection, &RenderStyle::initialBoxDirection>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitBoxFlex, ApplyPropertyDefault<float, &RenderStyle::boxFlex, float, &RenderStyle::setBoxFlex, float, &RenderStyle::initialBoxFlex>::createHandler());
</span><del>- setPropertyHandler(CSSPropertyWebkitBoxFlexGroup, ApplyPropertyDefault<unsigned int, &RenderStyle::boxFlexGroup, unsigned int, &RenderStyle::setBoxFlexGroup, unsigned int, &RenderStyle::initialBoxFlexGroup>::createHandler());
</del><ins>+ setPropertyHandler(CSSPropertyWebkitBoxFlexGroup, ApplyPropertyDefault<unsigned, &RenderStyle::boxFlexGroup, unsigned, &RenderStyle::setBoxFlexGroup, unsigned, &RenderStyle::initialBoxFlexGroup>::createHandler());
</ins><span class="cx"> setPropertyHandler(CSSPropertyWebkitBoxLines, ApplyPropertyDefault<EBoxLines, &RenderStyle::boxLines, EBoxLines, &RenderStyle::setBoxLines, EBoxLines, &RenderStyle::initialBoxLines>::createHandler());
</span><del>- setPropertyHandler(CSSPropertyWebkitBoxOrdinalGroup, ApplyPropertyDefault<unsigned int, &RenderStyle::boxOrdinalGroup, unsigned int, &RenderStyle::setBoxOrdinalGroup, unsigned int, &RenderStyle::initialBoxOrdinalGroup>::createHandler());
</del><ins>+ setPropertyHandler(CSSPropertyWebkitBoxOrdinalGroup, ApplyPropertyDefault<unsigned, &RenderStyle::boxOrdinalGroup, unsigned, &RenderStyle::setBoxOrdinalGroup, unsigned, &RenderStyle::initialBoxOrdinalGroup>::createHandler());
</ins><span class="cx"> setPropertyHandler(CSSPropertyWebkitBoxOrient, ApplyPropertyDefault<EBoxOrient, &RenderStyle::boxOrient, EBoxOrient, &RenderStyle::setBoxOrient, EBoxOrient, &RenderStyle::initialBoxOrient>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitBoxPack, ApplyPropertyDefault<EBoxPack, &RenderStyle::boxPack, EBoxPack, &RenderStyle::setBoxPack, EBoxPack, &RenderStyle::initialBoxPack>::createHandler());
</span><span class="cx"> setPropertyHandler(CSSPropertyWebkitColorCorrection, ApplyPropertyDefault<ColorSpace, &RenderStyle::colorSpace, ColorSpace, &RenderStyle::setColorSpace, ColorSpace, &RenderStyle::initialColorSpace>::createHandler());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBox.cpp        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -1409,7 +1409,7 @@
</span><span class="cx"> if (hasOverflowClip() && fillLayer->attachment() == LocalBackgroundAttachment)
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (fillLayer->hasOpaqueImage(this) && fillLayer->hasRepeatXY() && fillLayer->image()->canRender(this, style().effectiveZoom()))
</del><ins>+ if (fillLayer->hasOpaqueImage(*this) && fillLayer->hasRepeatXY() && fillLayer->image()->canRender(this, style().effectiveZoom()))
</ins><span class="cx"> return true;
</span><span class="cx">
</span><span class="cx"> // If there is only one layer and no image, check whether the background color is opaque
</span><span class="lines">@@ -1511,7 +1511,7 @@
</span><span class="cx"> shouldDrawBackgroundInSeparateBuffer = true;
</span><span class="cx">
</span><span class="cx"> // The clipOccludesNextLayers condition must be evaluated first to avoid short-circuiting.
</span><del>- if (curLayer->clipOccludesNextLayers(curLayer == fillLayer) && curLayer->hasOpaqueImage(this) && curLayer->image()->canRender(this, style().effectiveZoom()) && curLayer->hasRepeatXY() && curLayer->blendMode() == BlendModeNormal)
</del><ins>+ if (curLayer->clipOccludesNextLayers(curLayer == fillLayer) && curLayer->hasOpaqueImage(*this) && curLayer->image()->canRender(this, style().effectiveZoom()) && curLayer->hasRepeatXY() && curLayer->blendMode() == BlendModeNormal)
</ins><span class="cx"> break;
</span><span class="cx"> curLayer = curLayer->next();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -774,7 +774,7 @@
</span><span class="cx"> if (!bgLayer->next()) {
</span><span class="cx"> LayoutRect backgroundRect(scrolledPaintRect);
</span><span class="cx"> bool boxShadowShouldBeAppliedToBackground = this->boxShadowShouldBeAppliedToBackground(bleedAvoidance, box);
</span><del>- if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(this) || !bgLayer->hasRepeatXY()) {
</del><ins>+ if (boxShadowShouldBeAppliedToBackground || !shouldPaintBackgroundImage || !bgLayer->hasOpaqueImage(*this) || !bgLayer->hasRepeatXY()) {
</ins><span class="cx"> if (!boxShadowShouldBeAppliedToBackground)
</span><span class="cx"> backgroundRect.intersect(paintInfo.rect);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.cpp (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.cpp        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/rendering/style/FillLayer.cpp        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
</span><del>- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="cx"> * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -25,24 +25,23 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> struct SameSizeAsFillLayer {
</span><del>- FillLayer* m_next;
</del><ins>+ FillLayer* next;
</ins><span class="cx">
</span><del>- RefPtr<StyleImage> m_image;
</del><ins>+ RefPtr<StyleImage> image;
</ins><span class="cx">
</span><del>- Length m_xPosition;
- Length m_yPosition;
</del><ins>+ Length x;
+ Length y;
</ins><span class="cx">
</span><del>- LengthSize m_sizeLength;
</del><ins>+ LengthSize sizeLength;
</ins><span class="cx">
</span><del>- unsigned m_bitfields: 32;
- unsigned m_bitfields2: 1;
</del><ins>+ unsigned bitfields : 32;
+ unsigned bitfields2 : 11;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> COMPILE_ASSERT(sizeof(FillLayer) == sizeof(SameSizeAsFillLayer), FillLayer_should_stay_small);
</span><span class="cx">
</span><span class="cx"> FillLayer::FillLayer(EFillLayerType type)
</span><del>- : m_next(0)
- , m_image(FillLayer::initialFillImage(type))
</del><ins>+ : m_image(FillLayer::initialFillImage(type))
</ins><span class="cx"> , m_xPosition(FillLayer::initialFillXPosition(type))
</span><span class="cx"> , m_yPosition(FillLayer::initialFillYPosition(type))
</span><span class="cx"> , m_sizeLength(FillLayer::initialFillSizeLength(type))
</span><span class="lines">@@ -74,7 +73,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FillLayer::FillLayer(const FillLayer& o)
</span><del>- : m_next(o.m_next ? new FillLayer(*o.m_next) : 0)
</del><ins>+ : m_next(o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr)
</ins><span class="cx"> , m_image(o.m_image)
</span><span class="cx"> , m_xPosition(o.m_xPosition)
</span><span class="cx"> , m_yPosition(o.m_yPosition)
</span><span class="lines">@@ -108,15 +107,13 @@
</span><span class="cx">
</span><span class="cx"> FillLayer::~FillLayer()
</span><span class="cx"> {
</span><del>- delete m_next;
</del><ins>+ // Delete the layers in a loop rather than allowing recursive calls to the destructors.
+ for (std::unique_ptr<FillLayer> next = std::move(m_next); next; next = std::move(next->m_next)) { }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> FillLayer& FillLayer::operator=(const FillLayer& o)
</span><span class="cx"> {
</span><del>- if (m_next != o.m_next) {
- delete m_next;
- m_next = o.m_next ? new FillLayer(*o.m_next) : 0;
- }
</del><ins>+ m_next = o.m_next ? std::make_unique<FillLayer>(*o.m_next) : nullptr;
</ins><span class="cx">
</span><span class="cx"> m_image = o.m_image;
</span><span class="cx"> m_xPosition = o.m_xPosition;
</span><span class="lines">@@ -155,14 +152,14 @@
</span><span class="cx"> bool FillLayer::operator==(const FillLayer& o) const
</span><span class="cx"> {
</span><span class="cx"> // We do not check the "isSet" booleans for each property, since those are only used during initial construction
</span><del>- // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
</del><ins>+ // to propagate patterns into layers. All layer comparisons happen after values have all been filled in anyway.
</ins><span class="cx"> return StyleImage::imagesEquivalent(m_image.get(), o.m_image.get()) && m_xPosition == o.m_xPosition && m_yPosition == o.m_yPosition
</span><del>- && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
- && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
- && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX
- && m_repeatY == o.m_repeatY && m_sizeType == o.m_sizeType && m_maskSourceType == o.m_maskSourceType
- && m_sizeLength == o.m_sizeLength && m_type == o.m_type
- && ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
</del><ins>+ && m_backgroundXOrigin == o.m_backgroundXOrigin && m_backgroundYOrigin == o.m_backgroundYOrigin
+ && m_attachment == o.m_attachment && m_clip == o.m_clip && m_composite == o.m_composite
+ && m_blendMode == o.m_blendMode && m_origin == o.m_origin && m_repeatX == o.m_repeatX
+ && m_repeatY == o.m_repeatY && m_sizeType == o.m_sizeType && m_maskSourceType == o.m_maskSourceType
+ && m_sizeLength == o.m_sizeLength && m_type == o.m_type
+ && ((m_next && o.m_next) ? *m_next == *o.m_next : m_next == o.m_next);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void FillLayer::fillUnsetProperties()
</span><span class="lines">@@ -290,18 +287,15 @@
</span><span class="cx">
</span><span class="cx"> void FillLayer::cullEmptyLayers()
</span><span class="cx"> {
</span><del>- FillLayer* next;
- for (FillLayer* p = this; p; p = next) {
- next = p->m_next;
- if (next && !next->isImageSet()) {
- delete next;
- p->m_next = 0;
</del><ins>+ for (FillLayer* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_next && !layer->m_next->isImageSet()) {
+ layer->m_next = nullptr;
</ins><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static EFillBox clipMax(EFillBox clipA, EFillBox clipB)
</del><ins>+static inline EFillBox clipMax(EFillBox clipA, EFillBox clipB)
</ins><span class="cx"> {
</span><span class="cx"> if (clipA == BorderFillBox || clipB == BorderFillBox)
</span><span class="cx"> return BorderFillBox;
</span><span class="lines">@@ -314,11 +308,15 @@
</span><span class="cx">
</span><span class="cx"> void FillLayer::computeClipMax() const
</span><span class="cx"> {
</span><del>- if (m_next) {
- m_next->computeClipMax();
- m_clipMax = clipMax(clip(), m_next->clip());
- } else
- m_clipMax = m_clip;
</del><ins>+ Vector<const FillLayer*, 4> layers;
+ for (auto* layer = this; layer; layer = layer->m_next.get())
+ layers.append(layer);
+ EFillBox computedClipMax = TextFillBox;
+ for (unsigned i = layers.size(); i; --i) {
+ auto& layer = *layers[i - 1];
+ computedClipMax = clipMax(computedClipMax, layer.clip());
+ layer.m_clipMax = computedClipMax;
+ }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool FillLayer::clipOccludesNextLayers(bool firstLayer) const
</span><span class="lines">@@ -328,29 +326,25 @@
</span><span class="cx"> return m_clip == m_clipMax;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool FillLayer::containsImage(StyleImage* s) const
</del><ins>+bool FillLayer::containsImage(StyleImage& image) const
</ins><span class="cx"> {
</span><del>- if (!s)
- return false;
- if (m_image && *s == *m_image)
- return true;
- if (m_next)
- return m_next->containsImage(s);
</del><ins>+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && image == *layer->m_image)
+ return true;
+ }
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool FillLayer::imagesAreLoaded() const
</span><span class="cx"> {
</span><del>- const FillLayer* curr;
- for (curr = this; curr; curr = curr->next()) {
- if (curr->m_image && !curr->m_image->isLoaded())
</del><ins>+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && !layer->m_image->isLoaded())
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool FillLayer::hasOpaqueImage(const RenderElement* renderer) const
</del><ins>+bool FillLayer::hasOpaqueImage(const RenderElement& renderer) const
</ins><span class="cx"> {
</span><span class="cx"> if (!m_image)
</span><span class="cx"> return false;
</span><span class="lines">@@ -358,18 +352,30 @@
</span><span class="cx"> if (m_composite == CompositeClear || m_composite == CompositeCopy)
</span><span class="cx"> return true;
</span><span class="cx">
</span><del>- if (m_blendMode != BlendModeNormal)
- return false;
</del><ins>+ return m_blendMode == BlendModeNormal && m_composite == CompositeSourceOver && m_image->knownToBeOpaque(&renderer);
+}
</ins><span class="cx">
</span><del>- if (m_composite == CompositeSourceOver)
- return m_image->knownToBeOpaque(renderer);
</del><ins>+bool FillLayer::hasRepeatXY() const
+{
+ return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
+}
</ins><span class="cx">
</span><ins>+bool FillLayer::hasImage() const
+{
+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image)
+ return true;
+ }
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool FillLayer::hasRepeatXY() const
</del><ins>+bool FillLayer::hasFixedImage() const
</ins><span class="cx"> {
</span><del>- return m_repeatX == RepeatFill && m_repeatY == RepeatFill;
</del><ins>+ for (auto* layer = this; layer; layer = layer->m_next.get()) {
+ if (layer->m_image && layer->m_attachment == FixedBackgroundAttachment)
+ return true;
+ }
+ return false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingstyleFillLayerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/style/FillLayer.h (167207 => 167208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/style/FillLayer.h        2014-04-14 02:57:33 UTC (rev 167207)
+++ trunk/Source/WebCore/rendering/style/FillLayer.h        2014-04-14 04:28:25 UTC (rev 167208)
</span><span class="lines">@@ -2,7 +2,7 @@
</span><span class="cx"> * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
</span><span class="cx"> * (C) 2000 Antti Koivisto (koivisto@kde.org)
</span><span class="cx"> * (C) 2000 Dirk Mueller (mueller@kde.org)
</span><del>- * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2003, 2005, 2006, 2007, 2008, 2014 Apple Inc. All rights reserved.
</ins><span class="cx"> * Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
</span><span class="cx"> *
</span><span class="cx"> * This library is free software; you can redistribute it and/or
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #define FillLayer_h
</span><span class="cx">
</span><span class="cx"> #include "GraphicsTypes.h"
</span><del>-#include "Length.h"
</del><span class="cx"> #include "LengthSize.h"
</span><span class="cx"> #include "RenderStyleConstants.h"
</span><span class="cx"> #include "StyleImage.h"
</span><span class="lines">@@ -42,29 +41,30 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>- FillSize(EFillSizeType t, LengthSize size)
- : type(t)
- , size(std::move(size))
</del><ins>+ FillSize(EFillSizeType type, const LengthSize& size)
+ : type(type)
+ , size(size)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>- bool operator==(const FillSize& o) const
- {
- return type == o.type && size == o.size;
- }
- bool operator!=(const FillSize& o) const
- {
- return !(*this == o);
- }
-
</del><span class="cx"> EFillSizeType type;
</span><span class="cx"> LengthSize size;
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+inline bool operator==(const FillSize& a, const FillSize& b)
+{
+ return a.type == b.type && a.size == b.size;
+}
+
+inline bool operator!=(const FillSize& a, const FillSize& b)
+{
+ return !(a == b);
+}
+
</ins><span class="cx"> class FillLayer {
</span><span class="cx"> WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> public:
</span><del>- FillLayer(EFillLayerType);
</del><ins>+ explicit FillLayer(EFillLayerType);
</ins><span class="cx"> ~FillLayer();
</span><span class="cx">
</span><span class="cx"> StyleImage* image() const { return m_image.get(); }
</span><span class="lines">@@ -84,8 +84,8 @@
</span><span class="cx"> FillSize size() const { return FillSize(static_cast<EFillSizeType>(m_sizeType), m_sizeLength); }
</span><span class="cx"> EMaskSourceType maskSourceType() const { return static_cast<EMaskSourceType>(m_maskSourceType); }
</span><span class="cx">
</span><del>- const FillLayer* next() const { return m_next; }
- FillLayer* next() { return m_next; }
</del><ins>+ const FillLayer* next() const { return m_next.get(); }
+ FillLayer* next() { return m_next.get(); }
</ins><span class="cx">
</span><span class="cx"> bool isImageSet() const { return m_imageSet; }
</span><span class="cx"> bool isXPositionSet() const { return m_xPosSet; }
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> bool isSizeSet() const { return m_sizeType != SizeNone; }
</span><span class="cx"> bool isMaskSourceTypeSet() const { return m_maskSourceTypeSet; }
</span><span class="cx">
</span><del>- void setImage(PassRefPtr<StyleImage> i) { m_image = i; m_imageSet = true; }
</del><ins>+ void setImage(PassRefPtr<StyleImage> image) { m_image = image; m_imageSet = true; }
</ins><span class="cx"> void setXPosition(Length length) { m_xPosition = std::move(length); m_xPosSet = true; }
</span><span class="cx"> void setYPosition(Length length) { m_yPosition = std::move(length); m_yPosSet = true; }
</span><span class="cx"> void setBackgroundXOrigin(BackgroundEdgeOrigin o) { m_backgroundXOrigin = o; m_backgroundOriginSet = true; }
</span><span class="lines">@@ -119,16 +119,8 @@
</span><span class="cx"> void setMaskSourceType(EMaskSourceType m) { m_maskSourceType = m; m_maskSourceTypeSet = true; }
</span><span class="cx">
</span><span class="cx"> void clearImage() { m_image.clear(); m_imageSet = false; }
</span><del>- void clearXPosition()
- {
- m_xPosSet = false;
- m_backgroundOriginSet = false;
- }
- void clearYPosition()
- {
- m_yPosSet = false;
- m_backgroundOriginSet = false;
- }
</del><ins>+ void clearXPosition() { m_xPosSet = false; m_backgroundOriginSet = false; }
+ void clearYPosition() { m_yPosSet = false; m_backgroundOriginSet = false; }
</ins><span class="cx">
</span><span class="cx"> void clearAttachment() { m_attachmentSet = false; }
</span><span class="cx"> void clearClip() { m_clipSet = false; }
</span><span class="lines">@@ -140,35 +132,19 @@
</span><span class="cx"> void clearSize() { m_sizeType = SizeNone; }
</span><span class="cx"> void clearMaskSourceType() { m_maskSourceTypeSet = false; }
</span><span class="cx">
</span><del>- void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
</del><ins>+ void setNext(std::unique_ptr<FillLayer> next) { m_next = std::move(next); }
</ins><span class="cx">
</span><del>- FillLayer& operator=(const FillLayer& o);
- FillLayer(const FillLayer& o);
</del><ins>+ FillLayer& operator=(const FillLayer&);
+ FillLayer(const FillLayer&);
</ins><span class="cx">
</span><del>- bool operator==(const FillLayer& o) const;
- bool operator!=(const FillLayer& o) const
- {
- return !(*this == o);
- }
</del><ins>+ bool operator==(const FillLayer&) const;
+ bool operator!=(const FillLayer& other) const { return !(*this == other); }
</ins><span class="cx">
</span><del>- bool containsImage(StyleImage*) const;
</del><ins>+ bool containsImage(StyleImage&) const;
</ins><span class="cx"> bool imagesAreLoaded() const;
</span><del>-
- bool hasImage() const
- {
- if (m_image)
- return true;
- return m_next ? m_next->hasImage() : false;
- }
-
- bool hasFixedImage() const
- {
- if (m_image && m_attachment == FixedBackgroundAttachment)
- return true;
- return m_next ? m_next->hasFixedImage() : false;
- }
-
- bool hasOpaqueImage(const RenderElement*) const;
</del><ins>+ bool hasImage() const;
+ bool hasFixedImage() const;
+ bool hasOpaqueImage(const RenderElement&) const;
</ins><span class="cx"> bool hasRepeatXY() const;
</span><span class="cx"> bool clipOccludesNextLayers(bool firstLayer) const;
</span><span class="cx">
</span><span class="lines">@@ -197,10 +173,8 @@
</span><span class="cx">
</span><span class="cx"> void computeClipMax() const;
</span><span class="cx">
</span><del>- FillLayer() { }
</del><ins>+ std::unique_ptr<FillLayer> m_next;
</ins><span class="cx">
</span><del>- FillLayer* m_next;
-
</del><span class="cx"> RefPtr<StyleImage> m_image;
</span><span class="cx">
</span><span class="cx"> Length m_xPosition;
</span></span></pre>
</div>
</div>
</body>
</html>