Reviewed by Eric.
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2006 19:04:45 +0000 (19:04 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 22 Apr 2006 19:04:45 +0000 (19:04 +0000)
        - push down a bunch of WebCoreFrameBridge code to C++ (plus some reformatting)

        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge isDescendantOfFrame:]):
        (-[WebCoreFrameBridge traverseNextFrameStayWithin:]):
        (-[WebCoreFrameBridge nextFrameWithWrap:]):
        (-[WebCoreFrameBridge previousFrameWithWrap:]):
        (+[WebCoreFrameBridge bridgeForDOMDocument:]):
        (-[WebCoreFrameBridge parent]):
        (-[WebCoreFrameBridge addData:]):
        (-[WebCoreFrameBridge didNotOpenURL:pageCache:]):
        (-[WebCoreFrameBridge restoreDocumentState]):
        (-[WebCoreFrameBridge _stringWithDocumentTypeStringAndMarkupString:]):
        (-[WebCoreFrameBridge nodesFromList:]):
        (-[WebCoreFrameBridge markupStringFromNode:nodes:]):
        (-[WebCoreFrameBridge markupStringFromRange:nodes:]):
        (-[WebCoreFrameBridge rangeByExpandingSelectionWithGranularity:]):
        (-[WebCoreFrameBridge rangeByAlteringCurrentSelection:direction:granularity:]):
        (-[WebCoreFrameBridge alterCurrentSelection:direction:granularity:]):
        (-[WebCoreFrameBridge rangeByAlteringCurrentSelection:verticalDistance:]):
        (-[WebCoreFrameBridge alterCurrentSelection:verticalDistance:]):
        (-[WebCoreFrameBridge replaceMarkedTextWithText:]):
        (-[WebCoreFrameBridge replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
        (-[WebCoreFrameBridge increaseSelectionListLevel]):
        (-[WebCoreFrameBridge decreaseSelectionListLevel]):
        (-[WebCoreFrameBridge insertLineBreak]):
        (-[WebCoreFrameBridge insertParagraphSeparator]):
        (-[WebCoreFrameBridge insertParagraphSeparatorInQuotedContent]):
        (-[WebCoreFrameBridge insertText:selectInsertedText:]):
        (-[WebCoreFrameBridge deleteSelectionWithSmartDelete:]):
        (-[WebCoreFrameBridge ensureSelectionVisible]):
        (-[WebCoreFrameBridge RenderObject::nodeInfoAtPoint:allowShadowContent:]):
        * page/Frame.cpp:
        (WebCore::Frame::nodeInfoAtPoint):
        (WebCore::Frame::hasSelection):
        (WebCore::Frame::documentTypeString):
        * page/Frame.h:
        * page/FrameTree.cpp:
        (WebCore::FrameTree::traverseNextWithWrap):
        (WebCore::FrameTree::traversePreviousWithWrap):
        (WebCore::FrameTree::deepLastChild):
        * page/FrameTree.h:

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

WebCore/ChangeLog
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebCore/page/FrameTree.cpp
WebCore/page/FrameTree.h

index 01c343489d42d787a7ffbf853832701d64161218..0b10da9b79f2815e990e71d5a98b0200e3929b1c 100644 (file)
@@ -1,3 +1,50 @@
+2006-04-22  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Eric.
+
+        - push down a bunch of WebCoreFrameBridge code to C++ (plus some reformatting)
+
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge isDescendantOfFrame:]):
+        (-[WebCoreFrameBridge traverseNextFrameStayWithin:]):
+        (-[WebCoreFrameBridge nextFrameWithWrap:]):
+        (-[WebCoreFrameBridge previousFrameWithWrap:]):
+        (+[WebCoreFrameBridge bridgeForDOMDocument:]):
+        (-[WebCoreFrameBridge parent]):
+        (-[WebCoreFrameBridge addData:]):
+        (-[WebCoreFrameBridge didNotOpenURL:pageCache:]):
+        (-[WebCoreFrameBridge restoreDocumentState]):
+        (-[WebCoreFrameBridge _stringWithDocumentTypeStringAndMarkupString:]):
+        (-[WebCoreFrameBridge nodesFromList:]):
+        (-[WebCoreFrameBridge markupStringFromNode:nodes:]):
+        (-[WebCoreFrameBridge markupStringFromRange:nodes:]):
+        (-[WebCoreFrameBridge rangeByExpandingSelectionWithGranularity:]):
+        (-[WebCoreFrameBridge rangeByAlteringCurrentSelection:direction:granularity:]):
+        (-[WebCoreFrameBridge alterCurrentSelection:direction:granularity:]):
+        (-[WebCoreFrameBridge rangeByAlteringCurrentSelection:verticalDistance:]):
+        (-[WebCoreFrameBridge alterCurrentSelection:verticalDistance:]):
+        (-[WebCoreFrameBridge replaceMarkedTextWithText:]):
+        (-[WebCoreFrameBridge replaceSelectionWithFragment:selectReplacement:smartReplace:matchStyle:]):
+        (-[WebCoreFrameBridge increaseSelectionListLevel]):
+        (-[WebCoreFrameBridge decreaseSelectionListLevel]):
+        (-[WebCoreFrameBridge insertLineBreak]):
+        (-[WebCoreFrameBridge insertParagraphSeparator]):
+        (-[WebCoreFrameBridge insertParagraphSeparatorInQuotedContent]):
+        (-[WebCoreFrameBridge insertText:selectInsertedText:]):
+        (-[WebCoreFrameBridge deleteSelectionWithSmartDelete:]):
+        (-[WebCoreFrameBridge ensureSelectionVisible]):
+        (-[WebCoreFrameBridge RenderObject::nodeInfoAtPoint:allowShadowContent:]):
+        * page/Frame.cpp:
+        (WebCore::Frame::nodeInfoAtPoint):
+        (WebCore::Frame::hasSelection):
+        (WebCore::Frame::documentTypeString):
+        * page/Frame.h:
+        * page/FrameTree.cpp:
+        (WebCore::FrameTree::traverseNextWithWrap):
+        (WebCore::FrameTree::traversePreviousWithWrap):
+        (WebCore::FrameTree::deepLastChild):
+        * page/FrameTree.h:
+
 2006-04-22  Beth Dakin  <bdakin@apple.com>
 
         Reviewed by Hyatt.
         (WebCore::Image::tileInRect):
         (WebCore::Image::scaleAndTileInRect):
 
->>>>>>> .r13996
 2006-04-20  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin.
index babe2d6de2597105df9280b9c63f8d397388db12..f64cd94da52c14c26e13704be3ddcfacce0fd2db 100644 (file)
@@ -140,24 +140,6 @@ static void updateRenderingForBindings (ExecState *exec, JSObject *rootObject)
         doc->updateRendering();
 }
 
-static BOOL frameHasSelection(WebCoreFrameBridge *bridge)
-{
-    if (!bridge)
-        return NO;
-    
-    Frame *frame = [bridge impl];
-    if (!frame)
-        return NO;
-        
-    if (frame->selection().isNone())
-        return NO;
-
-    // If a part has a selection, it should also have a document.        
-    ASSERT(frame->document());
-
-    return YES;
-}
-
 static BOOL hasCaseInsensitivePrefix(NSString *string, NSString *prefix)
 {
     return [string rangeOfString:prefix options:(NSCaseInsensitiveSearch | NSAnchoredSearch)].location !=
@@ -260,42 +242,12 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
 
 - (BOOL)isDescendantOfFrame:(WebCoreFrameBridge *)ancestor
 {
-    for (WebCoreFrameBridge *frame = self; frame; frame = [frame parent])
-        if (frame == ancestor)
-            return YES;
-
-    return NO;
+    return m_frame->tree()->isDescendantOf(ancestor->m_frame);
 }
 
 - (WebCoreFrameBridge *)traverseNextFrameStayWithin:(WebCoreFrameBridge *)stayWithin
 {
-    WebCoreFrameBridge *firstChild = [self firstChild];
-    if (firstChild) {
-        ASSERT(!stayWithin || [firstChild isDescendantOfFrame:stayWithin]);
-        return firstChild;
-    }
-
-    if (self == stayWithin)
-        return 0;
-
-    WebCoreFrameBridge *nextSibling = [self nextSibling];
-    if (nextSibling) {
-        assert(!stayWithin || [nextSibling isDescendantOfFrame:stayWithin]);
-        return nextSibling;
-    }
-
-    WebCoreFrameBridge *frame = self;
-    while (frame && !nextSibling && (!stayWithin || [frame parent] != stayWithin)) {
-        frame = (WebCoreFrameBridge *)[frame parent];
-        nextSibling = [frame nextSibling];
-    }
-
-    if (frame) {
-        ASSERT(!stayWithin || !nextSibling || [nextSibling isDescendantOfFrame:stayWithin]);
-        return nextSibling;
-    }
-
-    return nil;
+    return bridge(m_frame->tree()->traverseNext(stayWithin->m_frame));
 }
 
 - (void)appendChild:(WebCoreFrameBridge *)child
@@ -313,44 +265,17 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return bridge(m_frame->tree()->child(name));
 }
 
-// Returns the last child of us and any children, or self
-- (WebCoreFrameBridge *)_deepLastChildFrame
-{
-    WebCoreFrameBridge *result = self;
-    for (WebCoreFrameBridge *lastChild = [self lastChild]; lastChild; lastChild = [lastChild lastChild])
-        result = lastChild;
-
-    return result;
-}
-
-// Return next frame to be traversed, visiting children after parent
 - (WebCoreFrameBridge *)nextFrameWithWrap:(BOOL)wrapFlag
 {
-    WebCoreFrameBridge *result = [self traverseNextFrameStayWithin:nil];
-    if (!result && wrapFlag)
-        return [[self page] mainFrame];
-    return result;
+    return bridge(m_frame->tree()->traverseNextWithWrap(wrapFlag));
 }
 
-// Return previous frame to be traversed, exact reverse order of _nextFrame
 - (WebCoreFrameBridge *)previousFrameWithWrap:(BOOL)wrapFlag
 {
-    // FIXME: besides the wrap feature, this is just the traversePreviousNode algorithm
-
-    WebCoreFrameBridge *prevSibling = [self previousSibling];
-    if (prevSibling)
-        return [prevSibling _deepLastChildFrame];
-    if ([self parent])
-        return [self parent];
-    
-    // no siblings, no parent, self==top
-    if (wrapFlag)
-        return [self _deepLastChildFrame];
-
-    // top view is always the last one in this ordering, so prev is nil without wrap
-    return nil;
+    return bridge(m_frame->tree()->traversePreviousWithWrap(wrapFlag));
 }
 
+// FIXME: this is not getting called any more! security regression...
 - (BOOL)_shouldAllowAccessFrom:(WebCoreFrameBridge *)source
 {
     // if no source frame, allow access
@@ -415,8 +340,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
 
 + (WebCoreFrameBridge *)bridgeForDOMDocument:(DOMDocument *)document
 {
-    Frame *frame = [document _document]->frame();
-    return frame ? Mac(frame)->bridge() : nil;
+    return bridge([document _document]->frame());
 }
 
 - (id)initMainFrameWithPage:(WebCorePageBridge *)page
@@ -480,17 +404,9 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     [super finalize];
 }
 
-- (FrameMac *)part
-{
-    return m_frame;
-}
-
 - (WebCoreFrameBridge *)parent
 {
-    FrameMac *parentFrame = Mac(m_frame->tree()->parent());
-    if (!parentFrame)
-        return nil;
-    return parentFrame->bridge();
+    return bridge(m_frame->tree()->parent());
 }
 
 - (void)provisionalLoadStarted
@@ -540,7 +456,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     // as a result of JS executing during load, i.e. one frame
     // changing another's location before the frame's document
     // has been created. 
-    if (doc){
+    if (doc) {
         doc->setShouldCreateRenderers([self shouldCreateRenderers]);
         m_frame->addData((const char *)[data bytes], [data length]);
     }
@@ -564,9 +480,9 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     // transitioned to the new page (before WebFrameState==commit).  The goal here is to restore any state
     // so that the existing view (that wenever got far enough to replace) can continue being used.
     Document *doc = m_frame->document();
-    if (doc) {
+    if (doc)
         doc->setInPageCache(NO);
-    }
+
     KWQPageState *state = [pageCache objectForKey:WebCorePageCacheStateKey];
     [state invalidate];
 }
@@ -607,7 +523,7 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
         NSArray *documentState = [self documentState];
         
         DeprecatedStringList s;
-        for (unsigned i = 0; i < [documentState count]; i++){
+        for (unsigned i = 0; i < [documentState count]; i++) {
             NSString *string = [documentState objectAtIndex: i];
             s.append(DeprecatedString::fromNSString(string));
         }
@@ -747,37 +663,17 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     return WebSelectionStateNone;
 }
 
-- (NSString *)_documentTypeString
-{
-    NSString *documentTypeString = nil;
-    Document *doc = m_frame->document();
-    if (doc) {
-        if (DocumentType *doctype = doc->realDocType())
-            documentTypeString = doctype->toString();
-    }
-    return documentTypeString;
-}
-
 - (NSString *)_stringWithDocumentTypeStringAndMarkupString:(NSString *)markupString
 {
-    NSString *documentTypeString = [self _documentTypeString];
-    if (documentTypeString && markupString) {
-        return [NSString stringWithFormat:@"%@%@", documentTypeString, markupString];
-    } else if (documentTypeString) {
-        return documentTypeString;
-    } else if (markupString) {
-        return markupString;
-    } else {
-        return @"";
-    }
+    return m_frame->documentTypeString() + markupString;
 }
 
 - (NSArray *)nodesFromList:(DeprecatedPtrList<Node> *)nodeList
 {
     NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:nodeList->count()];
-    for (DeprecatedPtrListIterator<Node> i(*nodeList); i.current(); ++i) {
+    for (DeprecatedPtrListIterator<Node> i(*nodeList); i.current(); ++i)
         [nodes addObject:[DOMNode _nodeWith:i.current()]];
-    }
+
     return nodes;
 }
 
@@ -786,9 +682,9 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     // FIXME: This is never "for interchange". Is that right? See the next method.
     DeprecatedPtrList<Node> nodeList;
     NSString *markupString = createMarkup([node _node], IncludeNode, nodes ? &nodeList : 0).getNSString();
-    if (nodes) {
+    if (nodes)
         *nodes = [self nodesFromList:&nodeList];
-    }
+
     return [self _stringWithDocumentTypeStringAndMarkupString:markupString];
 }
 
@@ -797,9 +693,9 @@ static inline WebCoreFrameBridge *bridge(Frame *frame)
     // FIXME: This is always "for interchange". Is that right? See the previous method.
     DeprecatedPtrList<Node> nodeList;
     NSString *markupString = createMarkup([range _range], nodes ? &nodeList : 0, AnnotateForInterchange).getNSString();
-    if (nodes) {
+    if (nodes)
         *nodes = [self nodesFromList:&nodeList];
-    }
+
     return [self _stringWithDocumentTypeStringAndMarkupString:markupString];
 }
 
@@ -1572,7 +1468,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (DOMRange *)rangeByExpandingSelectionWithGranularity:(WebBridgeSelectionGranularity)granularity
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return nil;
         
     // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
@@ -1583,7 +1479,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (DOMRange *)rangeByAlteringCurrentSelection:(WebSelectionAlteration)alteration direction:(WebBridgeSelectionDirection)direction granularity:(WebBridgeSelectionGranularity)granularity
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return nil;
         
     // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
@@ -1596,7 +1492,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)alterCurrentSelection:(WebSelectionAlteration)alteration direction:(WebBridgeSelectionDirection)direction granularity:(WebBridgeSelectionGranularity)granularity
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
         
     // NOTE: The enums *must* match the very similar ones declared in SelectionController.h
@@ -1645,7 +1541,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (DOMRange *)rangeByAlteringCurrentSelection:(WebSelectionAlteration)alteration verticalDistance:(float)verticalDistance
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return nil;
         
     SelectionController selection(m_frame->selection());
@@ -1655,7 +1551,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)alterCurrentSelection:(WebSelectionAlteration)alteration verticalDistance:(float)verticalDistance
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
         
     SelectionController selection(m_frame->selection());
@@ -1788,7 +1684,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)replaceMarkedTextWithText:(NSString *)text
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     int exception = 0;
@@ -1951,7 +1847,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)replaceSelectionWithFragment:(DOMDocumentFragment *)fragment selectReplacement:(BOOL)selectReplacement smartReplace:(BOOL)smartReplace matchStyle:(BOOL)matchStyle
 {
-    if (!frameHasSelection(self) || !fragment)
+    if (!m_frame->hasSelection() || !fragment)
         return;
     
     EditCommandPtr(new ReplaceSelectionCommand(m_frame->document(), [fragment _fragment], selectReplacement, smartReplace, matchStyle)).apply();
@@ -1988,7 +1884,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)increaseSelectionListLevel
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     ModifySelectionListLevelCommand::increaseSelectionListLevel(m_frame->document());
@@ -1997,7 +1893,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)decreaseSelectionListLevel
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     ModifySelectionListLevelCommand::decreaseSelectionListLevel(m_frame->document());
@@ -2006,7 +1902,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)insertLineBreak
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     TypingCommand::insertLineBreak(m_frame->document());
@@ -2015,7 +1911,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)insertParagraphSeparator
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     TypingCommand::insertParagraphSeparator(m_frame->document());
@@ -2024,7 +1920,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)insertParagraphSeparatorInQuotedContent
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     TypingCommand::insertParagraphSeparatorInQuotedContent(m_frame->document());
@@ -2033,7 +1929,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)insertText:(NSString *)text selectInsertedText:(BOOL)selectInsertedText
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     TypingCommand::insertText(m_frame->document(), text, selectInsertedText);
@@ -2121,7 +2017,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)deleteSelectionWithSmartDelete:(BOOL)smartDelete
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     EditCommandPtr(new DeleteSelectionCommand(m_frame->document(), smartDelete)).apply();
@@ -2247,7 +2143,7 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
 
 - (void)ensureSelectionVisible
 {
-    if (!frameHasSelection(self))
+    if (!m_frame->hasSelection())
         return;
     
     FrameView *v = m_frame->view();
@@ -2451,47 +2347,7 @@ static PlatformMouseEvent createMouseEventFromDraggingInfo(NSWindow* window, id
 
 - (RenderObject::NodeInfo)nodeInfoAtPoint:(NSPoint)point allowShadowContent:(BOOL)allow
 {
-    RenderObject *renderer = m_frame->renderer();
-
-    RenderObject::NodeInfo nodeInfo(true, true);
-    renderer->layer()->hitTest(nodeInfo, IntPoint(point));
-
-    Node *n;
-    Widget *widget = 0;
-    IntPoint widgetPoint(point);
-    
-    while (true) {
-        n = nodeInfo.innerNode();
-        if (!n || !n->renderer() || !n->renderer()->isWidget())
-            break;
-        widget = static_cast<RenderWidget *>(n->renderer())->widget();
-        if (!widget || !widget->isFrameView())
-            break;
-        Frame* frame = static_cast<HTMLFrameElement *>(n)->contentFrame();
-        if (!frame || !frame->renderer())
-            break;
-        int absX, absY;
-        n->renderer()->absolutePosition(absX, absY, true);
-        FrameView *view = static_cast<FrameView *>(widget);
-        widgetPoint.setX(widgetPoint.x() - absX + view->contentsX());
-        widgetPoint.setY(widgetPoint.y() - absY + view->contentsY());
-
-        RenderObject::NodeInfo widgetNodeInfo(true, true);
-        frame->renderer()->layer()->hitTest(widgetNodeInfo, widgetPoint);
-        nodeInfo = widgetNodeInfo;
-    }
-    
-    if (!allow) {
-        Node* node = nodeInfo.innerNode();
-        if (node)
-            node = node->shadowAncestorNode();
-        nodeInfo.setInnerNode(node);
-        node = nodeInfo.innerNonSharedNode();
-        if (node)
-            node = node->shadowAncestorNode();
-        nodeInfo.setInnerNonSharedNode(node); 
-    }
-    return nodeInfo;
+    return m_frame->nodeInfoAtPoint(IntPoint(point), allow);
 }
 
 @end
index 3c48087226a47882a6f64b7698c86177e3a4af0b..10340f0401e017652277708d8a2aac1a8c4775b2 100644 (file)
@@ -36,6 +36,7 @@
 #include "CachedCSSStyleSheet.h"
 #include "DOMImplementation.h"
 #include "DocLoader.h"
+#include "DocumentType.h"
 #include "DOMWindow.h"
 #include "EditingText.h"
 #include "EventNames.h"
@@ -2671,6 +2672,60 @@ void Frame::autoscrollTimerFired(Timer<Frame>*)
     } 
 }
 
+RenderObject::NodeInfo Frame::nodeInfoAtPoint(const IntPoint& point, bool allowShadowContent)
+{
+    RenderObject::NodeInfo nodeInfo(true, true);
+    renderer()->layer()->hitTest(nodeInfo, point);
+
+    Node *n;
+    Widget *widget = 0;
+    IntPoint widgetPoint(point);
+    
+    while (true) {
+        n = nodeInfo.innerNode();
+        if (!n || !n->renderer() || !n->renderer()->isWidget())
+            break;
+        widget = static_cast<RenderWidget *>(n->renderer())->widget();
+        if (!widget || !widget->isFrameView())
+            break;
+        Frame* frame = static_cast<HTMLFrameElement *>(n)->contentFrame();
+        if (!frame || !frame->renderer())
+            break;
+        int absX, absY;
+        n->renderer()->absolutePosition(absX, absY, true);
+        FrameView *view = static_cast<FrameView *>(widget);
+        widgetPoint.setX(widgetPoint.x() - absX + view->contentsX());
+        widgetPoint.setY(widgetPoint.y() - absY + view->contentsY());
+
+        RenderObject::NodeInfo widgetNodeInfo(true, true);
+        frame->renderer()->layer()->hitTest(widgetNodeInfo, widgetPoint);
+        nodeInfo = widgetNodeInfo;
+    }
+    
+    if (!allowShadowContent) {
+        Node* node = nodeInfo.innerNode();
+        if (node)
+            node = node->shadowAncestorNode();
+        nodeInfo.setInnerNode(node);
+        node = nodeInfo.innerNonSharedNode();
+        if (node)
+            node = node->shadowAncestorNode();
+        nodeInfo.setInnerNonSharedNode(node); 
+    }
+    return nodeInfo;
+}
+
+bool Frame::hasSelection()
+{
+    if (selection().isNone())
+        return false;
+
+    // If a part has a selection, it should also have a document.        
+    ASSERT(document());
+
+    return true;
+}
+
 void Frame::startAutoscrollTimer()
 {
     d->m_autoscrollTimer.startRepeating(autoscrollInterval);
@@ -3328,4 +3383,14 @@ void Frame::disconnectOwnerRenderer()
     d->m_ownerRenderer = 0;
 }
 
+String Frame::documentTypeString() const
+{
+    if (Document *doc = document())
+        if (DocumentType *doctype = doc->realDocType())
+            return doctype->toString();
+
+    return String();
+}
+
+
 } // namespace WebCore
index 8a37a5bb5d247363de6384f1982af0db46a15f49..9866a8b977b8c9d26a35e35cbe8db7d523716759 100644 (file)
@@ -39,6 +39,7 @@
 #include "TextGranularity.h"
 #include "TransferJobClient.h"
 #include <kxmlcore/Vector.h>
+#include "RenderObject.h"
 
 class KHTMLSettings;
 
@@ -766,6 +767,10 @@ public:
   friend class FrameMac;
   friend class FrameWin;
 
+  RenderObject::NodeInfo nodeInfoAtPoint(const IntPoint&, bool allowShadowContent);
+  bool hasSelection();
+  String Frame::documentTypeString() const;
+
   void checkEmitLoadEvent();
   bool didOpenURL(const KURL&);
   virtual void didFirstLayout() {}
index 507e3c0d32d14349c53a4995e75ddf2b4f39e21c..d8d0b9f0b2b29b1426530b02e794ecdd513428be 100644 (file)
@@ -244,4 +244,41 @@ Frame* FrameTree::traverseNext(Frame* stayWithin) const
     return 0;
 }
 
+Frame* FrameTree::traverseNextWithWrap(bool wrap) const
+{
+    if (Frame* result = traverseNext())
+        return result;
+
+    if (wrap)
+        return m_thisFrame->page()->mainFrame();
+
+    return 0;
+}
+
+Frame* FrameTree::traversePreviousWithWrap(bool wrap) const
+{
+    // FIXME: besides the wrap feature, this is just the traversePreviousNode algorithm
+
+    if (Frame* prevSibling = previousSibling())
+        return prevSibling->tree()->deepLastChild();
+    if (Frame* parentFrame = parent())
+        return parentFrame;
+    
+    // no siblings, no parent, self==top
+    if (wrap)
+        return deepLastChild();
+
+    // top view is always the last one in this ordering, so prev is nil without wrap
+    return 0;
+}
+
+Frame* FrameTree::deepLastChild() const
+{
+    Frame* result = m_thisFrame;
+    for (Frame* last = lastChild(); last; last = last->tree()->lastChild())
+        result = last;
+
+    return result;
+}
+
 }
index c09513bba5733dbf5126ed2ebea5a9957c7eaca9..78b5ca175b71b4afee9c7609b2a42f64d4f595c2 100644 (file)
@@ -52,6 +52,8 @@ namespace WebCore {
 
         bool isDescendantOf(Frame* ancestor) const;
         Frame* traverseNext(Frame* stayWithin = 0) const;
+        Frame* traverseNextWithWrap(bool) const;
+        Frame* traversePreviousWithWrap(bool) const;
         
         void appendChild(PassRefPtr<Frame>);
         void removeChild(Frame*);
@@ -63,6 +65,8 @@ namespace WebCore {
         AtomicString uniqueChildName(const AtomicString& requestedName) const;
 
     private:
+        Frame* deepLastChild() const;
+
         Frame* m_thisFrame;
 
         Frame* m_parent;