Ignore:
Timestamp:
Jun 18, 2015, 6:13:37 PM (10 years ago)
Author:
[email protected]
Message:

Provide a way for web developers to draw a Theme-specific Wireless Playback icon
https://bugs.webkit.org/show_bug.cgi?id=146123
<rdar://problem/21119287>

Reviewed by Simon Fraser.

Source/WebCore:

Implement a -webkit-named-image() CSS <image> generator that allows a site to
request artwork by name and get the platform variant. At the moment
we only support "wireless-playback" which returns a generic image everywhere
but Cocoa platforms, where we render the AirPlay icon.

In order to do this I added a ThemeCocoa to share any Theme code between
Mac and iOS.

Test: fast/css/named-icons.html

  • WebCore.xcodeproj/project.pbxproj: Add new files CSSNamedImageValue, NamedImageGeneratedImage and ThemeCocoa.
  • css/CSSImageGeneratorValue.cpp: Handle the new NamedImageClass in the switch statements for downcasting.

(WebCore::CSSImageGeneratorValue::image):
(WebCore::CSSImageGeneratorValue::isFixedSize):
(WebCore::CSSImageGeneratorValue::isPending):
(WebCore::CSSImageGeneratorValue::knownToBeOpaque):

  • css/CSSNamedImageValue.cpp: New class. Just holds a name String.

(WebCore::CSSNamedImageValue::customCSSText):
(WebCore::CSSNamedImageValue::image):
(WebCore::CSSNamedImageValue::equals):

  • css/CSSNamedImageValue.h:

(WebCore::CSSNamedImageValue::create):
(WebCore::CSSNamedImageValue::isFixedSize):
(WebCore::CSSNamedImageValue::isPending):
(WebCore::CSSNamedImageValue::CSSNamedImageValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::isGeneratedImageValue): Allow "-webkit-named-image(".
(WebCore::CSSParser::parseGeneratedImage): Call parseNamedImage if we hit named-icon.
(WebCore::CSSParser::parseNamedImage): Parse the function looking for a CSS ident.

  • css/CSSParser.h:
  • css/CSSValue.cpp: Handle NamedImageClass in the various switch statements.

(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):

  • css/CSSValue.h:

(WebCore::CSSValue::isNamedImageValue): Helper to detect the correct CSSValue subclass.

  • platform/Theme.cpp:

(WebCore::Theme::drawNamedImage): Draw a generic wireless playback icon.

  • platform/Theme.h: Add drawNamedImage.
  • platform/cocoa/ThemeCocoa.cpp: New shared base class for ThemeMac and ThemeIOS.

(WebCore::fitContextToBox):
(WebCore::ThemeCocoa::drawNamedImage): Draw an AirPlay icon for wireless playback.

  • platform/cocoa/ThemeCocoa.h:
  • platform/graphics/CrossfadeGeneratedImage.h: Drive-by removal of unnecessary forward class definition.
  • platform/graphics/ImageBuffer.h: Add NamedImageGeneratedImage as a friend class.
  • platform/graphics/NamedImageGeneratedImage.cpp: New class. Calls into the Theme to render the artwork.

(WebCore::NamedImageGeneratedImage::NamedImageGeneratedImage):
(WebCore::NamedImageGeneratedImage::draw):
(WebCore::NamedImageGeneratedImage::drawPattern):

  • platform/graphics/NamedImageGeneratedImage.h:
  • platform/ios/ThemeIOS.h: Inherit from ThemeCocoa.
  • platform/mac/ThemeMac.h: Ditto.

LayoutTests:

Test the new -webkit-named-image CSS generator. Only "wireless-playback"
is supported for now, and has platform-specific results for Cocoa.

  • fast/css/named-images-expected.png: Added.
  • fast/css/named-images.html: Added.
  • platform/mac/fast/css/named-images-expected.png: Added.
  • platform/mac/fast/css/named-images-expected.txt: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/css/CSSValue.cpp

    r184315 r185731  
    4848#include "CSSInitialValue.h"
    4949#include "CSSLineBoxContainValue.h"
     50#include "CSSNamedImageValue.h"
    5051#include "CSSPrimitiveValue.h"
    5152#include "CSSReflectValue.h"
     
    169170        case CanvasClass:
    170171            return compareCSSValues<CSSCanvasValue>(*this, other);
     172        case NamedImageClass:
     173            return compareCSSValues<CSSNamedImageValue>(*this, other);
    171174        case CursorImageClass:
    172175            return compareCSSValues<CSSCursorImageValue>(*this, other);
     
    261264    case CanvasClass:
    262265        return downcast<CSSCanvasValue>(*this).customCSSText();
     266    case NamedImageClass:
     267        return downcast<CSSNamedImageValue>(*this).customCSSText();
    263268    case CursorImageClass:
    264269        return downcast<CSSCursorImageValue>(*this).customCSSText();
     
    353358        delete downcast<CSSCanvasValue>(this);
    354359        return;
     360    case NamedImageClass:
     361        delete downcast<CSSNamedImageValue>(this);
     362        return;
    355363    case CursorImageClass:
    356364        delete downcast<CSSCursorImageValue>(this);
Note: See TracChangeset for help on using the changeset viewer.