Diff
Modified: trunk/Source/WebCore/ChangeLog (174728 => 174729)
--- trunk/Source/WebCore/ChangeLog 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/ChangeLog 2014-10-15 17:13:41 UTC (rev 174729)
@@ -1,5 +1,28 @@
2014-10-15 Chris Dumez <[email protected]>
+ Use is<>() / downcast<>() for ClipPathOperation subclasses
+ https://bugs.webkit.org/show_bug.cgi?id=137733
+
+ Reviewed by Mihnea Ovidenie.
+
+ Use is<>() / downcast<>() for ClipPathOperation subclasses.
+
+ No new tests, no behavior change.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * css/DeprecatedStyleBuilder.cpp:
+ (WebCore::ApplyPropertyClipPath::applyValue):
+ * rendering/ClipPathOperation.h:
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::nodeAtPoint):
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::setupClipPath):
+ * rendering/svg/SVGRenderingContext.cpp:
+ (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+
+2014-10-15 Chris Dumez <[email protected]>
+
[Mac] Use CFDictionaryContainsKey() in ImageSource::isSizeAvailable()
https://bugs.webkit.org/show_bug.cgi?id=137723
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (174728 => 174729)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2014-10-15 17:13:41 UTC (rev 174729)
@@ -2852,19 +2852,19 @@
ClipPathOperation* operation = style->clipPath();
if (!operation)
return cssValuePool().createIdentifierValue(CSSValueNone);
- if (operation->type() == ClipPathOperation::Reference) {
- ReferenceClipPathOperation& referenceOperation = toReferenceClipPathOperation(*operation);
+ if (is<ReferenceClipPathOperation>(*operation)) {
+ const auto& referenceOperation = downcast<ReferenceClipPathOperation>(*operation);
return CSSPrimitiveValue::create(referenceOperation.url(), CSSPrimitiveValue::CSS_URI);
}
RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
- if (operation->type() == ClipPathOperation::Shape) {
- ShapeClipPathOperation& shapeOperation = toShapeClipPathOperation(*operation);
+ if (is<ShapeClipPathOperation>(*operation)) {
+ const auto& shapeOperation = downcast<ShapeClipPathOperation>(*operation);
list->append(valueForBasicShape(style.get(), shapeOperation.basicShape()));
if (shapeOperation.referenceBox() != BoxMissing)
list->append(cssValuePool().createValue(shapeOperation.referenceBox()));
}
- if (operation->type() == ClipPathOperation::Box) {
- BoxClipPathOperation& boxOperation = toBoxClipPathOperation(*operation);
+ if (is<BoxClipPathOperation>(*operation)) {
+ const auto& boxOperation = downcast<BoxClipPathOperation>(*operation);
list->append(cssValuePool().createValue(boxOperation.referenceBox()));
}
return list.release();
Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (174728 => 174729)
--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp 2014-10-15 17:13:41 UTC (rev 174729)
@@ -2163,7 +2163,7 @@
return;
operation = BoxClipPathOperation::create(referenceBox);
} else
- toShapeClipPathOperation(operation.get())->setReferenceBox(referenceBox);
+ downcast<ShapeClipPathOperation>(*operation).setReferenceBox(referenceBox);
setValue(styleResolver->style(), operation.release());
}
static PropertyHandler createHandler()
Modified: trunk/Source/WebCore/rendering/ClipPathOperation.h (174728 => 174729)
--- trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/ClipPathOperation.h 2014-10-15 17:13:41 UTC (rev 174729)
@@ -34,6 +34,7 @@
#include "Path.h"
#include "RenderStyleConstants.h"
#include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -166,13 +167,15 @@
CSSBoxType m_referenceBox;
};
-#define CLIP_PATH_OPERATION_CASTS(ToValueTypeName, predicate) \
- TYPE_CASTS_BASE(ToValueTypeName, ClipPathOperation, operation, operation->type() == ClipPathOperation::predicate, operation.type() == ClipPathOperation::predicate)
+} // namespace WebCore
-CLIP_PATH_OPERATION_CASTS(ReferenceClipPathOperation, Reference)
-CLIP_PATH_OPERATION_CASTS(ShapeClipPathOperation, Shape)
-CLIP_PATH_OPERATION_CASTS(BoxClipPathOperation, Box)
+#define SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ToValueTypeName, predicate) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
+ static bool isType(const WebCore::ClipPathOperation& operation) { return operation.type() == WebCore::predicate; } \
+SPECIALIZE_TYPE_TRAITS_END()
-} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ReferenceClipPathOperation, ClipPathOperation::Reference)
+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(ShapeClipPathOperation, ClipPathOperation::Shape)
+SPECIALIZE_TYPE_TRAITS_CLIP_PATH_OPERATION(BoxClipPathOperation, ClipPathOperation::Box)
#endif // ClipPathOperation_h
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (174728 => 174729)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2014-10-15 17:13:41 UTC (rev 174729)
@@ -2453,10 +2453,10 @@
if (style().clipPath()) {
switch (style().clipPath()->type()) {
case ClipPathOperation::Shape: {
- ShapeClipPathOperation* clipPath = toShapeClipPathOperation(style().clipPath());
+ const auto& clipPath = downcast<ShapeClipPathOperation>(*style().clipPath());
LayoutRect referenceBoxRect;
- switch (clipPath->referenceBox()) {
+ switch (clipPath.referenceBox()) {
case CSSBoxType::MarginBox:
referenceBoxRect = marginBoxRect();
break;
@@ -2475,7 +2475,7 @@
case CSSBoxType::ViewBox:
referenceBoxRect = borderBoxRect();
}
- if (!clipPath->pathForReferenceRect(referenceBoxRect).contains(locationInContainer.point() - localOffset, clipPath->windRule()))
+ if (!clipPath.pathForReferenceRect(referenceBoxRect).contains(locationInContainer.point() - localOffset, clipPath.windRule()))
return false;
break;
}
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (174728 => 174729)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2014-10-15 17:13:41 UTC (rev 174729)
@@ -3925,23 +3925,23 @@
RenderStyle& style = renderer().style();
ASSERT(style.clipPath());
- if (style.clipPath()->type() == ClipPathOperation::Shape) {
- ShapeClipPathOperation& clippingPath = toShapeClipPathOperation(*(style.clipPath()));
+ if (is<ShapeClipPathOperation>(*style.clipPath())) {
+ const auto& clipPath = downcast<ShapeClipPathOperation>(*style.clipPath());
- LayoutRect referenceBox = computeReferenceBox(renderer(), clippingPath, offsetFromRoot, rootRelativeBounds);
+ LayoutRect referenceBox = computeReferenceBox(renderer(), clipPath, offsetFromRoot, rootRelativeBounds);
context->save();
- context->clipPath(clippingPath.pathForReferenceRect(referenceBox), clippingPath.windRule());
+ context->clipPath(clipPath.pathForReferenceRect(referenceBox), clipPath.windRule());
return true;
}
- if (style.clipPath()->type() == ClipPathOperation::Box && renderer().isBox()) {
- BoxClipPathOperation& clippingPath = toBoxClipPathOperation(*(style.clipPath()));
+ if (is<BoxClipPathOperation>(*style.clipPath()) && is<RenderBox>(renderer())) {
+ const auto& clipPath = downcast<BoxClipPathOperation>(*style.clipPath());
- RoundedRect shapeRect = computeRoundedRectForBoxShape(clippingPath.referenceBox(), toRenderBox(renderer()));
+ RoundedRect shapeRect = computeRoundedRectForBoxShape(clipPath.referenceBox(), downcast<RenderBox>(renderer()));
shapeRect.move(offsetFromRoot);
context->save();
- context->clipPath(clippingPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
+ context->clipPath(clipPath.pathForReferenceRect(shapeRect), RULE_NONZERO);
return true;
}
Modified: trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp (174728 => 174729)
--- trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-10-15 17:01:16 UTC (rev 174728)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderingContext.cpp 2014-10-15 17:13:41 UTC (rev 174729)
@@ -136,8 +136,8 @@
}
ClipPathOperation* clipPathOperation = style.clipPath();
- if (clipPathOperation && clipPathOperation->type() == ClipPathOperation::Shape) {
- ShapeClipPathOperation& clipPath = toShapeClipPathOperation(*clipPathOperation);
+ if (is<ShapeClipPathOperation>(clipPathOperation)) {
+ const auto& clipPath = downcast<ShapeClipPathOperation>(*clipPathOperation);
FloatRect referenceBox;
if (clipPath.referenceBox() == Stroke)
// FIXME: strokeBoundingBox() takes dasharray into account but shouldn't.