Diff
Modified: trunk/Source/WebCore/ChangeLog (233266 => 233267)
--- trunk/Source/WebCore/ChangeLog 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/ChangeLog 2018-06-27 18:07:00 UTC (rev 233267)
@@ -1,3 +1,61 @@
+2018-06-27 David Kilzer <[email protected]>
+
+ Fix clang static analyzer warnings: Branch condition evaluates to a garbage value
+ <https://webkit.org/b/186968>
+
+ Reviewed by Zalan Bujtas.
+
+ This patch changes two stack-allocated `bool` variables into
+ `std::optional<bool>` since the functions that set the variable
+ may return early without setting it. It also changes one
+ stack-allocated pointer to be initialized to `nullptr`.
+
+ * animation/AnimationTimeline.cpp:
+ (WebCore::AnimationTimeline::updateCSSTransitionsForElement):
+ Update for change to CSSPropertyAnimation::getPropertyAtIndex()
+ argument type.
+
+ * editing/ios/EditorIOS.mm:
+ (WebCore::Editor::writeImageToPasteboard): Initialize
+ `cachedImage` stack pointer to nullptr since getImage() has an
+ early return that doesn't set `cachedImage`.
+ * editing/mac/EditorMac.mm:
+ (WebCore::Editor::writeImageToPasteboard): Ditto.
+
+ * page/animation/CSSPropertyAnimation.cpp:
+ (WebCore::CSSPropertyAnimation::getPropertyAtIndex):
+ * page/animation/CSSPropertyAnimation.h:
+ (WebCore::CSSPropertyAnimation::getPropertyAtIndex):
+ - Change method to take `std::optional<bool>` instead of `bool`
+ as second argument since the method may return early without
+ setting `isShorthand`.
+
+ * page/animation/CompositeAnimation.cpp:
+ (WebCore::CompositeAnimation::updateTransitions): Update for
+ change to CSSPropertyAnimation::getPropertyAtIndex() argument
+ type.
+
+ * rendering/InlineFlowBox.cpp:
+ (WebCore::InlineFlowBox::placeBoxesInBlockDirection): Also
+ rename local `emphasisMarkIsOver` to `emphasisMarkIsAbove` to
+ match other call sites.
+ (WebCore::InlineFlowBox::addTextBoxVisualOverflow):
+ (WebCore::InlineFlowBox::computeOverAnnotationAdjustment const):
+ (WebCore::InlineFlowBox::computeUnderAnnotationAdjustment const):
+ - Update for change to InlineTextBox::emphasisMarkExistsAndIsAbove()
+ argument type.
+ * rendering/InlineTextBox.cpp:
+ (WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove const):
+ - Change method to take `std::optional<bool>` instead of `bool`
+ as second argument since the method may return early without
+ setting `above`.
+ (WebCore::InlineTextBox::paintMarkedTextForeground):
+ - Update for change to InlineTextBox::emphasisMarkExistsAndIsAbove()
+ argument type.
+ * rendering/InlineTextBox.h:
+ (WebCore::InlineTextBox::emphasisMarkExistsAndIsAbove const):
+ - Change method to take `std::optional<bool>` instead of `bool`.
+
2018-06-27 Zalan Bujtas <[email protected]>
[LFC] Move formatting context root layout logic to a dedicated function.
Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (233266 => 233267)
--- trunk/Source/WebCore/animation/AnimationTimeline.cpp 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp 2018-06-27 18:07:00 UTC (rev 233267)
@@ -320,9 +320,9 @@
auto numberOfProperties = CSSPropertyAnimation::getNumProperties();
for (int propertyIndex = 0; propertyIndex < numberOfProperties; ++propertyIndex) {
- bool isShorthand;
+ std::optional<bool> isShorthand;
auto property = CSSPropertyAnimation::getPropertyAtIndex(propertyIndex, isShorthand);
- if (isShorthand)
+ if (isShorthand && *isShorthand)
continue;
const Animation* matchingBackingAnimation = nullptr;
Modified: trunk/Source/WebCore/editing/ios/EditorIOS.mm (233266 => 233267)
--- trunk/Source/WebCore/editing/ios/EditorIOS.mm 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/editing/ios/EditorIOS.mm 2018-06-27 18:07:00 UTC (rev 233267)
@@ -189,7 +189,7 @@
PasteboardImage pasteboardImage;
RefPtr<Image> image;
- CachedImage* cachedImage;
+ CachedImage* cachedImage = nullptr;
getImage(imageElement, image, cachedImage);
if (!image)
return;
Modified: trunk/Source/WebCore/editing/mac/EditorMac.mm (233266 => 233267)
--- trunk/Source/WebCore/editing/mac/EditorMac.mm 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/editing/mac/EditorMac.mm 2018-06-27 18:07:00 UTC (rev 233267)
@@ -263,7 +263,7 @@
{
PasteboardImage pasteboardImage;
- CachedImage* cachedImage;
+ CachedImage* cachedImage = nullptr;
getImage(imageElement, pasteboardImage.image, cachedImage);
if (!pasteboardImage.image)
return;
Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp (233266 => 233267)
--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.cpp 2018-06-27 18:07:00 UTC (rev 233267)
@@ -1790,7 +1790,7 @@
return false;
}
-CSSPropertyID CSSPropertyAnimation::getPropertyAtIndex(int i, bool& isShorthand)
+CSSPropertyID CSSPropertyAnimation::getPropertyAtIndex(int i, std::optional<bool>& isShorthand)
{
CSSPropertyAnimationWrapperMap& map = CSSPropertyAnimationWrapperMap::singleton();
Modified: trunk/Source/WebCore/page/animation/CSSPropertyAnimation.h (233266 => 233267)
--- trunk/Source/WebCore/page/animation/CSSPropertyAnimation.h 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/page/animation/CSSPropertyAnimation.h 2018-06-27 18:07:00 UTC (rev 233267)
@@ -42,7 +42,7 @@
static bool animationOfPropertyIsAccelerated(CSSPropertyID);
static bool propertiesEqual(CSSPropertyID, const RenderStyle* a, const RenderStyle* b);
static bool canPropertyBeInterpolated(CSSPropertyID, const RenderStyle* a, const RenderStyle* b);
- static CSSPropertyID getPropertyAtIndex(int, bool& isShorthand);
+ static CSSPropertyID getPropertyAtIndex(int, std::optional<bool>& isShorthand);
static int getNumProperties();
static HashSet<CSSPropertyID> animatableShorthandsAffectingProperty(CSSPropertyID);
Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.cpp (233266 => 233267)
--- trunk/Source/WebCore/page/animation/CompositeAnimation.cpp 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.cpp 2018-06-27 18:07:00 UTC (rev 233267)
@@ -109,9 +109,9 @@
for (int propertyIndex = 0; propertyIndex < CSSPropertyAnimation::getNumProperties(); ++propertyIndex) {
if (all) {
// Get the next property which is not a shorthand.
- bool isShorthand;
+ std::optional<bool> isShorthand;
prop = CSSPropertyAnimation::getPropertyAtIndex(propertyIndex, isShorthand);
- if (isShorthand)
+ if (isShorthand && *isShorthand)
continue;
}
Modified: trunk/Source/WebCore/rendering/InlineFlowBox.cpp (233266 => 233267)
--- trunk/Source/WebCore/rendering/InlineFlowBox.cpp 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/rendering/InlineFlowBox.cpp 2018-06-27 18:07:00 UTC (rev 233267)
@@ -698,9 +698,9 @@
}
}
if (is<InlineTextBox>(*child)) {
- bool emphasisMarkIsOver;
- if (downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsOver)) {
- if (emphasisMarkIsOver != childLineStyle.isFlippedLinesWritingMode())
+ std::optional<bool> emphasisMarkIsAbove;
+ if (downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove)) {
+ if (emphasisMarkIsAbove && (*emphasisMarkIsAbove != childLineStyle.isFlippedLinesWritingMode()))
hasAnnotationsBefore = true;
else
hasAnnotationsAfter = true;
@@ -894,10 +894,10 @@
int leftGlyphOverflow = -strokeOverflow - leftGlyphEdge;
int rightGlyphOverflow = strokeOverflow + rightGlyphEdge;
- bool emphasisMarkIsAbove;
+ std::optional<bool> emphasisMarkIsAbove;
if (lineStyle.textEmphasisMark() != TextEmphasisMark::None && textBox.emphasisMarkExistsAndIsAbove(lineStyle, emphasisMarkIsAbove)) {
int emphasisMarkHeight = lineStyle.fontCascade().emphasisMarkHeight(lineStyle.textEmphasisMarkString());
- if (emphasisMarkIsAbove == !lineStyle.isFlippedLinesWritingMode())
+ if (emphasisMarkIsAbove && (*emphasisMarkIsAbove == !lineStyle.isFlippedLinesWritingMode()))
topGlyphOverflow = std::min(topGlyphOverflow, -emphasisMarkHeight);
else
bottomGlyphOverflow = std::max(bottomGlyphOverflow, emphasisMarkHeight);
@@ -1575,8 +1575,8 @@
if (is<InlineTextBox>(*child)) {
const RenderStyle& childLineStyle = child->lineStyle();
- bool emphasisMarkIsAbove;
- if (childLineStyle.textEmphasisMark() != TextEmphasisMark::None && downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove) && emphasisMarkIsAbove) {
+ std::optional<bool> emphasisMarkIsAbove;
+ if (childLineStyle.textEmphasisMark() != TextEmphasisMark::None && downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove) && emphasisMarkIsAbove && *emphasisMarkIsAbove) {
if (!childLineStyle.isFlippedLinesWritingMode()) {
int topOfEmphasisMark = child->logicalTop() - childLineStyle.fontCascade().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
result = std::max(result, allowedPosition - topOfEmphasisMark);
@@ -1623,9 +1623,9 @@
if (is<InlineTextBox>(*child)) {
const RenderStyle& childLineStyle = child->lineStyle();
- bool emphasisMarkIsAbove;
+ std::optional<bool> emphasisMarkIsAbove;
downcast<InlineTextBox>(*child).emphasisMarkExistsAndIsAbove(childLineStyle, emphasisMarkIsAbove);
- if (childLineStyle.textEmphasisMark() != TextEmphasisMark::None && !emphasisMarkIsAbove) {
+ if (childLineStyle.textEmphasisMark() != TextEmphasisMark::None && emphasisMarkIsAbove && !*emphasisMarkIsAbove) {
if (!childLineStyle.isFlippedLinesWritingMode()) {
LayoutUnit bottomOfEmphasisMark = child->logicalBottom() + childLineStyle.fontCascade().emphasisMarkHeight(childLineStyle.textEmphasisMarkString());
result = std::max(result, bottomOfEmphasisMark - allowedPosition);
Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (233266 => 233267)
--- trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp 2018-06-27 18:07:00 UTC (rev 233267)
@@ -358,7 +358,7 @@
return !(emphasisPosition & TextEmphasisPosition::Left) && !(emphasisPosition & TextEmphasisPosition::Right);
}
-bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, bool& above) const
+bool InlineTextBox::emphasisMarkExistsAndIsAbove(const RenderStyle& style, std::optional<bool>& above) const
{
// This function returns true if there are text emphasis marks and they are suppressed by ruby text.
if (style.textEmphasisMark() == TextEmphasisMark::None)
@@ -1001,11 +1001,11 @@
const RenderStyle& lineStyle = this->lineStyle();
float emphasisMarkOffset = 0;
- bool emphasisMarkAbove;
+ std::optional<bool> emphasisMarkAbove;
bool hasTextEmphasis = emphasisMarkExistsAndIsAbove(lineStyle, emphasisMarkAbove);
const AtomicString& emphasisMark = hasTextEmphasis ? lineStyle.textEmphasisMarkString() : nullAtom();
if (!emphasisMark.isEmpty())
- emphasisMarkOffset = emphasisMarkAbove ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
+ emphasisMarkOffset = (emphasisMarkAbove && *emphasisMarkAbove) ? -font.fontMetrics().ascent() - font.emphasisMarkDescent(emphasisMark) : font.fontMetrics().descent() + font.emphasisMarkAscent(emphasisMark);
TextPainter textPainter { context };
textPainter.setFont(font);
Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (233266 => 233267)
--- trunk/Source/WebCore/rendering/InlineTextBox.h 2018-06-27 18:02:56 UTC (rev 233266)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h 2018-06-27 18:07:00 UTC (rev 233267)
@@ -87,7 +87,7 @@
int baselinePosition(FontBaseline) const final;
LayoutUnit lineHeight() const final;
- bool emphasisMarkExistsAndIsAbove(const RenderStyle&, bool& isAbove) const;
+ bool emphasisMarkExistsAndIsAbove(const RenderStyle&, std::optional<bool>& isAbove) const;
LayoutRect logicalOverflowRect() const;
void setLogicalOverflowRect(const LayoutRect&);