Diff
Modified: trunk/Source/WebCore/ChangeLog (198577 => 198578)
--- trunk/Source/WebCore/ChangeLog 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebCore/ChangeLog 2016-03-23 05:46:00 UTC (rev 198578)
@@ -1,3 +1,24 @@
+2016-03-22 Tim Horton <[email protected]>
+
+ Invoking a link preview on a complex link (e.g. an image) results in an empty TextIndicator
+ https://bugs.webkit.org/show_bug.cgi?id=155779
+ <rdar://problem/22408793>
+
+ Reviewed by Simon Fraser.
+
+ * page/FrameSnapshotting.cpp:
+ (WebCore::snapshotFrameRect):
+ (WebCore::snapshotFrameRectWithClip):
+ * page/FrameSnapshotting.h:
+ * page/TextIndicator.cpp:
+ (WebCore::takeSnapshot):
+ (WebCore::takeSnapshots):
+ (WebCore::initializeIndicator):
+ When snapshotting, clip to the indicated range's rects. This is important
+ to avoid painting into the margins in the non-selection-only painting case.
+ This didn't come up with normal selection-only painting because the text
+ didn't intersect the margin, and the background doesn't paint.
+
2016-03-22 Darin Adler <[email protected]>
showModalDialog code runs with "first window" set to wrong window
Modified: trunk/Source/WebCore/page/FrameSnapshotting.cpp (198577 => 198578)
--- trunk/Source/WebCore/page/FrameSnapshotting.cpp 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebCore/page/FrameSnapshotting.cpp 2016-03-23 05:46:00 UTC (rev 198578)
@@ -32,6 +32,7 @@
#include "FrameSnapshotting.h"
#include "Document.h"
+#include "FloatRect.h"
#include "Frame.h"
#include "FrameSelection.h"
#include "FrameView.h"
@@ -68,6 +69,12 @@
std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame& frame, const IntRect& imageRect, SnapshotOptions options)
{
+ Vector<FloatRect> clipRects;
+ return snapshotFrameRectWithClip(frame, imageRect, clipRects, options);
+}
+
+std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame& frame, const IntRect& imageRect, Vector<FloatRect>& clipRects, SnapshotOptions options)
+{
if (!frame.page())
return nullptr;
@@ -104,6 +111,13 @@
return nullptr;
buffer->context().translate(-imageRect.x(), -imageRect.y());
+ if (!clipRects.isEmpty()) {
+ Path clipPath;
+ for (auto& rect : clipRects)
+ clipPath.addRect(rect);
+ buffer->context().clipPath(clipPath);
+ }
+
frame.view()->paintContentsForSnapshot(buffer->context(), imageRect, shouldIncludeSelection, coordinateSpace);
return buffer;
}
Modified: trunk/Source/WebCore/page/FrameSnapshotting.h (198577 => 198578)
--- trunk/Source/WebCore/page/FrameSnapshotting.h 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebCore/page/FrameSnapshotting.h 2016-03-23 05:46:00 UTC (rev 198578)
@@ -31,9 +31,11 @@
#define FrameSnapshotting_h
#include <memory>
+#include <wtf/Vector.h>
namespace WebCore {
+class FloatRect;
class Frame;
class IntRect;
class ImageBuffer;
@@ -50,6 +52,7 @@
typedef unsigned SnapshotOptions;
WEBCORE_EXPORT std::unique_ptr<ImageBuffer> snapshotFrameRect(Frame&, const IntRect&, SnapshotOptions = SnapshotOptionsNone);
+std::unique_ptr<ImageBuffer> snapshotFrameRectWithClip(Frame&, const IntRect&, Vector<FloatRect>& clipRects, SnapshotOptions = SnapshotOptionsNone);
std::unique_ptr<ImageBuffer> snapshotNode(Frame&, Node&);
WEBCORE_EXPORT std::unique_ptr<ImageBuffer> snapshotSelection(Frame&, SnapshotOptions = SnapshotOptionsNone);
Modified: trunk/Source/WebCore/page/TextIndicator.cpp (198577 => 198578)
--- trunk/Source/WebCore/page/TextIndicator.cpp 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebCore/page/TextIndicator.cpp 2016-03-23 05:46:00 UTC (rev 198578)
@@ -149,26 +149,26 @@
return snapshotOptions;
}
-static RefPtr<Image> takeSnapshot(Frame& frame, IntRect rect, SnapshotOptions options, float& scaleFactor)
+static RefPtr<Image> takeSnapshot(Frame& frame, IntRect rect, SnapshotOptions options, float& scaleFactor, Vector<FloatRect>& clipRectsInDocumentCoordinates)
{
- std::unique_ptr<ImageBuffer> buffer = snapshotFrameRect(frame, rect, options);
+ std::unique_ptr<ImageBuffer> buffer = snapshotFrameRectWithClip(frame, rect, clipRectsInDocumentCoordinates, options);
if (!buffer)
return nullptr;
scaleFactor = buffer->resolutionScale();
return ImageBuffer::sinkIntoImage(WTFMove(buffer), Unscaled);
}
-static bool takeSnapshots(TextIndicatorData& data, Frame& frame, IntRect snapshotRect)
+static bool takeSnapshots(TextIndicatorData& data, Frame& frame, IntRect snapshotRect, Vector<FloatRect>& clipRectsInDocumentCoordinates)
{
SnapshotOptions snapshotOptions = snapshotOptionsForTextIndicatorOptions(data.options);
- data.contentImage = takeSnapshot(frame, snapshotRect, snapshotOptions, data.contentImageScaleFactor);
+ data.contentImage = takeSnapshot(frame, snapshotRect, snapshotOptions, data.contentImageScaleFactor, clipRectsInDocumentCoordinates);
if (!data.contentImage)
return false;
if (data.options & TextIndicatorOptionIncludeSnapshotWithSelectionHighlight) {
float snapshotScaleFactor;
- data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, SnapshotOptionsNone, snapshotScaleFactor);
+ data.contentImageWithHighlight = takeSnapshot(frame, snapshotRect, SnapshotOptionsNone, snapshotScaleFactor, clipRectsInDocumentCoordinates);
ASSERT(!data.contentImageWithHighlight || data.contentImageScaleFactor == snapshotScaleFactor);
}
@@ -238,7 +238,7 @@
data.textBoundingRectInRootViewCoordinates = textBoundingRectInRootViewCoordinates;
data.textRectsInBoundingRectCoordinates = textRectsInBoundingRectCoordinates;
- return takeSnapshots(data, frame, enclosingIntRect(textBoundingRectInDocumentCoordinates));
+ return takeSnapshots(data, frame, enclosingIntRect(textBoundingRectInDocumentCoordinates), textRects);
}
} // namespace WebCore
Modified: trunk/Source/WebKit2/ChangeLog (198577 => 198578)
--- trunk/Source/WebKit2/ChangeLog 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-23 05:46:00 UTC (rev 198578)
@@ -1,3 +1,17 @@
+2016-03-22 Tim Horton <[email protected]>
+
+ Invoking a link preview on a complex link (e.g. an image) results in an empty TextIndicator
+ https://bugs.webkit.org/show_bug.cgi?id=155779
+ <rdar://problem/22408793>
+
+ Reviewed by Simon Fraser.
+
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::dictionaryPopupInfoForRange):
+ (WebKit::WebPage::performImmediateActionHitTestAtLocation):
+ Use the TextIndicator mode where we give up on selection-only snapshotting
+ and just paint all content on Mac, similar to what we do for 3D Touch indicators.
+
2016-03-22 Alex Christensen <[email protected]>
Fix HTTPS on Mac using NSURLSession after r198457
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (198577 => 198578)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-03-23 04:29:19 UTC (rev 198577)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2016-03-23 05:46:00 UTC (rev 198578)
@@ -443,7 +443,7 @@
[scaledNSAttributedString addAttributes:scaledAttributes.get() range:range];
}];
- TextIndicatorOptions indicatorOptions = TextIndicatorOptionDefault;
+ TextIndicatorOptions indicatorOptions = TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges;
if (presentationTransition == TextIndicatorPresentationTransition::BounceAndCrossfade)
indicatorOptions |= TextIndicatorOptionIncludeSnapshotWithSelectionHighlight;
@@ -969,7 +969,7 @@
Element *URLElement = hitTestResult.URLElement();
if (!absoluteLinkURL.isEmpty() && URLElement) {
RefPtr<Range> linkRange = rangeOfContents(*URLElement);
- immediateActionResult.linkTextIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn);
+ immediateActionResult.linkTextIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges, TextIndicatorPresentationTransition::FadeIn);
}
NSDictionary *options = nil;
@@ -1005,7 +1005,7 @@
detectedDataBoundingBox.unite(frameView->contentsToWindow(quad.enclosingBoundingBox()));
immediateActionResult.detectedDataBoundingBox = detectedDataBoundingBox;
- immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(*mainResultRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn);
+ immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(*mainResultRange, TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges, TextIndicatorPresentationTransition::FadeIn);
immediateActionResult.detectedDataOriginatingPageOverlay = overlay->pageOverlayID();
break;
@@ -1018,7 +1018,7 @@
immediateActionResult.detectedDataActionContext = DataDetection::detectItemAroundHitTestResult(hitTestResult, detectedDataBoundingBox, detectedDataRange);
if (immediateActionResult.detectedDataActionContext && detectedDataRange) {
immediateActionResult.detectedDataBoundingBox = detectedDataBoundingBox;
- immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(*detectedDataRange, TextIndicatorOptionDefault, TextIndicatorPresentationTransition::FadeIn);
+ immediateActionResult.detectedDataTextIndicator = TextIndicator::createWithRange(*detectedDataRange, TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges, TextIndicatorPresentationTransition::FadeIn);
}
}