Make a better flag for system preview, and disable it where necessary
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 15:16:51 +0000 (15:16 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 25 Apr 2018 15:16:51 +0000 (15:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184968
<rdar://problem/39686506>

Reviewed by Eric Carlson.

Source/WebCore:

Use USE(SYSTEM_PREVIEW).

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::isSystemPreviewLink const):
* html/HTMLAnchorElement.h:
* html/HTMLImageElement.cpp:
* html/HTMLImageElement.h:
* html/HTMLPictureElement.cpp:
* html/HTMLPictureElement.h:
* rendering/RenderImage.cpp:
(WebCore::RenderImage::paintIntoRect):
* rendering/RenderTheme.cpp:
* rendering/RenderTheme.h:
* testing/Internals.cpp:
(WebCore::Internals::systemPreviewRelType):
(WebCore::Internals::isSystemPreviewLink const):
(WebCore::Internals::isSystemPreviewImage const):

Source/WebKit:

Use USE(SYSTEM_PREVIEW).

* UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
* UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
(-[WKWebViewContentProviderRegistry init]):
* UIProcess/ios/WKSystemPreviewView.mm:

Source/WTF:

Add a new USE(SYSTEM_PREVIEW).

* wtf/Platform.h:

LayoutTests:

These tests have platform-specific results for the moment.

* TestExpectations:
* system-preview/badge-expected.html: Removed.
* system-preview/detection-expected.txt: Removed.

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/system-preview/badge-expected.html [deleted file]
LayoutTests/system-preview/detection-expected.txt [deleted file]
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLAnchorElement.h
Source/WebCore/html/HTMLImageElement.cpp
Source/WebCore/html/HTMLImageElement.h
Source/WebCore/html/HTMLPictureElement.cpp
Source/WebCore/html/HTMLPictureElement.h
Source/WebCore/rendering/RenderImage.cpp
Source/WebCore/rendering/RenderTheme.cpp
Source/WebCore/rendering/RenderTheme.h
Source/WebCore/testing/Internals.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/SystemPreviewControllerCocoa.mm
Source/WebKit/UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm
Source/WebKit/UIProcess/ios/WKSystemPreviewView.mm

index 33af372..4dcd82d 100644 (file)
@@ -1,3 +1,17 @@
+2018-04-25  Dean Jackson  <dino@apple.com>
+
+        Make a better flag for system preview, and disable it where necessary
+        https://bugs.webkit.org/show_bug.cgi?id=184968
+        <rdar://problem/39686506>
+
+        Reviewed by Eric Carlson.
+
+        These tests have platform-specific results for the moment.
+
+        * TestExpectations:
+        * system-preview/badge-expected.html: Removed.
+        * system-preview/detection-expected.txt: Removed.
+
 2018-04-25  Miguel Gomez  <magomez@igalia.com>
 
         [GTK] fast/repaint/fixed-scale.html failing since r230479 "[TexMap] TextureMapperLayer unnecessarily duplicates state in GraphicsLayerTransform"
index f3c268f..9435eb4 100644 (file)
@@ -45,6 +45,7 @@ http/tests/events/touch/ios [ Skip ]
 http/tests/preload/viewport [ Skip ]
 http/tests/gzip-content-encoding [ Skip ]
 http/tests/cookies/same-site [ Skip ]
+system-preview [ Skip ]
 
 # window.showModalDialog is only tested in DumpRenderTree on Mac.
 editing/execCommand/show-modal-dialog-during-execCommand.html [ Skip ]
diff --git a/LayoutTests/system-preview/badge-expected.html b/LayoutTests/system-preview/badge-expected.html
deleted file mode 100644 (file)
index 1c71165..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<!DOCTYPE html>
-<style>
-    a {
-        -webkit-clip-path: path("M 82 14 L 86 14 L 86 18 L 82 18 z");
-    }
-    img {
-        width: 100px;
-        height: 100px;
-    }
-</style>
-<p>This test only works in WKTR or DRT.</p>
-<a href="/">
-    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABGdBTUEAAK/INwWK6QAAAANQTFRF/wAAGeIJNwAAAApJREFUeNpjYAAAAAIAAeUn3vwAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAAAAElFTkSuQmCC">
-</a>
diff --git a/LayoutTests/system-preview/detection-expected.txt b/LayoutTests/system-preview/detection-expected.txt
deleted file mode 100644 (file)
index c187c17..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-This test only works in WKTR or DRT.
-
-Valid system preview
-
-Result: Link element present. Identified as system preview. Child 0 is an image inside a system preview.
-
-Valid system preview (multiple rel values)
-
-Result: Link element present. Identified as system preview. Child 0 is an image inside a system preview.
-
-Valid system preview (picture child)
-
-Result: Link element present. Identified as system preview. Child 0 is an image inside a system preview.
-
-Invalid system preview (wrong rel value)
-
-Result: Link element present. Not identified as system preview. Child 0 is not an image inside a system preview.
-
-Invalid system preview (wrong children)
-
-hello
-Result: Link element present. Not identified as system preview. Child 0 is not an image inside a system preview.
-
-Invalid system preview (too many children)
-
-hello  
-Result: Link element present. Not identified as system preview. Child 0 is not an image inside a system preview. Child 1 is not an image inside a system preview.
-
-Invalid system preview (no children)
-
-Result: Link element present. Not identified as system preview.
-
-Invalid system preview (just an image)
-
-
-Result: No link. Child is not an image inside a system preview.
index bc57c04..34d6827 100644 (file)
@@ -1,3 +1,15 @@
+2018-04-25  Dean Jackson  <dino@apple.com>
+
+        Make a better flag for system preview, and disable it where necessary
+        https://bugs.webkit.org/show_bug.cgi?id=184968
+        <rdar://problem/39686506>
+
+        Reviewed by Eric Carlson.
+
+        Add a new USE(SYSTEM_PREVIEW).
+
+        * wtf/Platform.h:
+
 2018-04-24  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r230971.
index 236adb2..d9ba176 100644 (file)
 #endif
 #endif
 
+#if PLATFORM(IOS) && USE(QUICK_LOOK)
+#define USE_SYSTEM_PREVIEW 1
+#endif
+
 #if PLATFORM(COCOA)
 
 #define USE_AVFOUNDATION 1
index 3ab0369..1949379 100644 (file)
@@ -1,3 +1,29 @@
+2018-04-25  Dean Jackson  <dino@apple.com>
+
+        Make a better flag for system preview, and disable it where necessary
+        https://bugs.webkit.org/show_bug.cgi?id=184968
+        <rdar://problem/39686506>
+
+        Reviewed by Eric Carlson.
+
+        Use USE(SYSTEM_PREVIEW).
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::isSystemPreviewLink const):
+        * html/HTMLAnchorElement.h:
+        * html/HTMLImageElement.cpp:
+        * html/HTMLImageElement.h:
+        * html/HTMLPictureElement.cpp:
+        * html/HTMLPictureElement.h:
+        * rendering/RenderImage.cpp:
+        (WebCore::RenderImage::paintIntoRect):
+        * rendering/RenderTheme.cpp:
+        * rendering/RenderTheme.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::systemPreviewRelType):
+        (WebCore::Internals::isSystemPreviewLink const):
+        (WebCore::Internals::isSystemPreviewImage const):
+
 2018-04-25  Zalan Bujtas  <zalan@apple.com>
 
         Fix project file after r230931.
index c5639e5..7152317 100644 (file)
@@ -53,7 +53,7 @@
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/text/StringBuilder.h>
 
-#if USE(APPLE_INTERNAL_SDK)
+#if USE(SYSTEM_PREVIEW) && USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SystemPreviewDetection.cpp>
 #endif
 
@@ -368,6 +368,7 @@ void HTMLAnchorElement::sendPings(const URL& destinationURL)
         PingLoader::sendPing(*document().frame(), document().completeURL(pingURLs[i]), destinationURL);
 }
 
+#if USE(SYSTEM_PREVIEW)
 bool HTMLAnchorElement::isSystemPreviewLink() const
 {
 #if USE(APPLE_INTERNAL_SDK)
@@ -376,8 +377,6 @@ bool HTMLAnchorElement::isSystemPreviewLink() const
     auto systemPreviewRelValue = String { ASCIILiteral("system-preview") };
 #endif
 
-    // The relList is created on demand, which means that calling relList()
-    // is only available in a non-const method.
     if (!relList().contains(systemPreviewRelValue))
         return false;
 
@@ -391,6 +390,7 @@ bool HTMLAnchorElement::isSystemPreviewLink() const
 
     return false;
 }
+#endif
 
 void HTMLAnchorElement::handleClick(Event& event)
 {
index f9cffc4..b1c51f7 100644 (file)
@@ -68,7 +68,9 @@ public:
 
     WEBCORE_EXPORT DOMTokenList& relList() const;
 
+#if USE(SYSTEM_PREVIEW)
     WEBCORE_EXPORT bool isSystemPreviewLink() const;
+#endif
 
 protected:
     HTMLAnchorElement(const QualifiedName&, Document&);
index 6ea882d..4f6597c 100644 (file)
@@ -677,6 +677,7 @@ bool HTMLImageElement::willRespondToMouseClickEvents()
 }
 #endif
 
+#if USE(SYSTEM_PREVIEW)
 bool HTMLImageElement::isSystemPreviewImage() const
 {
     const auto* parent = parentElement();
@@ -684,5 +685,6 @@ bool HTMLImageElement::isSystemPreviewImage() const
         return false;
     return downcast<HTMLAnchorElement>(parent)->isSystemPreviewLink();
 }
+#endif
 
 }
index f648fc6..48aec1a 100644 (file)
@@ -100,7 +100,9 @@ public:
     HTMLPictureElement* pictureElement() const;
     void setPictureElement(HTMLPictureElement*);
 
+#if USE(SYSTEM_PREVIEW)
     WEBCORE_EXPORT bool isSystemPreviewImage() const;
+#endif
 
 protected:
     HTMLImageElement(const QualifiedName&, Document&, HTMLFormElement* = 0);
index cb9de7c..e9c6e7e 100644 (file)
@@ -76,6 +76,7 @@ bool HTMLPictureElement::viewportChangeAffectedPicture() const
     return false;
 }
 
+#if USE(SYSTEM_PREVIEW)
 bool HTMLPictureElement::isSystemPreviewImage() const
 {
     const auto* parent = parentElement();
@@ -83,6 +84,7 @@ bool HTMLPictureElement::isSystemPreviewImage() const
         return false;
     return downcast<HTMLAnchorElement>(parent)->isSystemPreviewLink();
 }
+#endif
 
 }
 
index 0da4ce1..3d507ce 100644 (file)
@@ -46,7 +46,9 @@ public:
 
     WeakPtr<HTMLPictureElement> createWeakPtr() { return m_weakFactory.createWeakPtr(*this); }
 
+#if USE(SYSTEM_PREVIEW)
     WEBCORE_EXPORT bool isSystemPreviewImage() const;
+#endif
 
 private:
     HTMLPictureElement(const QualifiedName&, Document&);
index fbd7834..984681f 100644 (file)
@@ -593,8 +593,10 @@ ImageDrawResult RenderImage::paintIntoRect(PaintInfo& paintInfo, const FloatRect
     if (drawResult == ImageDrawResult::DidRequestDecoding)
         imageResource().cachedImage()->addPendingImageDrawingClient(*this);
 
+#if USE(SYSTEM_PREVIEW)
     if (imageElement && imageElement->isSystemPreviewImage())
         theme().paintSystemPreviewBadge(*img, paintInfo, rect);
+#endif
 
     return drawResult;
 }
index 99b46aa..7920b77 100644 (file)
@@ -1357,6 +1357,7 @@ String RenderTheme::fileListNameForWidth(const FileList* fileList, const FontCas
     return StringTruncator::centerTruncate(string, width, font);
 }
 
+#if USE(SYSTEM_PREVIEW)
 void RenderTheme::paintSystemPreviewBadge(Image& image, const PaintInfo& paintInfo, const FloatRect& rect)
 {
     // The default implementation paints a small marker
@@ -1375,6 +1376,7 @@ void RenderTheme::paintSystemPreviewBadge(Image& image, const PaintInfo& paintIn
     auto color = Color { 255, 0, 0 };
     context.fillRoundedRect(roundedMarkerRect, color);
 }
+#endif
 
 #if ENABLE(TOUCH_EVENTS)
 
index ae68677..cdb349a 100644 (file)
@@ -246,7 +246,9 @@ public:
     virtual bool shouldMockBoldSystemFontForAccessibility() const { return false; }
     virtual void setShouldMockBoldSystemFontForAccessibility(bool) { }
 
+#if USE(SYSTEM_PREVIEW)
     virtual void paintSystemPreviewBadge(Image&, const PaintInfo&, const FloatRect&);
+#endif
 
 protected:
     virtual FontCascadeDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
index d44fc0a..81a4009 100644 (file)
 #include "MockCredentialsMessenger.h"
 #endif
 
-#if USE(APPLE_INTERNAL_SDK)
+#if USE(SYSTEM_PREVIEW) && USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SystemPreviewDetection.cpp>
 #endif
 
@@ -4474,7 +4474,7 @@ MockCredentialsMessenger& Internals::mockCredentialsMessenger() const
 
 String Internals::systemPreviewRelType()
 {
-#if USE(APPLE_INTERNAL_SDK)
+#if USE(SYSTEM_PREVIEW) && USE(APPLE_INTERNAL_SDK)
     return getSystemPreviewRelValue();
 #else
     return ASCIILiteral("system-preview");
@@ -4483,16 +4483,26 @@ String Internals::systemPreviewRelType()
 
 bool Internals::isSystemPreviewLink(Element& element) const
 {
+#if USE(SYSTEM_PREVIEW)
     return is<HTMLAnchorElement>(element) && downcast<HTMLAnchorElement>(element).isSystemPreviewLink();
+#else
+    UNUSED_PARAM(element);
+    return false;
+#endif
 }
 
 bool Internals::isSystemPreviewImage(Element& element) const
 {
+#if USE(SYSTEM_PREVIEW)
     if (is<HTMLImageElement>(element))
         return downcast<HTMLImageElement>(element).isSystemPreviewImage();
     if (is<HTMLPictureElement>(element))
         return downcast<HTMLPictureElement>(element).isSystemPreviewImage();
     return false;
+#else
+    UNUSED_PARAM(element);
+    return false;
+#endif
 }
 
 bool Internals::usingAppleInternalSDK() const
index f5b3dcb..0b633e2 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-25  Dean Jackson  <dino@apple.com>
+
+        Make a better flag for system preview, and disable it where necessary
+        https://bugs.webkit.org/show_bug.cgi?id=184968
+        <rdar://problem/39686506>
+
+        Reviewed by Eric Carlson.
+
+        Use USE(SYSTEM_PREVIEW).
+
+        * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm:
+        * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm:
+        (-[WKWebViewContentProviderRegistry init]):
+        * UIProcess/ios/WKSystemPreviewView.mm:
+
 2018-04-25  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Implement MouseEvent.buttons
index 52be6e6..d23a22e 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "SystemPreviewController.h"
 
-#if PLATFORM(IOS) && USE(QUICK_LOOK)
+#if USE(SYSTEM_PREVIEW)
 
 #import "APIUIClient.h"
 #import "WebPageProxy.h"
index 23891ff..79b6113 100644 (file)
@@ -41,7 +41,7 @@
 #import <wtf/text/StringHash.h>
 #import <wtf/text/WTFString.h>
 
-#if USE(APPLE_INTERNAL_SDK)
+#if USE(SYSTEM_PREVIEW) && USE(APPLE_INTERNAL_SDK)
 #import <WebKitAdditions/SystemPreviewTypes.cpp>
 #endif
 
@@ -65,7 +65,7 @@ using namespace WebKit;
         [self registerProvider:[WKLegacyPDFView class] forMIMEType:mimeType];
 #endif
 
-#if PLATFORM(IOS) && USE(QUICK_LOOK) && USE(APPLE_INTERNAL_SDK)
+#if USE(SYSTEM_PREVIEW) && USE(APPLE_INTERNAL_SDK)
     for (auto& mimeType : getSystemPreviewMIMETypes())
         [self registerProvider:[WKSystemPreviewView class] forMIMEType:mimeType];
 #endif
index 7441947..8527507 100644 (file)
@@ -26,7 +26,7 @@
 #import "config.h"
 #import "WKSystemPreviewView.h"
 
-#if PLATFORM(IOS) && USE(QUICK_LOOK)
+#if USE(SYSTEM_PREVIEW)
 
 #import "APIFindClient.h"
 #import "APIUIClient.h"