Commit 0fa2fbcf authored by hyatt's avatar hyatt
Browse files

WebCore:

        Move frame borders out of WebKit and into WebCore.

        Reviewed by aroben, olliej

        * bridge/mac/FrameViewMac.mm:
        * css/html4.css:
        * html/HTMLFrameSetElement.cpp:
        (WebCore::HTMLFrameSetElement::HTMLFrameSetElement):
        (WebCore::HTMLFrameSetElement::mapToEntry):
        (WebCore::HTMLFrameSetElement::parseMappedAttribute):
        (WebCore::HTMLFrameSetElement::attach):
        * html/HTMLFrameSetElement.h:
        (WebCore::HTMLFrameSetElement::hasBorderColor):
        * page/FrameView.cpp:
        (WebCore::FrameViewPrivate::FrameViewPrivate):
        * page/FrameView.h:
        * page/mac/WebCoreFrameBridge.h:
        * platform/graphics/IntRect.h:
        (WebCore::IntRect::topLeft):
        (WebCore::IntRect::topRight):
        (WebCore::IntRect::bottomLeft):
        (WebCore::IntRect::bottomRight):
        * rendering/RenderFrame.cpp:
        (WebCore::RenderFrame::viewCleared):
        * rendering/RenderFrameSet.cpp:
        (WebCore::borderStartEdgeColor):
        (WebCore::borderEndEdgeColor):
        (WebCore::RenderFrameSet::paintColumnBorder):
        (WebCore::RenderFrameSet::paintRowBorder):
        (WebCore::RenderFrameSet::paint):
        * rendering/RenderFrameSet.h:
        * rendering/RenderPartObject.cpp:
        (WebCore::RenderPartObject::viewCleared):
        * rendering/RenderView.cpp:
        (WebCore::RenderView::repaintViewRectangle):

WebKit:

        Move frame borders out of WebKit and into WebCore.

        Reviewed by aroben, olliej

        * WebCoreSupport/WebFrameBridge.mm:
        * WebKit.xcodeproj/project.pbxproj:
        * WebView/WebFrameView.mm:
        (-[WebFrameView drawRect:]):
        (-[WebFrameView setFrameSize:]):
        * WebView/WebFrameViewInternal.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@20269 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 563ba091
2007-03-18 David Hyatt <hyatt@apple.com>
Move frame borders out of WebKit and into WebCore.
Reviewed by aroben, olliej
* bridge/mac/FrameViewMac.mm:
* css/html4.css:
* html/HTMLFrameSetElement.cpp:
(WebCore::HTMLFrameSetElement::HTMLFrameSetElement):
(WebCore::HTMLFrameSetElement::mapToEntry):
(WebCore::HTMLFrameSetElement::parseMappedAttribute):
(WebCore::HTMLFrameSetElement::attach):
* html/HTMLFrameSetElement.h:
(WebCore::HTMLFrameSetElement::hasBorderColor):
* page/FrameView.cpp:
(WebCore::FrameViewPrivate::FrameViewPrivate):
* page/FrameView.h:
* page/mac/WebCoreFrameBridge.h:
* platform/graphics/IntRect.h:
(WebCore::IntRect::topLeft):
(WebCore::IntRect::topRight):
(WebCore::IntRect::bottomLeft):
(WebCore::IntRect::bottomRight):
* rendering/RenderFrame.cpp:
(WebCore::RenderFrame::viewCleared):
* rendering/RenderFrameSet.cpp:
(WebCore::borderStartEdgeColor):
(WebCore::borderEndEdgeColor):
(WebCore::RenderFrameSet::paintColumnBorder):
(WebCore::RenderFrameSet::paintRowBorder):
(WebCore::RenderFrameSet::paint):
* rendering/RenderFrameSet.h:
* rendering/RenderPartObject.cpp:
(WebCore::RenderPartObject::viewCleared):
* rendering/RenderView.cpp:
(WebCore::RenderView::repaintViewRectangle):
2007-03-17 David Hyatt <hyatt@apple.com>
 
Make onload do an explicit paint when a top-level document is ready (to ensure that a first paint always
......
......@@ -36,13 +36,6 @@
namespace WebCore {
void FrameView::updateBorder()
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
[m_frame.get()->bridge() setHasBorder:hasBorder()];
END_BLOCK_OBJC_EXCEPTIONS;
}
void FrameView::updateDashboardRegions()
{
Document* doc = m_frame->document();
......
......@@ -586,6 +586,10 @@ frameset, frame {
display: block
}
frameset {
border-color: inherit
}
blockquote.webkit-indent-blockquote {
margin: 0 0 0 40px;
}
......
......@@ -26,6 +26,7 @@
#include "config.h"
#include "HTMLFrameSetElement.h"
#include "CSSPropertyNames.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
......@@ -45,7 +46,9 @@ HTMLFrameSetElement::HTMLFrameSetElement(Document *doc)
, m_cols(0)
, m_totalRows(1)
, m_totalCols(1)
, m_border(4)
, m_border(6)
, m_borderSet(false)
, m_borderColorSet(false)
, frameborder(true)
, frameBorderSet(false)
, noresize(false)
......@@ -67,6 +70,16 @@ bool HTMLFrameSetElement::checkDTD(const Node* newChild)
return newChild->hasTagName(framesetTag) || newChild->hasTagName(frameTag);
}
bool HTMLFrameSetElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == bordercolorAttr) {
result = eUniversal;
return true;
}
return HTMLElement::mapToEntry(attrName, result);
}
void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr)
{
if (attr->name() == rowsAttr) {
......@@ -82,18 +95,33 @@ void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr)
setChanged();
}
} else if (attr->name() == frameborderAttr) {
// false or "no" or "0"..
if (attr->value().toInt() == 0) {
if (!attr->isNull()) {
// false or "no" or "0"..
if (attr->value().toInt() == 0) {
frameborder = false;
m_border = 0;
}
frameBorderSet = true;
} else {
frameborder = false;
m_border = 0;
frameBorderSet = false;
}
frameBorderSet = true;
} else if (attr->name() == noresizeAttr) {
noresize = true;
} else if (attr->name() == borderAttr) {
m_border = attr->value().toInt();
if(!m_border)
frameborder = false;
if (!attr->isNull()) {
m_border = attr->value().toInt();
if (!m_border)
frameborder = false;
m_borderSet = true;
} else
m_borderSet = false;
} else if (attr->name() == bordercolorAttr) {
m_borderColorSet = attr->decl();
if (!attr->decl() && !attr->isEmpty()) {
addCSSColor(attr, CSS_PROP_BORDER_COLOR, attr->value());
m_borderColorSet = true;
}
} else if (attr->name() == onloadAttr) {
document()->setHTMLWindowEventListener(loadEvent, attr);
} else if (attr->name() == onbeforeunloadAttr) {
......@@ -121,13 +149,22 @@ RenderObject *HTMLFrameSetElement::createRenderer(RenderArena *arena, RenderStyl
void HTMLFrameSetElement::attach()
{
// inherit default settings from parent frameset
// Inherit default settings from parent frameset
// FIXME: This is not dynamic.
HTMLElement* node = static_cast<HTMLElement*>(parentNode());
while (node) {
if (node->hasTagName(framesetTag)) {
HTMLFrameSetElement* frameset = static_cast<HTMLFrameSetElement*>(node);
if(!frameBorderSet) frameborder = frameset->frameBorder();
if(!noresize) noresize = frameset->noResize();
if (!frameBorderSet)
frameborder = frameset->frameBorder();
if (frameborder) {
if (!m_borderSet)
m_border = frameset->border();
if (!m_borderColorSet)
m_borderColorSet = frameset->hasBorderColor();
}
if (!noresize)
noresize = frameset->noResize();
break;
}
node = static_cast<HTMLElement*>(node->parentNode());
......
......@@ -27,6 +27,7 @@
#define HTMLFrameSetElement_h
#include "HTMLElement.h"
#include "Color.h"
namespace WebCore {
......@@ -39,11 +40,13 @@ public:
virtual int tagPriority() const { return 10; }
virtual bool checkDTD(const Node* newChild);
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
virtual void parseMappedAttribute(MappedAttribute*);
virtual void attach();
virtual bool rendererIsNeeded(RenderStyle*);
virtual RenderObject *createRenderer(RenderArena*, RenderStyle*);
virtual void defaultEventHandler(Event*);
bool frameBorder() const { return frameborder; }
......@@ -53,6 +56,8 @@ public:
int totalCols() const { return m_totalCols; }
int border() const { return m_border; }
bool hasBorderColor() const { return m_borderColorSet; }
virtual void recalcStyle( StyleChange ch );
String cols() const;
......@@ -70,7 +75,11 @@ private:
int m_totalRows;
int m_totalCols;
int m_border;
bool m_borderSet;
bool m_borderColorSet;
bool frameborder;
bool frameBorderSet;
......
......@@ -53,8 +53,7 @@ struct ScheduledEvent {
class FrameViewPrivate {
public:
FrameViewPrivate(FrameView* view)
: m_hasBorder(false)
, layoutTimer(view, &FrameView::layoutTimerFired)
: layoutTimer(view, &FrameView::layoutTimerFired)
, m_mediaType("screen")
, m_enqueueEvents(0)
, m_overflowStatusDirty(true)
......@@ -83,7 +82,6 @@ public:
}
bool doFullRepaint;
bool m_hasBorder;
ScrollbarMode vmode;
ScrollbarMode hmode;
......@@ -740,17 +738,6 @@ void FrameView::setBaseBackgroundColor(Color bc)
d->baseBackgroundColor = bc;
}
void FrameView::setHasBorder(bool b)
{
d->m_hasBorder = b;
updateBorder();
}
bool FrameView::hasBorder() const
{
return d->m_hasBorder;
}
void FrameView::scheduleEvent(PassRefPtr<Event> event, PassRefPtr<EventTargetNode> eventTarget, bool tempEvent)
{
if (!d->m_enqueueEvents) {
......
......@@ -102,9 +102,6 @@ public:
void adjustViewSize();
void initScrollbars();
void setHasBorder(bool);
bool hasBorder() const;
virtual IntRect windowClipRect() const;
IntRect windowClipRect(bool clipToContents) const;
IntRect windowClipRectForLayer(const RenderLayer*, bool clipToLayerContents) const;
......
......@@ -294,8 +294,6 @@ typedef enum ObjectElementType {
- (BOOL)startDraggingImage:(NSImage *)dragImage at:(NSPoint)dragLoc operation:(NSDragOperation)op event:(NSEvent *)event sourceIsDHTML:(BOOL)flag DHTMLWroteData:(BOOL)dhtmlWroteData;
- (void)setHasBorder:(BOOL)hasBorder;
- (void)print;
- (jobject)getAppletInView:(NSView *)view;
......
......@@ -80,6 +80,11 @@ public:
void setWidth(int width) { m_size.setWidth(width); }
void setHeight(int height) { m_size.setHeight(height); }
IntPoint topLeft() const { return m_location; }
IntPoint topRight() const { return IntPoint(right() - 1, y()); }
IntPoint bottomLeft() const { return IntPoint(x(), bottom() - 1); }
IntPoint bottomRight() const { return IntPoint(right() - 1, bottom() - 1); }
bool isEmpty() const { return m_size.isEmpty(); }
int right() const { return x() + width(); }
......
......@@ -44,12 +44,9 @@ void RenderFrame::viewCleared()
{
if (element() && m_widget && m_widget->isFrameView()) {
FrameView* view = static_cast<FrameView*>(m_widget);
HTMLFrameSetElement* frameSet = static_cast<HTMLFrameSetElement*>(element()->parentNode());
bool hasBorder = element()->hasFrameBorder() && frameSet->frameBorder();
int marginw = element()->getMarginWidth();
int marginh = element()->getMarginHeight();
view->setHasBorder(hasBorder);
if (marginw != -1)
view->setMarginWidth(marginw);
if (marginh != -1)
......
......@@ -31,6 +31,7 @@
#include "EventNames.h"
#include "Frame.h"
#include "FrameView.h"
#include "GraphicsContext.h"
#include "HTMLFrameSetElement.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
......@@ -65,6 +66,101 @@ inline HTMLFrameSetElement* RenderFrameSet::frameSet() const
return static_cast<HTMLFrameSetElement*>(node());
}
static Color borderStartEdgeColor()
{
return Color(170,170,170);
}
static Color borderEndEdgeColor()
{
return Color::black;
}
void RenderFrameSet::paintColumnBorder(const PaintInfo& paintInfo, const IntRect& borderRect)
{
if (!paintInfo.rect.intersects(borderRect))
return;
// FIXME: We should do something clever when borders from distinct framesets meet at a join.
// Fill first.
GraphicsContext* context = paintInfo.context;
context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : Color::white);
// Now stroke the edges but only if we have enough room to paint both edges with a little
// bit of the fill color showing through.
if (borderRect.width() >= 3) {
context->setStrokeThickness(1.0f);
context->setStrokeColor(borderStartEdgeColor());
context->drawLine(borderRect.topLeft(), borderRect.bottomLeft());
context->setStrokeColor(borderEndEdgeColor());
context->drawLine(borderRect.topRight(), borderRect.bottomRight());
}
}
void RenderFrameSet::paintRowBorder(const PaintInfo& paintInfo, const IntRect& borderRect)
{
if (!paintInfo.rect.intersects(borderRect))
return;
// FIXME: We should do something clever when borders from distinct framesets meet at a join.
// Fill first.
GraphicsContext* context = paintInfo.context;
context->fillRect(borderRect, frameSet()->hasBorderColor() ? style()->borderLeftColor() : Color::white);
// Now stroke the edges but only if we have enough room to paint both edges with a little
// bit of the fill color showing through.
if (borderRect.height() >= 3) {
Color startEdge(170, 170, 170);
Color endEdge(Color::black);
context->setStrokeThickness(1.0f);
context->setStrokeColor(borderStartEdgeColor());
context->drawLine(borderRect.topLeft(), borderRect.topRight());
context->setStrokeColor(borderEndEdgeColor());
context->drawLine(borderRect.bottomLeft(), borderRect.bottomRight());
}
}
void RenderFrameSet::paint(PaintInfo& paintInfo, int tx, int ty)
{
if (paintInfo.phase != PaintPhaseForeground)
return;
RenderObject* child = firstChild();
if (!child)
return;
// Add in our offsets.
tx += m_x;
ty += m_y;
int rows = frameSet()->totalRows();
int cols = frameSet()->totalCols();
int borderThickness = frameSet()->border();
int yPos = 0;
for (int r = 0; r < rows; r++) {
int xPos = 0;
for (int c = 0; c < cols; c++) {
child->paint(paintInfo, tx, ty);
xPos += m_cols.m_sizes[c];
if (borderThickness) {
paintColumnBorder(paintInfo, IntRect(tx + xPos, ty + yPos, borderThickness, height()));
xPos += borderThickness;
}
child = child->nextSibling();
if (!child)
return;
}
yPos += m_rows.m_sizes[r];
if (borderThickness) {
paintRowBorder(paintInfo, IntRect(tx, ty + yPos, width(), borderThickness));
yPos += borderThickness;
}
}
}
bool RenderFrameSet::nodeAtPoint(const HitTestRequest& request, HitTestResult& result,
int x, int y, int tx, int ty, HitTestAction action)
{
......
......@@ -42,7 +42,8 @@ public:
virtual void layout();
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
virtual void paint(PaintInfo& paintInfo, int tx, int ty);
bool userResize(MouseEvent*);
bool isResizingRow() const;
......@@ -84,6 +85,9 @@ private:
void startResizing(GridAxis&, int position);
void continueResizing(GridAxis&, int position);
void paintRowBorder(const PaintInfo& paintInfo, const IntRect& rect);
void paintColumnBorder(const PaintInfo& paintInfo, const IntRect& rect);
GridAxis m_rows;
GridAxis m_cols;
......
......@@ -259,17 +259,13 @@ void RenderPartObject::viewCleared()
{
if (element() && m_widget && m_widget->isFrameView()) {
FrameView* view = static_cast<FrameView*>(m_widget);
bool hasBorder = false;
int marginw = -1;
int marginh = -1;
if (element()->hasTagName(iframeTag)) {
HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(element());
hasBorder = frame->hasFrameBorder();
marginw = frame->getMarginWidth();
marginh = frame->getMarginHeight();
}
view->setHasBorder(hasBorder);
if (marginw != -1)
view->setMarginWidth(marginw);
if (marginh != -1)
......
......@@ -185,10 +185,8 @@ void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
r.move(-vr.x(), -vr.y());
// FIXME: Hardcoded offsets here are not good.
int yFrameOffset = m_frameView->hasBorder() ? 2 : 0;
int xFrameOffset = m_frameView->hasBorder() ? 1 : 0;
r.move(obj->borderLeft() + obj->paddingLeft() + xFrameOffset,
obj->borderTop() + obj->paddingTop() + yFrameOffset);
r.move(obj->borderLeft() + obj->paddingLeft(),
obj->borderTop() + obj->paddingTop());
obj->repaintRectangle(r, immediate);
}
}
......
2007-03-18 David Hyatt <hyatt@apple.com>
Move frame borders out of WebKit and into WebCore.
Reviewed by aroben, olliej
* WebCoreSupport/WebFrameBridge.mm:
* WebKit.xcodeproj/project.pbxproj:
* WebView/WebFrameView.mm:
(-[WebFrameView drawRect:]):
(-[WebFrameView setFrameSize:]):
* WebView/WebFrameViewInternal.h:
2007-03-17 John Sullivan <sullivan@apple.com>
 
Reviewed by Tim Hatcher
......
......@@ -671,11 +671,6 @@ static BOOL loggedObjectCacheSize = NO;
sourceIsDHTML:flag DHTMLWroteData:dhtmlWroteData];
}
- (void)setHasBorder:(BOOL)hasBorder
{
[[_frame frameView] _setHasBorder:hasBorder];
}
- (void)print
{
id wd = [[self webView] UIDelegate];
......
......@@ -73,8 +73,6 @@ enum {
@interface WebFrameView (WebFrameViewFileInternal) <WebCoreBridgeHolder>
- (float)_verticalKeyboardScrollDistance;
- (void)_tile;
- (BOOL)_shouldDrawBorder;
- (WebCoreFrameBridge *) webCoreBridge;
@end
......@@ -88,8 +86,6 @@ enum {
// we have the appropriate document view type.
int marginWidth;
int marginHeight;
BOOL hasBorder;
}
@end
......@@ -121,32 +117,6 @@ enum {
return [[self _scrollView] verticalLineScroll];
}
- (BOOL)_shouldDrawBorder
{
if (!_private->hasBorder)
return NO;
// Only draw a border for frames that request a border and the frame does
// not contain a frameset. Additionally we should (some day) not draw
// a border (left, right, top or bottom) if the frame edge abutts the window frame.
NSView *docV = [self documentView];
if ([docV isKindOfClass:[WebHTMLView class]])
if (core(_private->webFrame)->isFrameSet())
return NO;
return YES;
}
- (void)_tile
{
NSRect scrollViewFrame = [self bounds];
// The border drawn by WebFrameView is 1 pixel on the left and right,
// two pixels on top and bottom. Shrink the scroll view to accomodate
// the border.
if ([self _shouldDrawBorder])
scrollViewFrame = NSInsetRect (scrollViewFrame, 1, 2);
[_private->frameScrollView setFrame:scrollViewFrame];
}
- (WebCoreFrameBridge *) webCoreBridge
{
return [_private->webFrame _bridge];
......@@ -295,15 +265,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
return [WebView _viewClass:&viewClass andRepresentationClass:nil forMIMEType:MIMEType] ? viewClass : nil;
}
- (void)_setHasBorder:(BOOL)hasBorder
{
if (_private->hasBorder == hasBorder) {
return;
}
_private->hasBorder = hasBorder;
[self _tile];
}
@end
@implementation WebFrameView
......@@ -451,33 +412,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
return [[self _webView] drawsBackground];
}
- (void)_drawBorder
{
if ([self _shouldDrawBorder]){
NSRect vRect = [self frame];
// Left, black
[[NSColor blackColor] set];
NSRectFill(NSMakeRect(0,0,1,vRect.size.height));
// Top, light gray, black
[[NSColor lightGrayColor] set];
NSRectFill(NSMakeRect(0,0,vRect.size.width,1));
[[NSColor whiteColor] set];
NSRectFill(NSMakeRect(1,1,vRect.size.width-2,1));
// Right, light gray
[[NSColor lightGrayColor] set];
NSRectFill(NSMakeRect(vRect.size.width-1,1,1,vRect.size.height-2));
// Bottom, light gray, white
[[NSColor blackColor] set];
NSRectFill(NSMakeRect(0,vRect.size.height-1,vRect.size.width,1));
[[NSColor lightGrayColor] set];
NSRectFill(NSMakeRect(1,vRect.size.height-2,vRect.size.width-2,1));
}
}
- (void)drawRect:(NSRect)rect
{
if ([self documentView] == nil) {
......@@ -494,8 +428,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
}
#endif
}
[self _drawBorder];
}
- (void)setFrameSize:(NSSize)size
......@@ -504,7 +436,6 @@ static inline void addTypesFromClass(NSMutableDictionary *allTypes, Class objCCl
[[self _scrollView] setDrawsBackground:YES];
}
[super setFrameSize:size];
[self _tile];
}
- (WebFrameBridge *)_bridge
......