Skip to content
Permalink
Browse files
Move 'cursor' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=139660

Reviewed by Benjamin Poulain.

Move 'cursor' CSS property to the new StyleBuilder by using
custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyCursor::applyInheritValue): Deleted.
(WebCore::ApplyPropertyCursor::applyInitialValue): Deleted.
(WebCore::ApplyPropertyCursor::applyValue): Deleted.
(WebCore::ApplyPropertyCursor::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialCursor):
(WebCore::StyleBuilderCustom::applyInheritCursor):
(WebCore::StyleBuilderCustom::applyValueCursor):


Canonical link: https://commits.webkit.org/157613@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@177414 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Dec 17, 2014
1 parent 1e4996b commit 3fa2a580cdf05531ea727b384898223c65a77e8f
Showing with 70 additions and 46 deletions.
  1. +24 −0 Source/WebCore/ChangeLog
  2. +1 −1 Source/WebCore/css/CSSPropertyNames.in
  3. +0 −45 Source/WebCore/css/DeprecatedStyleBuilder.cpp
  4. +45 −0 Source/WebCore/css/StyleBuilderCustom.h
@@ -1,3 +1,27 @@
2014-12-16 Chris Dumez <cdumez@apple.com>

Move 'cursor' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=139660

Reviewed by Benjamin Poulain.

Move 'cursor' CSS property to the new StyleBuilder by using
custom code.

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyCursor::applyInheritValue): Deleted.
(WebCore::ApplyPropertyCursor::applyInitialValue): Deleted.
(WebCore::ApplyPropertyCursor::applyValue): Deleted.
(WebCore::ApplyPropertyCursor::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialCursor):
(WebCore::StyleBuilderCustom::applyInheritCursor):
(WebCore::StyleBuilderCustom::applyValueCursor):

2014-12-16 Zalan Bujtas <zalan@apple.com>

Subpixel rendering: Animating HTML elements leaves trails when embedded to a subpxiel positioned iframe.
@@ -168,7 +168,7 @@ clip [Custom=All]
content [LegacyStyleBuilder]
counter-increment [Custom=All]
counter-reset [Custom=All]
cursor [Inherited, LegacyStyleBuilder]
cursor [Inherited, Custom=All]
#if defined(ENABLE_CURSOR_VISIBILITY) && ENABLE_CURSOR_VISIBILITY
-webkit-cursor-visibility [Inherited, TypeName=CursorVisibility]
#endif
@@ -626,50 +626,6 @@ class ApplyPropertyFontVariantLigatures {
}
};

class ApplyPropertyCursor {
public:
static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
{
styleResolver->style()->setCursor(styleResolver->parentStyle()->cursor());
styleResolver->style()->setCursorList(styleResolver->parentStyle()->cursors());
}

static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
{
styleResolver->style()->clearCursorList();
styleResolver->style()->setCursor(RenderStyle::initialCursor());
}

static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
{
styleResolver->style()->clearCursorList();
if (is<CSSValueList>(*value)) {
CSSValueList& list = downcast<CSSValueList>(*value);
int length = list.length();
styleResolver->style()->setCursor(CursorAuto);
for (int i = 0; i < length; i++) {
CSSValue* item = list.itemWithoutBoundsCheck(i);
if (is<CSSCursorImageValue>(*item)) {
CSSCursorImageValue& image = downcast<CSSCursorImageValue>(*item);
if (image.updateIfSVGCursorIsUsed(styleResolver->element())) // Elements with SVG cursors are not allowed to share style.
styleResolver->style()->setUnique();
styleResolver->style()->addCursor(styleResolver->styleImage(CSSPropertyCursor, image), image.hotSpot());
} else if (is<CSSPrimitiveValue>(*item)) {
CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*item);
if (primitiveValue.isValueID())
styleResolver->style()->setCursor(primitiveValue);
}
}
} else if (is<CSSPrimitiveValue>(*value)) {
CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
if (primitiveValue.isValueID() && styleResolver->style()->cursor() != ECursor(primitiveValue))
styleResolver->style()->setCursor(primitiveValue);
}
}

static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
};

template <typename T,
T (Animation::*getterFunction)() const,
void (Animation::*setterFunction)(T),
@@ -774,7 +730,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
setPropertyHandler(CSSPropertyCursor, ApplyPropertyCursor::createHandler());
setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
@@ -28,7 +28,9 @@
#define StyleBuilderCustom_h

#include "CSSAspectRatioValue.h"
#include "CSSCursorImageValue.h"
#include "CSSShadowValue.h"
#include "CursorList.h"
#include "Frame.h"
#include "LocaleToScriptMapping.h"
#include "Rect.h"
@@ -133,6 +135,10 @@ class StyleBuilderCustom {
static void applyInheritCounterReset(StyleResolver&);
static void applyValueCounterReset(StyleResolver&, CSSValue&);

static void applyInitialCursor(StyleResolver&);
static void applyInheritCursor(StyleResolver&);
static void applyValueCursor(StyleResolver&, CSSValue&);

private:
static void resetEffectiveZoom(StyleResolver&);
static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
@@ -1136,6 +1142,45 @@ inline void StyleBuilderCustom::applyValueCounterReset(StyleResolver& styleResol
applyValueCounter<Reset>(styleResolver, value);
}

inline void StyleBuilderCustom::applyInitialCursor(StyleResolver& styleResolver)
{
styleResolver.style()->clearCursorList();
styleResolver.style()->setCursor(RenderStyle::initialCursor());
}

inline void StyleBuilderCustom::applyInheritCursor(StyleResolver& styleResolver)
{
styleResolver.style()->setCursor(styleResolver.parentStyle()->cursor());
styleResolver.style()->setCursorList(styleResolver.parentStyle()->cursors());
}

inline void StyleBuilderCustom::applyValueCursor(StyleResolver& styleResolver, CSSValue& value)
{
styleResolver.style()->clearCursorList();
if (is<CSSPrimitiveValue>(value)) {
ECursor cursor = downcast<CSSPrimitiveValue>(value);
if (styleResolver.style()->cursor() != cursor)
styleResolver.style()->setCursor(cursor);
return;
}

styleResolver.style()->setCursor(CursorAuto);
auto& list = downcast<CSSValueList>(value);
for (auto& item : list) {
if (is<CSSCursorImageValue>(item.get())) {
auto& image = downcast<CSSCursorImageValue>(item.get());
if (image.updateIfSVGCursorIsUsed(styleResolver.element())) // Elements with SVG cursors are not allowed to share style.
styleResolver.style()->setUnique();
styleResolver.style()->addCursor(styleResolver.styleImage(CSSPropertyCursor, image), image.hotSpot());
continue;
}

styleResolver.style()->setCursor(downcast<CSSPrimitiveValue>(item.get()));
ASSERT_WITH_MESSAGE(item.ptr() == list.item(list.length() - 1), "Cursor ID fallback should always be last in the list");
return;
}
}

} // namespace WebCore

#endif // StyleBuilderCustom_h

0 comments on commit 3fa2a58

Please sign in to comment.