Reviewed by darin.
Push more of MacFrame down into Frame.
Add visibleContentRect method to ScrollView.
* bridge/mac/MacFrame.h:
* bridge/mac/MacFrame.mm:
(WebCore::MacFrame::imageFromRect):
(WebCore::MacFrame::setDisplaysWithFocusAttributes):
(WebCore::MacFrame::bodyBackgroundColor):
* bridge/mac/WebCoreFrameBridge.mm:
* page/Frame.cpp:
(WebCore::Frame::visibleSelectionRect):
(WebCore::Frame::setDisplaysWithFocusAttributes):
* page/Frame.h:
* platform/ScrollView.h:
* platform/mac/ScrollViewMac.mm:
(WebCore::ScrollView::visibleWidth):
(WebCore::ScrollView::visibleHeight):
(WebCore::ScrollView::visibleContentRect):
(WebCore::ScrollView::contentsWidth):
(WebCore::ScrollView::contentsHeight):
(WebCore::ScrollView::contentsX):
(WebCore::ScrollView::contentsY):
(WebCore::ScrollView::scrollXOffset):
(WebCore::ScrollView::scrollYOffset):
(WebCore::ScrollView::inWindow):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@13327
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-03-15 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by darin.
+
+ Push more of MacFrame down into Frame.
+ Add visibleContentRect method to ScrollView.
+
+ * bridge/mac/MacFrame.h:
+ * bridge/mac/MacFrame.mm:
+ (WebCore::MacFrame::imageFromRect):
+ (WebCore::MacFrame::setDisplaysWithFocusAttributes):
+ (WebCore::MacFrame::bodyBackgroundColor):
+ * bridge/mac/WebCoreFrameBridge.mm:
+ * page/Frame.cpp:
+ (WebCore::Frame::visibleSelectionRect):
+ (WebCore::Frame::setDisplaysWithFocusAttributes):
+ * page/Frame.h:
+ * platform/ScrollView.h:
+ * platform/mac/ScrollViewMac.mm:
+ (WebCore::ScrollView::visibleWidth):
+ (WebCore::ScrollView::visibleHeight):
+ (WebCore::ScrollView::visibleContentRect):
+ (WebCore::ScrollView::contentsWidth):
+ (WebCore::ScrollView::contentsHeight):
+ (WebCore::ScrollView::contentsX):
+ (WebCore::ScrollView::contentsY):
+ (WebCore::ScrollView::scrollXOffset):
+ (WebCore::ScrollView::scrollYOffset):
+ (WebCore::ScrollView::inWindow):
+
2006-03-15 Eric Seidel <eseidel@apple.com>
Reviewed by darin.
virtual void restoreDocumentState();
virtual void addMessageToConsole(const DOMString& message, unsigned int lineNumber, const DOMString& sourceID);
- void setDisplaysWithFocusAttributes(bool flag);
+ virtual void setDisplaysWithFocusAttributes(bool flag);
NSView *nextKeyView(NodeImpl *startingPoint, KWQSelectionDirection);
NSView *nextKeyViewInFrameHierarchy(NodeImpl *startingPoint, KWQSelectionDirection);
virtual QString mimeTypeForFileName(const QString &) const;
- NSRect visibleSelectionRect() const;
NSImage *selectionImage() const;
NSImage *snapshotDragImage(NodeImpl *node, NSRect *imageRect, NSRect *elementRect) const;
#import "Cursor.h"
#import "DOMInternal.h"
#import "EventNames.h"
+#import "FloatRect.h"
#import "FoundationExtras.h"
#import "FramePrivate.h"
#import "FrameView.h"
return nil;
}
-// returns NSRect because going through IntRect would truncate any floats
-NSRect MacFrame::visibleSelectionRect() const
-{
- if (!d->m_view) {
- return NSZeroRect;
- }
- NSView *documentView = d->m_view->getDocumentView();
- if (!documentView) {
- return NSZeroRect;
- }
- return NSIntersectionRect(selectionRect(), [documentView visibleRect]);
-}
-
NSImage *MacFrame::imageFromRect(NSRect rect) const
{
NSView *view = d->m_view->getDocumentView();
- if (!view) {
+ if (!view)
return nil;
- }
NSImage *resultImage;
KWQ_BLOCK_EXCEPTIONS;
{
if (d->m_isFocused == flag)
return;
-
- d->m_isFocused = flag;
-
- // This method does the job of updating the view based on whether the view is "active".
- // This involves four kinds of drawing updates:
-
- // 1. The background color used to draw behind selected content (active | inactive color)
- if (d->m_view)
- d->m_view->updateContents(enclosingIntRect(visibleSelectionRect()));
-
- // 2. Caret blinking (blinks | does not blink)
- if (flag)
- setSelectionFromNone();
- setCaretVisible(flag);
- // 3. The drawing of a focus ring around links in web pages.
+ Frame::setDisplaysWithFocusAttributes(flag);
DocumentImpl *doc = document();
- if (doc) {
- NodeImpl *node = doc->focusNode();
- if (node) {
- node->setChanged();
- if (node->renderer() && node->renderer()->style()->hasAppearance())
- theme()->stateChanged(node->renderer(), FocusState);
- }
- }
-
- // 4. Changing the tint of controls from clear to aqua/graphite and vice versa. We
+ // Mac Specific: Changing the tint of controls from clear to aqua/graphite and vice versa. We
// do a "fake" paint. When the theme gets a paint call, it can then do an invalidate.
- if (theme()->supportsControlTints()) {
- NSView *documentView = d->m_view ? d->m_view->getDocumentView() : 0;
- if (documentView && renderer()) {
- doc->updateLayout(); // Ensure layout is up to date.
- IntRect visibleRect(enclosingIntRect([documentView visibleRect]));
- GraphicsContext p;
- p.setUpdatingControlTints(true);
- paint(&p, visibleRect);
- }
+ if (doc && d->m_view && d->m_view->getDocumentView() && theme()->supportsControlTints() && renderer()) {
+ doc->updateLayout(); // Ensure layout is up to date.
+ IntRect visibleRect(enclosingIntRect(d->m_view->visibleContentRect()));
+ GraphicsContext p;
+ p.setUpdatingControlTints(true);
+ paint(&p, visibleRect);
}
}
{
if (document() && document()->body() && document()->body()->renderer()) {
Color bgColor = document()->body()->renderer()->style()->backgroundColor();
- if (bgColor.isValid()) {
+ if (bgColor.isValid())
return nsColor(bgColor);
- }
}
return nil;
}
#import "CharsetNames.h"
#import "KWQClipboard.h"
#import "KWQEditCommand.h"
+#import "FloatRect.h"
#import "Font.h"
#import "FoundationExtras.h"
#import "KWQLoader.h"
#include "DocLoader.h"
#include "EditingTextImpl.h"
#include "EventNames.h"
+#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "render_canvas.h"
#include "render_frames.h"
#include "render_layer.h"
+#include "render_theme.h"
#include "visible_text.h"
#include "visible_units.h"
#include "xml_tokenizer.h"
return root->selectionRect();
}
+// returns FloatRect because going through IntRect would truncate any floats
+FloatRect Frame::visibleSelectionRect() const
+{
+ if (!d->m_view)
+ return FloatRect();
+
+ return intersection(selectionRect(), d->m_view->visibleContentRect());
+}
+
bool Frame::isFrameSet() const
{
DocumentImpl* document = d->m_doc.get();
return d->m_isFocused;
}
+void Frame::setDisplaysWithFocusAttributes(bool flag)
+{
+ if (d->m_isFocused == flag)
+ return;
+
+ d->m_isFocused = flag;
+
+ // This method does the job of updating the view based on whether the view is "active".
+ // This involves three kinds of drawing updates:
+
+ // 1. The background color used to draw behind selected content (active | inactive color)
+ if (d->m_view)
+ d->m_view->updateContents(enclosingIntRect(visibleSelectionRect()));
+
+ // 2. Caret blinking (blinks | does not blink)
+ if (flag)
+ setSelectionFromNone();
+ setCaretVisible(flag);
+
+ // 3. The drawing of a focus ring around links in web pages.
+ DocumentImpl *doc = document();
+ if (doc) {
+ NodeImpl *node = doc->focusNode();
+ if (node) {
+ node->setChanged();
+ if (node->renderer() && node->renderer()->style()->hasAppearance())
+ theme()->stateChanged(node->renderer(), FocusState);
+ }
+ }
+}
+
void Frame::setWindowHasFocus(bool flag)
{
if (m_windowHasFocus == flag)
RenderPart* ownerRenderer();
IntRect selectionRect() const;
+ FloatRect visibleSelectionRect() const;
bool isFrameSet() const;
HTMLFormElementImpl *currentForm() const;
static void clearTimers(FrameView *);
bool displaysWithFocusAttributes() const;
+ virtual void setDisplaysWithFocusAttributes(bool flag);
void setWindowHasFocus(bool flag);
// Convenience, to avoid repeating the code to dig down to get this.
#include "ScrollBarMode.h"
#include "Widget.h"
-#include "IntRect.h"
namespace WebCore {
+ class FloatRect;
class ScrollView : public Widget {
public:
int visibleWidth() const;
int visibleHeight() const;
+ FloatRect visibleContentRect() const;
int contentsWidth() const;
int contentsHeight() const;
int contentsX() const;
#import "config.h"
#import "ScrollView.h"
+#import "FloatRect.h"
#import "IntRect.h"
#import "KWQExceptions.h"
#import "Logging.h"
NSScrollView *view = (NSScrollView *)getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[view documentVisibleRect].size.width;
- } else {
+ else
return (int)[view bounds].size.width;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
NSScrollView *view = (NSScrollView *)getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[view documentVisibleRect].size.height;
- } else {
+ else
return (int)[view bounds].size.height;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
}
+FloatRect ScrollView::visibleContentRect() const
+{
+ KWQ_BLOCK_EXCEPTIONS;
+ if (NSView *docView = getDocumentView())
+ return [docView visibleRect];
+ KWQ_UNBLOCK_EXCEPTIONS;
+ return FloatRect();
+}
+
int ScrollView::contentsWidth() const
{
NSView *docView, *view = getView();
docView = getDocumentView();
KWQ_BLOCK_EXCEPTIONS;
- if (docView) {
+ if (docView)
return (int)[docView bounds].size.width;
- } else {
+ else
return (int)[view bounds].size.width;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
docView = getDocumentView();
KWQ_BLOCK_EXCEPTIONS;
- if (docView) {
+ if (docView)
return (int)[docView bounds].size.height;
- } else {
+ else
return (int)[view bounds].size.height;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
NSView *view = getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[(NSScrollView *)view documentVisibleRect].origin.x;
- } else {
+ else
return (int)[view visibleRect].origin.x;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
NSView *view = getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[(NSScrollView *)view documentVisibleRect].origin.y;
- } else {
+ else
return (int)[view visibleRect].origin.y;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
NSView *view = getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[[(NSScrollView *)view contentView] visibleRect].origin.x;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
}
NSView *view = getView();
KWQ_BLOCK_EXCEPTIONS;
- if ([view isKindOfClass:[NSScrollView class]]) {
+ if ([view isKindOfClass:[NSScrollView class]])
return (int)[[(NSScrollView *)view contentView] visibleRect].origin.y;
- }
KWQ_UNBLOCK_EXCEPTIONS;
return 0;
}
bool ScrollView::inWindow() const
{
- NSView* view = getView();
- return [view window];
+ return [getView() window];
}
}