+2006-01-30 Darin Adler <darin@apple.com>
+
+ - updated test result for rect changes
+
+ * fast/box-sizing/percentage-height-expected.txt: A bunch of strange empty
+ clip rects are now dumping as (0,0) 0x0.
+
2006-01-29 Sam Weinig <sam.weinig@gmail.com>
Reviewed by Darin.
RenderBlock (positioned) {DIV} at (0,0) size 1800x0
layer at (90,990) size 1892x2
RenderBlock (positioned) {DIV} at (0,0) size 1890x0
-layer at (90,990) size 1800x2 clip at (91,991) size 1783x0 scrollHeight 30
+layer at (90,990) size 1800x2 clip at (0,0) size 0x0 scrollHeight 30
RenderBlock (relative positioned) zI: 1 {DIV} at (0,0) size 1800x2 [bgcolor=#FFFFFF] [border: (1px solid #999999)]
RenderBlock {DIV} at (1,1) size 1783x30
RenderText {TEXT} at (0,1) size 1775x30
text run at (0,1) width 1775: "Luckily, the bit of the broadcast is now missing from BBCs website and folks in Cornwall swear they saw Bigfoot and Jersey Devil run off with miles and miles of audio tape containing tapes of Steve Jobs talking about the new Video iPod while drunk on soju, the confession of the true JFK assassin, and a tripping Chief Justice Roberts talking about how \x{201C}Green isn\x{2019}t just"
text run at (0,16) width 124: "a color, man, it\x{2019}s an idea.\x{201D}"
-layer at (1980,990) size 2x2 clip at (1981,991) size -15x-15 scrollWidth 26 scrollHeight 152
+layer at (1980,990) size 2x2 clip at (0,0) size 0x0 scrollWidth 26 scrollHeight 152
RenderBlock (relative positioned) zI: 1 {DIV} at (1890,0) size 2x2 [bgcolor=#FFFFFF] [border: (1px solid #999999)]
-layer at (1981,991) size 26x38 backgroundClip at (1981,991) size -15x-15 clip at (1981,991) size -15x-15 outlineClip at (1981,991) size -15x-15
+layer at (1981,991) size 26x38 backgroundClip at (0,0) size 0x0 clip at (0,0) size 0x0 outlineClip at (0,0) size 0x0
RenderBlock (relative positioned) {DIV} at (0,0) size 10x38
RenderText {TEXT} at (5,6) size 21x28
text run at (5,6) width 21: "Item"
text run at (5,20) width 6: "1"
-layer at (1981,1029) size 26x38 backgroundClip at (1981,991) size -15x-15 clip at (1981,991) size -15x-15 outlineClip at (1981,991) size -15x-15
+layer at (1981,1029) size 26x38 backgroundClip at (0,0) size 0x0 clip at (0,0) size 0x0 outlineClip at (0,0) size 0x0
RenderBlock (relative positioned) {DIV} at (0,0) size 10x38
RenderText {TEXT} at (5,6) size 21x28
text run at (5,6) width 21: "Item"
text run at (5,20) width 6: "2"
-layer at (1981,1067) size 26x38 backgroundClip at (1981,991) size -15x-15 clip at (1981,991) size -15x-15 outlineClip at (1981,991) size -15x-15
+layer at (1981,1067) size 26x38 backgroundClip at (0,0) size 0x0 clip at (0,0) size 0x0 outlineClip at (0,0) size 0x0
RenderBlock (relative positioned) {DIV} at (0,0) size 10x38
RenderText {TEXT} at (5,6) size 21x28
text run at (5,6) width 21: "Item"
text run at (5,20) width 6: "3"
-layer at (1981,1105) size 26x38 backgroundClip at (1981,991) size -15x-15 clip at (1981,991) size -15x-15 outlineClip at (1981,991) size -15x-15
+layer at (1981,1105) size 26x38 backgroundClip at (0,0) size 0x0 clip at (0,0) size 0x0 outlineClip at (0,0) size 0x0
RenderBlock (relative positioned) {DIV} at (0,0) size 10x38
RenderText {TEXT} at (5,6) size 21x28
text run at (5,6) width 21: "Item"
+2006-01-30 Darin Adler <darin@apple.com>
+
+ Reviewed by Eric.
+
+ - cleanup of Int/Float-Size/Point/Rect classes
+
+ I did this as part of a redo of QMatrix, but I decided I should
+ land this part separately.
+
+ Eliminated the concept of a null rect or point, which used to be
+ indicated by negative width and height.
+
+ Changed right and bottom to to be, e.g., 2 for a rect at (0,0) 2x2.
+ The old code followed Qt's system that says right is 1 in those cases,
+ which is inappropriate for floating point, and old fashioned because
+ modern graphics systems use coordinates for lines between pixels, not
+ the pixels themselves.
+
+ Other API improvements to the point, size, and rect classes. For example,
+ functions named with verbs now always modify the object itself.
+
+ * rendering/render_theme_mac.mm: (RenderThemeMac::paintButton): Fixed
+ a bug where it said x() where it should say y().
+
+ * bridge/mac/MacFrame.h:
+ * bridge/mac/MacFrame.mm:
+ * bridge/mac/WebCoreFrameBridge.mm:
+ * kcanvas/KCanvasContainer.cpp:
+ * kcanvas/KCanvasItem.cpp:
+ * kcanvas/RenderSVGImage.cpp:
+ * kcanvas/device/quartz/KCanvasFilterQuartz.mm:
+ * kcanvas/device/quartz/KCanvasItemQuartz.mm:
+ * kcanvas/device/quartz/KCanvasResourcesQuartz.mm:
+ * khtml/ecma/kjs_dom.cpp:
+ * khtml/ecma/kjs_window.cpp:
+ * khtml/editing/SelectionController.cpp:
+ * khtml/html/html_inlineimpl.cpp:
+ * khtml/html/html_objectimpl.cpp:
+ * khtml/html/html_objectimpl.h:
+ * khtml/misc/khtmllayout.h:
+ * ksvg2/svg/SVGSVGElementImpl.cpp:
+ * kwq/KWQAccObject.mm:
+ * kwq/KWQComboBox.mm:
+ * kwq/KWQFileButton.mm:
+ * kwq/KWQFontMetrics.mm:
+ * kwq/KWQPainter.h:
+ * kwq/KWQPainter.mm:
+ * kwq/KWQRegion.cpp:
+ * kwq/KWQRenderTreeDebug.cpp:
+ * kwq/KWQScrollView.mm:
+ * kwq/KWQWMatrix.cpp:
+ * kwq/KWQWidget.h:
+ * kwq/KWQWidget.mm:
+ * kwq/KWQWindowWidget.mm:
+ * loader/CachedImage.cpp:
+ * page/Frame.cpp:
+ * page/FrameView.cpp:
+ * platform/FloatPoint.cpp:
+ * platform/FloatPoint.h:
+ * platform/FloatRect.cpp:
+ * platform/FloatRect.h:
+ * platform/FloatSize.cpp:
+ * platform/FloatSize.h:
+ * platform/Image.h:
+ * platform/IntPoint.cpp:
+ * platform/IntPoint.h:
+ * platform/IntPointArray.cpp:
+ * platform/IntPointArray.h:
+ * platform/IntRect.cpp:
+ * platform/IntRect.h:
+ * platform/IntSize.cpp:
+ * platform/IntSize.h:
+ * platform/mac/FloatPoint.mm:
+ * platform/mac/FloatRect.mm:
+ * platform/mac/FloatSize.mm:
+ * platform/mac/Image.mm:
+ * platform/mac/IntPoint.mm:
+ * platform/mac/IntRect.mm:
+ * platform/mac/IntSize.mm:
+ * platform/mac/Screen.mm:
+ * rendering/InlineTextBox.cpp:
+ * rendering/RenderBlock.cpp:
+ * rendering/RenderBlock.h:
+ * rendering/RenderTable.cpp:
+ * rendering/RenderTableCell.cpp:
+ * rendering/RenderText.cpp:
+ * rendering/render_box.cpp:
+ * rendering/render_canvas.cpp:
+ * rendering/render_canvasimage.cpp:
+ * rendering/render_flow.cpp:
+ * rendering/render_form.cpp:
+ * rendering/render_frames.cpp:
+ * rendering/render_layer.cpp:
+ * rendering/render_line.cpp:
+ * rendering/render_list.cpp:
+ * rendering/render_object.cpp:
+ * rendering/render_object.h:
+ * rendering/render_replaced.cpp:
+
2006-01-29 Maciej Stachowiak <mjs@apple.com>
Reviewed by Darin.
#define MacFrame_H
#include "Frame.h"
+#include "IntRect.h"
#include "KWQClipboard.h"
#include "KWQScrollBar.h"
#include "NodeImpl.h"
// 1. The background color used to draw behind selected content (active | inactive color)
if (d->m_view)
- d->m_view->updateContents(IntRect(visibleSelectionRect()));
+ d->m_view->updateContents(enclosingIntRect(visibleSelectionRect()));
// 2. Caret blinking (blinks | does not blink)
if (flag)
NSView *documentView = d->m_view ? d->m_view->getDocumentView() : 0;
if (documentView && renderer()) {
doc->updateLayout(); // Ensure layout is up to date.
- IntRect visibleRect([documentView visibleRect]);
+ IntRect visibleRect(enclosingIntRect([documentView visibleRect]));
QPainter p;
p.setUpdatingControlTints(true);
paint(&p, visibleRect);
- (void)drawRect:(NSRect)rect withPainter:(QPainter *)p
{
[self _setupRootForPrinting:YES];
- m_frame->paint(p, IntRect(rect));
+ m_frame->paint(p, enclosingIntRect(rect));
[self _setupRootForPrinting:NO];
}
for(; current != 0; current = current->nextSibling()) {
FloatRect childBBox = current->relativeBBox(includeStroke);
FloatRect mappedBBox = current->localTransform().mapRect(childBBox);
- rect = rect.unite(mappedBBox);
+ rect.unite(mappedBBox);
}
return rect;
return result;
if (includeStroke) {
- if(!d->strokeBbox.isValid())
+ if (d->strokeBbox.isEmpty())
d->strokeBbox = bboxForPath(true);
result = d->strokeBbox;
} else {
- if(!d->fillBBox.isValid())
+ if (d->fillBBox.isEmpty())
d->fillBBox = bboxForPath(false);
result = d->fillBBox;
}
// Filters can expand the bounding box
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (filter)
- repaintRect = repaintRect.unite(filter->filterBBoxForItemBBox(repaintRect));
+ repaintRect.unite(filter->filterBBoxForItemBBox(repaintRect));
return enclosingIntRect(repaintRect);
}
void KCanvasFilterQuartz::prepareFilter(const FloatRect &bbox)
{
- if (!bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled())
+ if (bbox.isEmpty() || !KRenderingDeviceQuartz::filtersEnabled())
return;
if (m_effects.isEmpty())
void KCanvasFilterQuartz::applyFilter(const FloatRect &bbox)
{
- if (!bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled() || m_effects.isEmpty())
+ if (bbox.isEmpty() || !KRenderingDeviceQuartz::filtersEnabled() || m_effects.isEmpty())
return;
// restore the previous context, delete the filter context.
[filter setValue:inputColor forKey:@"inputColor"];
CGRect cropRect = CGRectMake(-100,-100,1000,1000); // HACK
- if (subRegion().isValid())
- cropRect = CGRect(subRegion());
+ if (!subRegion().isEmpty())
+ cropRect = subRegion();
FE_QUARTZ_CROP_TO_RECT(cropRect);
FE_QUARTZ_OUTPUT_RETURN;
[nsTransform setTransformStruct:*((NSAffineTransformStruct *)&cgTransform)];
[filter setValue:nsTransform forKey:@"inputTransform"];
- if (subRegion().isValid()) {
+ if (!subRegion().isEmpty()) {
CIFilter *scaleImage = [CIFilter filterWithName:@"CIAffineTransform"];
[scaleImage setDefaults];
[scaleImage setValue:[filter valueForKey:@"outputImage"] forKey:@"inputImage"];
// Filters can expand the bounding box
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (filter)
- repaintRect = repaintRect.unite(filter->filterBBoxForItemBBox(repaintRect));
+ repaintRect.unite(filter->filterBBoxForItemBBox(repaintRect));
if (!repaintRect.isEmpty())
repaintRect.inflate(1); // inflate 1 pixel for antialiasing
parentX = parentY = 0;
}
- if (viewport().isValid())
+ if (!viewport().isEmpty())
deviceContext->concatCTM(QMatrix().translate(viewport().x(), viewport().y()));
if (!localTransform().isIdentity())
if (filter)
filter->prepareFilter(relativeBBox(true));
- if (!viewBox().isNull())
+ if (!viewBox().isEmpty())
deviceContext->concatCTM(viewportTransform());
RenderContainer::paint(paintInfo, 0, 0);
QMatrix KCanvasContainerQuartz::viewportTransform() const
{
- if (!viewBox().isNull()) {
+ if (!viewBox().isEmpty()) {
FloatRect viewportRect = viewport();
if (!parent()->isKCanvasContainer())
viewportRect = FloatRect(viewport().x(), viewport().y(), width(), height());
IntRect repaintRect;
for (WebCore::RenderObject *current = firstChild(); current != 0; current = current->nextSibling())
- repaintRect = repaintRect.unite(current->getAbsoluteRepaintRect());
+ repaintRect.unite(current->getAbsoluteRepaintRect());
// Filters can expand the bounding box
KCanvasFilter *filter = getFilterById(document(), style()->svgStyle()->filter().mid(1));
if (filter)
- repaintRect = repaintRect.unite(enclosingIntRect(filter->filterBBoxForItemBBox(repaintRect)));
+ repaintRect.unite(enclosingIntRect(filter->filterBBoxForItemBBox(repaintRect)));
return repaintRect;
}
#include "config.h"
#include "kjs_dom.h"
-#include <kdebug.h>
-#include "Frame.h"
-#include "xml/dom2_eventsimpl.h"
-#include "xml/dom2_viewsimpl.h"
-#include "rendering/render_canvas.h"
-#include "DocumentTypeImpl.h"
#include "DOMImplementationImpl.h"
#include "DocumentFragmentImpl.h"
-#include "xml/dom_textimpl.h"
-#include "xml/EventNames.h"
-#include "xml/dom_xmlimpl.h"
-#include "html/html_documentimpl.h"
-#include "css/css_ruleimpl.h"
-#include "css/css_stylesheetimpl.h"
-
+#include "DocumentTypeImpl.h"
+#include "Frame.h"
#include "JSDOMImplementation.h"
#include "JSDocumentType.h"
-
-#include "kjs_html.h"
+#include "css/css_ruleimpl.h"
+#include "css/css_stylesheetimpl.h"
+#include "dom/dom_exception.h"
+#include "html/html_documentimpl.h"
+#include "html_objectimpl.h"
+#include "htmlnames.h"
+#include "khtml_settings.h"
#include "kjs_css.h"
+#include "kjs_events.h"
+#include "kjs_html.h"
#include "kjs_range.h"
#include "kjs_traversal.h"
-#include "kjs_events.h"
#include "kjs_views.h"
#include "kjs_window.h"
-#include "dom/dom_exception.h"
-
-#include "html_objectimpl.h"
-#include "htmlnames.h"
+#include "rendering/render_canvas.h"
+#include "xml/EventNames.h"
+#include "xml/dom2_eventsimpl.h"
+#include "xml/dom2_viewsimpl.h"
+#include "xml/dom_textimpl.h"
+#include "xml/dom_xmlimpl.h"
+#include <kdebug.h>
#if __APPLE__
#include <JavaScriptCore/runtime_object.h>
wargs.height = intFeature(features, "dialogheight", 100, screenRect.height(), 450); // default here came from frame size of dialog in MacIE
wargs.heightSet = true;
- wargs.x = intFeature(features, "dialogleft", screenRect.x(), screenRect.x() + screenRect.width() - wargs.width, -1);
+ wargs.x = intFeature(features, "dialogleft", screenRect.x(), screenRect.right() - wargs.width, -1);
wargs.xSet = wargs.x > 0;
- wargs.y = intFeature(features, "dialogtop", screenRect.y(), screenRect.y() + screenRect.height() - wargs.height, -1);
+ wargs.y = intFeature(features, "dialogtop", screenRect.y(), screenRect.bottom() - wargs.height, -1);
wargs.ySet = wargs.y > 0;
if (boolFeature(features, "center", true)) {
wargs.ySet = true;
}
}
-
+
wargs.dialog = true;
wargs.resizable = boolFeature(features, "resizable");
wargs.scrollBarsVisible = boolFeature(features, "scroll", true);
case Personalbar:
return personalbar(exec);
case ScreenLeft:
- case ScreenX: {
- if (m_frame->view()) {
- // We want to use frameGeometry here instead of mapToGlobal because it goes through
- // the windowFrame method of the WebKit's UI delegate. Also we don't want to try
- // to do anything relative to the screen the window is on, so the code below is no
- // good of us anyway.
- return jsNumber(m_frame->view()->topLevelWidget()->frameGeometry().x());
- } else
+ case ScreenX:
+ if (!m_frame->view())
return jsUndefined();
- }
+ // We want to use frameGeometry here instead of mapToGlobal because it goes through
+ // the windowFrame method of the WebKit's UI delegate. Also we don't want to try
+ // to do anything relative to the screen the window is on.
+ return jsNumber(m_frame->view()->topLevelWidget()->frameGeometry().x());
case ScreenTop:
- case ScreenY: {
- if (m_frame->view()) {
- // See comment above in ScreenX.
- return jsNumber(m_frame->view()->topLevelWidget()->frameGeometry().y());
- } else
+ case ScreenY:
+ if (!m_frame->view())
return jsUndefined();
- }
+ // See comment above in ScreenX.
+ return jsNumber(m_frame->view()->topLevelWidget()->frameGeometry().y());
case ScrollX:
if (!m_frame->view())
return jsUndefined();
}
}
-static void constrainToVisible(const IntRect &screen, WindowArgs& windowArgs)
+static void constrainToVisible(const IntRect& screen, WindowArgs& windowArgs)
{
windowArgs.x += screen.x();
- if (windowArgs.x < screen.x() || windowArgs.x > screen.right())
+ if (windowArgs.x < screen.x() || windowArgs.x >= screen.right())
windowArgs.x = screen.x(); // only safe choice until size is determined
windowArgs.y += screen.y();
- if (windowArgs.y < screen.y() || windowArgs.y > screen.bottom())
+ if (windowArgs.y < screen.y() || windowArgs.y >= screen.bottom())
windowArgs.y = screen.y(); // only safe choice until size is determined
- if (windowArgs.height > screen.height()) // should actually check workspace
+ if (windowArgs.height > screen.height()) // should actually check workspace
windowArgs.height = screen.height();
if (windowArgs.height < 100)
windowArgs.height = 100;
- if (windowArgs.width > screen.width()) // should actually check workspace
+ if (windowArgs.width > screen.width()) // should actually check workspace
windowArgs.width = screen.width();
if (windowArgs.width < 100)
windowArgs.width = 100;
case Window::Scroll:
case Window::ScrollTo:
window->updateLayout();
- if(args.size() >= 2 && widget)
+ if (args.size() >= 2 && widget)
widget->setContentsPos(args[0]->toInt32(exec), args[1]->toInt32(exec));
return jsUndefined();
case Window::MoveBy:
if(args.size() >= 2 && widget)
{
- QWidget * tl = widget->topLevelWidget();
+ QWidget* tl = widget->topLevelWidget();
IntRect sg = screenRect(widget);
- IntPoint dest = tl->pos() + IntPoint( args[0]->toInt32(exec), args[1]->toInt32(exec) );
+ IntPoint dest = tl->pos() + IntPoint(args[0]->toInt32(exec), args[1]->toInt32(exec));
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
- if ( dest.x() >= sg.x() && dest.y() >= sg.x() &&
- dest.x()+tl->width() <= sg.width()+sg.x() &&
- dest.y()+tl->height() <= sg.height()+sg.y() )
- tl->move( dest );
+ if (sg.contains(IntRect(dest, IntSize(tl->width(), tl->height()))))
+ tl->move(dest);
}
return jsUndefined();
case Window::MoveTo:
if(args.size() >= 2 && widget)
{
- QWidget * tl = widget->topLevelWidget();
+ QWidget* tl = widget->topLevelWidget();
IntRect sg = screenRect(widget);
- IntPoint dest( args[0]->toInt32(exec)+sg.x(), args[1]->toInt32(exec)+sg.y() );
+ IntPoint dest(args[0]->toInt32(exec) + sg.x(), args[1]->toInt32(exec) + sg.y());
// Security check (the spec talks about UniversalBrowserWrite to disable this check...)
- if ( dest.x() >= sg.x() && dest.y() >= sg.y() &&
- dest.x()+tl->width() <= sg.width()+sg.x() &&
- dest.y()+tl->height() <= sg.height()+sg.y() )
- tl->move( dest );
+ if (sg.contains(IntRect(dest, IntSize(tl->width(), tl->height()))))
+ tl->move(dest);
}
return jsUndefined();
case Window::ResizeBy:
if(args.size() >= 2 && widget)
{
- QWidget * tl = widget->topLevelWidget();
- IntSize dest = tl->size() + IntSize( args[0]->toInt32(exec), args[1]->toInt32(exec) );
+ QWidget* tl = widget->topLevelWidget();
+ IntSize dest = tl->size() + IntSize(args[0]->toInt32(exec), args[1]->toInt32(exec));
IntRect sg = screenRect(widget);
// Security check: within desktop limits and bigger than 100x100 (per spec)
- if ( tl->x()+dest.width() <= sg.x()+sg.width() &&
- tl->y()+dest.height() <= sg.y()+sg.height() &&
- dest.width() >= 100 && dest.height() >= 100 )
+ if (tl->x() + dest.width() <= sg.right() && tl->y() + dest.height() <= sg.bottom()
+ && dest.width() >= 100 && dest.height() >= 100)
{
// Take into account the window frame
int deltaWidth = tl->frameGeometry().width() - tl->width();
int deltaHeight = tl->frameGeometry().height() - tl->height();
- tl->resize( dest.width() - deltaWidth, dest.height() - deltaHeight );
+ tl->resize(dest.width() - deltaWidth, dest.height() - deltaHeight);
}
}
return jsUndefined();
case Window::ResizeTo:
- if(args.size() >= 2 && widget)
- {
- QWidget * tl = widget->topLevelWidget();
- IntSize dest = IntSize( args[0]->toInt32(exec), args[1]->toInt32(exec) );
+ if (args.size() >= 2 && widget) {
+ QWidget* tl = widget->topLevelWidget();
+ IntSize dest = IntSize(args[0]->toInt32(exec), args[1]->toInt32(exec));
IntRect sg = screenRect(widget);
// Security check: within desktop limits and bigger than 100x100 (per spec)
- if ( tl->x()+dest.width() <= sg.x()+sg.width() &&
- tl->y()+dest.height() <= sg.y()+sg.height() &&
- dest.width() >= 100 && dest.height() >= 100 )
+ if (tl->x() + dest.width() <= sg.right() && tl->y() + dest.height() <= sg.bottom() &&
+ dest.width() >= 100 && dest.height() >= 100)
{
// Take into account the window frame
int deltaWidth = tl->frameGeometry().width() - tl->width();
int deltaHeight = tl->frameGeometry().height() - tl->height();
- tl->resize( dest.width() - deltaWidth, dest.height() - deltaHeight );
+ tl->resize(dest.width() - deltaWidth, dest.height() - deltaHeight);
}
}
return jsUndefined();
IntRect SelectionController::caretRect() const
{
- if (m_needsLayout) {
+ if (m_needsLayout)
const_cast<SelectionController *>(this)->layout();
- }
IntRect caret = m_caretRect;
-
+
if (m_sel.start().node() && m_sel.start().node()->renderer()) {
int x, y;
m_sel.start().node()->renderer()->absolutePosition(x, y);
- IntPoint diff = IntPoint(x, y) - m_caretPositionOnLayout;
- caret.moveTopLeft(diff);
+ caret.move(IntPoint(x, y) - m_caretPositionOnLayout);
}
return caret;
IntRect r = caretRect();
if (r.isEmpty())
return IntRect();
- return IntRect(r.left() - 1, r.top() - 1, r.width() + 2, r.height() + 2);
+ return IntRect(r.x() - 1, r.y() - 1, r.width() + 2, r.height() + 2);
}
void SelectionController::needsCaretRepaint()
if (m_needsLayout)
layout();
- IntRect caret = caretRect();
-
- if (caret.isValid())
- p->fillRect(caret & rect, Brush());
+ IntRect caret = intersection(caretRect(), rect);
+ if (!caret.isEmpty())
+ p->fillRect(caret, Brush());
}
void SelectionController::debugRenderer(RenderObject *r, bool selected) const
// Before calling absoluteRects, check for the common case where the renderer
// or one of the continuations is non-empty, since this is a faster check and
// almost always returns true.
- for (RenderObject *r = renderer(); r; r = r->continuation()) {
+ for (RenderObject *r = renderer(); r; r = r->continuation())
if (r->width() > 0 && r->height() > 0)
return true;
- }
QValueList<IntRect> rects;
int x = 0, y = 0;
renderer()->absolutePosition(x, y);
renderer()->absoluteRects(rects, x, y);
- for (QValueList<IntRect>::ConstIterator it = rects.begin(); it != rects.end(); ++it) {
- if ((*it).isValid())
+ for (QValueList<IntRect>::ConstIterator it = rects.begin(); it != rects.end(); ++it)
+ if (!(*it).isEmpty())
return true;
- }
return false;
}
#include "dom_string.h"
#include "dom_textimpl.h"
#include "html_documentimpl.h"
+#include "html_imageimpl.h"
#include "render_applet.h"
#include "render_frames.h"
#include "render_image.h"
*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
- * Copyright (C) 2004 Apple Computer, Inc.
+ * Copyright (C) 2004, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* Boston, MA 02111-1307, USA.
*
*/
+
#ifndef HTML_OBJECTIMPL_H
#define HTML_OBJECTIMPL_H
-#include "html_imageimpl.h"
-#include "xml/dom_stringimpl.h"
+#include "HTMLElementImpl.h"
#if __APPLE__
#include <JavaScriptCore/runtime.h>
namespace KJS { namespace Bindings { class Instance; } }
#endif
-class QStringList;
-
namespace DOM {
class HTMLFormElementImpl;
+class HTMLImageLoader;
class HTMLAppletElementImpl : public HTMLElementImpl
{
public:
- HTMLAppletElementImpl(DocumentImpl *doc);
+ HTMLAppletElementImpl(DocumentImpl*);
~HTMLAppletElementImpl();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual bool checkDTD(const NodeImpl* newChild);
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
- virtual void parseMappedAttribute(MappedAttributeImpl *token);
+ virtual void parseMappedAttribute(MappedAttributeImpl*);
- virtual bool rendererIsNeeded(khtml::RenderStyle *);
- virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+ virtual bool rendererIsNeeded(RenderStyle*);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void closeRenderer();
virtual void detach();
DOMString align() const;
- void setAlign(const DOMString &);
+ void setAlign(const DOMString&);
DOMString alt() const;
- void setAlt(const DOMString &);
+ void setAlt(const DOMString&);
DOMString archive() const;
- void setArchive(const DOMString &);
+ void setArchive(const DOMString&);
DOMString code() const;
- void setCode(const DOMString &);
+ void setCode(const DOMString&);
DOMString codeBase() const;
- void setCodeBase(const DOMString &);
+ void setCodeBase(const DOMString&);
DOMString height() const;
- void setHeight(const DOMString &);
+ void setHeight(const DOMString&);
DOMString hspace() const;
- void setHspace(const DOMString &);
+ void setHspace(const DOMString&);
DOMString name() const;
- void setName(const DOMString &);
+ void setName(const DOMString&);
DOMString object() const;
- void setObject(const DOMString &);
+ void setObject(const DOMString&);
DOMString vspace() const;
- void setVspace(const DOMString &);
+ void setVspace(const DOMString&);
DOMString width() const;
- void setWidth(const DOMString &);
+ void setWidth(const DOMString&);
virtual bool allParamsAvailable();
void setupApplet() const;
- KJS::Bindings::Instance *getAppletInstance() const;
+ KJS::Bindings::Instance* getAppletInstance() const;
virtual void insertedIntoDocument();
virtual void removedFromDocument();
DOMString oldNameAttr;
DOMString oldIdAttr;
- mutable KJS::Bindings::Instance *appletInstance;
+ mutable KJS::Bindings::Instance* appletInstance;
bool m_allParamsAvailable;
};
class HTMLEmbedElementImpl : public HTMLElementImpl
{
public:
- HTMLEmbedElementImpl(DocumentImpl *doc);
+ HTMLEmbedElementImpl(DocumentImpl*);
~HTMLEmbedElementImpl();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual bool checkDTD(const NodeImpl* newChild);
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
- virtual void parseMappedAttribute(MappedAttributeImpl *attr);
+ virtual void parseMappedAttribute(MappedAttributeImpl*);
virtual void attach();
virtual void detach();
- virtual bool rendererIsNeeded(khtml::RenderStyle *);
- virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+ virtual bool rendererIsNeeded(RenderStyle*);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void insertedIntoDocument();
virtual void removedFromDocument();
- virtual bool isURLAttribute(AttributeImpl *attr) const;
+ virtual bool isURLAttribute(AttributeImpl*) const;
- KJS::Bindings::Instance *getEmbedInstance() const;
+ KJS::Bindings::Instance* getEmbedInstance() const;
QString url;
QString pluginPage;
private:
DOMString oldNameAttr;
- mutable KJS::Bindings::Instance *embedInstance;
+ mutable KJS::Bindings::Instance* embedInstance;
};
// -------------------------------------------------------------------------
class HTMLObjectElementImpl : public HTMLElementImpl
{
public:
- HTMLObjectElementImpl(DocumentImpl *doc);
+ HTMLObjectElementImpl(DocumentImpl*);
~HTMLObjectElementImpl();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusRequired; }
virtual int tagPriority() const { return 7; }
virtual bool checkDTD(const NodeImpl* newChild);
- HTMLFormElementImpl *form() const;
+ HTMLFormElementImpl* form() const;
virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const;
- virtual void parseMappedAttribute(MappedAttributeImpl *token);
+ virtual void parseMappedAttribute(MappedAttributeImpl*);
virtual void attach();
- virtual bool rendererIsNeeded(khtml::RenderStyle *);
- virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
+ virtual bool rendererIsNeeded(RenderStyle*);
+ virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual void closeRenderer();
virtual void detach();
virtual void insertedIntoDocument();
DocumentImpl* contentDocument() const;
- virtual bool isURLAttribute(AttributeImpl *attr) const;
+ virtual bool isURLAttribute(AttributeImpl*) const;
bool isImageType();
void renderFallbackContent();
DOMString code() const;
- void setCode(const DOMString &);
+ void setCode(const DOMString&);
DOMString align() const;
- void setAlign(const DOMString &);
+ void setAlign(const DOMString&);
DOMString archive() const;
- void setArchive(const DOMString &);
+ void setArchive(const DOMString&);
DOMString border() const;
- void setBorder(const DOMString &);
+ void setBorder(const DOMString&);
DOMString codeBase() const;
- void setCodeBase(const DOMString &);
+ void setCodeBase(const DOMString&);
DOMString codeType() const;
- void setCodeType(const DOMString &);
+ void setCodeType(const DOMString&);
DOMString data() const;
- void setData(const DOMString &);
+ void setData(const DOMString&);
bool declare() const;
void setDeclare(bool);
DOMString height() const;
- void setHeight(const DOMString &);
+ void setHeight(const DOMString&);
DOMString hspace() const;
- void setHspace(const DOMString &);
+ void setHspace(const DOMString&);
DOMString name() const;
- void setName(const DOMString &);
+ void setName(const DOMString&);
DOMString standby() const;
- void setStandby(const DOMString &);
+ void setStandby(const DOMString&);
int tabIndex() const;
void setTabIndex(int);
DOMString type() const;
- void setType(const DOMString &);
+ void setType(const DOMString&);
DOMString useMap() const;
- void setUseMap(const DOMString &);
+ void setUseMap(const DOMString&);
DOMString vspace() const;
- void setVspace(const DOMString &);
+ void setVspace(const DOMString&);
DOMString width() const;
- void setWidth(const DOMString &);
+ void setWidth(const DOMString&);
bool isComplete() const { return m_complete; }
void setComplete(bool complete);
bool isDocNamedItem() const { return m_docNamedItem; }
- KJS::Bindings::Instance *getObjectInstance() const;
+ KJS::Bindings::Instance* getObjectInstance() const;
QString serviceType;
QString url;
DOMString oldIdAttr;
DOMString oldNameAttr;
- mutable KJS::Bindings::Instance *objectInstance;
+ mutable KJS::Bindings::Instance* objectInstance;
bool m_complete;
bool m_docNamedItem;
{
friend class HTMLAppletElementImpl;
public:
- HTMLParamElementImpl(DocumentImpl *doc);
+ HTMLParamElementImpl(DocumentImpl*);
~HTMLParamElementImpl();
virtual HTMLTagStatus endTagRequirement() const { return TagStatusForbidden; }
virtual int tagPriority() const { return 0; }
- virtual void parseMappedAttribute(MappedAttributeImpl *token);
+ virtual void parseMappedAttribute(MappedAttributeImpl*);
- virtual bool isURLAttribute(AttributeImpl *attr) const;
+ virtual bool isURLAttribute(AttributeImpl*) const;
DOMString name() const { return m_name; }
- void setName(const DOMString &);
+ void setName(const DOMString&);
DOMString type() const;
- void setType(const DOMString &);
+ void setType(const DOMString&);
DOMString value() const { return m_value; }
- void setValue(const DOMString &);
+ void setValue(const DOMString&);
DOMString valueType() const;
- void setValueType(const DOMString &);
+ void setValueType(const DOMString&);
protected:
AtomicString m_name;
This widget holds some useful definitions needed for layouting Elements
*/
+
#ifndef HTML_LAYOUT_H
#define HTML_LAYOUT_H
#include <stdint.h>
namespace WebCore {
+
const int UNDEFINED = -1;
enum LengthType { Auto = 0, Relative, Percent, Fixed, Static, Intrinsic, MinIntrinsic };
struct Length
{
- Length() { *((int32_t *)this) = 0; }
+ // FIXME: A more reliable and straightforward way of doing this is to just have
+ // an unsigned and extract the bits as needed, instead of relying on bit fields layout
+ // fitting in a 32-bit integer. Should fix this.
+
+ Length() { *((uint32_t *)this) = 0; }
Length(LengthType t) { type = t; value = 0; quirk = false; }
Length(int v, LengthType t, bool q=false) : value(v), type(t), quirk(q) {}
Length(const Length &o)
- { *((int32_t *)this) = *((int32_t *)&o); }
+ { *((uint32_t *)this) = *((uint32_t *)&o); }
Length& operator=(const Length& o)
- { *((int32_t *)this) = *((int32_t *)&o); return *this; }
+ { *((uint32_t *)this) = *((uint32_t *)&o); return *this; }
bool operator==(const Length& o) const
- { return *((int32_t *)this) == *((int32_t *)&o); }
+ { return *((uint32_t *)this) == *((uint32_t *)&o); }
bool operator!=(const Length& o) const
- { return *((int32_t *)this) != *((int32_t *)&o); }
+ { return *((uint32_t *)this) != *((uint32_t *)&o); }
int length() const { return value; }
- /*
- * works only for Fixed and Percent, returns -1 otherwise
- */
- int width(int maxWidth) const
- {
- switch(type)
- {
+ // note: works only for certain types, returns -1 otherwise
+ int width(int maxWidth) const {
+ switch (type) {
case Fixed:
return value;
case Percent:
- return maxWidth*value/100;
+ return maxWidth * value / 100;
case Auto:
return maxWidth;
default:
return -1;
- }
}
- /*
- * returns the minimum width value which could work...
- */
- int minWidth(int maxWidth) const
- {
- switch(type)
- {
+ }
+
+ int minWidth(int maxWidth) const {
+ switch (type) {
case Fixed:
return value;
case Percent:
- return maxWidth*value/100;
+ return maxWidth * value / 100;
case Auto:
default:
return 0;
- }
}
- bool isAuto() const { return (type == Auto); }
- bool isRelative() const { return (type == Relative); }
- bool isPercent() const { return (type == Percent); }
- bool isFixed() const { return (type == Fixed); }
- bool isStatic() const { return (type == Static); }
- bool isIntrinsicOrAuto() const { return (type == Auto || type == MinIntrinsic || type == Intrinsic); }
+ }
+
+ bool isAuto() const { return type == Auto; }
+ bool isRelative() const { return type == Relative; }
+ bool isPercent() const { return type == Percent; }
+ bool isFixed() const { return type == Fixed; }
+ bool isStatic() const { return type == Static; }
+ bool isIntrinsicOrAuto() const { return type == Auto || type == MinIntrinsic || type == Intrinsic; }
int value : 28;
LengthType type : 3;
};
struct GapRects {
- IntRect m_left;
- IntRect m_center;
- IntRect m_right;
+ const IntRect& left() const { return m_left; }
+ const IntRect& center() const { return m_center; }
+ const IntRect& right() const { return m_right; }
- IntRect left() const { return m_left; }
- IntRect center() const { return m_center; }
- IntRect right() const { return m_right; }
-
- void uniteLeft(const IntRect& r) { m_left = m_left.unite(r); }
- void uniteCenter(const IntRect& r) { m_center = m_center.unite(r); }
- void uniteRight(const IntRect& r) { m_right = m_right.unite(r); }
+ void uniteLeft(const IntRect& r) { m_left.unite(r); }
+ void uniteCenter(const IntRect& r) { m_center.unite(r); }
+ void uniteRight(const IntRect& r) { m_right.unite(r); }
void unite(const GapRects& o) { uniteLeft(o.left()); uniteCenter(o.center()); uniteRight(o.right()); }
operator IntRect() const {
- IntRect result = m_left.unite(m_center);
- result = result.unite(m_right);
+ IntRect result = m_left;
+ result.unite(m_center);
+ result.unite(m_right);
return result;
}
bool operator==(const GapRects& other) {
return m_left == other.left() && m_center == other.center() && m_right == other.right();
}
bool operator!=(const GapRects& other) { return !(*this == other); }
+
+ private:
+ IntRect m_left;
+ IntRect m_center;
+ IntRect m_right;
};
+
}
#endif
SVGPointImpl *SVGSVGElementImpl::createSVGPoint(const IntPoint &p)
{
- if(p.isNull())
- return new SVGPointImpl();
- else
- return new SVGPointImpl(p);
+ return new SVGPointImpl(p);
}
SVGMatrixImpl *SVGSVGElementImpl::createSVGMatrix()
static IntRect boundingBoxRect(RenderObject* obj)
{
- IntRect rect(0,0,0,0);
+ IntRect rect;
if (obj) {
if (obj->isInlineContinuation())
obj = obj->element()->renderer();
obj->absoluteRects(rects, x, y);
for (QValueList<IntRect>::ConstIterator it = rects.begin(); it != rects.end(); ++it) {
IntRect r = *it;
- if (r.isValid()) {
+ if (!r.isEmpty()) {
if (obj->style()->hasAppearance())
theme()->adjustRepaintRect(obj, r);
if (rect.isEmpty())
{
IntRect rect = m_areaElement ? m_areaElement->getRect(m_renderer) : boundingBoxRect(m_renderer);
- // The Cocoa accessibility API wants the lower-left corner, not the upper-left, so we add in our height.
- NSPoint point = NSMakePoint(rect.x(), rect.y() + rect.height());
+ // The Cocoa accessibility API wants the lower-left corner.
+ NSPoint point = NSMakePoint(rect.x(), rect.bottom());
if (m_renderer && m_renderer->canvas() && m_renderer->canvas()->view()) {
NSView* view = m_renderer->canvas()->view()->getDocumentView();
point = [[view window] convertBaseToScreen: [view convertPoint: point toView:nil]];
// use the SelectionController class to help calculate the corresponding rectangle
IntRect rect1 = SelectionController(startVisiblePosition, startVisiblePosition).caretRect();
IntRect rect2 = SelectionController(endVisiblePosition, endVisiblePosition).caretRect();
- IntRect ourrect = rect1.unite(rect2);
+ IntRect ourrect = rect1;
+ ourrect.unite(rect2);
// try to use the document view from the selection, so that nested WebAreas work,
// but fall back to the top level doc if we do not find it easily
// if the selection spans lines, the rectangle is to extend
// across the width of the view
if (rect1.bottom() != rect2.bottom()) {
- ourrect.setX((int)[view frame].origin.x);
- ourrect.setWidth((int)[view frame].size.width);
+ ourrect.setX(static_cast<int>([view frame].origin.x));
+ ourrect.setWidth(static_cast<int>([view frame].size.width));
}
// convert our rectangle to screen coordinates
- NSRect rect = NSMakeRect(ourrect.left(), ourrect.top(), ourrect.width(), ourrect.height());
+ NSRect rect = ourrect;
rect = NSOffsetRect(rect, -docView->contentsX(), -docView->contentsY());
rect = [view convertRect:rect toView:nil];
rect.origin = [[view window] convertBaseToScreen:rect.origin];
r.height() - (dimensions()[topMargin] + dimensions()[bottomMargin]));
}
-void QComboBox::setFrameGeometry(const IntRect &r)
+void QComboBox::setFrameGeometry(const IntRect& r)
{
QWidget::setFrameGeometry(IntRect(-dimensions()[leftMargin] + r.x(), -dimensions()[topMargin] + r.y(),
dimensions()[leftMargin] + r.width() + dimensions()[rightMargin],
{
NSView <WebCoreFileButton> *button = getView();
- NSRect frame = {{0,0},{0,0}};
KWQ_BLOCK_EXCEPTIONS;
- frame = [button visualFrame];
- return IntRect(frame);
+ return enclosingIntRect([button visualFrame]);
KWQ_UNBLOCK_EXCEPTIONS;
return IntRect();
}
geometry.selectionY = y;
geometry.selectionHeight = h;
geometry.useFontMetricsForSelectionYAndHeight = false;
- return IntRect([data->getRenderer() selectionRectForRun:&run style:&style geometry:&geometry]);
+ return enclosingIntRect([data->getRenderer() selectionRectForRun:&run style:&style geometry:&geometry]);
}
int QFontMetrics::checkSelectionPoint(QChar *s, int slen, int pos, int len, int toAdd, int tabWidth, int xpos, int letterSpacing, int wordSpacing, bool smallCaps, int x, bool reversed, bool dirOverride, bool includePartialGlyphs) const
IntRect QFontMetrics::boundingRect(int x, int y, int width, int height, int flags, const QString &str, int tabWidth, int xpos) const
{
// FIXME: need to support word wrapping?
- return IntRect(x, y, width, height).intersect(boundingRect(str, tabWidth, xpos));
+ return intersection(IntRect(x, y, width, height), boundingRect(str, tabWidth, xpos));
}
IntSize QFontMetrics::size(int, const QString &qstring, int tabWidth, int xpos) const
#ifndef QPAINTER_H_
#define QPAINTER_H_
-#include "Color.h"
-#include "Pen.h"
#include "Brush.h"
#include "Image.h"
-#include "KWQFontMetrics.h"
-#include "KWQNamespace.h"
-#include "IntRect.h"
+#include "Pen.h"
#if __APPLE__
#include <ApplicationServices/ApplicationServices.h>
#endif
class QFont;
+class QFontMetrics;
class QString;
class QWidget;
namespace WebCore {
-class Image;
+class IntPoint;
+class IntPointArray;
class QPainterPrivate;
class QPainter : public Qt {
QPainter(bool forPrinting);
~QPainter();
- const QFont &font() const;
- void setFont(const QFont &);
+ const QFont& font() const;
+ void setFont(const QFont&);
QFontMetrics fontMetrics() const;
- const Pen &pen() const;
- void setPen(const Pen &);
+ const Pen& pen() const;
+ void setPen(const Pen&);
void setPen(Pen::PenStyle);
void setPen(RGBA32);
- const WebCore::Brush &QPainter::brush() const;
- void setBrush(const WebCore::Brush &);
- void setBrush(WebCore::Brush::BrushStyle);
+ const Brush& brush() const;
+ void setBrush(const Brush&);
+ void setBrush(Brush::BrushStyle);
void setBrush(RGBA32);
- IntRect xForm(const IntRect &) const;
+ IntRect xForm(const IntRect&) const;
void save();
void restore();
void drawLine(int, int, int, int);
void drawEllipse(int, int, int, int);
void drawArc(int, int, int, int, int, int);
- void drawConvexPolygon(const IntPointArray &);
+ void drawConvexPolygon(const IntPointArray&);
- void fillRect(int, int, int, int, const WebCore::Brush &);
- void fillRect(const IntRect &, const WebCore::Brush &);
+ void fillRect(int, int, int, int, const Brush&);
+ void fillRect(const IntRect&, const Brush&);
- void drawImageAtPoint(const Image&, const IntPoint&, Image::CompositeOperator compositeOperator = Image::CompositeSourceOver);
- void drawImageInRect(const Image&, const IntRect&, Image::CompositeOperator compositeOperator = Image::CompositeSourceOver);
+ void drawImageAtPoint(const Image&, const IntPoint&, Image::CompositeOperator = Image::CompositeSourceOver);
+ void drawImageInRect(const Image&, const IntRect&, Image::CompositeOperator = Image::CompositeSourceOver);
- void drawImage(const Image &, int x, int y,
- int sx=0, int sy=0, int sw=-1, int sh=-1, Image::CompositeOperator compositeOperator = Image::CompositeSourceOver,
- void* nativeData = 0);
+ void drawImage(const Image&, int x, int y,
+ int sx = 0, int sy = 0, int sw = -1, int sh = -1,
+ Image::CompositeOperator = Image::CompositeSourceOver,
+ void* nativeData = 0);
void drawImage(const Image&, int x, int y, int w, int h,
- int sx=0, int sy=0, int sw=-1, int sh=-1, Image::CompositeOperator compositeOperator = Image::CompositeSourceOver,
- void* nativeData = 0);
+ int sx = 0, int sy = 0, int sw = -1, int sh = -1,
+ Image::CompositeOperator = Image::CompositeSourceOver,
+ void* nativeData = 0);
void drawFloatImage(const Image&, float x, float y, float w, float h,
- float sx=0, float sy=0, float sw=-1, float sh=-1, Image::CompositeOperator compositeOperator = Image::CompositeSourceOver,
- void* nativeData = 0);
- void drawTiledImage(const Image&, int, int, int, int, int sx=0, int sy=0, void* nativeData = 0);
+ float sx = 0, float sy = 0, float sw = -1, float sh = -1,
+ Image::CompositeOperator = Image::CompositeSourceOver,
+ void* nativeData = 0);
+ void drawTiledImage(const Image&, int, int, int, int, int sx = 0, int sy = 0, void* nativeData = 0);
void drawScaledAndTiledImage(const Image &, int, int, int, int, int, int, int, int,
- TileRule hRule = STRETCH, TileRule vRule = STRETCH,
- void* nativeData = 0);
+ TileRule hRule = STRETCH, TileRule vRule = STRETCH,
+ void* nativeData = 0);
- void addClip(const IntRect &);
- void addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
- const IntSize& bottomLeft, const IntSize& bottomRight);
+ void addClip(const IntRect&);
+ void addRoundedRectClip(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight);
RasterOp rasterOp() const;
void setRasterOp(RasterOp);
- void drawText(int x, int y, int tabWidth, int xpos, int, int, int alignmentFlags, const QString &);
+ void drawText(int x, int y, int tabWidth, int xpos, int, int, int alignmentFlags, const QString&);
void drawHighlightForText(int x, int y, int h, int tabWidth, int xpos,
- const QChar *, int length, int from, int to, int toAdd,
- const Color& backgroundColor, QPainter::TextDirection d, bool visuallyOrdered,
- int letterSpacing, int wordSpacing, bool smallCaps);
- void drawText(int x, int y, int tabWidth, int xpos, const QChar *, int length, int from, int to, int toAdd,
- const Color& backgroundColor, QPainter::TextDirection d, bool visuallyOrdered,
- int letterSpacing, int wordSpacing, bool smallCaps);
+ const QChar*, int length, int from, int to, int toAdd,
+ const Color& backgroundColor, TextDirection, bool visuallyOrdered,
+ int letterSpacing, int wordSpacing, bool smallCaps);
+ void drawText(int x, int y, int tabWidth, int xpos,
+ const QChar*, int length, int from, int to, int toAdd,
+ const Color& backgroundColor, TextDirection, bool visuallyOrdered,
+ int letterSpacing, int wordSpacing, bool smallCaps);
void drawLineForText(int x, int y, int yOffset, int width);
void drawLineForMisspelling(int x, int y, int width);
int misspellingLineThickness() const;
void beginTransparencyLayer(float opacity);
void endTransparencyLayer();
- void setShadow(int x, int y, int blur, const Color& color);
+ void setShadow(int x, int y, int blur, const Color&);
void clearShadow();
void initFocusRing(int width, int offset);
- void initFocusRing(int width, int offset, const Color& color);
+ void initFocusRing(int width, int offset, const Color&);
void addFocusRingRect(int x, int y, int width, int height);
void drawFocusRing();
void clearFocusRing();
#if __APPLE__
CGContextRef currentContext();
+
+ static int getCompositeOperation(CGContextRef);
+ static void setCompositeOperation(CGContextRef, const QString& operation);
+ static void setCompositeOperation(CGContextRef, int operation);
#endif
#if SVG_SUPPORT
- KRenderingDeviceContext *createRenderingDeviceContext();
- static KRenderingDevice *renderingDevice();
-#endif
-
-#if __APPLE__
- static int getCompositeOperation(CGContextRef context);
- static void setCompositeOperation (CGContextRef context, const QString &operation);
- static void setCompositeOperation (CGContextRef context, int operation);
+ KRenderingDeviceContext* createRenderingDeviceContext();
+ static KRenderingDevice* renderingDevice();
#endif
bool printing() const { return _isForPrinting; }
private:
// no copying or assignment
- QPainter(const QPainter &);
- QPainter &operator=(const QPainter &);
+ QPainter(const QPainter&);
+ QPainter& operator=(const QPainter&);
void _setColorFromBrush();
void _setColorFromPen();
- void _fillRect(float x, float y, float w, float h, const Color& color);
-
+ void _fillRect(float x, float y, float w, float h, const Color&);
+
void _updateRenderer();
QPainterPrivate *data;
void QPainter::fillRect(const IntRect &rect, const WebCore::Brush &brush)
{
- fillRect(rect.left(), rect.top(), rect.width(), rect.height(), brush);
+ fillRect(rect.x(), rect.y(), rect.width(), rect.height(), brush);
}
void QPainter::addClip(const IntRect &rect)
// normal use cases these ellipses won't overlap one another (or when they do the curvature of one will
// be subsumed by the other).
CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y(), topLeft.width() * 2, topLeft.height() * 2));
- CGContextAddEllipseInRect(context, CGRectMake(rect.x() + rect.width() - topRight.width() * 2, rect.y(),
+ CGContextAddEllipseInRect(context, CGRectMake(rect.right() - topRight.width() * 2, rect.y(),
topRight.width() * 2, topRight.height() * 2));
- CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y() + rect.height() - bottomLeft.height() * 2,
+ CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.bottom() - bottomLeft.height() * 2,
bottomLeft.width() * 2, bottomLeft.height() * 2));
- CGContextAddEllipseInRect(context, CGRectMake(rect.x() + rect.width() - bottomRight.width() * 2,
- rect.y() + rect.height() - bottomRight.height() * 2,
+ CGContextAddEllipseInRect(context, CGRectMake(rect.right() - bottomRight.width() * 2,
+ rect.bottom() - bottomRight.height() * 2,
bottomRight.width() * 2, bottomRight.height() * 2));
// Now add five rects (one for each edge rect in between the rounded corners and one for the interior).
rect.width() - topLeft.width() - topRight.width(),
kMax(topLeft.height(), topRight.height())));
CGContextAddRect(context, CGRectMake(rect.x() + bottomLeft.width(),
- rect.y() + rect.height() - kMax(bottomLeft.height(), bottomRight.height()),
+ rect.bottom() - kMax(bottomLeft.height(), bottomRight.height()),
rect.width() - bottomLeft.width() - bottomRight.width(),
kMax(bottomLeft.height(), bottomRight.height())));
CGContextAddRect(context, CGRectMake(rect.x(), rect.y() + topLeft.height(),
kMax(topLeft.width(), bottomLeft.width()), rect.height() - topLeft.height() - bottomLeft.height()));
- CGContextAddRect(context, CGRectMake(rect.x() + rect.width() - kMax(topRight.width(), bottomRight.width()),
+ CGContextAddRect(context, CGRectMake(rect.right() - kMax(topRight.width(), bottomRight.width()),
rect.y() + topRight.height(),
kMax(topRight.width(), bottomRight.width()), rect.height() - topRight.height() - bottomRight.height()));
CGContextAddRect(context, CGRectMake(rect.x() + kMax(topLeft.width(), bottomLeft.width()),
IntRect QRegion::boundingRect() const
{
- return path ? IntRect(CGPathGetBoundingBox(path)) : IntRect();
+ return path ? enclosingIntRect(CGPathGetBoundingBox(path)) : IntRect();
}
ts << "layer";
ts << " " << layerBounds;
- if (layerBounds != layerBounds.intersect(backgroundClipRect))
- ts << " backgroundClip " << backgroundClipRect;
- if (layerBounds != layerBounds.intersect(clipRect))
- ts << " clip " << clipRect;
- if (layerBounds != layerBounds.intersect(outlineClipRect))
- ts << " outlineClip " << outlineClipRect;
+ if (!layerBounds.isEmpty()) {
+ if (!backgroundClipRect.contains(layerBounds))
+ ts << " backgroundClip " << backgroundClipRect;
+ if (!clipRect.contains(layerBounds))
+ ts << " clip " << clipRect;
+ if (!outlineClipRect.contains(layerBounds))
+ ts << " outlineClip " << outlineClipRect;
+ }
if (l.renderer()->hasOverflowClip()) {
if (l.scrollXOffset())
#include "config.h"
#import "KWQScrollView.h"
+#import "IntRect.h"
#import "KWQExceptions.h"
#import "KWQLogging.h"
#import "WebCoreFrameView.h"
#include "KWQWMatrix.h"
#include "FloatRect.h"
+#include "IntRect.h"
static const double deg2rad = 0.017453292519943295769; // pi/180
IntRect QMatrix::mapRect(const IntRect &rect) const
{
- return IntRect(CGRectApplyAffineTransform(CGRect(rect), m_transform));
+ return enclosingIntRect(CGRectApplyAffineTransform(CGRect(rect), m_transform));
}
FloatRect QMatrix::mapRect(const FloatRect &rect) const
class QPalette;
namespace WebCore {
+ class IntRect;
class QPainter;
}
+using WebCore::IntRect; // move QWidget into WebCore and remove this line
class QWidget : public QObject {
public:
int QWidget::x() const
{
- return frameGeometry().topLeft().x();
+ return frameGeometry().x();
}
int QWidget::y() const
{
- return frameGeometry().topLeft().y();
+ return frameGeometry().y();
}
int QWidget::width() const
{
- return frameGeometry().size().width();
+ return frameGeometry().width();
}
int QWidget::height() const
{
- return frameGeometry().size().height();
+ return frameGeometry().height();
}
IntSize QWidget::size() const
IntPoint QWidget::pos() const
{
- return frameGeometry().topLeft();
+ return frameGeometry().location();
}
void QWidget::move(int x, int y)
IntRect QWidget::frameGeometry() const
{
- IntRect rect;
KWQ_BLOCK_EXCEPTIONS;
- rect = IntRect([getOuterView() frame]);
- return rect;
+ return enclosingIntRect([getOuterView() frame]);
KWQ_UNBLOCK_EXCEPTIONS;
return IntRect();
}
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#import "config.h"
#import "KWQWindowWidget.h"
+#import "IntRect.h"
#import "WebCoreFrameBridge.h"
#import <Cocoa/Cocoa.h>
void KWQWindowWidget::setFrameGeometry(const IntRect &r)
{
// FIXME: Could do something to make it easy for the browser to avoid saving this change.
- [d->bridge setWindowFrame:NSMakeRect(r.x(), NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - (r.y() + r.height()),
+ [d->bridge setWindowFrame:NSMakeRect(r.x(), NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - r.bottom(),
r.width(), r.height())];
}
clear();
}
-void CachedImage::ref(CachedObjectClient *c)
+void CachedImage::ref(CachedObjectClient* c)
{
CachedObject::ref(c);
- // for mouseovers, dynamic changes
- if (!decodedRect().isNull())
+ if (!decodedRect().isEmpty())
c->imageChanged(this, decodedRect());
if (!m_loading)
fillWithRed = true;
if (fillWithRed)
- p->fillRect(rect.x(), rect.y(), rect.width(), rect.height(), Color(0xFF, 0, 0));
+ p->fillRect(rect, Color(0xFF, 0, 0));
#endif
if (renderer()) {
d->scrollingSelf = true; // so scroll events get ignored
int x, y, xe, ye;
- x = bounds.left();
- y = bounds.top();
- xe = bounds.right();
- ye = bounds.bottom();
+ x = bounds.x();
+ y = bounds.y();
+ xe = bounds.right() - 1;
+ ye = bounds.bottom() - 1;
int deltax;
int deltay;
int curHeight = visibleHeight();
int curWidth = visibleWidth();
- if (ye-y>curHeight-d->borderY)
- ye = y + curHeight - d->borderY;
+ if (ye - y>curHeight-d->borderY)
+ ye = y + curHeight - d->borderY;
- if (xe-x>curWidth-d->borderX)
+ if (xe - x>curWidth-d->borderX)
xe = x + curWidth - d->borderX;
// is xpos of target left of the view's border?
if (x < contentsX() + d->borderX )
- deltax = x - contentsX() - d->borderX;
+ deltax = x - contentsX() - d->borderX;
// is xpos of target right of the view's right border?
else if (xe + d->borderX > contentsX() + curWidth)
- deltax = xe + d->borderX - ( contentsX() + curWidth );
+ deltax = xe + d->borderX - ( contentsX() + curWidth );
else
deltax = 0;
// is ypos of target above upper border?
if (y < contentsY() + d->borderY)
- deltay = y - contentsY() - d->borderY;
+ deltay = y - contentsY() - d->borderY;
// is ypos of target below lower border?
else if (ye + d->borderY > contentsY() + curHeight)
- deltay = ye + d->borderY - ( contentsY() + curHeight );
+ deltay = ye + d->borderY - ( contentsY() + curHeight );
else
deltay = 0;
- int maxx = curWidth-d->borderX;
- int maxy = curHeight-d->borderY;
+ int maxx = curWidth - d->borderX;
+ int maxy = curHeight - d->borderY;
- int scrollX,scrollY;
-
- scrollX = deltax > 0 ? (deltax > maxx ? maxx : deltax) : deltax == 0 ? 0 : (deltax>-maxx ? deltax : -maxx);
- scrollY = deltay > 0 ? (deltay > maxy ? maxy : deltay) : deltay == 0 ? 0 : (deltay>-maxy ? deltay : -maxy);
+ int scrollX = deltax > 0 ? (deltax > maxx ? maxx : deltax) : deltax == 0 ? 0 : (deltax > -maxx ? deltax : -maxx);
+ int scrollY = deltay > 0 ? (deltay > maxy ? maxy : deltay) : deltay == 0 ? 0 : (deltay > -maxy ? deltay : -maxy);
if (contentsX() + scrollX < 0)
scrollX = -contentsX();
scrollBy(scrollX, scrollY);
// generate abs(scroll.)
- if (scrollX<0)
- scrollX=-scrollX;
- if (scrollY<0)
- scrollY=-scrollY;
+ if (scrollX < 0)
+ scrollX = -scrollX;
+ if (scrollY < 0)
+ scrollY = -scrollY;
d->scrollingSelf = false;
- if ( (scrollX!=maxx) && (scrollY!=maxy) )
- return true;
- else return false;
-
+ return scrollX != maxx && scrollY != maxy;
}
void FrameView::focusNextPrevNode(bool next)
bool visible = false;
NodeImpl *toFocus = newFocusNode;
while (!visible && toFocus) {
- IntRect focusNodeRect = toFocus->getRect();
- if ((focusNodeRect.left() > contentsX()) && (focusNodeRect.right() < contentsX() + visibleWidth()) &&
- (focusNodeRect.top() > contentsY()) && (focusNodeRect.bottom() < contentsY() + visibleHeight())) {
+ if (toFocus->getRect().intersects(IntRect(contentsX(), contentsY(), visibleWidth(), visibleHeight()))) {
// toFocus is visible in the contents area
visible = true;
- }
- else {
+ } else {
// toFocus is _not_ visible in the contents area, pick the next node
if (next)
toFocus = doc->nextFocusNode(toFocus);
#include "config.h"
#include "IntPoint.h"
+
#include "FloatPoint.h"
namespace WebCore {
-FloatPoint::FloatPoint() : xCoord(0), yCoord(0)
-{
-}
-
-FloatPoint::FloatPoint(float xIn, float yIn) : xCoord(xIn), yCoord(yIn)
-{
-}
-
-FloatPoint::FloatPoint(const IntPoint& p) :xCoord(p.x()), yCoord(p.y())
-{
-}
-
-FloatPoint operator+(const FloatPoint& a, const FloatPoint& b)
-{
- return FloatPoint(a.xCoord + b.xCoord, a.yCoord + b.yCoord);
-}
-
-FloatPoint operator-(const FloatPoint& a, const FloatPoint& b)
-{
- return FloatPoint(a.xCoord - b.xCoord, a.yCoord - b.yCoord);
-}
-
-const FloatPoint operator*(const FloatPoint& p, double s)
+FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
{
- return FloatPoint(p.xCoord * s, p.yCoord * s);
}
}
#define FLOATPOINT_H_
#if __APPLE__
+
+typedef struct CGPoint CGPoint;
+
// workaround for <rdar://problem/4294625>
-#if ! __LP64__ && ! NS_BUILD_32_LIKE_64
+#if !__LP64__ && !NS_BUILD_32_LIKE_64
#undef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
#endif
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#endif
-typedef struct CGPoint CGPoint;
+
#endif
namespace WebCore {
class FloatPoint {
public:
- FloatPoint();
- FloatPoint(float, float);
+ FloatPoint() : m_x(0), m_y(0) { }
+ FloatPoint(float x, float y) : m_x(x), m_y(y) { }
FloatPoint(const IntPoint&);
-
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit FloatPoint(const NSPoint&);
-#endif
- explicit FloatPoint(const CGPoint&);
-#endif
- float x() const { return xCoord; }
- float y() const { return yCoord; }
+ float x() const { return m_x; }
+ float y() const { return m_y; }
- void setX(int x) { xCoord = x; }
- void setY(int y) { yCoord = y; }
+ void setX(float x) { m_x = x; }
+ void setY(float y) { m_y = y; }
- bool isNull() const { return xCoord == 0.0f && yCoord == 0.0f; }
+#if __APPLE__
- FloatPoint& operator -=(const FloatPoint& two) { xCoord -= two.xCoord; yCoord -= two.yCoord; return *this; }
- friend const FloatPoint operator*(const FloatPoint& p, double s);
- friend FloatPoint operator+(const FloatPoint&, const FloatPoint&);
- friend FloatPoint operator-(const FloatPoint&, const FloatPoint&);
+ FloatPoint(const CGPoint&);
+ operator CGPoint() const;
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ FloatPoint(const NSPoint&);
operator NSPoint() const;
#endif
- operator CGPoint() const;
+
#endif
private:
- float xCoord;
- float yCoord;
+ float m_x, m_y;
};
+inline FloatPoint& operator+=(FloatPoint& a, const FloatPoint& b)
+{
+ a.setX(a.x() + b.x());
+ a.setY(a.y() + b.y());
+ return a;
+}
+
+inline FloatPoint& operator-=(FloatPoint& a, const FloatPoint& b)
+{
+ a.setX(a.x() - b.x());
+ a.setY(a.y() - b.y());
+ return a;
+}
+
+inline FloatPoint operator+(const FloatPoint& a, const FloatPoint& b)
+{
+ return FloatPoint(a.x() + b.x(), a.y() + b.y());
+}
+
+inline FloatPoint operator-(const FloatPoint& a, const FloatPoint& b)
+{
+ return FloatPoint(a.x() - b.x(), a.y() - b.y());
+}
+
+inline bool operator==(const FloatPoint& a, const FloatPoint& b)
+{
+ return a.x() == b.x() && a.y() == b.y();
+}
+
+inline bool operator!=(const FloatPoint& a, const FloatPoint& b)
+{
+ return a.x() != b.x() || a.y() != b.y();
+}
+
}
// FIXME: Remove when everything is in the WebCore namespace.
#include "config.h"
#include "FloatRect.h"
+
+#include "IntRect.h"
#include <algorithm>
using std::max;
namespace WebCore {
-FloatRect::FloatRect() : xp(0.0f), yp(0.0f), w(0.0f), h(0.0f)
-{
-}
-
-FloatRect::FloatRect(float x, float y, float width, float height) : xp(x), yp(y), w(width), h(height)
-{
-}
-
-FloatRect::FloatRect(FloatPoint p, FloatSize s) : xp(p.x()), yp(p.y()), w(s.width()), h(s.height())
-{
-}
-
-FloatRect::FloatRect(const FloatPoint &topLeft, const FloatPoint &bottomRight)
- : xp(topLeft.x()), yp(topLeft.y()),
- w(bottomRight.x() - topLeft.x() + 1.0f), h(bottomRight.y() - topLeft.y() + 1.0f)
-{
-}
-
-FloatRect::FloatRect(const IntRect& r) : xp(r.x()), yp(r.y()), w(r.width()), h(r.height())
-{
-}
-
-bool FloatRect::isNull() const
-{
- return w == 0.0f && h == 0.0f;
-}
-
-bool FloatRect::isValid() const
-{
- return w > 0.0f && h > 0.0f;
-}
-
-bool FloatRect::isEmpty() const
-{
- return w <= 0.0f || h <= 0.0f;
-}
-
-float FloatRect::right() const
-{
- return xp + w - 1.0f;
-}
-
-float FloatRect::bottom() const
-{
- return yp + h - 1.0f;
-}
-
-FloatPoint FloatRect::topLeft() const
-{
- return FloatPoint(xp,yp);
-}
-
-FloatPoint FloatRect::topRight() const
-{
- return FloatPoint(right(),top());
-}
-
-FloatPoint FloatRect::bottomRight() const
+FloatRect::FloatRect(const IntRect& r) : m_location(r.location()), m_size(r.size())
{
- return FloatPoint(right(),bottom());
}
-FloatPoint FloatRect::bottomLeft() const
+bool FloatRect::intersects(const FloatRect& other) const
{
- return FloatPoint(left(),bottom());
+ // Checking emptiness handles negative widths as well as zero.
+ return !isEmpty() && !other.isEmpty()
+ && x() < other.right() && other.x() < right()
+ && y() < other.bottom() && other.y() < bottom();
}
-FloatSize FloatRect::size() const
+bool FloatRect::contains(const FloatRect& other) const
{
- return FloatSize(w,h);
+ return x() <= other.x() && right() >= other.right()
+ && y() <= other.y() && bottom() >= other.bottom();
}
-FloatRect FloatRect::unite(const FloatRect &r) const
+void FloatRect::intersect(const FloatRect& other)
{
- if (r.isEmpty())
- return *this;
+ float l = max(x(), other.x());
+ float t = max(y(), other.y());
+ float r = min(right(), other.right());
+ float b = min(bottom(), other.bottom());
- if (isEmpty())
- return r;
+ // Return a clean empty rectangle for non-intersecting cases.
+ if (l >= r || t >= b) {
+ l = 0;
+ t = 0;
+ r = 0;
+ b = 0;
+ }
- float nx, ny, nw, nh;
-
- nx = min(xp, r.xp);
- ny = min(yp, r.yp);
-
- if (xp + w >= r.xp + r.w)
- nw = xp + w - nx;
- else
- nw = r.xp + r.w - nx;
-
- if (yp + h >= r.yp + r.h)
- nh = yp + h - ny;
- else
- nh = r.yp + r.h - ny;
-
- return FloatRect(nx, ny, nw, nh);
+ m_location.setX(l);
+ m_location.setY(t);
+ m_size.setWidth(r - l);
+ m_size.setHeight(b - t);
}
-FloatRect FloatRect::normalize() const
+void FloatRect::unite(const FloatRect& other)
{
- FloatRect newRect;
+ // Handle empty special cases first.
+ if (other.isEmpty())
+ return;
+ if (isEmpty()) {
+ *this = other;
+ return;
+ }
- newRect.xp = (w < 0.0f) ? (xp - w) : xp;
- newRect.w = (w < 0.0f) ? -w : w;
-
- newRect.yp = (h < 0.0f) ? (yp - h) : yp;
- newRect.h = (h < 0.0f) ? -h : h;
-
- return newRect;
-}
+ float l = min(x(), other.x());
+ float t = min(y(), other.y());
+ float r = max(right(), other.right());
+ float b = max(bottom(), other.bottom());
-bool FloatRect::intersects(const FloatRect &r) const
-{
- return intersect(r).isValid();
-}
-
-FloatRect FloatRect::intersect(const FloatRect &r) const
-{
- float nx, ny, nw, nh;
-
- nx = max(xp, r.xp);
- ny = max(yp, r.yp);
-
- if (xp + w <= r.xp + r.w)
- nw = xp + w - nx;
- else
- nw = r.xp + r.w - nx;
-
- if (yp + h <= r.yp + r.h)
- nh = yp + h - ny;
- else
- nh = r.yp + r.h - ny;
-
- return FloatRect(nx, ny, nw, nh);
-}
-
-void FloatRect::inflate(float s)
-{
- xp -= s;
- yp -= s;
- w += 2.0f * s;
- h += 2.0f * s;
-}
-
-bool operator==(const FloatRect& a, const FloatRect &b)
-{
- return a.xp == b.xp && a.yp == b.yp && a.w == b.w && a.h == b.h;
+ m_location.setX(l);
+ m_location.setY(t);
+ m_size.setWidth(r - l);
+ m_size.setHeight(b - t);
}
-bool operator!=(const FloatRect &a, const FloatRect &b)
+IntRect enclosingIntRect(const FloatRect& rect)
{
- return !(a == b);
+ int l = static_cast<int>(floorf(rect.x()));
+ int t = static_cast<int>(floorf(rect.y()));
+ int r = static_cast<int>(ceilf(rect.right()));
+ int b = static_cast<int>(ceilf(rect.bottom()));
+ return IntRect(l, t, r - l, b - t);
}
}
#ifndef FLOATRECTF_H_
#define FLOATRECTF_H_
-#include <math.h>
#include "FloatSize.h"
#include "FloatPoint.h"
-#include "IntRect.h"
#if __APPLE__
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+typedef struct CGRect CGRect;
+
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
-typedef struct CGRect CGRect;
+
#endif
namespace WebCore {
class FloatRect {
public:
- FloatRect();
- FloatRect(FloatPoint p, FloatSize s);
- FloatRect(float, float, float, float);
- FloatRect(const FloatPoint&, const FloatPoint&);
+ FloatRect() { }
+ FloatRect(const FloatPoint& location, const FloatSize& size)
+ : m_location(location), m_size(size) { }
+ FloatRect(float x, float y, float width, float height)
+ : m_location(FloatPoint(x, y)), m_size(FloatSize(width, height)) { }
FloatRect(const IntRect&);
-
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit FloatRect(const NSRect&);
-#endif
- explicit FloatRect(const CGRect&);
-#endif
- bool isNull() const;
- bool isValid() const;
- bool isEmpty() const;
-
- float x() const { return xp; }
- float y() const { return yp; }
- float left() const { return xp; }
- float top() const { return yp; }
- float right() const;
- float bottom() const;
- float width() const { return w; }
- float height() const { return h; }
-
- FloatPoint topLeft() const;
- FloatPoint topRight() const;
- FloatPoint bottomRight() const;
- FloatPoint bottomLeft() const;
-
- FloatSize size() const;
- void setX(float x) { xp = x; }
- void setY(float y) { yp = y; }
- void setWidth(float width) { w = width; }
- void setHeight(float height) { h = height; }
- void setRect(float x, float y, float width, float height) { xp = x; yp = y; w = width; h = height; }
- FloatRect intersect(const FloatRect&) const;
- bool intersects(const FloatRect&) const;
- FloatRect unite(const FloatRect&) const;
- FloatRect normalize() const;
+ FloatPoint location() const { return m_location; }
+ FloatSize size() const { return m_size; }
- bool contains(const FloatPoint& point) const { return contains(point.x(), point.y()); }
+ void setLocation(const FloatPoint& location) { m_location = location; }
+ void setSize(const FloatSize& size) { m_size = size; }
- bool contains(float x, float y, bool proper = false) const
- {
- if (proper)
- return x > xp && (x < (xp + w - 1)) && y > yp && y < (yp + h - 1);
- return x >= xp && x < (xp + w) && y >= yp && y < (yp + h);
- }
+ float x() const { return m_location.x(); }
+ float y() const { return m_location.y(); }
+ float width() const { return m_size.width(); }
+ float height() const { return m_size.height(); }
+
+ void setX(float x) { m_location.setX(x); }
+ void setY(float y) { m_location.setY(y); }
+ void setWidth(float width) { m_size.setWidth(width); }
+ void setHeight(float height) { m_size.setHeight(height); }
+
+ bool isEmpty() const { return m_size.isEmpty(); }
- bool contains(const FloatRect& rect) const { return intersect(rect) == rect; }
+ float right() const { return x() + width(); }
+ float bottom() const { return y() + height(); }
+
+ void move(const FloatPoint& p) { m_location += p; }
+ void move(float dx, float dy) { m_location += FloatPoint(dx, dy); }
+
+ bool intersects(const FloatRect&) const;
+ bool contains(const FloatRect&) const;
- void inflate(float s);
+ void intersect(const FloatRect&);
+ void unite(const FloatRect&);
- inline FloatRect operator&(const FloatRect& r) const { return intersect(r); }
+ void inflateX(float dx) {
+ m_location.setX(m_location.x() - dx);
+ m_size.setWidth(m_size.width() + dx + dx);
+ }
+ void inflateY(float dy) {
+ m_location.setY(m_location.y() - dy);
+ m_size.setHeight(m_size.height() + dy + dy);
+ }
+ void inflate(float d) { inflateX(d); inflateY(d); }
#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+ FloatRect(const CGRect&);
+ operator CGRect() const;
+
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ FloatRect(const NSRect&);
operator NSRect() const;
#endif
- operator CGRect() const;
+
#endif
private:
- float xp;
- float yp;
- float w;
- float h;
-
- friend bool operator==(const FloatRect&, const FloatRect&);
- friend bool operator!=(const FloatRect&, const FloatRect&);
+ FloatPoint m_location;
+ FloatSize m_size;
};
-inline IntRect enclosingIntRect(const FloatRect& fr)
+inline FloatRect intersection(const FloatRect& a, const FloatRect& b)
{
- int x = int(floor(fr.x()));
- int y = int(floor(fr.y()));
- return IntRect(x, y, int(ceil(fr.x() + fr.width())) - x, int(ceil(fr.y() + fr.height())) - y);
+ FloatRect c = a;
+ c.intersect(b);
+ return c;
}
+inline bool operator==(const FloatRect& a, const FloatRect& b)
+{
+ return a.location() == b.location() && a.size() == b.size();
+}
+
+inline bool operator!=(const FloatRect& a, const FloatRect& b)
+{
+ return a.location() != b.location() || a.size() != b.size();
+}
+
+IntRect enclosingIntRect(const FloatRect&);
+
}
// FIXME: Remove when everything is in the WebCore namespace.
#include "config.h"
#include "FloatSize.h"
+
#include "IntSize.h"
namespace WebCore {
-FloatSize::FloatSize() : w(-1.0f), h(-1.0f)
-{
-}
-
-FloatSize::FloatSize(float width, float height) : w(width), h(height)
+FloatSize::FloatSize(const IntSize& size) : m_width(size.width()), m_height(size.height())
{
}
-FloatSize::FloatSize(const IntSize& o) : w(o.width()), h(o.height())
-{
-}
-
-bool FloatSize::isValid() const
-{
- return w >= 0.0f && h >= 0.0f;
-}
-
-FloatSize FloatSize::expandedTo(const FloatSize& o) const
-{
- return FloatSize(w > o.w ? w : o.w, h > o.h ? h : o.h);
}
-
-FloatSize operator+(const FloatSize& a, const FloatSize& b)
-{
- return FloatSize(a.w + b.w, a.h + b.h);
-}
-
-bool operator==(const FloatSize& a, const FloatSize& b)
-{
- return a.w == b.w && a.h == b.h;
-}
-
-bool operator!=(const FloatSize& a, const FloatSize& b)
-{
- return a.w != b.w || a.h != b.h;
-}
-
-}
\ No newline at end of file
#include "KWQDef.h"
#if __APPLE__
+
+typedef struct CGSize CGSize;
+
// workaround for <rdar://problem/4294625>
-#if ! __LP64__ && ! NS_BUILD_32_LIKE_64
+#if !__LP64__ && !NS_BUILD_32_LIKE_64
#undef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
#endif
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#endif
-typedef struct CGSize CGSize;
+
#endif
namespace WebCore {
-
+
class IntSize;
-
+
class FloatSize {
public:
- FloatSize();
- FloatSize(float, float);
- FloatSize(const WebCore::IntSize&);
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit FloatSize(const NSSize&);
-#endif
- explicit FloatSize(const CGSize&);
-#endif
+ FloatSize() : m_width(0), m_height(0) { }
+ FloatSize(float width, float height) : m_width(width), m_height(height) { }
+ FloatSize(const IntSize&);
+
+ float width() const { return m_width; }
+ float height() const { return m_height; }
+
+ void setWidth(float width) { m_width = width; }
+ void setHeight(float height) { m_height = height; }
- bool isValid() const;
- float width() const { return w; }
- float height() const { return h; }
- void setWidth(float width) { w = width; }
- void setHeight(float height) { h = height; }
- FloatSize expandedTo(const FloatSize&) const;
+ bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
+
+ FloatSize expandedTo(const FloatSize& other) const
+ {
+ return FloatSize(m_width > other.m_width ? m_width : other.m_width,
+ m_height > other.m_height ? m_height : other.m_height);
+ }
#if __APPLE__
+
+ explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
+ operator CGSize() const;
+
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
- operator CGSize() const;
-#endif
- friend FloatSize operator+(const FloatSize&, const FloatSize&);
- friend bool operator==(const FloatSize&, const FloatSize&);
- friend bool operator!=(const FloatSize&, const FloatSize&);
+#endif
private:
- float w;
- float h;
+ float m_width, m_height;
};
+inline FloatSize& operator+=(FloatSize& a, const FloatSize& b)
+{
+ a.setWidth(a.width() + b.width());
+ a.setHeight(a.height() + b.height());
+ return a;
+}
+
+inline FloatSize& operator-=(FloatSize& a, const FloatSize& b)
+{
+ a.setWidth(a.width() - b.width());
+ a.setHeight(a.height() - b.height());
+ return a;
+}
+
+inline FloatSize operator+(const FloatSize& a, const FloatSize& b)
+{
+ return FloatSize(a.width() + b.width(), a.height() + b.height());
+}
+
+inline FloatSize operator-(const FloatSize& a, const FloatSize& b)
+{
+ return FloatSize(a.width() - b.width(), a.height() - b.height());
+}
+
+inline bool operator==(const FloatSize& a, const FloatSize& b)
+{
+ return a.width() == b.width() && a.height() == b.height();
+}
+
+inline bool operator!=(const FloatSize& a, const FloatSize& b)
+{
+ return a.width() != b.width() || a.height() != b.height();
+}
+
}
// FIXME: Remove when the engine files have been converted to be in the WebCore namespace.
#ifndef IMAGE_H_
#define IMAGE_H_
-#include "KWQNamespace.h"
-#include "KWQString.h"
-#include "IntSize.h"
-#include "IntRect.h"
-
#if __APPLE__
-#include <ApplicationServices/ApplicationServices.h>
+
+typedef struct CGImage *CGImageRef;
#ifdef __OBJC__
@protocol WebCoreImageRenderer;
#endif // __APPLE__
-class QWMatrix;
+class QString;
namespace WebCore {
+class IntRect;
+class IntSize;
class QPainter;
+template <typename T> class Array;
+typedef Array<char> ByteArray;
+
class Image {
public:
Image();
Image(const IntSize&);
Image(const ByteArray&, const QString& type);
Image(int, int);
-#if __APPLE__
- Image(WebCoreImageRendererPtr);
-#endif
~Image();
bool decode(const ByteArray &bytes, bool allDataReceived);
-#if __APPLE__
- WebCoreImageRendererPtr imageRenderer() const { return m_imageRenderer; }
- CGImageRef imageRef() const;
-#endif
-
void stopAnimations() const;
void resetAnimation() const;
void setAnimationRect(const IntRect&) const;
static CompositeOperator compositeOperatorFromString(const QString& compositeOperator);
+#if __APPLE__
+ Image(WebCoreImageRendererPtr);
+ WebCoreImageRendererPtr imageRenderer() const { return m_imageRenderer; }
+ CGImageRef imageRef() const;
+#endif
+
private:
// We do not allow images to be assigned to or copied.
Image(const Image&);
-/*
- * Copyright (C) 2004-6 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntPoint.h"
-
-namespace WebCore {
-
-IntPoint::IntPoint() : xCoord(0), yCoord(0)
-{
-}
-
-IntPoint::IntPoint(int xIn, int yIn) : xCoord(xIn), yCoord(yIn)
-{
-}
-
-IntPoint operator+(const IntPoint &a, const IntPoint &b)
-{
- return IntPoint(a.xCoord + b.xCoord, a.yCoord + b.yCoord);
-}
-
-IntPoint operator-(const IntPoint &a, const IntPoint &b)
-{
- return IntPoint(a.xCoord - b.xCoord, a.yCoord - b.yCoord);
-}
-
-const IntPoint operator*(const IntPoint &p, double s)
-{
- return IntPoint((int)(p.xCoord * s), (int)(p.yCoord * s));
-}
-
-}
/*
- * Copyright (C) 2004-6 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#define INTPOINT_H_
#if __APPLE__
+
+typedef struct CGPoint CGPoint;
+
// workaround for <rdar://problem/4294625>
-#if ! __LP64__ && ! NS_BUILD_32_LIKE_64
+#if !__LP64__ && !NS_BUILD_32_LIKE_64
#undef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
#endif
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#endif
-typedef struct CGPoint CGPoint;
+
#endif
namespace WebCore {
class IntPoint {
public:
- IntPoint();
- IntPoint(int, int);
-
+ IntPoint() : m_x(0), m_y(0) { }
+ IntPoint(int x, int y) : m_x(x), m_y(y) { }
+
+ int x() const { return m_x; }
+ int y() const { return m_y; }
+
+ void setX(int x) { m_x = x; }
+ void setY(int y) { m_y = y; }
+
#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit IntPoint(const NSPoint &); // don't do this implicitly since it's lossy
-#endif
- explicit IntPoint(const CGPoint &); // don't do this implicitly since it's lossy
-#endif
- int x() const { return xCoord; }
- int y() const { return yCoord; }
-
- void setX(int x) { xCoord = x; }
- void setY(int y) { yCoord = y; }
-
- bool isNull() const { return xCoord == 0 && yCoord == 0; }
-
- IntPoint &operator -=(const IntPoint &two) { xCoord -= two.xCoord; yCoord -= two.yCoord; return *this; }
- friend const IntPoint operator*(const IntPoint &p, double s);
- friend IntPoint operator+(const IntPoint &, const IntPoint &);
- friend IntPoint operator-(const IntPoint &, const IntPoint &);
-
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
+ operator CGPoint() const;
+
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
operator NSPoint() const;
#endif
- operator CGPoint() const;
+
#endif
private:
- int xCoord;
- int yCoord;
+ int m_x, m_y;
};
+inline IntPoint& operator+=(IntPoint& a, const IntPoint& b)
+{
+ a.setX(a.x() + b.x());
+ a.setY(a.y() + b.y());
+ return a;
+}
+
+inline IntPoint& operator-=(IntPoint& a, const IntPoint& b)
+{
+ a.setX(a.x() - b.x());
+ a.setY(a.y() - b.y());
+ return a;
+}
+
+inline IntPoint operator+(const IntPoint& a, const IntPoint& b)
+{
+ return IntPoint(a.x() + b.x(), a.y() + b.y());
+}
+
+inline IntPoint operator-(const IntPoint& a, const IntPoint& b)
+{
+ return IntPoint(a.x() - b.x(), a.y() - b.y());
+}
+
+inline bool operator==(const IntPoint& a, const IntPoint& b)
+{
+ return a.x() == b.x() && a.y() == b.y();
+}
+
+inline bool operator!=(const IntPoint& a, const IntPoint& b)
+{
+ return a.x() != b.x() || a.y() != b.y();
+}
+
}
// FIXME: Remove when everything is in the WebCore namespace.
setPoints(nPoints, points);
}
-IntPointArray::IntPointArray(const IntRect &rect)
-{
- setPoints(4, rect.topLeft().x(), rect.topLeft().y(),
- rect.topRight().x(), rect.topRight().y(),
- rect.bottomRight().x(), rect.bottomRight().y(),
- rect.bottomLeft().x(), rect.bottomLeft().y());
-}
-
IntPointArray IntPointArray::copy() const
{
IntPointArray copy;
{
int nPoints = count();
- if (nPoints < 1) return IntRect(0,0,0,0);
+ if (nPoints < 1) return IntRect();
int minX = INT_MAX, maxX = 0;
int minY = INT_MAX, maxY = 0;
/*
- * Copyright (C) 2004-6 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
public:
IntPointArray() { }
IntPointArray(int size) : Array<IntPoint>(size) { }
- IntPointArray(const IntRect &rect);
IntPointArray(int, const int *);
IntRect boundingRect() const;
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#include "config.h"
#include "IntRect.h"
+
#include <algorithm>
using std::max;
namespace WebCore {
-IntRect::IntRect() : xp(0), yp(0), w(0), h(0)
-{
-}
-
-IntRect::IntRect(int x, int y, int width, int height) : xp(x), yp(y), w(width), h(height)
-{
-}
-
-IntRect::IntRect(IntPoint p, IntSize s) : xp(p.x()), yp(p.y()), w(s.width()), h(s.height())
-{
-}
-
-IntRect::IntRect(const IntPoint &topLeft, const IntPoint &bottomRight)
-{
- xp = topLeft.x();
- yp = topLeft.y();
- w = bottomRight.x() - topLeft.x() + 1;
- h = bottomRight.y() - topLeft.y() + 1;
-}
-
-bool IntRect::isNull() const
-{
- return w == 0 && h == 0;
-}
-
-bool IntRect::isValid() const
-{
- return w > 0 && h > 0;
-}
-
-bool IntRect::isEmpty() const
+bool IntRect::intersects(const IntRect& other) const
{
- return w <= 0 || h <= 0;
+ // Checking emptiness handles negative widths as well as zero.
+ return !isEmpty() && !other.isEmpty()
+ && x() < other.right() && other.x() < right()
+ && y() < other.bottom() && other.y() < bottom();
}
-int IntRect::right() const
+bool IntRect::contains(const IntRect& other) const
{
- return xp + w - 1;
+ return x() <= other.x() && right() >= other.right()
+ && y() <= other.y() && bottom() >= other.bottom();
}
-int IntRect::bottom() const
+void IntRect::intersect(const IntRect& other)
{
- return yp + h - 1;
-}
-
-IntPoint IntRect::topLeft() const
-{
- return IntPoint(xp,yp);
-}
+ int l = max(x(), other.x());
+ int t = max(y(), other.y());
+ int r = min(right(), other.right());
+ int b = min(bottom(), other.bottom());
-IntPoint IntRect::topRight() const
-{
- return IntPoint(right(),top());
-}
-
-IntPoint IntRect::bottomRight() const
-{
- return IntPoint(right(),bottom());
-}
-
-IntPoint IntRect::bottomLeft() const
-{
- return IntPoint(left(),bottom());
-}
-
-IntSize IntRect::size() const
-{
- return IntSize(w,h);
-}
-
-IntRect IntRect::unite(const IntRect &r) const
-{
- if (r.isEmpty())
- return *this;
-
- if (isEmpty())
- return r;
-
- int nx, ny, nw, nh;
-
- nx = min(xp, r.xp);
- ny = min(yp, r.yp);
-
- if (xp + w >= r.xp + r.w) {
- nw = xp + w - nx;
- } else {
- nw = r.xp + r.w - nx;
- }
-
- if (yp + h >= r.yp + r.h) {
- nh = yp + h - ny;
- } else {
- nh = r.yp + r.h - ny;
+ // Return a clean empty rectangle for non-intersecting cases.
+ if (l >= r || t >= b) {
+ l = 0;
+ t = 0;
+ r = 0;
+ b = 0;
}
- return IntRect(nx, ny, nw, nh);
+ m_location.setX(l);
+ m_location.setY(t);
+ m_size.setWidth(r - l);
+ m_size.setHeight(b - t);
}
-IntRect IntRect::normalize() const
+void IntRect::unite(const IntRect& other)
{
- IntRect newRect;
-
- newRect.xp = (w < 0) ? (xp - w) : xp;
- newRect.w = (w < 0) ? -w : w;
-
- newRect.yp = (h < 0) ? (yp - h) : yp;
- newRect.h = (h < 0) ? -h : h;
-
- return newRect;
-}
-
-bool IntRect::intersects(const IntRect &r) const
-{
- return intersect(r).isValid();
-}
-
-IntRect IntRect::intersect(const IntRect &r) const
-{
- int nx, ny, nw, nh;
-
- nx = max(xp, r.xp);
- ny = max(yp, r.yp);
-
- if (xp + w <= r.xp + r.w) {
- nw = xp + w - nx;
- } else {
- nw = r.xp + r.w - nx;
+ // Handle empty special cases first.
+ if (other.isEmpty())
+ return;
+ if (isEmpty()) {
+ *this = other;
+ return;
}
- if (yp + h <= r.yp + r.h) {
- nh = yp + h - ny;
- } else {
- nh = r.yp + r.h - ny;
- }
-
- return IntRect(nx, ny, nw, nh);
-}
-
-void IntRect::inflate(int s)
-{
- xp -= s;
- yp -= s;
- w += 2*s;
- h += 2*s;
-}
+ int l = min(x(), other.x());
+ int t = min(y(), other.y());
+ int r = max(right(), other.right());
+ int b = max(bottom(), other.bottom());
-bool operator==(const IntRect &a, const IntRect &b)
-{
- return a.xp == b.xp && a.yp == b.yp && a.w == b.w && a.h == b.h;
-}
-
-bool operator!=(const IntRect &a, const IntRect &b)
-{
- return !(a == b);
+ m_location.setX(l);
+ m_location.setY(t);
+ m_size.setWidth(r - l);
+ m_size.setHeight(b - t);
}
}
/*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#ifndef INTRECT_H_
#define INTRECT_H_
+#include "IntPoint.h"
#include "IntSize.h"
-#include "IntPointArray.h"
#if __APPLE__
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+typedef struct CGRect CGRect;
+
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#endif
-typedef struct CGRect CGRect;
+
#endif
namespace WebCore {
class IntRect {
public:
- IntRect();
- IntRect(IntPoint p, IntSize s);
- IntRect(int, int, int, int);
- IntRect(const IntPoint &, const IntPoint &);
-
-#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit IntRect(const NSRect &); // don't do this implicitly since it's lossy
-#endif
- explicit IntRect(const CGRect &); // don't do this implicitly since it's lossy
-#endif
+ IntRect() { }
+ IntRect(const IntPoint& location, const IntSize& size)
+ : m_location(location), m_size(size) { }
+ IntRect(int x, int y, int width, int height)
+ : m_location(IntPoint(x, y)), m_size(IntSize(width, height)) { }
- bool isNull() const;
- bool isValid() const;
- bool isEmpty() const;
-
- int x() const { return xp; }
- int y() const { return yp; }
- int left() const { return xp; }
- int top() const { return yp; }
- int right() const;
- int bottom() const;
- int width() const { return w; }
- int height() const { return h; }
-
- IntPoint topLeft() const;
- IntPoint topRight() const;
- IntPoint bottomRight() const;
- IntPoint bottomLeft() const;
-
- void moveTopLeft(const IntPoint &p) { xp += p.x(); yp += p.y(); }
-
- IntSize size() const;
- void setX(int x) { xp = x; }
- void setY(int y) { yp = y; }
- void setWidth(int width) { w = width; }
- void setHeight(int height) { h = height; }
- void setRect(int x, int y, int width, int height) { xp = x; yp = y; w = width; h = height; }
- IntRect intersect(const IntRect &) const;
- bool intersects(const IntRect &) const;
- IntRect unite(const IntRect &) const;
- IntRect normalize() const;
-
- bool contains(const IntPoint &point) const { return contains(point.x(), point.y()); }
-
- bool contains(int x, int y, bool proper = false) const {
- if (proper)
- return x > xp && (x < (xp + w - 1)) && y > yp && y < (yp + h - 1);
- return x >= xp && x < (xp + w) && y >= yp && y < (yp + h);
- }
+ IntPoint location() const { return m_location; }
+ IntSize size() const { return m_size; }
+
+ void setLocation(const IntPoint& location) { m_location = location; }
+ void setSize(const IntSize& size) { m_size = size; }
- bool contains(const IntRect &rect) const { return intersect(rect) == rect; }
-
- void inflate(int s);
+ int x() const { return m_location.x(); }
+ int y() const { return m_location.y(); }
+ int width() const { return m_size.width(); }
+ int height() const { return m_size.height(); }
- inline IntRect operator&(const IntRect &r) const { return intersect(r); }
+ void setX(int x) { m_location.setX(x); }
+ void setY(int y) { m_location.setY(y); }
+ void setWidth(int width) { m_size.setWidth(width); }
+ void setHeight(int height) { m_size.setHeight(height); }
+
+ bool isEmpty() const { return m_size.isEmpty(); }
+
+ int right() const { return x() + width(); }
+ int bottom() const { return y() + height(); }
+
+ void move(const IntPoint& p) { m_location += p; }
+ void move(int dx, int dy) { m_location += IntPoint(dx, dy); }
+
+ bool intersects(const IntRect&) const;
+ bool contains(const IntRect&) const;
+
+ // This checks to see if the rect contains x,y in the traditional sense.
+ // Equivalent to checking if the rect contains a 1x1 rect below and to the right of (px,py).
+ bool contains(int px, int py) const
+ { return px >= x() && px < right() && py >= y() && py < bottom(); }
+
+ void intersect(const IntRect&);
+ void unite(const IntRect&);
+
+ void inflateX(int dx) {
+ m_location.setX(m_location.x() - dx);
+ m_size.setWidth(m_size.width() + dx + dx);
+ }
+ void inflateY(int dy) {
+ m_location.setY(m_location.y() - dy);
+ m_size.setHeight(m_size.height() + dy + dy);
+ }
+ void inflate(int d) { inflateX(d); inflateY(d); }
#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+ operator CGRect() const;
+
+#if! NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
operator NSRect() const;
#endif
- operator CGRect() const;
+
#endif
private:
- int xp;
- int yp;
- int w;
- int h;
-
- friend bool operator==(const IntRect &, const IntRect &);
- friend bool operator!=(const IntRect &, const IntRect &);
+ IntPoint m_location;
+ IntSize m_size;
};
+inline IntRect intersection(const IntRect& a, const IntRect& b)
+{
+ IntRect c = a;
+ c.intersect(b);
+ return c;
+}
+
+inline bool operator==(const IntRect& a, const IntRect& b)
+{
+ return a.location() == b.location() && a.size() == b.size();
+}
+
+inline bool operator!=(const IntRect& a, const IntRect& b)
+{
+ return a.location() != b.location() || a.size() != b.size();
+}
+
+#if __APPLE__
+
+IntRect enclosingIntRect(const CGRect&);
+
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+IntRect enclosingIntRect(const NSRect&);
+
+#endif
+
+#endif
+
}
// FIXME: Remove when everything is in the WebCore namespace.
using WebCore::IntRect;
+using WebCore::enclosingIntRect;
#endif
-/*
- * Copyright (C) 2003-6 Apple Computer, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "IntSize.h"
-
-namespace WebCore {
-
-IntSize::IntSize() : w(-1), h(-1)
-{
-}
-
-IntSize::IntSize(int width, int height) : w(width), h(height)
-{
-}
-
-bool IntSize::isValid() const
-{
- return w >= 0 && h >= 0;
-}
-
-IntSize IntSize::expandedTo(const IntSize &o) const
-{
- return IntSize(w > o.w ? w : o.w, h > o.h ? h : o.h);
-}
-
-IntSize operator+(const IntSize &a, const IntSize &b)
-{
- return IntSize(a.w + b.w, a.h + b.h);
-}
-
-bool operator==(const IntSize &a, const IntSize &b)
-{
- return a.w == b.w && a.h == b.h;
-}
-
-bool operator!=(const IntSize &a, const IntSize &b)
-{
- return a.w != b.w || a.h != b.h;
-}
-
-}
/*
- * Copyright (C) 2003-6 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
#define INTSIZE_H_
#if __APPLE__
+
+typedef struct CGSize CGSize;
+
// workaround for <rdar://problem/4294625>
-#if ! __LP64__ && ! NS_BUILD_32_LIKE_64
+#if !__LP64__ && !NS_BUILD_32_LIKE_64
#undef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
#endif
-#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#endif
-typedef struct CGSize CGSize;
+
#endif
namespace WebCore {
class IntSize {
public:
- IntSize();
- IntSize(int,int);
+ IntSize() : m_width(0), m_height(0) { }
+ IntSize(int width, int height) : m_width(width), m_height(height) { }
+ int width() const { return m_width; }
+ int height() const { return m_height; }
+
+ void setWidth(int width) { m_width = width; }
+ void setHeight(int height) { m_height = height; }
+
+ bool isEmpty() const { return m_width <= 0 || m_height <= 0; }
+
+ IntSize expandedTo(const IntSize& other) const
+ {
+ return IntSize(m_width > other.m_width ? m_width : other.m_width,
+ m_height > other.m_height ? m_height : other.m_height);
+ }
+
#if __APPLE__
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
- explicit IntSize(const NSSize &);
-#endif
- explicit IntSize(const CGSize &);
-#endif
- bool isValid() const;
- int width() const { return w; }
- int height() const { return h; }
- void setWidth(int width) { w = width; }
- void setHeight(int height) { h = height; }
- IntSize expandedTo(const IntSize &) const;
+ explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
+ operator CGSize() const;
-#if __APPLE__
#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+ explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
- operator CGSize() const;
-#endif
- friend IntSize operator+(const IntSize &, const IntSize &);
- friend bool operator==(const IntSize &, const IntSize &);
- friend bool operator!=(const IntSize &, const IntSize &);
+#endif
private:
- int w;
- int h;
+ int m_width, m_height;
};
+inline IntSize& operator+=(IntSize& a, const IntSize& b)
+{
+ a.setWidth(a.width() + b.width());
+ a.setHeight(a.height() + b.height());
+ return a;
+}
+
+inline IntSize& operator-=(IntSize& a, const IntSize& b)
+{
+ a.setWidth(a.width() - b.width());
+ a.setHeight(a.height() - b.height());
+ return a;
+}
+
+inline IntSize operator+(const IntSize& a, const IntSize& b)
+{
+ return IntSize(a.width() + b.width(), a.height() + b.height());
+}
+
+inline IntSize operator-(const IntSize& a, const IntSize& b)
+{
+ return IntSize(a.width() - b.width(), a.height() - b.height());
+}
+
+inline bool operator==(const IntSize& a, const IntSize& b)
+{
+ return a.width() == b.width() && a.height() == b.height();
+}
+
+inline bool operator!=(const IntSize& a, const IntSize& b)
+{
+ return a.width() != b.width() || a.height() != b.height();
+}
+
}
// FIXME: Remove when the engine files have been converted to be in the WebCore namespace.
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatPoint::FloatPoint(const NSPoint& p) : xCoord(p.x), yCoord(p.y)
+FloatPoint::FloatPoint(const CGPoint& p) : m_x(p.x), m_y(p.y)
{
}
-#endif
-FloatPoint::FloatPoint(const CGPoint& p) : xCoord(p.x), yCoord(p.y)
+FloatPoint::operator CGPoint() const
{
+ return CGPointMake(m_x, m_y);
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatPoint::operator NSPoint() const
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+FloatPoint::FloatPoint(const NSPoint& p) : m_x(p.x), m_y(p.y)
{
- return NSMakePoint(xCoord, yCoord);
}
-#endif
-FloatPoint::operator CGPoint() const
+FloatPoint::operator NSPoint() const
{
- return CGPointMake(xCoord, yCoord);
+ return NSMakePoint(m_x, m_y);
}
+#endif
+
}
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatRect::FloatRect(const NSRect &r) : xp(r.origin.x), yp(r.origin.y), w(r.size.width), h(r.size.height)
+FloatRect::FloatRect(const CGRect& r) : m_location(r.origin), m_size(r.size)
{
}
-#endif
-FloatRect::FloatRect(const CGRect &r) : xp(r.origin.x), yp(r.origin.y), w(r.size.width), h(r.size.height)
+FloatRect::operator CGRect() const
{
+ return CGRectMake(x(), y(), width(), height());
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatRect::operator NSRect() const
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+FloatRect::FloatRect(const NSRect& r) : m_location(r.origin), m_size(r.size)
{
- return NSMakeRect(xp, yp, w, h);
}
-#endif
-FloatRect::operator CGRect() const
+FloatRect::operator NSRect() const
{
- return CGRectMake(xp, yp, w, h);
+ return NSMakeRect(x(), y(), width(), height());
}
+#endif
+
}
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatSize::FloatSize(const NSSize& s) : w(s.width), h(s.height)
+FloatSize::FloatSize(const CGSize& s) : m_width(s.width), m_height(s.height)
{
}
-#endif
-FloatSize::FloatSize(const CGSize& s) : w(s.width), h(s.height)
+FloatSize::operator CGSize() const
{
+ return CGSizeMake(m_width, m_height);
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-FloatSize::operator NSSize() const
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+FloatSize::FloatSize(const NSSize& s) : m_width(s.width), m_height(s.height)
{
- return NSMakeSize(w, h);
}
-#endif
-FloatSize::operator CGSize() const
+FloatSize::operator NSSize() const
{
- return CGSizeMake(w, h);
+ return NSMakeSize(m_width, m_height);
}
-}
\ No newline at end of file
+#endif
+
+}
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "config.h"
+#import "config.h"
#import "Image.h"
-#import "IntSize.h"
-#import "IntRect.h"
+#import "IntRect.h"
#import "KWQFoundationExtras.h"
#import "WebCoreImageRenderer.h"
#import "WebCoreImageRendererFactory.h"
+#import <qstring.h>
namespace WebCore {
-
- /*
- * Copyright (C) 2004-6 Apple Computer, Inc. All rights reserved.
+/*
+ * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
*/
#include "config.h"
-#import "IntPoint.h"
+#include "IntPoint.h"
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-IntPoint::IntPoint(const NSPoint &p) : xCoord((int)p.x), yCoord((int)p.y)
+IntPoint::IntPoint(const CGPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
{
}
-#endif
-IntPoint::IntPoint(const CGPoint &p) : xCoord((int)p.x), yCoord((int)p.y)
+IntPoint::operator CGPoint() const
{
+ return CGPointMake(m_x, m_y);
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-IntPoint::operator NSPoint() const
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+IntPoint::IntPoint(const NSPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
{
- return NSMakePoint(xCoord, yCoord);
}
-#endif
-IntPoint::operator CGPoint() const
+IntPoint::operator NSPoint() const
{
- return CGPointMake(xCoord, yCoord);
+ return NSMakePoint(m_x, m_y);
}
+#endif
}
- /*
- * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+/*
+ * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
*/
#include "config.h"
-#import "IntRect.h"
-
-#import <algorithm>
-
-using std::max;
-using std::min;
+#include "IntRect.h"
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-IntRect::IntRect(const NSRect &r) : xp((int)r.origin.x), yp((int)r.origin.y), w((int)r.size.width), h((int)r.size.height)
+IntRect::operator CGRect() const
{
+ return CGRectMake(x(), y(), width(), height());
}
-#endif
-IntRect::IntRect(const CGRect &r) : xp((int)r.origin.x), yp((int)r.origin.y), w((int)r.size.width), h((int)r.size.height)
+IntRect enclosingIntRect(const CGRect& rect)
{
+ int l = static_cast<int>(floorf(rect.origin.x));
+ int t = static_cast<int>(floorf(rect.origin.y));
+ int r = static_cast<int>(ceilf(CGRectGetMaxX(rect)));
+ int b = static_cast<int>(ceilf(CGRectGetMaxY(rect)));
+ return IntRect(l, t, r - l, b - t);
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
IntRect::operator NSRect() const
{
- return NSMakeRect(xp, yp, w, h);
+ return NSMakeRect(x(), y(), width(), height());
}
-#endif
-IntRect::operator CGRect() const
+IntRect enclosingIntRect(const NSRect& rect)
{
- return CGRectMake(xp, yp, w, h);
+ int l = static_cast<int>(floorf(rect.origin.x));
+ int t = static_cast<int>(floorf(rect.origin.y));
+ int r = static_cast<int>(ceilf(NSMaxX(rect)));
+ int b = static_cast<int>(ceilf(NSMaxY(rect)));
+ return IntRect(l, t, r - l, b - t);
}
+#endif
+
}
/*
- * Copyright (C) 2003-6 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
namespace WebCore {
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-IntSize::IntSize(const NSSize &s) : w((int)s.width), h((int)s.height)
+IntSize::IntSize(const CGSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
{
}
-#endif
-IntSize::IntSize(const CGSize &s) : w((int)s.width), h((int)s.height)
+IntSize::operator CGSize() const
{
+ return CGSizeMake(m_width, m_height);
}
-#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
-IntSize::operator NSSize() const
+#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+
+IntSize::IntSize(const NSSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
{
- return NSMakeSize(w, h);
}
-#endif
-IntSize::operator CGSize() const
+IntSize::operator NSSize() const
{
- return CGSizeMake(w, h);
+ return NSMakeSize(m_width, m_height);
}
-}
\ No newline at end of file
+#endif
+
+}
IntRect screenRect(QWidget* widget)
{
- return IntRect(flipGlobalRect([screen(widget) frame]));
+ return enclosingIntRect(flipGlobalRect([screen(widget) frame]));
}
IntRect usableScreenRect(QWidget* widget)
{
- return IntRect(flipGlobalRect([screen(widget) visibleFrame]));
+ return enclosingIntRect(flipGlobalRect([screen(widget) visibleFrame]));
}
}
const Font *f = textObj->htmlFont(m_firstLine);
IntRect r = f->selectionRectForText(tx + m_x, ty + selTop, selHeight, textObj->tabWidth(), textPos(), textObj->str->s, textObj->str->l, m_start, m_len, m_toAdd, m_reversed, m_dirOverride, sPos, ePos);
- if (r.left() > tx + m_x + m_width)
+ if (r.x() > tx + m_x + m_width)
r.setWidth(0);
- else if (r.right() > tx + m_x + m_width)
- r.setWidth(tx + m_x + m_width - r.left());
+ else if (r.right() - 1 > tx + m_x + m_width)
+ r.setWidth(tx + m_x + m_width - r.x());
return r;
}
return false;
IntRect rect(tx + m_x, ty + m_y, m_width, m_height);
- if (m_truncation != cFullTruncation &&
- object()->style()->visibility() == VISIBLE && rect.contains(x, y)) {
+ if (m_truncation != cFullTruncation && object()->style()->visibility() == VISIBLE && rect.contains(x, y)) {
object()->setInnerNode(i);
return true;
}
int xPos = tx + m_x;
int w = width();
- if ((xPos >= i.r.x() + i.r.width()) || (xPos + w <= i.r.x()))
+ if (xPos >= i.r.right() || xPos + w <= i.r.x())
return;
bool isPrinting = i.p->printing();
RenderText* text = static_cast<RenderText*>(m_object);
RenderStyle *style = text->style(m_firstLine);
const Font* f = &style->htmlFont();
- return f->checkSelectionPoint(text->str->s, text->str->l, m_start, m_len, m_toAdd, text->tabWidth(), textPos(), _x - m_x, m_reversed ? QPainter::RTL : QPainter::LTR, m_dirOverride || style->visuallyOrdered(), includePartialGlyphs);
+ return f->checkSelectionPoint(text->str->s, text->str->l, m_start, m_len,
+ m_toAdd, text->tabWidth(), textPos(), _x - m_x,
+ m_reversed ? QPainter::RTL : QPainter::LTR, m_dirOverride || style->visuallyOrdered(), includePartialGlyphs);
}
int InlineTextBox::positionForOffset(int offset) const
int from = m_reversed ? offset - m_start : 0;
int to = m_reversed ? m_len : offset - m_start;
// FIXME: Do we need to add rightBearing here?
- return f->selectionRectForText(m_x, 0, 0, text->tabWidth(), textPos(), text->str->s, text->str->l, m_start, m_len, m_toAdd, m_reversed, m_dirOverride, from, to).right();
+ return f->selectionRectForText(m_x, 0, 0, text->tabWidth(), textPos(), text->str->s, text->str->l, m_start, m_len,
+ m_toAdd, m_reversed, m_dirOverride, from, to).right() - 1;
}
}
if (!r->noPaint && !r->node->layer()) {
IntRect childRect, childFullRect;
r->node->getAbsoluteRepaintRectIncludingFloats(childRect, childFullRect);
- fullBounds = fullBounds.unite(childFullRect);
+ fullBounds.unite(childFullRect);
}
}
}
if (!isInlineFlow() && !isRoot()) {
IntRect overflowBox = overflowRect(false);
overflowBox.inflate(maximalOutlineSize(i.phase));
- overflowBox.setX(overflowBox.x() + _tx);
- overflowBox.setY(overflowBox.y() + _ty);
+ overflowBox.move(_tx, _ty);
bool intersectsOverflowBox = overflowBox.intersects(i.r);
if (!intersectsOverflowBox) {
// Check floats next.
return;
IntRect floatBox = floatRect();
floatBox.inflate(maximalOutlineSize(i.phase));
- floatBox.setX(floatBox.x() + _tx);
- floatBox.setY(floatBox.y() + _ty);
+ floatBox.move(_tx, _ty);
if (!floatBox.intersects(i.r))
return;
}
// Check for page-break-before: always, and if it's set, break and bail.
if (isPrinting && !childrenInline() && child->style()->pageBreakBefore() == PBALWAYS &&
inRootBlockContext() && (_ty + child->yPos()) > i.r.y() &&
- (_ty + child->yPos()) < i.r.y() + i.r.height()) {
+ (_ty + child->yPos()) < i.r.bottom()) {
canvas()->setBestTruncatedAt(_ty + child->yPos(), this, true);
return;
}
// Check for page-break-after: always, and if it's set, break and bail.
if (isPrinting && !childrenInline() && child->style()->pageBreakAfter() == PBALWAYS &&
inRootBlockContext() && (_ty + child->yPos() + child->height()) > i.r.y() &&
- (_ty + child->yPos() + child->height()) < i.r.y() + i.r.height()) {
+ (_ty + child->yPos() + child->height()) < i.r.bottom()) {
canvas()->setBestTruncatedAt(_ty + child->yPos() + child->height() + child->collapsedMarginBottom(), this, true);
return;
}
// intersect.
int yPos = _ty + firstLineBox()->yPos();;
int h = lastLineBox()->yPos() + lastLineBox()->height() - firstLineBox()->yPos();
- if( (yPos >= i.r.y() + i.r.height()) || (yPos + h <= i.r.y()))
+ if (yPos >= i.r.bottom() || yPos + h <= i.r.y())
return;
// See if our boxes intersect with the dirty rect. If so, then we paint
for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
yPos = _ty + curr->yPos();
h = curr->height();
- if (curr->ellipsisBox() && (yPos < i.r.y() + i.r.height()) && (yPos + h > i.r.y()))
+ if (curr->ellipsisBox() && yPos < i.r.bottom() && yPos + h > i.r.y())
curr->paintEllipsisBox(i, _tx, _ty);
}
}
result.uniteCenter(fillVerticalSelectionGap(lastTop, lastLeft, lastRight, ty + selTop,
rootBlock, blockX, blockY, i));
- if (!i || (ty + selTop < i->r.y() + i->r.height()) && (ty + selTop + selHeight > i->r.y()))
+ if (!i || ty + selTop < i->r.bottom() && ty + selTop + selHeight > i->r.y())
result.unite(curr->fillLineSelectionGap(selTop, selHeight, rootBlock, blockX, blockY, tx, ty, i));
lastSelectedLine = curr;
for (; (r = it.current()); ++it) {
if (!r->noPaint && !r->node->layer()) {
// Check this float.
- int bottomDelta = kMax(0, r->startY + r->node->marginTop() + r->node->overflowHeight(false) -
- (result.y() + result.height()));
+ int bottomDelta = kMax(0, r->startY + r->node->marginTop() + r->node->overflowHeight(false) - result.bottom());
if (bottomDelta)
result.setHeight(result.height() + bottomDelta);
- int rightDelta = kMax(0, r->left + r->node->marginLeft() + r->node->overflowWidth(false) -
- (result.x() + result.width()));
+ int rightDelta = kMax(0, r->left + r->node->marginLeft() + r->node->overflowWidth(false) - result.right());
if (rightDelta)
result.setWidth(result.width() + rightDelta);
// Now check left and top
int topDelta = kMin(0, r->startY + r->node->marginTop() - result.y());
- if (topDelta < 0) {
- result.setY(result.y() + topDelta);
- result.setHeight(result.height() - 2*topDelta);
- }
+ if (topDelta < 0)
+ result.inflateY(-topDelta);
int leftDelta = kMin(0, r->left + r->node->marginLeft() - result.x());
- if (topDelta < 0) {
- result.setX(result.x() + leftDelta);
- result.setHeight(result.width() - 2*leftDelta);
- }
+ if (leftDelta < 0)
+ result.inflateX(-leftDelta);
}
}
return false;
}
-bool RenderBlock::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
- HitTestAction hitTestAction)
+bool RenderBlock::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, HitTestAction hitTestAction)
{
bool inlineFlow = isInlineFlow();
if (!inlineFlow && !isRoot()) {
// Check if we need to do anything at all.
IntRect overflowBox = overflowRect(false);
- overflowBox.setX(overflowBox.x() + tx);
- overflowBox.setY(overflowBox.y() + ty);
+ overflowBox.move(tx, ty);
bool insideOverflowBox = overflowBox.contains(_x, _y);
if (!insideOverflowBox) {
// Check floats next.
if (hitTestAction != HitTestFloat)
return false;
IntRect floatBox = floatRect();
- floatBox.setX(floatBox.x() + tx);
- floatBox.setY(floatBox.y() + ty);
+ floatBox.move(tx, ty);
if (!floatBox.contains(_x, _y))
return false;
}
}
#ifndef NDEBUG
-void RenderBlock::printTree(int indent) const
-{
- RenderFlow::printTree(indent);
-
- if (m_floatingObjects)
- {
- QPtrListIterator<FloatingObject> it(*m_floatingObjects);
- FloatingObject *r;
- for ( ; (r = it.current()); ++it )
- {
- QString s;
- s.fill(' ', indent);
- kdDebug() << s << renderName() << ": " <<
- (r->type == FloatingObject::FloatLeft ? "FloatLeft" : "FloatRight" ) <<
- "[" << r->node->renderName() << ": " << (void*)r->node << "] (" << r->startY << " - " << r->endY << ")" << "width: " << r->width <<
- endl;
- }
- }
-}
void RenderBlock::dump(QTextStream *stream, QString ind) const
{
RenderFlow::dump(stream,ind);
}
+
#endif
} // namespace WebCore
int leftSelectionOffset(RenderBlock* rootBlock, int y);
int rightSelectionOffset(RenderBlock* rootBlock, int y);
-#ifndef NDEBUG
- virtual void printTree(int indent=0) const;
+#if !NDEBUG
virtual void dump(QTextStream *stream, QString ind = "") const;
#endif
PaintAction paintAction = i.phase;
int os = 2*maximalOutlineSize(paintAction);
- if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + height() <= i.r.y() - os))
+ if (_ty >= i.r.bottom() + os || _ty + height() <= i.r.y() - os)
return;
- if ((_tx >= i.r.x() + i.r.width() + os) || (_tx + width() <= i.r.x() - os))
+ if (_tx >= i.r.right() + os || _tx + width() <= i.r.x() - os)
return;
if ((paintAction == PaintActionBlockBackground || paintAction == PaintActionChildBlockBackground)
// check if we need to do anything at all...
int os = 2*maximalOutlineSize(i.phase);
- if ((_ty >= i.r.y() + i.r.height() + os) || (_ty + _topExtra + m_height + _bottomExtra <= i.r.y() - os))
+ if (_ty >= i.r.bottom() + os || _ty + _topExtra + m_height + _bottomExtra <= i.r.y() - os)
return;
if (i.phase == PaintActionCollapsedTableBorders && style()->visibility() == VISIBLE) {
int w = width();
int h = height() + borderTopExtra() + borderBottomExtra();
paintCollapsedBorder(i.p, _tx, _ty, w, h);
- }
- else
+ } else
RenderBlock::paintObject(i, _tx, _ty + _topExtra);
#ifdef BOX_DEBUG
}
int my = kMax(_ty, i.r.y());
- int end = kMin(i.r.y() + i.r.height(), _ty + h);
+ int end = kMin(i.r.bottom(), _ty + h);
int mh = end - my;
if (bgLayer->hasImage() || c.isValid()) {
int absx, absy;
cb->absolutePosition(absx, absy);
- RenderLayer *layer = cb->layer();
+ RenderLayer* layer = cb->layer();
if (layer)
layer->subtractScrollOffset(absx, absy);
- for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox()) {
- IntRect r = box->selectionRect(absx, absy, startPos, endPos);
- if (!r.isEmpty()) {
- if (rect.isEmpty())
- rect = r;
- else
- rect = rect.unite(r);
- }
- }
+ for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
+ rect.unite(box->selectionRect(absx, absy, startPos, endPos));
return rect;
}
}
// Hit Testing
-bool RenderBox::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty,
- HitTestAction hitTestAction)
+bool RenderBox::nodeAtPoint(NodeInfo& info, int x, int y, int tx, int ty, HitTestAction action)
{
+ tx += m_x;
+ ty += m_y;
+
// Check kids first.
- _tx += m_x;
- _ty += m_y;
for (RenderObject* child = lastChild(); child; child = child->previousSibling()) {
- // FIXME: We have to skip over inline flows, since they can show up inside table rows at the moment (a demoted inline <form> for example). If we ever implement a
- // table-specific hit-test method (which we should do for performance reasons anyway), then we can remove this check.
- if (!child->layer() && !child->isInlineFlow() && child->nodeAtPoint(info, _x, _y, _tx, _ty, hitTestAction)) {
+ // FIXME: We have to skip over inline flows, since they can show up inside table rows
+ // at the moment (a demoted inline <form> for example). If we ever implement a
+ // table-specific hit-test method (which we should do for performance reasons anyway),
+ // then we can remove this check.
+ if (!child->layer() && !child->isInlineFlow() && child->nodeAtPoint(info, x, y, tx, ty, action)) {
setInnerNode(info);
return true;
}
}
- // Check our bounds next. For this purpose always assume that we can only be hit in the
+ // Check our bounds next. For this purpose always assume that we can only be hit in the
// foreground phase (which is true for replaced elements like images).
- if (hitTestAction != HitTestForeground)
- return false;
-
- IntRect boundsRect(_tx, _ty, m_width, m_height);
- if (boundsRect.contains(_x, _y)) {
+ if (action == HitTestForeground && IntRect(tx, ty, m_width, m_height).contains(x, y)) {
setInnerNode(info);
return true;
}
+
return false;
}
int my = kMax(_ty, i.r.y());
int mh;
if (_ty < i.r.y())
- mh= kMax(0, h - (i.r.y() - _ty));
+ mh = kMax(0, h - (i.r.y() - _ty));
else
mh = kMin(i.r.height(), h);
cx += xPosition;
cw -= xPosition;
} else {
- sx = pixw - (xPosition % pixw );
+ sx = pixw - (xPosition % pixw );
sx -= left % pixw;
}
}
EBackgroundRepeat bgr = bgLayer->backgroundRepeat();
if( (bgr == NO_REPEAT || bgr == REPEAT_Y) && pw > pixw ) {
cw = pixw;
- cx = vr.x() + bgLayer->backgroundXPosition().minWidth(pw-pixw);
+ cx = vr.x() + bgLayer->backgroundXPosition().minWidth(pw - pixw);
} else {
cw = pw;
cx = vr.x();
- if (pixw > 0) {
- sx = pixw - ((bgLayer->backgroundXPosition().minWidth(pw-pixw)) % pixw );
- }
+ if (pixw > 0)
+ sx = pixw - bgLayer->backgroundXPosition().minWidth(pw - pixw) % pixw;
}
if( (bgr == NO_REPEAT || bgr == REPEAT_X) && ph > pixh ) {
ch = pixh;
- cy = vr.y() + bgLayer->backgroundYPosition().minWidth(ph-pixh);
+ cy = vr.y() + bgLayer->backgroundYPosition().minWidth(ph - pixh);
} else {
ch = ph;
cy = vr.y();
- if (pixh > 0) {
- sy = pixh - ((bgLayer->backgroundYPosition().minWidth(ph-pixh)) % pixh );
- }
+ if (pixh > 0)
+ sy = pixh - bgLayer->backgroundYPosition().minWidth(ph - pixh) % pixh;
}
- IntRect fix(cx,cy,cw,ch);
- IntRect ele(_tx,_ty,w,h);
- IntRect b = fix.intersect(ele);
- sx+=b.x()-cx;
- sy+=b.y()-cy;
- cx=b.x();cy=b.y();cw=b.width();ch=b.height();
+ IntRect b = intersection(IntRect(cx, cy, cw, ch), IntRect(_tx, _ty, w, h));
+ sx += b.x() - cx;
+ sy += b.y() - cy;
+ cx = b.x();
+ cy = b.y();
+ cw = b.width();
+ ch = b.height();
}
if (cw>0 && ch>0)
IntRect boxRect(0, 0, o->layer()->width(), o->layer()->height());
o->layer()->subtractScrollOffset(x,y); // For overflow:auto/scroll/hidden.
IntRect repaintRect(x, y, r.width(), r.height());
- r = repaintRect.intersect(boxRect);
+ r = intersection(repaintRect, boxRect);
if (r.isEmpty())
return;
- }
- else {
+ } else {
r.setX(x);
r.setY(y);
}
if (elt || view()->isTransparent())
view()->useSlowRepaints(); // The parent must show behind the child.
else
- i.p->fillRect(i.r.x(), i.r.y(), i.r.width(), i.r.height(),
- view()->palette().active().color(QColorGroup::Base));
+ i.p->fillRect(i.r, view()->palette().active().color(QColorGroup::Base));
}
void RenderCanvas::repaintViewRectangle(const IntRect& ur, bool immediate)
if (m_view && ur.intersects(vr)) {
// We always just invalidate the root view, since we could be an iframe that is clipped out
// or even invisible.
- IntRect r = ur.intersect(vr);
+ IntRect r = intersection(ur, vr);
DOM::ElementImpl* elt = element()->getDocument()->ownerElement();
if (!elt)
m_view->repaintRectangle(r, immediate);
else {
// Subtract out the contentsX and contentsY offsets to get our coords within the viewing
// rectangle.
- r.setX(r.x() - m_view->contentsX());
- r.setY(r.y() - m_view->contentsY());
+ r.move(-m_view->contentsX(), -m_view->contentsY());
RenderObject* obj = elt->renderer();
int yFrameOffset = (m_view->frameStyle() != QFrame::NoFrame) ? 2 : 0;
int xFrameOffset = (m_view->frameStyle() != QFrame::NoFrame) ? 1 : 0;
- r.setX(r.x() + obj->borderLeft()+obj->paddingLeft() + xFrameOffset);
- r.setY(r.y() + obj->borderTop()+obj->paddingTop() + yFrameOffset);
+ r.move(obj->borderLeft() + obj->paddingLeft() + xFrameOffset,
+ obj->borderTop() + obj->paddingTop() + yFrameOffset);
obj->repaintRectangle(r, immediate);
}
}
void RenderCanvas::computeAbsoluteRepaintRect(IntRect& r, bool f)
{
- if (m_printingMode) return;
+ if (m_printingMode)
+ return;
- if (f && m_view) {
- r.setX(r.x() + m_view->contentsX());
- r.setY(r.y() + m_view->contentsY());
- }
+ if (f && m_view)
+ r.move(m_view->contentsX(), m_view->contentsY());
}
void RenderCanvas::absoluteRects(QValueList<IntRect>& rects, int _tx, int _ty)
SelectionMap::iterator end = selectedObjects.end();
for (SelectionMap::iterator i = selectedObjects.begin(); i != end; ++i) {
SelectionInfo* info = i->second;
- selRect = selRect.unite(info->rect());
+ selRect.unite(info->rect());
delete info;
}
return selRect;
QPainter::setCompositeOperation (p->currentContext(), oldOperation);
}
- if (drawSelectionTint) {
- Brush brush(selectionColor(p));
- IntRect selRect(selectionRect());
- p->fillRect(selRect.x(), selRect.y(), selRect.width(), selRect.height(), brush);
- }
+ if (drawSelectionTint)
+ p->fillRect(selectionRect(), selectionColor(p));
}
void RenderCanvasImage::layout()
int yPos = firstLineBox()->root()->selectionTop() - maximalOutlineSize(i.phase);
int h = maximalOutlineSize(i.phase) + lastLineBox()->root()->selectionTop() + lastLineBox()->root()->selectionHeight() - yPos;
yPos += _ty;
- if ((yPos >= i.r.y() + i.r.height()) || (yPos + h <= i.r.y()))
+ if (yPos >= i.r.bottom() || yPos + h <= i.r.y())
return;
// See if our root lines intersect with the dirty rect. If so, then we paint
// Try to avoid splitting a line vertically, but only if it's less than the height
// of the entire page.
if (curr->root()->bottomOverflow() - curr->root()->topOverflow() <= c->printRect().height()) {
- if (_ty + curr->root()->bottomOverflow() > c->printRect().y() + c->printRect().height()) {
+ if (_ty + curr->root()->bottomOverflow() > c->printRect().bottom()) {
if (_ty + curr->root()->topOverflow() < c->truncatedAt())
c->setBestTruncatedAt(_ty + curr->root()->topOverflow(), this);
// If we were able to truncate, don't paint.
int bottom = kMax(curr->root()->selectionTop() + curr->root()->selectionHeight(), curr->root()->bottomOverflow()) + maximalOutlineSize(i.phase);
h = bottom - top;
yPos = _ty + top;
- if ((yPos < i.r.y() + i.r.height()) && (yPos + h > i.r.y()))
+ if (yPos < i.r.bottom() && yPos + h > i.r.y())
curr->paint(i, _tx, _ty);
}
// cb->height() is inaccurate if we're in the middle of a layout of |cb|, so use the
// layer's size instead. Even if the layer's size is wrong, the layer itself will repaint
// anyway if its size does change.
- int x = r.left();
- int y = r.top();
+ int x = r.x();
+ int y = r.y();
IntRect boxRect(0, 0, cb->layer()->width(), cb->layer()->height());
- cb->layer()->subtractScrollOffset(x,y); // For overflow:auto/scroll/hidden.
+ cb->layer()->subtractScrollOffset(x, y); // For overflow:auto/scroll/hidden.
IntRect repaintRect(x, y, r.width(), r.height());
- r = repaintRect.intersect(boxRect);
+ r = intersection(repaintRect, boxRect);
}
cb->computeAbsoluteRepaintRect(r);
for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
if (!curr->isText()) {
IntRect childRect = curr->getAbsoluteRepaintRectWithOutline(ow);
- r = r.unite(childRect);
+ r.unite(childRect);
}
}
if (continuation() && !continuation()->isInline()) {
IntRect contRect = continuation()->getAbsoluteRepaintRectWithOutline(ow);
- r = r.unite(contRect);
+ r.unite(contRect);
}
}
QPtrList <IntRect> rects;
rects.setAutoDelete(true);
- rects.append(new IntRect(0,0,0,0));
+ rects.append(new IntRect);
for (InlineRunBox* curr = firstLineBox(); curr; curr = curr->nextLineBox()) {
rects.append(new IntRect(curr->xPos(), curr->yPos(), curr->width(), curr->height()));
}
- rects.append(new IntRect(0,0,0,0));
+ rects.append(new IntRect);
for (unsigned int i = 1; i < rects.count() - 1; i++)
paintOutlineForLine(p, _tx, _ty, *rects.at(i-1), *rects.at(i), *rects.at(i+1));
int offset = style()->outlineOffset();
- int t = ty + thisline.top() - offset;
- int l = tx + thisline.left() - offset;
- int b = ty + thisline.bottom() + offset + 1;
- int r = tx + thisline.right() + offset + 1;
+ int t = ty + thisline.y() - offset;
+ int l = tx + thisline.x() - offset;
+ int b = ty + thisline.bottom() + offset;
+ int r = tx + thisline.right() + offset;
// left edge
drawBorder(p,
l - ow,
- t - (lastline.isEmpty() || thisline.left() < lastline.left() || lastline.right() <= thisline.left() ? ow : 0),
+ t - (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.right() - 1) <= thisline.x() ? ow : 0),
l,
- b + (nextline.isEmpty() || thisline.left() <= nextline.left() || nextline.right() <= thisline.left() ? ow : 0),
+ b + (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.right() - 1) <= thisline.x() ? ow : 0),
BSLeft,
oc, style()->color(), os,
- (lastline.isEmpty() || thisline.left() < lastline.left() || lastline.right() <= thisline.left() ? ow : -ow),
- (nextline.isEmpty() || thisline.left() <= nextline.left() || nextline.right() <= thisline.left() ? ow : -ow),
+ (lastline.isEmpty() || thisline.x() < lastline.x() || (lastline.right() - 1) <= thisline.x() ? ow : -ow),
+ (nextline.isEmpty() || thisline.x() <= nextline.x() || (nextline.right() - 1) <= thisline.x() ? ow : -ow),
true);
// right edge
drawBorder(p,
r,
- t - (lastline.isEmpty() || lastline.right() < thisline.right() || thisline.right() <= lastline.left() ? ow : 0),
+ t - (lastline.isEmpty() || lastline.right() < thisline.right() || (thisline.right() - 1) <= lastline.x() ? ow : 0),
r + ow,
- b + (nextline.isEmpty() || nextline.right() <= thisline.right() || thisline.right() <= nextline.left() ? ow : 0),
+ b + (nextline.isEmpty() || nextline.right() <= thisline.right() || (thisline.right() - 1) <= nextline.x() ? ow : 0),
BSRight,
oc, style()->color(), os,
- (lastline.isEmpty() || lastline.right() < thisline.right() || thisline.right() <= lastline.left() ? ow : -ow),
- (nextline.isEmpty() || nextline.right() <= thisline.right() || thisline.right() <= nextline.left() ? ow : -ow),
+ (lastline.isEmpty() || lastline.right() < thisline.right() || (thisline.right() - 1) <= lastline.x() ? ow : -ow),
+ (nextline.isEmpty() || nextline.right() <= thisline.right() || (thisline.right() - 1) <= nextline.x() ? ow : -ow),
true);
// upper edge
- if ( thisline.left() < lastline.left())
+ if (thisline.x() < lastline.x())
drawBorder(p,
l - ow,
t - ow,
- kMin(r+ow, (lastline.isValid()? tx+lastline.left() : 1000000)),
+ kMin(r+ow, (lastline.isEmpty() ? 1000000 : tx + lastline.x())),
t ,
BSTop, oc, style()->color(), os,
ow,
- (lastline.isValid() && tx+lastline.left()+1<r+ow ? -ow : ow),
+ (!lastline.isEmpty() && tx + lastline.x() + 1 < r + ow) ? -ow : ow,
true);
if (lastline.right() < thisline.right())
drawBorder(p,
- kMax(lastline.isValid()?tx + lastline.right() + 1:-1000000, l - ow),
+ kMax(lastline.isEmpty() ? -1000000 : tx + lastline.right(), l - ow),
t - ow,
r + ow,
t ,
BSTop, oc, style()->color(), os,
- (lastline.isValid() && l-ow < tx+lastline.right()+1 ? -ow : ow),
+ (!lastline.isEmpty() && l - ow < tx + lastline.right()) ? -ow : ow,
ow,
true);
// lower edge
- if ( thisline.left() < nextline.left())
+ if (thisline.x() < nextline.x())
drawBorder(p,
l - ow,
b,
- kMin(r+ow, nextline.isValid()? tx+nextline.left()+1 : 1000000),
+ kMin(r + ow, !nextline.isEmpty() ? tx + nextline.x() + 1 : 1000000),
b + ow,
BSBottom, oc, style()->color(), os,
ow,
- (nextline.isValid() && tx+nextline.left()+1<r+ow? -ow : ow),
+ (!nextline.isEmpty() && tx + nextline.x() + 1 < r + ow) ? -ow : ow,
true);
if (nextline.right() < thisline.right())
drawBorder(p,
- kMax(nextline.isValid()?tx+nextline.right()+1:-1000000 , l-ow),
+ kMax(!nextline.isEmpty() ? tx + nextline.right() : -1000000, l - ow),
b,
r + ow,
b + ow,
BSBottom, oc, style()->color(), os,
- (nextline.isValid() && l-ow < tx+nextline.right()+1? -ow : ow),
+ (!nextline.isEmpty() && l - ow < tx + nextline.right()) ? -ow : ow,
ow,
true);
}
_ty += yOff - borderTopExtra();
int my = kMax(_ty, i.r.y());
- int end = kMin(i.r.y() + i.r.height(), _ty + h);
+ int end = kMin(i.r.bottom(), _ty + h);
int mh = end - my;
paintBackground(i.p, style()->backgroundColor(), style()->backgroundLayers(), my, mh, _tx, _ty, w, h);
int sw = element()->border();
int p = m_resizing ? (m_vSplit > -1 ? _x : _y) : -1;
if (m_vSplit > -1) {
- if ( m_oldpos >= 0 )
- v->updateContents( m_oldpos + sw/2 - rBord , r.y(), 2*rBord, r.height(), true );
- if ( p >= 0 ){
+ if (m_oldpos >= 0)
+ v->updateContents(m_oldpos + sw/2 - rBord, r.y(), 2 * rBord, r.height(), true );
+ if (p >= 0) {
paint.setPen(Pen::NoPen);
- paint.setBrush( Color::gray );
- v->setDrawingAlpha((float)0.25);
- paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
- v->setDrawingAlpha((float)1.0);
+ paint.setBrush(Color::gray);
+ v->setDrawingAlpha(0.25);
+ paint.drawRect(p + sw/2 - rBord, r.y(), 2*rBord, r.height());
+ v->setDrawingAlpha(1.0);
}
} else {
- if ( m_oldpos >= 0 )
- v->updateContents( r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord, true );
- if ( p >= 0 ){
+ if (m_oldpos >= 0)
+ v->updateContents(r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord, true);
+ if (p >= 0) {
paint.setPen(Pen::NoPen);
- paint.setBrush( Color::gray );
- v->setDrawingAlpha((float)0.25);
- paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
- v->setDrawingAlpha((float)1.0);
+ paint.setBrush(Color::gray);
+ v->setDrawingAlpha(0.25);
+ paint.drawRect(r.x(), p + sw/2 - rBord, r.width(), 2 * rBord);
+ v->setDrawingAlpha(1.0);
}
}
m_oldpos = p;
// Find the appropriate X coordinate to scroll to.
ScrollBehavior scrollX = getHiddenBehavior(alignX);
- int intersectWidth = visibleRect.intersect(exposeRect).width();
+ int intersectWidth = intersection(visibleRect, exposeRect).width();
// If the rectangle is fully visible, use the specified visible behavior.
// If the rectangle is partially visible, but over a certain threshold, then treat it as fully visible to avoid unnecessary horizontal scrolling
if (intersectWidth == w || intersectWidth >= MIN_INTERSECT_FOR_REVEAL)
x = visibleRect.x();
// If we're trying to align to the closest edge, and the exposeRect is further right than the visibleRect, and not bigger than the visible area, then alignRight.
else if ((scrollX == alignRight) || ((scrollX == alignToClosestEdge) && exposeRect.right() > visibleRect.right() && w < visibleRect.width()))
- x = exposeRect.right() - visibleRect.width();
+ x = (exposeRect.right() - 1) - visibleRect.width();
else if (scrollX == alignCenter)
x -= (visibleRect.width() - w) / 2;
// By default, x is set to the left of the exposeRect, so for the alignLeft case,
// Find the appropriate Y coordinate to scroll to.
ScrollBehavior scrollY = getHiddenBehavior(alignY);
- int intersectHeight = visibleRect.intersect(exposeRect).height();
+ int intersectHeight = intersection(visibleRect, exposeRect).height();
// If the rectangle is fully visible, use the specified visible behavior.
if (intersectHeight == h)
scrollY = getVisibleBehavior(alignY);
y = visibleRect.y();
// If we're trying to align to the closest edge, and the exposeRect is further down than the visibleRect, and not bigger than the visible area, then alignBottom.
else if ((scrollY == alignBottom) || ((scrollY == alignToClosestEdge) && exposeRect.bottom() > visibleRect.bottom() && h < visibleRect.height()))
- y = exposeRect.bottom() - visibleRect.height();
+ y = (exposeRect.bottom() - 1) - visibleRect.height();
else if (scrollY == alignCenter)
y -= (visibleRect.height() - h) / 2;
// By default, y is set to the top of the exposeRect, so for the alignTop case,
RenderLayer::positionScrollbars(const IntRect& absBounds)
{
if (m_vBar) {
- m_vBar->move(absBounds.x()+absBounds.width()-m_object->borderRight()-m_vBar->width(),
- absBounds.y()+m_object->borderTop());
- m_vBar->resize(m_vBar->width(), absBounds.height() -
- (m_object->borderTop()+m_object->borderBottom()) -
- (m_hBar ? m_hBar->height()-1 : 0));
+ m_vBar->move(absBounds.right() - m_object->borderRight() - m_vBar->width(),
+ absBounds.y() + m_object->borderTop());
+ m_vBar->resize(m_vBar->width(),
+ absBounds.height() - (m_object->borderTop() + m_object->borderBottom()) - (m_hBar ? m_hBar->height() - 1 : 0));
}
if (m_hBar) {
- m_hBar->move(absBounds.x()+m_object->borderLeft(),
- absBounds.y()+absBounds.height()-m_object->borderBottom()-m_hBar->height());
- m_hBar->resize(absBounds.width() - (m_object->borderLeft()+m_object->borderRight()) -
- (m_vBar ? m_vBar->width()-1 : 0),
- m_hBar->height());
+ m_hBar->move(absBounds.x() + m_object->borderLeft(),
+ absBounds.bottom() - m_object->borderBottom() - m_hBar->height());
+ m_hBar->resize(absBounds.width() - (m_object->borderLeft() + m_object->borderRight()) - (m_vBar ? m_vBar->width() - 1 : 0),
+ m_hBar->height());
}
}
if (m_object->hasOverflowClip()) {
IntRect newOverflowClip = m_object->getOverflowClipRect(x,y);
- overflowClipRect = newOverflowClip.intersect(overflowClipRect);
+ overflowClipRect.intersect(newOverflowClip);
if (m_object->isPositioned() || m_object->isRelPositioned())
- posClipRect = newOverflowClip.intersect(posClipRect);
+ posClipRect.intersect(newOverflowClip);
}
if (m_object->hasClip()) {
IntRect newPosClip = m_object->getClipRect(x,y);
- posClipRect = posClipRect.intersect(newPosClip);
- overflowClipRect = overflowClipRect.intersect(newPosClip);
- fixedClipRect = fixedClipRect.intersect(newPosClip);
+ posClipRect.intersect(newPosClip);
+ overflowClipRect.intersect(newPosClip);
+ fixedClipRect.intersect(newPosClip);
}
}
backgroundRect = m_object->style()->position() == FIXED ? parent()->clipRects()->fixedClipRect() :
(m_object->isPositioned() ? parent()->clipRects()->posClipRect() :
parent()->clipRects()->overflowClipRect());
- backgroundRect = backgroundRect.intersect(paintDirtyRect);
+ backgroundRect.intersect(paintDirtyRect);
} else
backgroundRect = paintDirtyRect;
foregroundRect = backgroundRect;
if (m_object->hasOverflowClip() || m_object->hasClip()) {
// This layer establishes a clip of some kind.
if (m_object->hasOverflowClip())
- foregroundRect = foregroundRect.intersect(m_object->getOverflowClipRect(x,y));
+ foregroundRect.intersect(m_object->getOverflowClipRect(x,y));
if (m_object->hasClip()) {
// Clip applies to *us* as well, so go ahead and update the damageRect.
IntRect newPosClip = m_object->getClipRect(x,y);
- backgroundRect = backgroundRect.intersect(newPosClip);
- foregroundRect = foregroundRect.intersect(newPosClip);
- outlineRect = outlineRect.intersect(newPosClip);
+ backgroundRect.intersect(newPosClip);
+ foregroundRect.intersect(newPosClip);
+ outlineRect.intersect(newPosClip);
}
// If we establish a clip at all, then go ahead and make sure our background
// rect is intersected with our layer's bounds.
- backgroundRect = backgroundRect.intersect(layerBounds);
+ backgroundRect.intersect(layerBounds);
}
}
void InlineFlowBox::paint(RenderObject::PaintInfo& i, int tx, int ty)
{
- bool intersectsDamageRect = true;
int xPos = tx + m_x - object()->maximalOutlineSize(i.phase);
int w = width() + 2 * object()->maximalOutlineSize(i.phase);
- if ((xPos >= i.r.x() + i.r.width()) || (xPos + w <= i.r.x()))
- intersectsDamageRect = false;
+ bool intersectsDamageRect = xPos < i.r.right() && xPos + w > i.r.x();
if (intersectsDamageRect) {
if (i.phase == PaintActionOutline) {
int my = kMax(_ty, i.r.y());
int mh;
if (_ty < i.r.y())
- mh= kMax(0, h - (i.r.y() - _ty));
+ mh = kMax(0, h - (i.r.y() - _ty));
else
mh = kMin(i.r.height(), h);
}
}
-bool EllipsisBox::nodeAtPoint(RenderObject::NodeInfo& info, int _x, int _y, int _tx, int _ty)
+bool EllipsisBox::nodeAtPoint(RenderObject::NodeInfo& info, int x, int y, int tx, int ty)
{
+ tx += m_x;
+ ty += m_y;
+
// Hit test the markup box.
if (m_markupBox) {
- _tx += m_x + m_width - m_markupBox->xPos();
- _ty += m_y + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
- if (m_markupBox->nodeAtPoint(info, _x, _y, _tx, _ty)) {
+ int mtx = tx + m_width - m_markupBox->xPos();
+ int mty = ty + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
+ if (m_markupBox->nodeAtPoint(info, x, y, mtx, mty)) {
object()->setInnerNode(info);
return true;
}
}
- IntRect rect(_tx + m_x, _ty + m_y, m_width, m_height);
- if (object()->style()->visibility() == VISIBLE && rect.contains(_x, _y)) {
+ if (object()->style()->visibility() == VISIBLE && IntRect(tx, ty, m_width, m_height).contains(x, y)) {
object()->setInnerNode(info);
return true;
}
+
return false;
}
_tx += m_x;
_ty += m_y;
- if ((_ty > i.r.y() + i.r.height()) || (_ty + m_height < i.r.y()))
+ if (_ty > i.r.bottom() || _ty + m_height < i.r.y())
return;
if (shouldPaintBackgroundOrBorder())
return;
RenderCanvas* c = canvas();
- if (_ty + m_height + paddingBottom() + borderBottom() >= c->printRect().y() + c->printRect().height()) {
+ if (_ty + m_height + paddingBottom() + borderBottom() >= c->printRect().bottom()) {
if (_ty < c->truncatedAt())
c->setBestTruncatedAt(_ty, this);
// Let's print this on the next page.
#include "CachedImage.h"
#include "DocumentImpl.h"
#include "EventNames.h"
+#include "FloatRect.h"
#include "Frame.h"
#include "FrameView.h"
#include "KWQAccObjectCache.h"
+#include "Pen.h"
+#include "RenderBlock.h"
+#include "RenderTable.h"
+#include "RenderTableCell.h"
+#include "RenderTableCol.h"
+#include "RenderTableRow.h"
#include "RenderText.h"
#include "cssstyleselector.h"
#include "dom2_eventsimpl.h"
#include "dom_elementimpl.h"
#include "dom_position.h"
-#include "visible_position.h"
#include "htmlnames.h"
#include "render_arena.h"
-#include "RenderBlock.h"
#include "render_canvas.h"
#include "render_flexbox.h"
#include "render_inline.h"
#include "render_line.h"
#include "render_list.h"
-#include "RenderTable.h"
-#include "RenderTableRow.h"
-#include "RenderTableCol.h"
-#include "RenderTableCell.h"
-
-#include <assert.h>
-#include <kdebug.h>
+#include "visible_position.h"
+#include <qmatrix.h>
#include <qpainter.h>
-#include "Pen.h"
#include <qtextcodec.h>
-#include <qwmatrix.h>
+#include <qtextstream.h>
namespace WebCore {
void RenderObject::operator delete(void* ptr, size_t sz)
{
- assert(baseOfRenderObjectBeingDeleted == ptr);
+ ASSERT(baseOfRenderObjectBeingDeleted == ptr);
// Stash size where destroy can find it.
*(size_t *)ptr = sz;
break;
case TABLE:
case INLINE_TABLE:
- //kdDebug( 6040 ) << "creating RenderTable" << endl;
o = new (arena) RenderTable(node);
break;
case TABLE_ROW_GROUP:
absoluteRects(rects, x, y);
if (rects.isEmpty())
- return IntRect(0, 0, 0, 0);
+ return IntRect();
QValueList<IntRect>::ConstIterator it = rects.begin();
IntRect result = *it;
- while (++it != rects.end()) {
- result = result.unite(*it);
- }
+ while (++it != rects.end())
+ result.unite(*it);
return result;
}
void RenderObject::addAbsoluteRectForLayer(IntRect& result)
{
- if (layer()) {
- result = result.unite(absoluteBoundingBoxRect());
- }
- for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
+ if (layer())
+ result.unite(absoluteBoundingBoxRect());
+ for (RenderObject* current = firstChild(); current; current = current->nextSibling())
current->addAbsoluteRectForLayer(result);
- }
}
IntRect RenderObject::paintingRootRect(IntRect& topLevelRect)
{
IntRect result = absoluteBoundingBoxRect();
topLevelRect = result;
- for (RenderObject* current = firstChild(); current; current = current->nextSibling()) {
+ for (RenderObject* current = firstChild(); current; current = current->nextSibling())
current->addAbsoluteRectForLayer(result);
- }
return result;
}
if (newBounds == oldBounds && !selfNeedsLayout())
return false;
- bool fullRepaint = selfNeedsLayout() || newBounds.x() != oldBounds.x() ||
- newBounds.y() != oldBounds.y() ||
- mustRepaintBackgroundOrBorder();
+ bool fullRepaint = selfNeedsLayout() || newBounds.location() != oldBounds.location() || mustRepaintBackgroundOrBorder();
if (fullRepaint) {
c->repaintViewRectangle(oldFullBounds);
if (newBounds != oldBounds)
c->repaintViewRectangle(newFullBounds);
- } else {
- // We didn't move, but we did change size. Invalidate the delta, which will consist of possibly
- // two rectangles (but typically only one).
- int width = abs(newBounds.width() - oldBounds.width());
- if (width)
- c->repaintViewRectangle(IntRect(kMin(newBounds.x() + newBounds.width(), oldBounds.x() + oldBounds.width()) - borderRight(),
- newBounds.y(),
- width + borderRight(),
- kMax(newBounds.height(), oldBounds.height())));
- int height = abs(newBounds.height() - oldBounds.height());
- if (height)
- c->repaintViewRectangle(IntRect(newBounds.x(),
- kMin(newBounds.y() + newBounds.height(), oldBounds.y() + oldBounds.height()) - borderBottom(),
- kMax(newBounds.width(), oldBounds.width()),
- height + borderBottom()));
- return false;
+ return true;
}
- return true;
+
+ // We didn't move, but we did change size. Invalidate the delta, which will consist of possibly
+ // two rectangles (but typically only one).
+ int width = abs(newBounds.width() - oldBounds.width());
+ if (width)
+ c->repaintViewRectangle(IntRect(kMin(newBounds.x() + newBounds.width(), oldBounds.x() + oldBounds.width()) - borderRight(),
+ newBounds.y(),
+ width + borderRight(),
+ kMax(newBounds.height(), oldBounds.height())));
+ int height = abs(newBounds.height() - oldBounds.height());
+ if (height)
+ c->repaintViewRectangle(IntRect(newBounds.x(),
+ kMin(newBounds.bottom(), oldBounds.bottom()) - borderBottom(),
+ kMax(newBounds.width(), oldBounds.width()),
+ height + borderBottom()));
+ return false;
}
void RenderObject::repaintDuringLayoutIfMoved(int x, int y)
IntRect RenderObject::getAbsoluteRepaintRectWithOutline(int ow)
{
IntRect r(getAbsoluteRepaintRect());
- r.setRect(r.x()-ow, r.y()-ow, r.width()+ow*2, r.height()+ow*2);
+ r.inflate(ow);
if (continuation() && !isInline())
- r.setRect(r.x(), r.y()-collapsedMarginTop(), r.width(), r.height()+collapsedMarginTop()+collapsedMarginBottom());
+ r.inflateY(collapsedMarginTop());
- if (isInlineFlow()) {
- for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling()) {
- if (!curr->isText()) {
- IntRect childRect = curr->getAbsoluteRepaintRectWithOutline(ow);
- r = r.unite(childRect);
- }
- }
- }
+ if (isInlineFlow())
+ for (RenderObject* curr = firstChild(); curr; curr = curr->nextSibling())
+ if (!curr->isText())
+ r.unite(curr->getAbsoluteRepaintRectWithOutline(ow));
return r;
}
return str;
}
-void RenderObject::printTree(int indent) const
-{
- QString ind;
- ind.fill(' ', indent);
-
- kdDebug() << ind << information() << endl;
-
- RenderObject *child = firstChild();
- while( child != 0 )
- {
- child->printTree(indent+2);
- child = child->nextSibling();
- }
-}
-
void RenderObject::dump(QTextStream *stream, QString ind) const
{
if (isAnonymous()) { *stream << " anonymous"; }
}
// somewhere up the render tree there must be an element!
- assert(node);
+ ASSERT(node);
return node;
}
}
int x, y;
- absolutePosition (x, y);
- region.bounds.setX (x + styleRegion.offset.left.value);
- region.bounds.setY (y + styleRegion.offset.top.value);
+ absolutePosition(x, y);
+ region.bounds.setX(x + styleRegion.offset.left.value);
+ region.bounds.setY(y + styleRegion.offset.top.value);
- regions.append (region);
+ regions.append(region);
}
}
}
#if SVG_SUPPORT
+FloatRect RenderObject::relativeBBox(bool) const
+{
+ return FloatRect();
+}
+
QMatrix RenderObject::localTransform() const
{
return QMatrix(1, 0, 0, 1, xPos(), yPos());
}
+void RenderObject::setLocalTransform(const QMatrix&)
+{
+ ASSERT(false);
+}
+
QMatrix RenderObject::absoluteTransform() const
{
if (parent())
#define render_object_h
#include "CachedObjectClient.h"
-#include "FloatRect.h"
#include "KWQScrollBar.h"
#include "NodeImpl.h"
#include "render_style.h"
class QTextStream;
class RenderArena;
-#if !NDEBUG
- #define KHTMLAssert(x) \
- if (!(x)) { \
- const RenderObject* o = this; \
- while (o->parent()) \
- o = o->parent(); \
- o->printTree(); \
- ASSERT(false); \
- }
-#else
- #define KHTMLAssert(x)
-#endif
+#define KHTMLAssert(x) ASSERT(x)
/*
* The painting of a layer occurs in three distinct phases. Each phase involves
namespace WebCore {
+class AffineTransform;
class Color;
class CollapsedBorderValue;
class DOMString;
class DocumentImpl;
class ElementImpl;
class EventImpl;
+class FloatRect;
class HTMLAreaElementImpl;
class InlineBox;
class InlineFlowBox;
class RenderFlow;
class RenderFrameSet;
class RenderLayer;
-class RenderStyle;
class RenderTable;
class RenderText;
class VisiblePosition;
virtual const char *renderName() const { return "RenderObject"; }
#if !NDEBUG
QString information() const;
- virtual void printTree(int indent=0) const;
virtual void dump(QTextStream *stream, QString ind = "") const;
void showTree() const;
static void showTree(const RenderObject *ro);
#if SVG_SUPPORT
virtual bool isKCanvasContainer() const { return false; }
virtual bool isRenderPath() const { return false; }
- virtual FloatRect relativeBBox(bool includeStroke = true) const { return FloatRect(); }
+ virtual FloatRect relativeBBox(bool includeStroke = true) const;
// We may eventually want to make these non-virtual
virtual QMatrix localTransform() const;
- virtual void setLocalTransform(const QMatrix&) { ASSERT(false); }
+ virtual void setLocalTransform(const QMatrix&);
virtual QMatrix absoluteTransform() const;
#endif
}
int os = 2*maximalOutlineSize(i.phase);
- if ((tx >= i.r.x() + i.r.width() + os) || (tx + m_width <= i.r.x() - os))
+ if (tx >= i.r.right() + os || tx + m_width <= i.r.x() - os)
return false;
- if ((top >= i.r.y() + i.r.height() + os) || (bottom <= i.r.y() - os))
+ if (top >= i.r.bottom() + os || bottom <= i.r.y() - os)
return false;
return true;
m_widget->paint(i.p, i.r);
// Paint a partially transparent wash over selected widgets.
- if (isSelected() && !i.p->printing()) {
- Brush brush(selectionColor(i.p));
- IntRect selRect(selectionRect());
- i.p->fillRect(selRect.x(), selRect.y(), selRect.width(), selRect.height(), brush);
- }
+ if (isSelected() && !i.p->printing())
+ i.p->fillRect(selectionRect(), selectionColor(i.p));
}
void RenderWidget::handleFocusOut()
if ([button bezelStyle] == NSRoundedBezelStyle) {
// Center the button within the available space.
if (inflatedRect.height() > size.height()) {
- inflatedRect.setX(inflatedRect.x() + (inflatedRect.height() - size.height())/2);
+ inflatedRect.setY(inflatedRect.y() + (inflatedRect.height() - size.height()) / 2);
inflatedRect.setHeight(size.height());
}