Title: [176795] branches/safari-600.3-branch/Source

Diff

Modified: branches/safari-600.3-branch/Source/WebCore/ChangeLog (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebCore/ChangeLog	2014-12-04 16:35:44 UTC (rev 176795)
@@ -1,3 +1,24 @@
+2014-12-04  Dana Burkart  <[email protected]>
+
+        Merge r176766. <rdar://problem/19072083>
+
+    2014-12-03  Beth Dakin  <[email protected]>
+
+            <input> elements get whitespace action menu instead of editable text menu
+            https://bugs.webkit.org/show_bug.cgi?id=139241
+            -and corresponding-
+            rdar://problem/19072083
+
+            Reviewed by Sam Weinig.
+
+            Since we will hit test form controls as form controls, we need a new function to 
+            determine if the hit point is over text inside that form control or not.
+            * WebCore.exp.in:
+            * rendering/HitTestResult.cpp:
+            (WebCore::HitTestResult::isOverTextInsideFormControlElement):
+            * rendering/HitTestResult.h:
+
+
 2014-12-03  Dana Burkart  <[email protected]>
 
         Merge r176753. <rdar://problem/19052381>

Modified: branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebCore/WebCore.exp.in	2014-12-04 16:35:44 UTC (rev 176795)
@@ -1078,6 +1078,7 @@
 __ZN7WebCore29cookieRequestHeaderFieldValueERKNS_21NetworkStorageSessionERKNS_3URLES5_
 __ZN7WebCore29createDefaultParagraphElementERNS_8DocumentE
 __ZN7WebCore29isCharacterSmartReplaceExemptEib
+__ZN7WebCore30enclosingTextUnitOfGranularityERKNS_15VisiblePositionENS_15TextGranularityENS_18SelectionDirectionE
 __ZN7WebCore30hostNameNeedsDecodingWithRangeEP8NSString8_NSRange
 __ZN7WebCore30hostNameNeedsEncodingWithRangeEP8NSString8_NSRange
 __ZN7WebCore30overrideUserPreferredLanguagesERKN3WTF6VectorINS0_6StringELm0ENS0_15CrashOnOverflowEEE
@@ -1684,6 +1685,7 @@
 __ZNK7WebCore13HitTestResult19mediaIsInFullscreenEv
 __ZNK7WebCore13HitTestResult19rectBasedTestResultEv
 __ZNK7WebCore13HitTestResult21innerNonSharedElementEv
+__ZNK7WebCore13HitTestResult34isOverTextInsideFormControlElementEv
 __ZNK7WebCore13HitTestResult5imageEv
 __ZNK7WebCore13HitTestResult5titleERNS_13TextDirectionE
 __ZNK7WebCore13HitTestResult9imageRectEv
@@ -2726,7 +2728,6 @@
 __ZN7WebCore27tileControllerMemoryHandlerEv
 __ZN7WebCore27withinTextUnitOfGranularityERKNS_15VisiblePositionENS_15TextGranularityENS_18SelectionDirectionE
 __ZN7WebCore30closestWordBoundaryForPositionERKNS_15VisiblePositionE
-__ZN7WebCore30enclosingTextUnitOfGranularityERKNS_15VisiblePositionENS_15TextGranularityENS_18SelectionDirectionE
 __ZN7WebCore30plainTextReplacingNoBreakSpaceEPKNS_5RangeEtb
 __ZN7WebCore31NonSharedCharacterBreakIteratorC1EN3WTF10StringViewE
 __ZN7WebCore31NonSharedCharacterBreakIteratorD1Ev

Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.cpp	2014-12-04 16:35:44 UTC (rev 176795)
@@ -49,6 +49,7 @@
 #include "SVGImageElement.h"
 #include "SVGNames.h"
 #include "UserGestureIndicator.h"
+#include "VisibleUnits.h"
 #include "XLinkNames.h"
 
 namespace WebCore {
@@ -515,6 +516,34 @@
     return false;
 }
 
+bool HitTestResult::isOverTextInsideFormControlElement() const
+{
+    Node* node = innerNode();
+    if (!node)
+        return false;
+
+    if (!is<HTMLTextFormControlElement>(*node))
+        return false;
+
+    Frame* frame = node->document().frame();
+    if (!frame)
+        return false;
+
+    IntPoint framePoint = roundedPointInInnerNodeFrame();
+    if (!frame->rangeForPoint(framePoint))
+        return false;
+
+    VisiblePosition position = frame->visiblePositionForPoint(framePoint);
+    if (position.isNull())
+        return false;
+
+    RefPtr<Range> wordRange = enclosingTextUnitOfGranularity(position, WordGranularity, DirectionForward);
+    if (!wordRange)
+        return false;
+
+    return !wordRange->text().isEmpty();
+}
+
 URL HitTestResult::absoluteLinkURL() const
 {
     if (m_innerURLElement)

Modified: branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebCore/rendering/HitTestResult.h	2014-12-04 16:35:44 UTC (rev 176795)
@@ -125,6 +125,7 @@
     bool mediaMuted() const;
     void toggleMediaMuteState() const;
     bool isDownloadableMedia() const;
+    bool isOverTextInsideFormControlElement() const;
 
     // Returns true if it is rect-based hit test and needs to continue until the rect is fully
     // enclosed by the boundaries of a node.

Modified: branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit/mac/ChangeLog	2014-12-04 16:35:44 UTC (rev 176795)
@@ -1,5 +1,32 @@
 2014-12-04  Dana Burkart  <[email protected]>
 
+        Merge r176766. <rdar://problem/19072083>
+
+    2014-12-03  Beth Dakin  <[email protected]>
+
+            <input> elements get whitespace action menu instead of editable text menu
+            https://bugs.webkit.org/show_bug.cgi?id=139241
+            -and corresponding-
+            rdar://problem/19072083
+
+            Reviewed by Sam Weinig.
+
+            We should disallow shadow content in the hit test. This is the default and it is 
+            how context menus behave. We originally wanted to text inside shadow content so 
+            that we could find the text, but the new function I added to HitTestResult will 
+            allow that.
+            * WebView/WebActionMenuController.mm:
+            (-[WebActionMenuController performHitTestAtPoint:]):
+
+            Adjust to the fact that we don’t hit test shadow content any more.
+            (-[WebActionMenuController focusAndSelectHitTestResult]):
+
+            Offer the text menus for text inside form controls.
+            (-[WebActionMenuController _defaultMenuItems]):
+
+
+2014-12-04  Dana Burkart  <[email protected]>
+
         Merge r176763. <rdar://problem/19115662>
 
     2014-12-03  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit/mac/WebView/WebActionMenuController.mm	2014-12-04 16:35:44 UTC (rev 176795)
@@ -109,18 +109,8 @@
     Frame* coreFrame = core([documentView _frame]);
     if (!coreFrame)
         return nil;
-    HitTestRequest::HitTestRequestType hitType = HitTestRequest::ReadOnly | HitTestRequest::Active;
-    _hitTestResult = coreFrame->eventHandler().hitTestResultAtPoint(IntPoint(point), hitType);
+    _hitTestResult = coreFrame->eventHandler().hitTestResultAtPoint(IntPoint(point));
 
-    // We hit test including shadow content to get the desired result for editable text regions.
-    // But for media, we want to re-set to the shadow root.
-    if (Node* node = _hitTestResult.innerNode()) {
-        if (Element* shadowHost = node->shadowHost()) {
-            if (shadowHost->isMediaElement())
-                _hitTestResult.setToNonShadowAncestor();
-        }
-    }
-
     return [[[WebElementDictionary alloc] initWithHitTestResult:_hitTestResult] autorelease];
 }
 
@@ -182,15 +172,13 @@
     if (!element)
         return;
 
-    auto renderer = element->renderer();
-    if (!renderer)
+    Frame* frame = element->document().frame();
+    if (!frame)
         return;
 
-    Frame& frame = renderer->frame();
-
-    frame.page()->focusController().setFocusedElement(element, element->document().frame());
-    VisiblePosition position = renderer->positionForPoint(_hitTestResult.localPoint(), nullptr);
-    frame.selection().setSelection(position);
+    frame->page()->focusController().setFocusedElement(element, frame);
+    VisiblePosition position = frame->visiblePositionForPoint(_hitTestResult.roundedPointInInnerNodeFrame());
+    frame->selection().setSelection(position);
 }
 
 - (void)willOpenMenu:(NSMenu *)menu withEvent:(NSEvent *)event
@@ -875,7 +863,7 @@
     }
 
     Node* node = _hitTestResult.innerNode();
-    if (node && node->isTextNode()) {
+    if ((node && node->isTextNode()) || _hitTestResult.isOverTextInsideFormControlElement()) {
         NSArray *dataDetectorMenuItems = [self _defaultMenuItemsForDataDetectedText];
         if (_currentActionContext) {
             // If this is a data detected item with no menu items, we should not fall back to regular text options.

Modified: branches/safari-600.3-branch/Source/WebKit2/ChangeLog (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit2/ChangeLog	2014-12-04 16:35:44 UTC (rev 176795)
@@ -1,5 +1,42 @@
 2014-12-04  Dana Burkart  <[email protected]>
 
+        Merge r176766. <rdar://problem/19072083>
+
+    2014-12-03  Beth Dakin  <[email protected]>
+
+            <input> elements get whitespace action menu instead of editable text menu
+            https://bugs.webkit.org/show_bug.cgi?id=139241
+            -and corresponding-
+            rdar://problem/19072083
+
+            Reviewed by Sam Weinig.
+
+            Add isOverTextInsideFormControlElement to WebHitTestResult.
+            * Shared/WebHitTestResult.cpp:
+            (WebKit::WebHitTestResult::Data::Data):
+            (WebKit::WebHitTestResult::Data::encode):
+            (WebKit::WebHitTestResult::Data::decode):
+            * Shared/WebHitTestResult.h:
+            (WebKit::WebHitTestResult::isOverTextInsideFormControlElement):
+
+            Offer the text menus for text inside form controls.
+            * UIProcess/mac/WKActionMenuController.mm:
+            (-[WKActionMenuController _defaultMenuItems]):
+
+            We should disallow shadow content in the hit test. This is the default and it is 
+            how context menus behave. We originally wanted to text inside shadow content so 
+            that we could find the text, but the new function I added to HitTestResult will 
+            allow that.
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+
+            Adjust to the fact that we don’t hit test shadow content any more.
+            (WebKit::WebPage::performActionMenuHitTestAtLocation):
+            (WebKit::WebPage::lookupTextAtLocation):
+            (WebKit::WebPage::focusAndSelectLastActionMenuHitTestResult):
+
+
+2014-12-04  Dana Burkart  <[email protected]>
+
         Merge r176763. <rdar://problem/19115662>
 
     2014-12-03  Tim Horton  <[email protected]>

Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.cpp	2014-12-04 16:35:44 UTC (rev 176795)
@@ -54,6 +54,7 @@
     , isScrollbar(hitTestResult.scrollbar())
     , isSelected(hitTestResult.isSelected())
     , isTextNode(hitTestResult.innerNode() && hitTestResult.innerNode()->isTextNode())
+    , isOverTextInsideFormControlElement(hitTestResult.isOverTextInsideFormControlElement())
     , isDownloadableMedia(hitTestResult.isDownloadableMedia())
 {
 }
@@ -75,6 +76,7 @@
     encoder << isScrollbar;
     encoder << isSelected;
     encoder << isTextNode;
+    encoder << isOverTextInsideFormControlElement;
     encoder << isDownloadableMedia;
 }
 
@@ -91,6 +93,7 @@
         || !decoder.decode(hitTestResultData.isScrollbar)
         || !decoder.decode(hitTestResultData.isSelected)
         || !decoder.decode(hitTestResultData.isTextNode)
+        || !decoder.decode(hitTestResultData.isOverTextInsideFormControlElement)
         || !decoder.decode(hitTestResultData.isDownloadableMedia))
         return false;
 

Modified: branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit2/Shared/WebHitTestResult.h	2014-12-04 16:35:44 UTC (rev 176795)
@@ -54,6 +54,7 @@
         bool isScrollbar;
         bool isSelected;
         bool isTextNode;
+        bool isOverTextInsideFormControlElement;
         bool isDownloadableMedia;
 
         Data();
@@ -86,6 +87,8 @@
 
     bool isTextNode() const { return m_data.isTextNode; }
 
+    bool isOverTextInsideFormControlElement() const { return m_data.isOverTextInsideFormControlElement; }
+
     bool isDownloadableMedia() const { return m_data.isDownloadableMedia; }
 
 private:

Modified: branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit2/UIProcess/mac/WKActionMenuController.mm	2014-12-04 16:35:44 UTC (rev 176795)
@@ -1124,7 +1124,7 @@
         return [self _defaultMenuItemsForImage];
     }
 
-    if (hitTestResult->isTextNode()) {
+    if (hitTestResult->isTextNode() || hitTestResult->isOverTextInsideFormControlElement()) {
         NSArray *dataDetectorMenuItems = [self _defaultMenuItemsForDataDetectedText];
         if (_currentActionContext) {
             // If this is a data detected item with no menu items, we should not fall back to regular text options.

Modified: branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (176794 => 176795)


--- branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-12-04 16:35:29 UTC (rev 176794)
+++ branches/safari-600.3-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2014-12-04 16:35:44 UTC (rev 176795)
@@ -977,23 +977,9 @@
         return;
     }
 
-    RenderView& mainRenderView = *mainFrame.view()->renderView();
-
-    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnoreClipping);
-
     IntPoint locationInContentCoordinates = mainFrame.view()->rootViewToContents(roundedIntPoint(locationInViewCooordinates));
-    HitTestResult hitTestResult(locationInContentCoordinates);
-    mainRenderView.hitTest(request, hitTestResult);
+    HitTestResult hitTestResult = mainFrame.eventHandler().hitTestResultAtPoint(locationInContentCoordinates);
 
-    // We hit test including shadow content to get the desired result for editable text regions.
-    // But for media, we want to re-set to the shadow root.
-    if (Node* node = hitTestResult.innerNode()) {
-        if (Element* shadowHost = node->shadowHost()) {
-            if (shadowHost->isMediaElement())
-                hitTestResult.setToNonShadowAncestor();
-        }
-    }
-
     ActionMenuHitTestResult actionMenuResult;
     actionMenuResult.hitTestLocationInViewCooordinates = locationInViewCooordinates;
     actionMenuResult.hitTestResult = WebHitTestResult::Data(hitTestResult);
@@ -1068,7 +1054,7 @@
         return nullptr;
 
     IntPoint point = roundedIntPoint(locationInViewCooordinates);
-    HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AllowChildFrameContent | HitTestRequest::IgnoreClipping);
+    HitTestResult result = mainFrame.eventHandler().hitTestResultAtPoint(m_page->mainFrame().view()->windowToContents(point));
     NSDictionary *options = nil;
     return rangeForDictionaryLookupAtHitTestResult(result, &options);
 }
@@ -1088,13 +1074,13 @@
     if (!element)
         return;
 
-    auto renderer = element->renderer();
-    if (!renderer)
+    Frame* frame = element->document().frame();
+    if (!frame)
         return;
 
-    m_page->focusController().setFocusedElement(element, element->document().frame());
-    VisiblePosition position = renderer->positionForPoint(m_lastActionMenuHitTestResult.localPoint(), nullptr);
-    element->document().frame()->selection().setSelection(position);
+    m_page->focusController().setFocusedElement(element, frame);
+    VisiblePosition position = frame->visiblePositionForPoint(m_lastActionMenuHitTestResult.roundedPointInInnerNodeFrame());
+    frame->selection().setSelection(position);
 }
 
 void WebPage::dataDetectorsDidPresentUI(PageOverlay::PageOverlayID overlayID)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to