Commit 44664ebc authored by darin's avatar darin

LayoutTests:

        - 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.

WebCore:

        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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@12476 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d8c22af3
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.
......
......@@ -14,30 +14,30 @@ layer at (90,990) size 1800x2
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.
......
......@@ -27,6 +27,7 @@
#define MacFrame_H
#include "Frame.h"
#include "IntRect.h"
#include "KWQClipboard.h"
#include "KWQScrollBar.h"
#include "NodeImpl.h"
......
......@@ -3042,7 +3042,7 @@ void MacFrame::setDisplaysWithFocusAttributes(bool flag)
// 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)
......@@ -3066,7 +3066,7 @@ void MacFrame::setDisplaysWithFocusAttributes(bool 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);
......
......@@ -972,7 +972,7 @@ static BOOL nowPrinting(WebCoreFrameBridge *self)
- (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];
}
......
......@@ -101,7 +101,7 @@ FloatRect KCanvasContainer::relativeBBox(bool includeStroke) const
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;
......
......@@ -92,11 +92,11 @@ FloatRect RenderPath::relativeBBox(bool includeStroke) const
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;
}
......
......@@ -114,7 +114,7 @@ IntRect RenderSVGImage::getAbsoluteRepaintRect()
// 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);
}
......
......@@ -79,7 +79,7 @@ KCanvasFilterQuartz::~KCanvasFilterQuartz()
void KCanvasFilterQuartz::prepareFilter(const FloatRect &bbox)
{
if (!bbox.isValid() || !KRenderingDeviceQuartz::filtersEnabled())
if (bbox.isEmpty() || !KRenderingDeviceQuartz::filtersEnabled())
return;
if (m_effects.isEmpty())
......@@ -105,7 +105,7 @@ void KCanvasFilterQuartz::prepareFilter(const FloatRect &bbox)
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.
......@@ -532,8 +532,8 @@ CIFilter *KCanvasFEFloodQuartz::getCIFilter(KCanvasFilterQuartz *quartzFilter) c
[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;
......@@ -559,7 +559,7 @@ CIFilter *KCanvasFEImageQuartz::getCIFilter(KCanvasFilterQuartz *quartzFilter) c
[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"];
......
......@@ -204,7 +204,7 @@ IntRect KCanvasItemQuartz::getAbsoluteRepaintRect()
// 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
......
......@@ -126,7 +126,7 @@ void KCanvasContainerQuartz::paint(PaintInfo &paintInfo, int parentX, int parent
parentX = parentY = 0;
}
if (viewport().isValid())
if (!viewport().isEmpty())
deviceContext->concatCTM(QMatrix().translate(viewport().x(), viewport().y()));
if (!localTransform().isIdentity())
......@@ -145,7 +145,7 @@ void KCanvasContainerQuartz::paint(PaintInfo &paintInfo, int parentX, int parent
if (filter)
filter->prepareFilter(relativeBBox(true));
if (!viewBox().isNull())
if (!viewBox().isEmpty())
deviceContext->concatCTM(viewportTransform());
RenderContainer::paint(paintInfo, 0, 0);
......@@ -196,7 +196,7 @@ KCAlign KCanvasContainerQuartz::align() const
QMatrix KCanvasContainerQuartz::viewportTransform() const
{
if (!viewBox().isNull()) {
if (!viewBox().isEmpty()) {
FloatRect viewportRect = viewport();
if (!parent()->isKCanvasContainer())
viewportRect = FloatRect(viewport().x(), viewport().y(), width(), height());
......@@ -210,12 +210,12 @@ IntRect KCanvasContainerQuartz::getAbsoluteRepaintRect()
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;
}
......
......@@ -21,35 +21,33 @@
#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>
......
......@@ -602,9 +602,9 @@ static JSValue *showModalDialog(ExecState *exec, Window *openerWindow, const Lis
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)) {
......@@ -617,7 +617,7 @@ static JSValue *showModalDialog(ExecState *exec, Window *openerWindow, const Lis
wargs.ySet = true;
}
}
wargs.dialog = true;
wargs.resizable = boolFeature(features, "resizable");
wargs.scrollBarsVisible = boolFeature(features, "scroll", true);
......@@ -737,24 +737,19 @@ JSValue *Window::getValueProperty(ExecState *exec, int token) const
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();
......@@ -1513,22 +1508,22 @@ static void parseWindowFeatures(const QString& features, WindowArgs& windowArgs)
}
}
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;
......@@ -1658,68 +1653,61 @@ JSValue *WindowFunc::callAsFunction(ExecState *exec, JSObject *thisObj, const Li
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();
......
......@@ -759,17 +759,15 @@ void SelectionController::layout()
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;
......@@ -781,7 +779,7 @@ IntRect SelectionController::caretRepaintRect() const
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()
......@@ -825,10 +823,9 @@ void SelectionController::paintCaret(QPainter *p, const IntRect &rect)
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
......
......@@ -75,19 +75,17 @@ bool HTMLAnchorElementImpl::isFocusable() 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()) {