Add very basic image control rendering
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Feb 2014 00:39:35 +0000 (00:39 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Feb 2014 00:39:35 +0000 (00:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129080

Reviewed by Tim Horton.

Source/WebCore:

Test: fast/images/image-controls-basic.html

This patch is groundwork that adds a very basic image control that can render on top of images.

* dom/Node.h:
(WebCore::Node:: isImageControlsRootElement): Returns false, unless you are an ImageControls object.
* html/HTMLAttributeNames.in:

Teach HTMLImageElement how to understand an experimental attribute to install controls,
how to actually build the DOM to attach to the shadow root, how to tear that DOM down,
and how to make sure that Renderers are created for that DOM:
* html/HTMLImageElement.cpp:
(WebCore::HTMLImageElement::HTMLImageElement):
(WebCore::HTMLImageElement::parseAttribute):
(WebCore::HTMLImageElement::didAttachRenderers):
(WebCore::HTMLImageElement::updateImageControls):
(WebCore::HTMLImageElement::createImageControls):
(WebCore::HTMLImageElement::destroyImageControls):
(WebCore::HTMLImageElement::hasImageControls):
(WebCore::HTMLImageElement::childShouldCreateRenderer):
* html/HTMLImageElement.h:
(WebCore::HTMLImageElement::hasShadowControls): For RenderImage to query when it is constructed.

Add a generic, platform independent ImageControls root element that does nothing:
* html/shadow/ImageControlsRootElement.cpp: Added.
(WebCore::ImageControlsRootElement::maybeCreate):
(WebCore::ImageControlsRootElement::ImageControlsRootElement):
(WebCore::ImageControlsRootElement::~ImageControlsRootElement):
* html/shadow/ImageControlsRootElement.h: Added.

Add a Mac-specific ImageControls root element that renders a 20x20 red box (for now):
* html/shadow/mac/ImageControlsRootElementMac.cpp: Added.
(WebCore::ImageControlsRootElementMac::ImageControlsRootElementMac):
(WebCore::ImageControlsRootElementMac::~ImageControlsRootElementMac):
(WebCore::ImageControlsRootElement::maybeCreate):
(WebCore::ImageControlsRootElementMac::maybeCreate):
* html/shadow/mac/ImageControlsRootElementMac.h: Added.

Since much of the RenderMedia::layout() method is now required for RenderImage as well,
move the logic to RenderImage. The extra work is controlled by a bool flag that will always
be set for RenderMedias but will only be set for certain RenderImages:
* rendering/RenderImage.cpp:
(WebCore::RenderImage::RenderImage):
(WebCore::RenderImage::canHaveChildren):
(WebCore::RenderImage::layout):
(WebCore::RenderImage::layoutShadowControls):
* rendering/RenderImage.h:
(WebCore::RenderImage::setHasShadowControls):
(WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics):

* rendering/RenderMedia.cpp:
(WebCore::RenderMedia::RenderMedia):
* rendering/RenderMedia.h:
(WebCore::RenderMedia::shadowControlsNeedCustomLayoutMetrics):

* WebCore.xcodeproj/project.pbxproj:

Source/WebKit/mac:

Expose the imageControlsEnabled setting to WebKit1 so DRT can use it.

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences imageControlsEnabled]):
(-[WebPreferences setImageControlsEnabled:]):
* WebView/WebPreferencesPrivate.h:

* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Source/WebKit2:

* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): Expose the
  imageControlsEnabled setting to WKTR.

LayoutTests:

* fast/images/image-controls-basic.html: Added.
* platform/mac/fast/images/image-controls-basic-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164457 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/images/image-controls-basic.html [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/image-controls-basic-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/dom/Node.h
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/shadow/ImageControlsRootElement.cpp [new file with mode: 0644]
Source/WebCore/html/shadow/ImageControlsRootElement.h [new file with mode: 0644]
Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp [new file with mode: 0644]
Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.h [new file with mode: 0644]
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderImage.h
Source/WebCore/rendering/RenderMedia.cpp
Source/WebCore/rendering/RenderMedia.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h
Source/WebKit/mac/WebView/WebPreferences.mm
Source/WebKit/mac/WebView/WebPreferencesPrivate.h
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp

index 32fc422..896d2a2 100644 (file)
@@ -1 +1,11 @@
+2014-02-20  Brady Eidson  <beidson@apple.com>
+
+        Add very basic image control rendering
+        https://bugs.webkit.org/show_bug.cgi?id=129080
+
+        Reviewed by Tim Horton.
+
+        * fast/images/image-controls-basic.html: Added.
+        * platform/mac/fast/images/image-controls-basic-expected.txt: Added.
+
 == Rolled over to ChangeLog-2014-02-20 ==
diff --git a/LayoutTests/fast/images/image-controls-basic.html b/LayoutTests/fast/images/image-controls-basic.html
new file mode 100644 (file)
index 0000000..ecc49ef
--- /dev/null
@@ -0,0 +1,8 @@
+<script>
+if (window.testRunner)
+       testRunner.overridePreference('WebKitImageControlsEnabled', 1);
+
+</script>
+<body>
+<img src="resources/green-256x256.jpg" x-webkit-imagemenu>
+</body>
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.png b/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.png
new file mode 100644 (file)
index 0000000..d0c1709
Binary files /dev/null and b/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt b/LayoutTests/platform/mac/fast/images/image-controls-basic-expected.txt
new file mode 100644 (file)
index 0000000..59b75d7
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderImage {IMG} at (0,0) size 256x256
+      RenderText {#text} at (0,0) size 0x0
index 32fc422..23f1a7f 100644 (file)
@@ -1 +1,65 @@
+2014-02-20  Brady Eidson  <beidson@apple.com>
+
+        Add very basic image control rendering
+        https://bugs.webkit.org/show_bug.cgi?id=129080
+
+        Reviewed by Tim Horton.
+
+        Test: fast/images/image-controls-basic.html
+
+        This patch is groundwork that adds a very basic image control that can render on top of images.
+
+        * dom/Node.h:
+        (WebCore::Node:: isImageControlsRootElement): Returns false, unless you are an ImageControls object.
+        * html/HTMLAttributeNames.in:
+
+        Teach HTMLImageElement how to understand an experimental attribute to install controls,
+        how to actually build the DOM to attach to the shadow root, how to tear that DOM down,
+        and how to make sure that Renderers are created for that DOM:
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::HTMLImageElement):
+        (WebCore::HTMLImageElement::parseAttribute):
+        (WebCore::HTMLImageElement::didAttachRenderers):
+        (WebCore::HTMLImageElement::updateImageControls):
+        (WebCore::HTMLImageElement::createImageControls):
+        (WebCore::HTMLImageElement::destroyImageControls):
+        (WebCore::HTMLImageElement::hasImageControls):
+        (WebCore::HTMLImageElement::childShouldCreateRenderer):
+        * html/HTMLImageElement.h:
+        (WebCore::HTMLImageElement::hasShadowControls): For RenderImage to query when it is constructed. 
+
+        Add a generic, platform independent ImageControls root element that does nothing:
+        * html/shadow/ImageControlsRootElement.cpp: Added.
+        (WebCore::ImageControlsRootElement::maybeCreate):
+        (WebCore::ImageControlsRootElement::ImageControlsRootElement):
+        (WebCore::ImageControlsRootElement::~ImageControlsRootElement):
+        * html/shadow/ImageControlsRootElement.h: Added.
+
+        Add a Mac-specific ImageControls root element that renders a 20x20 red box (for now):
+        * html/shadow/mac/ImageControlsRootElementMac.cpp: Added.
+        (WebCore::ImageControlsRootElementMac::ImageControlsRootElementMac):
+        (WebCore::ImageControlsRootElementMac::~ImageControlsRootElementMac):
+        (WebCore::ImageControlsRootElement::maybeCreate):
+        (WebCore::ImageControlsRootElementMac::maybeCreate):
+        * html/shadow/mac/ImageControlsRootElementMac.h: Added.
+
+        Since much of the RenderMedia::layout() method is now required for RenderImage as well,
+        move the logic to RenderImage. The extra work is controlled by a bool flag that will always
+        be set for RenderMedias but will only be set for certain RenderImages:
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::RenderImage):
+        (WebCore::RenderImage::canHaveChildren):
+        (WebCore::RenderImage::layout):
+        (WebCore::RenderImage::layoutShadowControls):
+        * rendering/RenderImage.h:
+        (WebCore::RenderImage::setHasShadowControls):
+        (WebCore::RenderImage::shadowControlsNeedCustomLayoutMetrics):
+
+        * rendering/RenderMedia.cpp:
+        (WebCore::RenderMedia::RenderMedia):
+        * rendering/RenderMedia.h:
+        (WebCore::RenderMedia::shadowControlsNeedCustomLayoutMetrics):
+
+        * WebCore.xcodeproj/project.pbxproj:
+
 == Rolled over to ChangeLog-2014-02-20 ==
index f6ce556..51e05bf 100644 (file)
                50D10D9A1545F5760096D288 /* RenderLayerFilterInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 50D10D981545F5760096D288 /* RenderLayerFilterInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
                510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
                5101846A0B08602A004A825F /* CachedPage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510184680B08602A004A825F /* CachedPage.cpp */; };
+               510192D118B6B9AB007FC7A1 /* ImageControlsRootElementMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510192CF18B6B9AB007FC7A1 /* ImageControlsRootElementMac.cpp */; };
+               510192D218B6B9AB007FC7A1 /* ImageControlsRootElementMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 510192D018B6B9AB007FC7A1 /* ImageControlsRootElementMac.h */; };
+               510192D518B6B9B7007FC7A1 /* ImageControlsRootElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510192D318B6B9B7007FC7A1 /* ImageControlsRootElement.cpp */; };
+               510192D618B6B9B7007FC7A1 /* ImageControlsRootElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 510192D418B6B9B7007FC7A1 /* ImageControlsRootElement.h */; };
                510194401836D20800925523 /* IDBIndexWriterLevelDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5101943E1836D20800925523 /* IDBIndexWriterLevelDB.cpp */; };
                510194411836D20800925523 /* IDBIndexWriterLevelDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 5101943F1836D20800925523 /* IDBIndexWriterLevelDB.h */; };
                510194441836F7E400925523 /* IDBCursorBackendOperations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 510194421836F7E400925523 /* IDBCursorBackendOperations.cpp */; };
                50D10D981545F5760096D288 /* RenderLayerFilterInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderLayerFilterInfo.h; sourceTree = "<group>"; };
                510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; };
                510184680B08602A004A825F /* CachedPage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedPage.cpp; sourceTree = "<group>"; };
+               510192CF18B6B9AB007FC7A1 /* ImageControlsRootElementMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageControlsRootElementMac.cpp; sourceTree = "<group>"; };
+               510192D018B6B9AB007FC7A1 /* ImageControlsRootElementMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageControlsRootElementMac.h; sourceTree = "<group>"; };
+               510192D318B6B9B7007FC7A1 /* ImageControlsRootElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageControlsRootElement.cpp; sourceTree = "<group>"; };
+               510192D418B6B9B7007FC7A1 /* ImageControlsRootElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageControlsRootElement.h; sourceTree = "<group>"; };
                5101943E1836D20800925523 /* IDBIndexWriterLevelDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBIndexWriterLevelDB.cpp; sourceTree = "<group>"; };
                5101943F1836D20800925523 /* IDBIndexWriterLevelDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBIndexWriterLevelDB.h; sourceTree = "<group>"; };
                510194421836F7E400925523 /* IDBCursorBackendOperations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IDBCursorBackendOperations.cpp; sourceTree = "<group>"; };
                4150F9ED12B6E0990008C860 /* shadow */ = {
                        isa = PBXGroup;
                        children = (
+                               51C4AA5118B28357007BFE9B /* mac */,
                                57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */,
                                57B791A014C6A62900F202D1 /* ContentDistributor.h */,
                                A7C9ABF61357A3BF00F5503F /* DetailsMarkerControl.cpp */,
                                A7C9ABF71357A3BF00F5503F /* DetailsMarkerControl.h */,
+                               510192D318B6B9B7007FC7A1 /* ImageControlsRootElement.cpp */,
+                               510192D418B6B9B7007FC7A1 /* ImageControlsRootElement.h */,
                                57CF497214EE36D700ECFF14 /* InsertionPoint.cpp */,
                                57CF497314EE36D700ECFF14 /* InsertionPoint.h */,
                                417253A81354BBBC00360F2A /* MediaControlElements.cpp */,
                        path = ios;
                        sourceTree = "<group>";
                };
+               51C4AA5118B28357007BFE9B /* mac */ = {
+                       isa = PBXGroup;
+                       children = (
+                               510192CF18B6B9AB007FC7A1 /* ImageControlsRootElementMac.cpp */,
+                               510192D018B6B9AB007FC7A1 /* ImageControlsRootElementMac.h */,
+                       );
+                       path = mac;
+                       sourceTree = "<group>";
+               };
                59B5977111086556007159E8 /* jsc */ = {
                        isa = PBXGroup;
                        children = (
                                07FFDE69181AED420072D409 /* MediaStreamTrackPrivate.h in Headers */,
                                76FC2B0C12370DA0006A991A /* DOMTokenList.h in Headers */,
                                E145349716A9BB6A000F6FD2 /* DOMTransitionEvent.h in Headers */,
+                               510192D218B6B9AB007FC7A1 /* ImageControlsRootElementMac.h in Headers */,
                                E145349916A9BB6A000F6FD2 /* DOMTransitionEventInternal.h in Headers */,
                                A14832BB187F643200DA63A6 /* WAKWindow.h in Headers */,
                                BC1A37BE097C715F0019F3D8 /* DOMTraversal.h in Headers */,
                                AAA4FAD2175D5CB300743873 /* JSUIRequestEvent.h in Headers */,
                                15C77093100D3CA8005BA267 /* JSValidityState.h in Headers */,
                                BE8EF04B171C9014009B48C3 /* JSVideoTrack.h in Headers */,
+                               510192D618B6B9B7007FC7A1 /* ImageControlsRootElement.h in Headers */,
                                BE8EF04D171C9014009B48C3 /* JSVideoTrackList.h in Headers */,
                                FD82D7F813D4C8BD004E4372 /* JSWaveShaperNode.h in Headers */,
                                A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */,
                                97BC6A231505F081001B74AC /* DatabaseAuthorizer.cpp in Sources */,
                                E125F8351822F18A00D84CD9 /* CryptoKeyHMAC.cpp in Sources */,
                                511EF2C517F0FD3500E4FA16 /* JSIDBIndex.cpp in Sources */,
+                               510192D518B6B9B7007FC7A1 /* ImageControlsRootElement.cpp in Sources */,
                                FE16CFD3169D1DED00D3A0C7 /* DatabaseBackend.cpp in Sources */,
                                97BC69DA1505F076001B74AC /* DatabaseBackendBase.cpp in Sources */,
                                FE6F6AAF169E057500FC30A2 /* DatabaseBackendContext.cpp in Sources */,
                                B2A1F2AD0CEF0ABF00442F6A /* SVGGlyphElement.cpp in Sources */,
                                24D912BD13CA9A9700D21915 /* SVGGlyphRefElement.cpp in Sources */,
                                B2227A290D00BF220071B782 /* SVGGradientElement.cpp in Sources */,
+                               510192D118B6B9AB007FC7A1 /* ImageControlsRootElementMac.cpp in Sources */,
                                B2227AB50D00BF220071B782 /* SVGGraphicsElement.cpp in Sources */,
                                078E090D17D14CEE00420AA1 /* RTCSessionDescriptionRequestImpl.cpp in Sources */,
                                650FBF2A0D9AF047008FC292 /* SVGHKernElement.cpp in Sources */,
index 9df8e83..78b431f 100644 (file)
@@ -238,6 +238,9 @@ public:
     virtual bool isFrameOwnerElement() const { return false; }
     virtual bool isPluginElement() const { return false; }
     virtual bool isInsertionPointNode() const { return false; }
+#if ENABLE(IMAGE_CONTROLS)
+    virtual bool isImageControlsRootElement() const { return false; }
+#endif
 
     bool isDocumentNode() const;
     bool isTreeScope() const;
index 0472753..5a7f5bf 100644 (file)
@@ -352,6 +352,7 @@ autocapitalize
 data-youtube-id
 onwebkitcurrentplaybacktargetiswirelesschanged
 onwebkitplaybacktargetavailabilitychanged
+x-webkit-imagemenu
 webkit-playsinline
 x-webkit-airplay
 x-webkit-wirelessvideoplaybackdisabled
index 9878c78..e61a0a4 100644 (file)
 #include "HTMLParserIdioms.h"
 #include "Page.h"
 #include "RenderImage.h"
+#include "Settings.h"
+#include "ShadowRoot.h"
+
+#if ENABLE(IMAGE_CONTROLS)
+#include "ImageControlsRootElement.h"
+#endif
 
 namespace WebCore {
 
@@ -46,6 +52,9 @@ HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document& docum
     , m_form(form)
     , m_compositeOperator(CompositeSourceOver)
     , m_imageDevicePixelRatio(1.0f)
+#if ENABLE(IMAGE_CONTROLS)
+    , m_experimentalImageMenuEnabled(false)
+#endif
 {
     ASSERT(hasTagName(imgTag));
     setHasCustomStyleResolveCallbacks();
@@ -151,6 +160,11 @@ void HTMLImageElement::parseAttribute(const QualifiedName& name, const AtomicStr
         BlendMode blendOp = BlendModeNormal;
         if (!parseCompositeAndBlendOperator(value, m_compositeOperator, blendOp))
             m_compositeOperator = CompositeSourceOver;
+#if ENABLE(IMAGE_CONTROLS)
+    } else if (name == webkitimagemenuAttr) {
+        m_experimentalImageMenuEnabled = !value.isNull();
+        updateImageControls();
+#endif
     } else {
         if (name == nameAttr) {
             bool willHaveName = !value.isNull();
@@ -203,6 +217,11 @@ void HTMLImageElement::didAttachRenderers()
         return;
     if (m_imageLoader.hasPendingBeforeLoadEvent())
         return;
+
+#if ENABLE(IMAGE_CONTROLS)
+    updateImageControls();
+#endif
+
     RenderImage* renderImage = toRenderImage(renderer());
     RenderImageResource& renderImageResource = renderImage->imageResource();
     if (renderImageResource.hasImage())
@@ -412,6 +431,77 @@ bool HTMLImageElement::isServerMap() const
     return document().completeURL(stripLeadingAndTrailingHTMLSpaces(usemap)).isEmpty();
 }
 
+#if ENABLE(IMAGE_CONTROLS)
+void HTMLImageElement::updateImageControls()
+{
+    // If this image element is inside a shadow tree then it is part of an image control.
+    if (isInShadowTree())
+        return;
+
+    Settings* settings = document().settings();
+    if (!settings || !settings->imageControlsEnabled())
+        return;
+
+    bool hasControls = hasImageControls();
+    if (!m_experimentalImageMenuEnabled && hasControls)
+        destroyImageControls();
+    else if (m_experimentalImageMenuEnabled && !hasControls)
+        createImageControls();
+}
+
+void HTMLImageElement::createImageControls()
+{
+    ASSERT(m_experimentalImageMenuEnabled);
+    ASSERT(!hasImageControls());
+
+    RefPtr<ImageControlsRootElement> imageControls = ImageControlsRootElement::maybeCreate(document());
+    if (!imageControls)
+        return;
+
+    ensureUserAgentShadowRoot().appendChild(imageControls);
+
+    RenderObject* renderObject = renderer();
+    if (!renderObject)
+        return;
+
+    toRenderImage(renderObject)->setHasShadowControls(true);
+}
+
+void HTMLImageElement::destroyImageControls()
+{
+    ShadowRoot* shadowRoot = userAgentShadowRoot();
+    if (!shadowRoot)
+        return;
+
+    if (Node* node = shadowRoot->firstChild()) {
+        ASSERT_WITH_SECURITY_IMPLICATION(node->isImageControlsRootElement());
+        shadowRoot->removeChild(node);
+    }
+
+    RenderObject* renderObject = renderer();
+    if (!renderObject)
+        return;
+
+    toRenderImage(renderObject)->setHasShadowControls(false);
+}
+
+bool HTMLImageElement::hasImageControls() const
+{
+    if (ShadowRoot* shadowRoot = userAgentShadowRoot()) {
+        Node* node = shadowRoot->firstChild();
+        ASSERT_WITH_SECURITY_IMPLICATION(!node || node->isImageControlsRootElement());
+        return node;
+    }
+
+    return false;
+}
+
+bool HTMLImageElement::childShouldCreateRenderer(const Node& child) const
+{
+    return hasShadowRootParent(child) && HTMLElement::childShouldCreateRenderer(child);
+}
+#endif // ENABLE(IMAGE_CONTROLS)
+
 #if PLATFORM(IOS)
 // FIXME: This is a workaround for <rdar://problem/7725158>. We should find a better place for the touchCalloutEnabled() logic.
 bool HTMLImageElement::willRespondToMouseClickEvents()
index 22d6d22..d57a9d8 100644 (file)
@@ -85,6 +85,8 @@ public:
 
     virtual const AtomicString& imageSourceURL() const override;
 
+    bool hasShadowControls() const { return m_experimentalImageMenuEnabled; }
+
 protected:
     HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = 0);
 
@@ -120,6 +122,15 @@ private:
     AtomicString m_bestFitImageURL;
     AtomicString m_lowercasedUsemap;
     float m_imageDevicePixelRatio;
+    bool m_experimentalImageMenuEnabled;
+
+#if ENABLE(IMAGE_CONTROLS)
+    void updateImageControls();
+    void createImageControls();
+    void destroyImageControls();
+    bool hasImageControls() const;
+    virtual bool childShouldCreateRenderer(const Node&) const override;
+#endif
 };
 
 NODE_TYPE_CASTS(HTMLImageElement)
diff --git a/Source/WebCore/html/shadow/ImageControlsRootElement.cpp b/Source/WebCore/html/shadow/ImageControlsRootElement.cpp
new file mode 100644 (file)
index 0000000..94998a0
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageControlsRootElement.h"
+
+#if ENABLE(IMAGE_CONTROLS)
+
+namespace WebCore {
+
+#if !PLATFORM(MAC)
+PassRefPtr<ImageControlsRootElement> ImageControlsRootElement::maybeCreate(Document& document)
+{
+    return adoptRef(new ImageControlsRootElement(document));
+}
+#endif
+
+ImageControlsRootElement::ImageControlsRootElement(Document& document)
+    : HTMLDivElement(HTMLNames::divTag, document)
+{
+}
+
+ImageControlsRootElement::~ImageControlsRootElement()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_CONTROLS)
diff --git a/Source/WebCore/html/shadow/ImageControlsRootElement.h b/Source/WebCore/html/shadow/ImageControlsRootElement.h
new file mode 100644 (file)
index 0000000..9fa0cf2
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ImageControlsRootElement_h
+#define ImageControlsRootElement_h
+
+#if ENABLE(IMAGE_CONTROLS)
+
+#include "HTMLDivElement.h"
+
+namespace WebCore {
+
+class Document;
+
+class ImageControlsRootElement : public HTMLDivElement {
+public:
+    virtual ~ImageControlsRootElement();
+
+    static PassRefPtr<ImageControlsRootElement> maybeCreate(Document&);
+
+protected:
+    explicit ImageControlsRootElement(Document&);
+
+private:
+    virtual bool isImageControlsRootElement() const override { return true; }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_CONTROLS)
+#endif // ImageControlsRootElement_h
diff --git a/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp b/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.cpp
new file mode 100644 (file)
index 0000000..4a2c516
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ImageControlsRootElementMac.h"
+
+#if ENABLE(IMAGE_CONTROLS)
+
+#include "Text.h"
+
+namespace WebCore {
+
+ImageControlsRootElementMac::ImageControlsRootElementMac(Document& document)
+    : ImageControlsRootElement(document)
+{
+}
+
+ImageControlsRootElementMac::~ImageControlsRootElementMac()
+{
+}
+
+PassRefPtr<ImageControlsRootElement> ImageControlsRootElement::maybeCreate(Document& document)
+{
+    return ImageControlsRootElementMac::maybeCreate(document);
+}
+
+PassRefPtr<ImageControlsRootElementMac> ImageControlsRootElementMac::maybeCreate(Document& document)
+{
+    if (!document.page())
+        return nullptr;
+
+    RefPtr<ImageControlsRootElementMac> controls = adoptRef(new ImageControlsRootElementMac(document));
+    controls->setAttribute(HTMLNames::styleAttr, "position: relative; background-color: red; width: 20px; height: 20px;");
+
+    ExceptionCode ec;
+    controls->appendChild(Text::create(document, ""), ec);
+    if (ec)
+        return nullptr;
+
+    return controls.release();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_CONTROLS)
diff --git a/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.h b/Source/WebCore/html/shadow/mac/ImageControlsRootElementMac.h
new file mode 100644 (file)
index 0000000..8c1df9b
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef ImageControlsRootElementMac_h
+#define ImageControlsRootElementMac_h
+
+#include "ImageControlsRootElement.h"
+
+#if ENABLE(IMAGE_CONTROLS)
+
+namespace WebCore {
+
+class ImageControlsRootElementMac : public ImageControlsRootElement {
+public:
+    ~ImageControlsRootElementMac();
+
+    static PassRefPtr<ImageControlsRootElementMac> maybeCreate(Document&);
+
+private:
+    ImageControlsRootElementMac(Document&);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(IMAGE_CONTROLS)
+#endif // ImageControlsRootElementMac_h
index 87b7b5e..be78805 100644 (file)
@@ -44,6 +44,7 @@
 #include "InlineElementBox.h"
 #include "Page.h"
 #include "PaintInfo.h"
+#include "RenderFlowThread.h"
 #include "RenderImageResourceStyleImage.h"
 #include "RenderView.h"
 #include "SVGImage.h"
@@ -122,10 +123,14 @@ RenderImage::RenderImage(Element& element, PassRef<RenderStyle> style, StyleImag
     , m_needsToSetSizeForAltText(false)
     , m_didIncrementVisuallyNonEmptyPixelCount(false)
     , m_isGeneratedContent(false)
+    , m_hasShadowControls(false)
     , m_imageDevicePixelRatio(imageDevicePixelRatio)
 {
     updateAltText();
     imageResource().initialize(this);
+
+    if (isHTMLImageElement(element))
+        m_hasShadowControls = toHTMLImageElement(element).hasShadowControls();
 }
 
 RenderImage::RenderImage(Document& document, PassRef<RenderStyle> style, StyleImage* styleImage)
@@ -134,6 +139,7 @@ RenderImage::RenderImage(Document& document, PassRef<RenderStyle> style, StyleIm
     , m_needsToSetSizeForAltText(false)
     , m_didIncrementVisuallyNonEmptyPixelCount(false)
     , m_isGeneratedContent(false)
+    , m_hasShadowControls(false)
     , m_imageDevicePixelRatio(1.0f)
 {
     imageResource().initialize(this);
@@ -655,11 +661,63 @@ void RenderImage::updateAltText()
         m_altText = toHTMLImageElement(element())->altText();
 }
 
+bool RenderImage::canHaveChildren() const
+{
+#if !ENABLE(IMAGE_CONTROLS)
+    return false;
+#else
+    return m_hasShadowControls;
+#endif
+}
+
 void RenderImage::layout()
 {
     StackStats::LayoutCheckPoint layoutCheckPoint;
+
+    LayoutSize oldSize = contentBoxRect().size();
     RenderReplaced::layout();
+
     updateInnerContentRect();
+
+    if (m_hasShadowControls)
+        layoutShadowControls(oldSize);
+}
+
+void RenderImage::layoutShadowControls(const LayoutSize& oldSize)
+{
+    RenderBox* controlsRenderer = toRenderBox(firstChild());
+    if (!controlsRenderer)
+        return;
+    
+    bool controlsNeedLayout = controlsRenderer->needsLayout();
+    // If the region chain has changed we also need to relayout the controls to update the region box info.
+    // FIXME: We can do better once we compute region box info for RenderReplaced, not only for RenderBlock.
+    const RenderFlowThread* flowThread = flowThreadContainingBlock();
+    if (flowThread && !controlsNeedLayout) {
+        if (flowThread->pageLogicalSizeChanged())
+            controlsNeedLayout = true;
+    }
+
+    LayoutSize newSize = contentBoxRect().size();
+    if (newSize == oldSize && !controlsNeedLayout)
+        return;
+
+    // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or 
+    // instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient,
+    // and this method might be called many times per second during video playback, use a LayoutStateMaintainer:
+    LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
+
+    if (shadowControlsNeedCustomLayoutMetrics()) {
+        controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
+        controlsRenderer->style().setHeight(Length(newSize.height(), Fixed));
+        controlsRenderer->style().setWidth(Length(newSize.width(), Fixed));
+    }
+
+    controlsRenderer->setNeedsLayout(MarkOnlyThis);
+    controlsRenderer->layout();
+    clearChildNeedsLayout();
+
+    statePusher.pop();
 }
 
 void RenderImage::computeIntrinsicRatioInformation(FloatSize& intrinsicSize, double& intrinsicRatio, bool& isPercentageIntrinsicSize) const
index 24ec40a..e2de4f6 100644 (file)
@@ -64,6 +64,8 @@ public:
     inline void setImageDevicePixelRatio(float factor) { m_imageDevicePixelRatio = factor; }
     float imageDevicePixelRatio() const { return m_imageDevicePixelRatio; }
 
+    void setHasShadowControls(bool hasShadowControls) { m_hasShadowControls = hasShadowControls; }
+
 protected:
     virtual bool needsPreferredWidthsRecalculation() const override final;
     virtual RenderBox* embeddedContentBox() const override final;
@@ -86,6 +88,8 @@ protected:
 private:
     virtual const char* renderName() const override { return "RenderImage"; }
 
+    virtual bool canHaveChildren() const override;
+
     virtual bool isImage() const override { return true; }
     virtual bool isRenderImage() const override final { return true; }
 
@@ -100,6 +104,8 @@ private:
 
     virtual bool boxShadowShouldBeAppliedToBackground(BackgroundBleedAvoidance, InlineFlowBox*) const override final;
 
+    virtual bool shadowControlsNeedCustomLayoutMetrics() const { return false; }
+
     IntSize imageSizeForError(CachedImage*) const;
     void imageDimensionsChanged(bool imageSizeChanged, const IntRect* = 0);
     bool updateIntrinsicSizeIfNeeded(const LayoutSize&, bool imageSizeChanged);
@@ -107,6 +113,8 @@ private:
     void updateInnerContentRect();
 
     void paintAreaElementFocusRing(PaintInfo&);
+    
+    void layoutShadowControls(const LayoutSize& oldSize);
 
     // Text to display as long as the image isn't available.
     String m_altText;
@@ -114,6 +122,7 @@ private:
     bool m_needsToSetSizeForAltText;
     bool m_didIncrementVisuallyNonEmptyPixelCount;
     bool m_isGeneratedContent;
+    bool m_hasShadowControls;
     float m_imageDevicePixelRatio;
 
     friend class RenderImageScaleObserver;
index 438ab65..5428c9e 100644 (file)
@@ -37,57 +37,20 @@ namespace WebCore {
 RenderMedia::RenderMedia(HTMLMediaElement& element, PassRef<RenderStyle> style)
     : RenderImage(element, std::move(style))
 {
+    setHasShadowControls(true);
 }
 
 RenderMedia::RenderMedia(HTMLMediaElement& element, PassRef<RenderStyle> style, const IntSize& intrinsicSize)
     : RenderImage(element, std::move(style))
 {
     setIntrinsicSize(intrinsicSize);
+    setHasShadowControls(true);
 }
 
 RenderMedia::~RenderMedia()
 {
 }
 
-void RenderMedia::layout()
-{
-    StackStats::LayoutCheckPoint layoutCheckPoint;
-    LayoutSize oldSize = contentBoxRect().size();
-
-    RenderImage::layout();
-
-    RenderBox* controlsRenderer = toRenderBox(firstChild());
-    if (!controlsRenderer)
-        return;
-
-    bool controlsNeedLayout = controlsRenderer->needsLayout();
-    // If the region chain has changed we also need to relayout the controls to update the region box info.
-    // FIXME: We can do better once we compute region box info for RenderReplaced, not only for RenderBlock.
-    const RenderFlowThread* flowThread = flowThreadContainingBlock();
-    if (flowThread && !controlsNeedLayout) {
-        if (flowThread->pageLogicalSizeChanged())
-            controlsNeedLayout = true;
-    }
-
-    LayoutSize newSize = contentBoxRect().size();
-    if (newSize == oldSize && !controlsNeedLayout)
-        return;
-
-    // When calling layout() on a child node, a parent must either push a LayoutStateMaintainter, or 
-    // instantiate LayoutStateDisabler. Since using a LayoutStateMaintainer is slightly more efficient,
-    // and this method will be called many times per second during playback, use a LayoutStateMaintainer:
-    LayoutStateMaintainer statePusher(view(), *this, locationOffset(), hasTransform() || hasReflection() || style().isFlippedBlocksWritingMode());
-
-    controlsRenderer->setLocation(LayoutPoint(borderLeft(), borderTop()) + LayoutSize(paddingLeft(), paddingTop()));
-    controlsRenderer->style().setHeight(Length(newSize.height(), Fixed));
-    controlsRenderer->style().setWidth(Length(newSize.width(), Fixed));
-    controlsRenderer->setNeedsLayout(MarkOnlyThis);
-    controlsRenderer->layout();
-    clearChildNeedsLayout();
-
-    statePusher.pop();
-}
-
 void RenderMedia::paintReplaced(PaintInfo&, const LayoutPoint&)
 {
 }
index 8ef887e..0613c4c 100644 (file)
@@ -41,9 +41,6 @@ public:
 
     HTMLMediaElement& mediaElement() const { return toHTMLMediaElement(nodeForNonAnonymous()); }
 
-protected:
-    virtual void layout();
-
 private:
     void element() const = delete;
 
@@ -55,6 +52,8 @@ private:
     virtual void paintReplaced(PaintInfo&, const LayoutPoint&) override;
 
     virtual bool requiresForcedStyleRecalcPropagation() const override final { return true; }
+
+    virtual bool shadowControlsNeedCustomLayoutMetrics() const { return true; }
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderMedia, isMedia())
index db44ab8..239fb8a 100644 (file)
@@ -1,3 +1,22 @@
+2014-02-20  Brady Eidson  <beidson@apple.com>
+
+        Add very basic image control rendering
+        https://bugs.webkit.org/show_bug.cgi?id=129080
+
+        Reviewed by Tim Horton.
+
+        Expose the imageControlsEnabled setting to WebKit1 so DRT can use it.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences imageControlsEnabled]):
+        (-[WebPreferences setImageControlsEnabled:]):
+        * WebView/WebPreferencesPrivate.h:
+
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2014-02-20  David Kilzer  <ddkilzer@apple.com>
 
         [ASan] WebKit1 sources are not compiled using ASAN macros
index ce061d4..a8c1b3b 100644 (file)
 #define WebKitUseLegacyTextAlignPositionedElementBehaviorPreferenceKey @"WebKitUseLegacyTextAlignPositionedElementBehavior"
 #define WebKitMediaSourceEnabledPreferenceKey @"WebKitMediaSourceEnabled"
 #define WebKitShouldConvertPositionStyleOnCopyPreferenceKey @"WebKitShouldConvertPositionStyleOnCopy"
+#define WebKitImageControlsEnabledPreferenceKey @"WebKitImageControlsEnabled"
 
 #if !TARGET_OS_IPHONE
 // These are private both because callers should be using the cover methods and because the
index 7e1f38b..7e5b997 100644 (file)
@@ -595,6 +595,9 @@ public:
 #if ENABLE(MEDIA_SOURCE)
         [NSNumber numberWithBool:NO], WebKitMediaSourceEnabledPreferenceKey,
 #endif
+#if ENABLE(IMAGE_CONTROLS)
+        [NSNumber numberWithBool:NO], WebKitImageControlsEnabledPreferenceKey,
+#endif
         nil];
 
 #if !PLATFORM(IOS)
@@ -2535,6 +2538,16 @@ static bool needsScreenFontsEnabledQuirk()
     [self _setBoolValue:enabled forKey:WebKitMediaSourceEnabledPreferenceKey];
 }
 
+- (BOOL)imageControlsEnabled
+{
+    return [self _boolValueForKey:WebKitImageControlsEnabledPreferenceKey];
+}
+
+- (void)setImageControlsEnabled:(BOOL)enabled
+{
+    [self _setBoolValue:enabled forKey:WebKitImageControlsEnabledPreferenceKey];
+}
+
 - (BOOL)shouldConvertPositionStyleOnCopy
 {
     return [self _boolValueForKey:WebKitShouldConvertPositionStyleOnCopyPreferenceKey];
index d4da612..e9a24b5 100644 (file)
@@ -435,4 +435,7 @@ extern NSString *WebPreferencesCacheModelChangedInternalNotification;
 - (void)setShouldConvertPositionStyleOnCopy:(BOOL)flag;
 - (BOOL)shouldConvertPositionStyleOnCopy;
 
+- (void)setImageControlsEnabled:(BOOL)flag;
+- (BOOL)imageControlsEnabled;
+
 @end
index 8f4e906..7d69721 100644 (file)
@@ -2383,6 +2383,10 @@ static bool needsSelfRetainWhileLoadingQuirk()
     settings.setMediaSourceEnabled([preferences mediaSourceEnabled]);
 #endif
 
+#if ENABLE(IMAGE_CONTROLS)
+    settings.setImageControlsEnabled([preferences imageControlsEnabled]);
+#endif
+
     settings.setShouldConvertPositionStyleOnCopy([preferences shouldConvertPositionStyleOnCopy]);
 
     switch ([preferences storageBlockingPolicy]) {
index 8b769ca..67de7db 100644 (file)
@@ -1,3 +1,14 @@
+2014-02-20  Brady Eidson  <beidson@apple.com>
+
+        Add very basic image control rendering
+        https://bugs.webkit.org/show_bug.cgi?id=129080
+
+        Reviewed by Tim Horton.
+
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): Expose the 
+          imageControlsEnabled setting to WKTR.
+
 2014-02-20  Tim Horton  <timothy_horton@apple.com>
 
         Add magnification and swiping properties to WKWebView
index 53f5f6e..e7450ba 100644 (file)
@@ -189,6 +189,15 @@ void InjectedBundle::overrideBoolPreferenceForTestRunner(WebPageGroupProxy* page
         }
     }
 
+#if ENABLE(IMAGE_CONTROLS)
+    if (preference == "WebKitImageControlsEnabled") {
+        WebPreferencesStore::overrideBoolValueForKey(WebPreferencesKey::imageControlsEnabledKey(), enabled);
+        for (HashSet<Page*>::iterator iter = pages.begin(); iter != pages.end(); ++iter)
+            (*iter)->settings().setImageControlsEnabled(enabled);
+        return;
+    }
+#endif
+
 #if ENABLE(CSS_REGIONS)
     if (preference == "WebKitCSSRegionsEnabled")
         RuntimeEnabledFeatures::sharedFeatures().setCSSRegionsEnabled(enabled);