Diff
Modified: trunk/Source/WebCore/ChangeLog (172300 => 172301)
--- trunk/Source/WebCore/ChangeLog 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebCore/ChangeLog 2014-08-07 23:08:38 UTC (rev 172301)
@@ -1,3 +1,27 @@
+2014-08-07 Enrica Casucci <[email protected]>
+
+ [Services with UI] Action menu does not appear if selection includes both text and an image.
+ https://bugs.webkit.org/show_bug.cgi?id=135731
+ <rdar://problem/17837491>
+
+ Reviewed by Brady Eidson.
+
+ When collecting selection rects via SelectionRectGatherer we should also note if the selection
+ contains non text elements. This way the Notifier class can send that information to ServicesOverlayController
+ to properly handle the highlight for the service.
+
+ * editing/SelectionRectGatherer.cpp:
+ (WebCore::SelectionRectGatherer::SelectionRectGatherer):
+ (WebCore::SelectionRectGatherer::Notifier::~Notifier):
+ (WebCore::SelectionRectGatherer::clearAndCreateNotifier):
+ * editing/SelectionRectGatherer.h:
+ (WebCore::SelectionRectGatherer::setTextOnly):
+ (WebCore::SelectionRectGatherer::isTextOnly):
+ * page/EditorClient.h:
+ (WebCore::EditorClient::selectionRectsDidChange):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::applySubtreeSelection):
+
2014-08-07 Andy Estes <[email protected]>
[Mac] Parental Controls content filter is mistakenly enabled for HTTP responses
Modified: trunk/Source/WebCore/editing/SelectionRectGatherer.cpp (172300 => 172301)
--- trunk/Source/WebCore/editing/SelectionRectGatherer.cpp 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebCore/editing/SelectionRectGatherer.cpp 2014-08-07 23:08:38 UTC (rev 172301)
@@ -37,6 +37,7 @@
SelectionRectGatherer::SelectionRectGatherer(RenderView& renderView)
: m_renderView(renderView)
+ , m_isTextOnly(true)
{
}
@@ -70,13 +71,14 @@
SelectionRectGatherer::Notifier::~Notifier()
{
if (EditorClient* client = m_gatherer.m_renderView.view().frame().editor().client())
- client->selectionRectsDidChange(m_gatherer.m_rects, m_gatherer.m_gapRects);
+ client->selectionRectsDidChange(m_gatherer.m_rects, m_gatherer.m_gapRects, m_gatherer.isTextOnly());
}
std::unique_ptr<SelectionRectGatherer::Notifier> SelectionRectGatherer::clearAndCreateNotifier()
{
m_rects.clear();
m_gapRects.clear();
+ m_isTextOnly = true;
return std::make_unique<Notifier>(*this);
}
Modified: trunk/Source/WebCore/editing/SelectionRectGatherer.h (172300 => 172301)
--- trunk/Source/WebCore/editing/SelectionRectGatherer.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebCore/editing/SelectionRectGatherer.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -47,6 +47,8 @@
void addRect(RenderLayerModelObject *repaintContainer, const LayoutRect&);
void addGapRects(RenderLayerModelObject *repaintContainer, const GapRects&);
+ void setTextOnly(bool isTextOnly) { m_isTextOnly = isTextOnly; }
+ bool isTextOnly() const { return m_isTextOnly; }
class Notifier {
WTF_MAKE_NONCOPYABLE(Notifier);
@@ -66,6 +68,7 @@
// All rects are in RenderView coordinates.
Vector<LayoutRect> m_rects;
Vector<GapRects> m_gapRects;
+ bool m_isTextOnly;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/page/EditorClient.h (172300 => 172301)
--- trunk/Source/WebCore/page/EditorClient.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebCore/page/EditorClient.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -183,7 +183,7 @@
#if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
virtual void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<Range>>&) { }
- virtual void selectionRectsDidChange(const Vector<LayoutRect>&, const Vector<GapRects>&) { }
+ virtual void selectionRectsDidChange(const Vector<LayoutRect>&, const Vector<GapRects>&, bool) { }
#endif
// Support for global selections, used on platforms like the X Window System that treat
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (172300 => 172301)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2014-08-07 23:08:38 UTC (rev 172301)
@@ -1016,6 +1016,8 @@
#if ENABLE(SERVICE_CONTROLS)
for (auto& rect : selectionInfo->collectedSelectionRects())
m_selectionRectGatherer.addRect(selectionInfo->repaintContainer(), rect);
+ if (!o->isTextOrLineBreak())
+ m_selectionRectGatherer.setTextOnly(false);
#endif
newSelectedObjects.set(o, WTF::move(selectionInfo));
Modified: trunk/Source/WebKit2/ChangeLog (172300 => 172301)
--- trunk/Source/WebKit2/ChangeLog 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/ChangeLog 2014-08-07 23:08:38 UTC (rev 172301)
@@ -1,3 +1,42 @@
+2014-08-07 Enrica Casucci <[email protected]>
+
+ [Services with UI] Action menu does not appear if selection includes both text and an image.
+ https://bugs.webkit.org/show_bug.cgi?id=135731
+ <rdar://problem/17837491>
+
+ Reviewed by Brady Eidson.
+
+ Adding a new setting to ServicesController to communicate to the WebProcess if
+ there are services installed that can handle a combination of text and images.
+ This way ServicesOverlayController can decide if it appropriate to show the hightlight
+ based on the type of selection (text only or non text only). This information is retrieved
+ when the selection rects are collected by SelectionGatherer and used by
+ SelectionGatherer::Notifier to communicate the selection change.
+
+ * Shared/WebProcessCreationParameters.cpp:
+ (WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
+ * Shared/WebProcessCreationParameters.h:
+ * UIProcess/mac/ServicesController.h:
+ (WebKit::ServicesController::hasRichContentServices):
+ * UIProcess/mac/ServicesController.mm:
+ (WebKit::ServicesController::ServicesController):
+ (WebKit::ServicesController::refreshExistingServices):
+ * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+ (WebKit::WebEditorClient::selectionRectsDidChange):
+ * WebProcess/WebCoreSupport/WebEditorClient.h:
+ * WebProcess/WebPage/ServicesOverlayController.h:
+ * WebProcess/WebPage/mac/ServicesOverlayController.mm:
+ (WebKit::ServicesOverlayController::ServicesOverlayController):
+ (WebKit::ServicesOverlayController::selectionRectsDidChange):
+ (WebKit::ServicesOverlayController::drawSelectionHighlight):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::WebProcess):
+ (WebKit::WebProcess::initializeWebProcess):
+ (WebKit::WebProcess::setEnabledServices):
+ * WebProcess/WebProcess.h:
+ (WebKit::WebProcess::hasRichContentServices):
+ * WebProcess/WebProcess.messages.in:
+
2014-08-07 Ryuan Choi <[email protected]>
[EFL] Fix several warnings of doxygen
Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (172300 => 172301)
--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp 2014-08-07 23:08:38 UTC (rev 172301)
@@ -51,6 +51,7 @@
#if ENABLE(SERVICE_CONTROLS)
, hasImageServices(false)
, hasSelectionServices(false)
+ , hasRichContentServices(false)
#endif
{
}
Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (172300 => 172301)
--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -168,6 +168,7 @@
#if ENABLE(SERVICE_CONTROLS)
bool hasImageServices;
bool hasSelectionServices;
+ bool hasRichContentServices;
#endif
};
Modified: trunk/Source/WebKit2/UIProcess/mac/ServicesController.h (172300 => 172301)
--- trunk/Source/WebKit2/UIProcess/mac/ServicesController.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/UIProcess/mac/ServicesController.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -45,6 +45,7 @@
bool hasImageServices() const { return m_hasImageServices; }
bool hasSelectionServices() const { return m_hasSelectionServices; }
+ bool hasRichContentServices() const { return m_hasRichContentServices; }
void refreshExistingServices(WebContext*);
@@ -58,6 +59,7 @@
bool m_hasImageServices;
bool m_hasSelectionServices;
+ bool m_hasRichContentServices;
HashSet<RefPtr<WebContext>> m_contextsToNotify;
};
Modified: trunk/Source/WebKit2/UIProcess/mac/ServicesController.mm (172300 => 172301)
--- trunk/Source/WebKit2/UIProcess/mac/ServicesController.mm 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/UIProcess/mac/ServicesController.mm 2014-08-07 23:08:38 UTC (rev 172301)
@@ -61,6 +61,7 @@
, m_isRefreshing(false)
, m_hasImageServices(false)
, m_hasSelectionServices(false)
+ , m_hasRichContentServices(false)
{
refreshExistingServices();
}
@@ -93,14 +94,30 @@
bool hasSelectionServices = picker.get().menu;
+ static NSAttributedString *attributedStringWithRichContent;
+ if (!attributedStringWithRichContent) {
+ NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
+ NSTextAttachmentCell *cell = [[NSTextAttachmentCell alloc] initImageCell:image.get()];
+ [attachment setAttachmentCell:cell];
+ NSMutableAttributedString *richString = (NSMutableAttributedString *)[NSMutableAttributedString attributedStringWithAttachment:attachment];
+ [richString appendAttributedString: attributedString];
+ attributedStringWithRichContent = [richString retain];
+ }
+
+ picker = adoptNS([[NSSharingServicePicker alloc] initWithItems:@[ attributedStringWithRichContent ]]);
+ [picker setStyle:NSSharingServicePickerStyleTextSelection];
+
+ bool hasRichContentServices = picker.get().menu;
+
dispatch_async(dispatch_get_main_queue(), ^{
- bool notifyContexts = (hasImageServices != m_hasImageServices) || (hasSelectionServices != m_hasSelectionServices);
+ bool notifyContexts = (hasImageServices != m_hasImageServices) || (hasSelectionServices != m_hasSelectionServices) || (hasRichContentServices != m_hasRichContentServices);
m_hasSelectionServices = hasSelectionServices;
m_hasImageServices = hasImageServices;
+ m_hasRichContentServices = hasRichContentServices;
if (notifyContexts) {
for (const RefPtr<WebContext>& context : m_contextsToNotify)
- context->sendToAllProcesses(Messages::WebProcess::SetEnabledServices(m_hasImageServices, m_hasSelectionServices));
+ context->sendToAllProcesses(Messages::WebProcess::SetEnabledServices(m_hasImageServices, m_hasSelectionServices, m_hasRichContentServices));
}
m_contextsToNotify.clear();
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.cpp 2014-08-07 23:08:38 UTC (rev 172301)
@@ -538,11 +538,11 @@
m_page->servicesOverlayController().selectedTelephoneNumberRangesChanged(ranges);
#endif
}
-void WebEditorClient::selectionRectsDidChange(const Vector<LayoutRect>& rects, const Vector<GapRects>& gapRects)
+void WebEditorClient::selectionRectsDidChange(const Vector<LayoutRect>& rects, const Vector<GapRects>& gapRects, bool isTextOnly)
{
#if PLATFORM(MAC)
if (m_page->serviceControlsEnabled())
- m_page->servicesOverlayController().selectionRectsDidChange(rects, gapRects);
+ m_page->servicesOverlayController().selectionRectsDidChange(rects, gapRects, isTextOnly);
#endif
}
#endif // ENABLE(SERVICE_CONTROLS) && ENABLE(TELEPHONE_NUMBER_DETECTION)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebEditorClient.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -170,7 +170,7 @@
#if ENABLE(TELEPHONE_NUMBER_DETECTION) || ENABLE(SERVICE_CONTROLS)
virtual void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<WebCore::Range>>&) override;
- virtual void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&) override;
+ virtual void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&, bool isTextOnly) override;
#endif
WebPage* m_page;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ServicesOverlayController.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -63,7 +63,7 @@
~ServicesOverlayController();
void selectedTelephoneNumberRangesChanged(const Vector<RefPtr<WebCore::Range>>&);
- void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&);
+ void selectionRectsDidChange(const Vector<WebCore::LayoutRect>&, const Vector<WebCore::GapRects>&, bool isTextOnly);
private:
void createOverlayIfNeeded();
@@ -95,6 +95,7 @@
Vector<WebCore::LayoutRect> m_currentSelectionRects;
RetainPtr<DDHighlightRef> m_selectionHighlight;
+ bool m_isTextOnly;
std::chrono::steady_clock::time_point m_lastSelectionChangeTime;
std::chrono::steady_clock::time_point m_lastHoveredHighlightChangeTime;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/ServicesOverlayController.mm 2014-08-07 23:08:38 UTC (rev 172301)
@@ -76,6 +76,7 @@
ServicesOverlayController::ServicesOverlayController(WebPage& webPage)
: m_webPage(&webPage)
, m_servicesOverlay(nullptr)
+ , m_isTextOnly(false)
, m_repaintHighlightTimer(this, &ServicesOverlayController::repaintHighlightTimerFired)
{
}
@@ -211,11 +212,12 @@
}
}
-void ServicesOverlayController::selectionRectsDidChange(const Vector<LayoutRect>& rects, const Vector<GapRects>& gapRects)
+void ServicesOverlayController::selectionRectsDidChange(const Vector<LayoutRect>& rects, const Vector<GapRects>& gapRects, bool isTextOnly)
{
#if __MAC_OS_X_VERSION_MIN_REQUIRED > 1090
clearSelectionHighlight();
m_currentSelectionRects = rects;
+ m_isTextOnly = isTextOnly;
m_lastSelectionChangeTime = std::chrono::steady_clock::now();
@@ -271,7 +273,7 @@
{
// It's possible to end up drawing the selection highlight before we've actually received the selection rects.
// If that happens we'll end up here again once we have the rects.
- if (m_currentSelectionRects.isEmpty())
+ if (m_currentSelectionRects.isEmpty() || (!WebProcess::shared().hasRichContentServices() && !m_isTextOnly))
return;
// If there are no installed selection services and we have no phone numbers detected, then we have nothing to draw.
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2014-08-07 23:08:38 UTC (rev 172301)
@@ -174,6 +174,7 @@
#if ENABLE(SERVICE_CONTROLS)
, m_hasImageServices(false)
, m_hasSelectionServices(false)
+ , m_hasRichContentServices(false)
#endif
, m_nonVisibleProcessCleanupTimer(this, &WebProcess::nonVisibleProcessCleanupTimerFired)
{
@@ -364,7 +365,7 @@
setMemoryCacheDisabled(parameters.memoryCacheDisabled);
#if ENABLE(SERVICE_CONTROLS)
- setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices);
+ setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices, parameters.hasRichContentServices);
#endif
#if ENABLE(REMOTE_INSPECTOR)
@@ -1251,10 +1252,11 @@
}
#if ENABLE(SERVICE_CONTROLS)
-void WebProcess::setEnabledServices(bool hasImageServices, bool hasSelectionServices)
+void WebProcess::setEnabledServices(bool hasImageServices, bool hasSelectionServices, bool hasRichContentServices)
{
m_hasImageServices = hasImageServices;
m_hasSelectionServices = hasSelectionServices;
+ m_hasRichContentServices = hasRichContentServices;
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2014-08-07 23:08:38 UTC (rev 172301)
@@ -189,6 +189,7 @@
#if ENABLE(SERVICE_CONTROLS)
bool hasImageServices() const { return m_hasImageServices; }
bool hasSelectionServices() const { return m_hasSelectionServices; }
+ bool hasRichContentServices() const { return m_hasRichContentServices; }
#endif
private:
@@ -252,7 +253,7 @@
void setMemoryCacheDisabled(bool);
#if ENABLE(SERVICE_CONTROLS)
- void setEnabledServices(bool hasImageServices, bool hasSelectionServices);
+ void setEnabledServices(bool hasImageServices, bool hasSelectionServices, bool hasRichContentServices);
#endif
void postInjectedBundleMessage(const IPC::DataReference& messageData);
@@ -339,6 +340,7 @@
#if ENABLE(SERVICE_CONTROLS)
bool m_hasImageServices;
bool m_hasSelectionServices;
+ bool m_hasRichContentServices;
#endif
HashSet<uint64_t> m_pagesInWindows;
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (172300 => 172301)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2014-08-07 23:06:56 UTC (rev 172300)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2014-08-07 23:08:38 UTC (rev 172301)
@@ -90,7 +90,7 @@
SetMemoryCacheDisabled(bool disabled);
#if ENABLE(SERVICE_CONTROLS)
- SetEnabledServices(bool hasImageServices, bool hasSelectionServices)
+ SetEnabledServices(bool hasImageServices, bool hasSelectionServices, bool hasRichContentServices)
#endif
ProcessWillSuspend()