Changeset 48188 in webkit


Ignore:
Timestamp:
Sep 8, 2009 3:02:41 PM (15 years ago)
Author:
weinig@apple.com
Message:

WebCore: Fix for https://bugs.webkit.org/show_bug.cgi?id=27046
Implement CSSOM DocumentView.caretRangeFromPoint

Reviewed by Timothy Hatcher.

Tests: fast/dom/Document/CaretRangeFromPoint/basic.html

fast/dom/Document/CaretRangeFromPoint/replace-element.html

  • dom/Document.cpp:

(WebCore::Document::caretRangeFromPoint):

  • dom/Document.h:
  • dom/Document.idl:

LayoutTests: Test for https://bugs.webkit.org/show_bug.cgi?id=27046
Implement CSSOM DocumentView.caretRangeFromPoint

Reviewed by Timothy Hatcher.

  • fast/dom/Document/CaretRangeFromPoint: Added.
  • fast/dom/Document/CaretRangeFromPoint/basic-expected.txt: Added.
  • fast/dom/Document/CaretRangeFromPoint/basic.html: Added.
  • fast/dom/Document/CaretRangeFromPoint/replace-element-expected.txt: Added.
  • fast/dom/Document/CaretRangeFromPoint/replace-element.html: Added.
  • fast/dom/Window/window-properties-expected.txt:
Location:
trunk
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48184 r48188  
     12009-09-08  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Test for https://bugs.webkit.org/show_bug.cgi?id=27046
     6        Implement CSSOM DocumentView.caretRangeFromPoint
     7
     8        * fast/dom/Document/CaretRangeFromPoint: Added.
     9        * fast/dom/Document/CaretRangeFromPoint/basic-expected.txt: Added.
     10        * fast/dom/Document/CaretRangeFromPoint/basic.html: Added.
     11        * fast/dom/Document/CaretRangeFromPoint/replace-element-expected.txt: Added.
     12        * fast/dom/Document/CaretRangeFromPoint/replace-element.html: Added.
     13        * fast/dom/Window/window-properties-expected.txt:
     14
    1152009-09-08  Brian Weinstein  <bweinstein@apple.com>
    216
  • trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt

    r48137 r48188  
    540540window.Document.prototype.adoptNode [function]
    541541window.Document.prototype.appendChild [function]
     542window.Document.prototype.caretRangeFromPoint [function]
    542543window.Document.prototype.cloneNode [function]
    543544window.Document.prototype.compareDocumentPosition [function]
  • trunk/WebCore/ChangeLog

    r48186 r48188  
     12009-09-08  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Timothy Hatcher.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=27046
     6        Implement CSSOM DocumentView.caretRangeFromPoint
     7
     8        Tests: fast/dom/Document/CaretRangeFromPoint/basic.html
     9               fast/dom/Document/CaretRangeFromPoint/replace-element.html
     10
     11        * dom/Document.cpp:
     12        (WebCore::Document::caretRangeFromPoint):
     13        * dom/Document.h:
     14        * dom/Document.idl:
     15
    1162009-09-08  Kevin Ollivier  <kevino@theolliviers.com>
    217
  • trunk/WebCore/dom/Document.cpp

    r48181 r48188  
    111111#include "SelectionController.h"
    112112#include "Settings.h"
    113 
    114 #if ENABLE(SHARED_WORKERS)
    115 #include "SharedWorkerRepository.h"
    116 #endif
    117 
    118113#include "StyleSheetList.h"
    119114#include "TextEvent.h"
     
    129124#include "XMLNames.h"
    130125#include "XMLTokenizer.h"
     126#include "htmlediting.h"
    131127#include <wtf/CurrentTime.h>
    132128#include <wtf/HashFunctions.h>
     
    138134#include "Database.h"
    139135#include "DatabaseThread.h"
     136#endif
     137
     138#if ENABLE(SHARED_WORKERS)
     139#include "SharedWorkerRepository.h"
    140140#endif
    141141
     
    942942        n = n->shadowAncestorNode();
    943943    return static_cast<Element*>(n);
     944}
     945
     946PassRefPtr<Range> Document::caretRangeFromPoint(int x, int y)
     947{
     948    if (!renderer())
     949        return 0;
     950    Frame* frame = this->frame();
     951    if (!frame)
     952        return 0;
     953
     954    float zoomFactor = frame->pageZoomFactor();
     955    IntPoint point = roundedIntPoint(FloatPoint(x * zoomFactor, y * zoomFactor));
     956
     957    FrameView* frameView = frame->view();
     958    if (!frameView)
     959        return 0;
     960    if (!frameView->boundsRect().contains(point))
     961        return 0;
     962
     963    HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active);
     964    HitTestResult result(point);
     965    renderView()->layer()->hitTest(request, result);
     966
     967    Node* node = result.innerNode();
     968    if (!node)
     969        return 0;
     970
     971    Node* shadowAncestorNode = node->shadowAncestorNode();
     972    if (shadowAncestorNode != node) {
     973        unsigned offset = shadowAncestorNode->nodeIndex();
     974        Node* container = shadowAncestorNode->parentNode();
     975        return Range::create(this, container, offset, container, offset);
     976    }
     977
     978    RenderObject* renderer = node->renderer();
     979    if (!renderer)
     980        return 0;
     981    VisiblePosition visiblePosition = renderer->positionForPoint(result.localPoint());
     982    if (visiblePosition.isNull())
     983        return 0;
     984
     985    Position rangeCompliantPosition = rangeCompliantEquivalent(visiblePosition);
     986    return Range::create(this, rangeCompliantPosition, rangeCompliantPosition);
    944987}
    945988
  • trunk/WebCore/dom/Document.h

    r48181 r48188  
    229229
    230230    Element* elementFromPoint(int x, int y) const;
     231    PassRefPtr<Range> caretRangeFromPoint(int x, int y);
     232
    231233    String readyState() const;
    232234
  • trunk/WebCore/dom/Document.idl

    r47649 r48188  
    192192
    193193        Element            elementFromPoint(in long x, in long y);
     194        Range              caretRangeFromPoint(in long x, in long y);
    194195
    195196        // Mozilla extensions
Note: See TracChangeset for help on using the changeset viewer.