+2006-03-17 Eric Seidel <eseidel@apple.com>
+
+ Reviewed by darin.
+
+ Move Form code from MacFrame to Frame.
+ Move GraphicsContext code from GraphicsContextMac to GraphicsContext.
+ Use IntRect, FloatRect in more places throughout the code.
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=7824
+
+ * bridge/mac/MacFrame.h:
+ * bridge/mac/MacFrame.mm:
+ (WebCore::MacFrame::MacFrame):
+ (WebCore::MacFrame::searchForLabelsAboveCell):
+ (WebCore::MacFrame::searchForLabelsBeforeElement):
+ (WebCore::dictionaryFromHashMap):
+ (WebCore::MacFrame::submitForm):
+ (WebCore::MacFrame::setView):
+ (WebCore::MacFrame::currentEventIsMouseDownInWidget):
+ (WebCore::MacFrame::currentEventIsKeyboardOptionTab):
+ (WebCore::MacFrame::handleKeyboardOptionTabInView):
+ (WebCore::MacFrame::tabsToAllControls):
+ (WebCore::MacFrame::shouldDragAutoNode):
+ (WebCore::MacFrame::selectionImage):
+ (WebCore::MacFrame::snapshotDragImage):
+ * bridge/mac/WebCoreFrameBridge.mm:
+ (-[WebCoreFrameBridge nextKeyView]):
+ (-[WebCoreFrameBridge previousKeyView]):
+ (-[WebCoreFrameBridge nextKeyViewInsideWebFrameViews]):
+ (-[WebCoreFrameBridge previousKeyViewInsideWebFrameViews]):
+ * kcanvas/RenderSVGImage.cpp:
+ (WebCore::RenderSVGImage::paint):
+ * page/Frame.cpp:
+ (WebCore::Frame::Frame):
+ (WebCore::Frame::clearRecordedFormValues):
+ (WebCore::Frame::recordFormValue):
+ (WebCore::Frame::didNotOpenURL):
+ (WebCore::scanForForm):
+ (WebCore::Frame::paint):
+ (WebCore::Frame::prepareForUserAction):
+ * page/Frame.h:
+ * platform/GraphicsContext.cpp:
+ (WebCore::GraphicsContextState::GraphicsContextState):
+ (WebCore::GraphicsContextPrivate::GraphicsContextPrivate):
+ (WebCore::GraphicsContextPrivate::~GraphicsContextPrivate):
+ (WebCore::GraphicsContext::save):
+ (WebCore::GraphicsContext::restore):
+ (WebCore::GraphicsContext::font):
+ (WebCore::GraphicsContext::setFont):
+ (WebCore::GraphicsContext::pen):
+ (WebCore::GraphicsContext::setPen):
+ (WebCore::GraphicsContext::setBrush):
+ (WebCore::GraphicsContext::brush):
+ (WebCore::GraphicsContext::setUsesInactiveTextBackgroundColor):
+ (WebCore::GraphicsContext::usesInactiveTextBackgroundColor):
+ (WebCore::GraphicsContext::updatingControlTints):
+ (WebCore::GraphicsContext::setUpdatingControlTints):
+ (WebCore::GraphicsContext::setPaintingDisabled):
+ (WebCore::GraphicsContext::paintingDisabled):
+ (WebCore::GraphicsContext::printing):
+ (WebCore::GraphicsContext::drawImageAtPoint):
+ (WebCore::GraphicsContext::drawImageInRect):
+ (WebCore::GraphicsContext::drawImage):
+ (WebCore::GraphicsContext::initFocusRing):
+ (WebCore::GraphicsContext::clearFocusRing):
+ (WebCore::GraphicsContext::addFocusRingRect):
+ (WebCore::GraphicsContext::focusRingWidth):
+ (WebCore::GraphicsContext::focusRingOffset):
+ (WebCore::GraphicsContext::focusRingRects):
+ * platform/GraphicsContext.h:
+ * platform/mac/GraphicsContextMac.mm:
+ (WebCore::fillRectSourceOver):
+ (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
+ (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
+ (WebCore::GraphicsContext::GraphicsContext):
+ (WebCore::GraphicsContext::~GraphicsContext):
+ (WebCore::GraphicsContext::savePlatformState):
+ (WebCore::GraphicsContext::restorePlatformState):
+ (WebCore::GraphicsContext::drawRect):
+ (WebCore::GraphicsContext::setColorFromBrush):
+ (WebCore::GraphicsContext::setColorFromPen):
+ (WebCore::GraphicsContext::drawLine):
+ (WebCore::GraphicsContext::drawEllipse):
+ (WebCore::GraphicsContext::drawArc):
+ (WebCore::GraphicsContext::drawConvexPolygon):
+ (WebCore::GraphicsContext::drawFloatImage):
+ (WebCore::GraphicsContext::drawTiledImage):
+ (WebCore::GraphicsContext::drawScaledAndTiledImage):
+ (WebCore::GraphicsContext::selectedTextBackgroundColor):
+ (WebCore::GraphicsContext::fillRect):
+ (WebCore::GraphicsContext::addClip):
+ (WebCore::GraphicsContext::addRoundedRectClip):
+ (WebCore::GraphicsContext::beginTransparencyLayer):
+ (WebCore::GraphicsContext::endTransparencyLayer):
+ (WebCore::GraphicsContext::setShadow):
+ (WebCore::GraphicsContext::clearShadow):
+ (WebCore::GraphicsContext::drawFocusRing):
+ * rendering/render_box.cpp:
+ (WebCore::RenderBox::paintBackgroundExtended):
+ (WebCore::RenderBox::outlineBox):
+ * rendering/render_frames.cpp:
+ (WebCore::RenderFrameSet::userResize):
+ * rendering/render_image.cpp:
+ (WebCore::RenderImage::paint):
+ * rendering/render_list.cpp:
+ (WebCore::RenderListMarker::paint):
+ * rendering/render_object.cpp:
+ (WebCore::RenderObject::drawBorder):
+ (WebCore::RenderObject::paintBorderImage):
+
2006-03-19 Darin Adler <darin@apple.com>
Reviewed by Eric.
virtual bool passSubframeEventToSubframe(MouseEventWithHitTestResults &);
virtual bool passWheelEventToChildWidget(Node *);
- virtual void clearRecordedFormValues();
- virtual void recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element);
-
NSString *searchForLabelsAboveCell(RegularExpression *regExp, HTMLTableCellElement *cell);
NSString *searchForLabelsBeforeElement(NSArray *labels, Element *element);
NSString *matchLabelsAgainstElement(NSArray *labels, Element *element);
return true;
}
-void FrameMac::clearRecordedFormValues()
-{
- // It's safe to assume that our own classes and Foundation data
- // structures won't raise exceptions in dealloc
-
- KWQRelease(_formValuesAboutToBeSubmitted);
- _formValuesAboutToBeSubmitted = nil;
- KWQRelease(_formAboutToBeSubmitted);
- _formAboutToBeSubmitted = nil;
-}
-
-void FrameMac::recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element)
-{
- // It's safe to assume that our own classes and basic Foundation
- // data structures won't raise exceptions
-
- if (!_formValuesAboutToBeSubmitted) {
- _formValuesAboutToBeSubmitted = KWQRetainNSRelease([[NSMutableDictionary alloc] init]);
- ASSERT(!_formAboutToBeSubmitted);
- _formAboutToBeSubmitted = KWQRetain([DOMElement _elementWith:element]);
- } else {
- ASSERT([_formAboutToBeSubmitted _element] == element);
- }
- [_formValuesAboutToBeSubmitted setObject:value.getNSString() forKey:name.getNSString()];
-}
-
void FrameMac::submitForm(const ResourceRequest& request)
{
BEGIN_BLOCK_OBJC_EXCEPTIONS;
// The form multi-submit logic here is only needed when we are submitting a form that affects this frame.
// FIXME: Frame targeting is only one of the ways the submission could end up doing something other
// than replacing this frame's content, so this check is flawed. On the other hand, the check is hardly
- // needed any more now that we reset _submittedFormURL on each mouse or key down event.
+ // needed any more now that we reset d->m_submittedFormURL on each mouse or key down event.
WebCoreFrameBridge *target = request.frameName.isEmpty() ? _bridge : [_bridge findFrameNamed:request.frameName.getNSString()];
Frame *targetPart = [target impl];
bool willReplaceThisFrame = false;
}
}
if (willReplaceThisFrame) {
- if (_submittedFormURL == request.url()) {
+ if (d->m_submittedFormURL == request.url())
return;
- }
- _submittedFormURL = request.url();
+ d->m_submittedFormURL = request.url();
}
if (!request.doPost()) {
// Only one form submission is allowed per view of a part.
// Since this part may be getting reused as a result of being
// pulled from the back/forward cache, reset this flag.
- _submittedFormURL = KURL();
+ d->m_submittedFormURL = KURL();
}
void FrameMac::setTitle(const String &title)
NSImage *FrameMac::selectionImage() const
{
- _drawSelectionOnly = true; // invoke special drawing mode
+ d->m_drawSelectionOnly = true; // invoke special drawing mode
NSImage *result = imageFromRect(visibleSelectionRect());
- _drawSelectionOnly = false;
+ d->m_drawSelectionOnly = false;
return result;
}
NSImage *FrameMac::snapshotDragImage(Node *node, NSRect *imageRect, NSRect *elementRect) const
{
RenderObject *renderer = node->renderer();
- if (!renderer) {
+ if (!renderer)
return nil;
- }
renderer->updateDragState(true); // mark dragged nodes (so they pick up the right CSS)
d->m_doc->updateLayout(); // forces style recalc - needed since changing the drag state might
IntRect topLevelRect;
NSRect paintingRect = renderer->paintingRootRect(topLevelRect);
- _elementToDraw = node; // invoke special sub-tree drawing mode
+ d->m_elementToDraw = node; // invoke special sub-tree drawing mode
NSImage *result = imageFromRect(paintingRect);
renderer->updateDragState(false);
d->m_doc->updateLayout();
- _elementToDraw = 0;
+ d->m_elementToDraw = 0;
- if (elementRect) {
+ if (elementRect)
*elementRect = topLevelRect;
- }
- if (imageRect) {
+ if (imageRect)
*imageRect = paintingRect;
- }
return result;
}
ASSERT(!range || range->collapsed(exception) || range->startContainer(exception)->isTextNode());
if (attributes == nil) {
- m_markedTextUsesUnderlines = false;
- m_markedTextUnderlines.clear();
+ d->m_markedTextUsesUnderlines = false;
+ d->m_markedTextUnderlines.clear();
} else {
- m_markedTextUsesUnderlines = true;
- m_markedTextUnderlines = convertAttributesToUnderlines(range, attributes, ranges);
+ d->m_markedTextUsesUnderlines = true;
+ d->m_markedTextUnderlines = convertAttributesToUnderlines(range, attributes, ranges);
}
if (m_markedTextRange.get() && document() && m_markedTextRange->startContainer(exception)->renderer())
m_markedTextRange->startContainer(exception)->renderer()->repaint();
- if ( range && range->collapsed(exception) ) {
+ if (range && range->collapsed(exception))
m_markedTextRange = 0;
- } else {
+ else
m_markedTextRange = const_cast<Range *>(range);
- }
- if (m_markedTextRange.get() && document() && m_markedTextRange->startContainer(exception)->renderer()) {
+ if (m_markedTextRange.get() && document() && m_markedTextRange->startContainer(exception)->renderer())
m_markedTextRange->startContainer(exception)->renderer()->repaint();
- }
}
bool FrameMac::canGoBackOrForward(int distance) const
NSMutableDictionary *FrameMac::dashboardRegionsDictionary()
{
Document *doc = document();
- if (!doc) {
+ if (!doc)
return nil;
- }
const DeprecatedValueList<DashboardRegionValue> regions = doc->dashboardRegions();
unsigned i, count = regions.count();
- (NSView *)nextKeyView
{
Document *doc = m_frame->document();
- if (!doc) {
+ if (!doc)
return nil;
- }
return m_frame->nextKeyView(doc->focusNode(), KWQSelectingNext);
}
- (NSView *)previousKeyView
{
Document *doc = m_frame->document();
- if (!doc) {
+ if (!doc)
return nil;
- }
return m_frame->nextKeyView(doc->focusNode(), KWQSelectingPrevious);
}
- (NSView *)nextKeyViewInsideWebFrameViews
{
Document *doc = m_frame->document();
- if (!doc) {
+ if (!doc)
return nil;
- }
-
return m_frame->nextKeyViewInFrameHierarchy(doc->focusNode(), KWQSelectingNext);
}
- (NSView *)previousKeyViewInsideWebFrameViews
{
Document *doc = m_frame->document();
- if (!doc) {
+ if (!doc)
return nil;
- }
-
return m_frame->nextKeyViewInFrameHierarchy(doc->focusNode(), KWQSelectingPrevious);
}
FloatRect destRect(m_x, m_y, contentWidth(), contentHeight());
FloatRect srcRect(0, 0, image()->width(), image()->height());
adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()->baseVal());
- paintInfo.p->drawFloatImage(image(),
- destRect.x(), destRect.y(), destRect.width(), destRect.height(),
+ paintInfo.p->drawImage(image(), destRect,
srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(),
Image::CompositeSourceOver);
}
HTMLInputElement *input = static_cast<HTMLInputElement*>(current);
if (input->inputType() == HTMLInputElement::TEXT
|| input->inputType() == HTMLInputElement::PASSWORD
- || input->inputType() == HTMLInputElement::SEARCH)
- {
+ || input->inputType() == HTMLInputElement::SEARCH) {
frame->recordFormValue(input->name().deprecatedString(), input->value().deprecatedString(), this);
if (input->renderer() && input->inputType() == HTMLInputElement::SEARCH)
static_cast<RenderLineEdit*>(input->renderer())->addSearchResult();
}
if (needButtonActivation) {
- if (current->isActivatedSubmit()) {
+ if (current->isActivatedSubmit())
needButtonActivation = false;
- } else if (firstSuccessfulSubmitButton == 0 && current->isSuccessfulSubmitButton()) {
+ else if (firstSuccessfulSubmitButton == 0 && current->isSuccessfulSubmitButton())
firstSuccessfulSubmitButton = current;
- }
}
}
- if (needButtonActivation && firstSuccessfulSubmitButton) {
+ if (needButtonActivation && firstSuccessfulSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(true);
- }
if (!m_post)
m_multipart = false;
FormData form_data;
if (formData(form_data)) {
- if(m_post) {
- frame->submitForm( "post", m_url.deprecatedString(), form_data,
+ if(m_post)
+ frame->submitForm("post", m_url.deprecatedString(), form_data,
m_target.deprecatedString(),
enctype().deprecatedString(),
- boundary().deprecatedString() );
- }
- else {
- frame->submitForm( "get", m_url.deprecatedString(), form_data,
- m_target.deprecatedString() );
- }
+ boundary().deprecatedString());
+ else
+ frame->submitForm("get", m_url.deprecatedString(), form_data, m_target.deprecatedString());
}
- if (needButtonActivation && firstSuccessfulSubmitButton) {
+ if (needButtonActivation && firstSuccessfulSubmitButton)
firstSuccessfulSubmitButton->setActivatedSubmit(false);
- }
m_doingsubmit = m_insubmit = false;
}
-void HTMLFormElement::reset( )
+void HTMLFormElement::reset()
{
Frame *frame = getDocument()->frame();
- if(m_inreset || !frame) return;
+ if (m_inreset || !frame)
+ return;
m_inreset = true;
void HTMLFormElement::parseMappedAttribute(MappedAttribute *attr)
{
- if (attr->name() == actionAttr)
- {
+ if (attr->name() == actionAttr) {
bool oldURLWasSecure = formWouldHaveSecureSubmission(m_url);
m_url = WebCore::parseURL(attr->value());
bool newURLIsSecure = formWouldHaveSecureSubmission(m_url);
else
getDocument()->secureFormRemoved();
}
- else if (attr->name() == targetAttr) {
+ else if (attr->name() == targetAttr)
m_target = attr->value();
- } else if (attr->name() == methodAttr) {
+ else if (attr->name() == methodAttr) {
if (equalIgnoringCase(attr->value(), "post"))
m_post = true;
else if (equalIgnoringCase(attr->value(), "get"))
m_post = false;
- } else if (attr->name() == enctypeAttr) {
+ } else if (attr->name() == enctypeAttr)
parseEnctype(attr->value());
- } else if (attr->name() == accept_charsetAttr) {
+ else if (attr->name() == accept_charsetAttr)
// space separated list of charsets the server
// accepts - see rfc2045
m_acceptcharset = attr->value();
- } else if (attr->name() == acceptAttr) {
+ else if (attr->name() == acceptAttr) {
// ignore this one for the moment...
- } else if (attr->name() == autocompleteAttr) {
+ } else if (attr->name() == autocompleteAttr)
m_autocomplete = !equalIgnoringCase(attr->value(), "off");
- } else if (attr->name() == onsubmitAttr) {
+ else if (attr->name() == onsubmitAttr)
setHTMLEventListener(submitEvent, attr);
- } else if (attr->name() == onresetAttr) {
+ else if (attr->name() == onresetAttr)
setHTMLEventListener(resetEvent, attr);
- } else if (attr->name() == nameAttr) {
+ else if (attr->name() == nameAttr) {
String newNameAttr = attr->value();
if (inDocument() && getDocument()->isHTMLDocument()) {
HTMLDocument *document = static_cast<HTMLDocument *>(getDocument());
Frame::Frame(Page* page, RenderPart* ownerRenderer)
: d(new FramePrivate(page, parentFromOwnerRenderer(ownerRenderer), this, ownerRenderer))
- , _drawSelectionOnly(false)
- , m_markedTextUsesUnderlines(false)
- , m_windowHasFocus(false)
- , frameCount(0)
{
AtomicString::init();
Cache::init();
return frame;
}
+void Frame::clearRecordedFormValues()
+{
+ d->m_formAboutToBeSubmitted = 0;
+ d->m_formValuesAboutToBeSubmitted.clear();
+}
+
+void Frame::recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement> element)
+{
+ d->m_formAboutToBeSubmitted = element;
+ d->m_formValuesAboutToBeSubmitted.set(name, value);
+}
+
void Frame::submitFormAgain()
{
FramePrivate::SubmitForm* form = d->m_submitForm;
}
}
-
void Frame::parentCompleted()
{
if (d->m_scheduledRedirection != noRedirectionScheduled && !d->m_redirectionTimer.isActive())
void Frame::didNotOpenURL(const KURL &URL)
{
- if (_submittedFormURL == URL) {
- _submittedFormURL = KURL();
- }
+ if (d->m_submittedFormURL == URL)
+ d->m_submittedFormURL = KURL();
}
// Scans logically forward from "start", including any child frames
{
Node *n;
for (n = start; n; n = n->traverseNextNode()) {
- if (n->hasTagName(formTag)) {
+ if (n->hasTagName(formTag))
return static_cast<HTMLFormElement *>(n);
- } else if (n->isHTMLElement()
- && static_cast<HTMLElement *>(n)->isGenericFormElement()) {
- return static_cast<HTMLGenericFormElement *>(n)->form();
- } else if (n->hasTagName(frameTag) || n->hasTagName(iframeTag)) {
+ else if (n->isHTMLElement() && static_cast<HTMLElement*>(n)->isGenericFormElement())
+ return static_cast<HTMLGenericFormElement*>(n)->form();
+ else if (n->hasTagName(frameTag) || n->hasTagName(iframeTag)) {
Node *childDoc = static_cast<HTMLFrameElement *>(n)->contentDocument();
- HTMLFormElement *frameResult = scanForForm(childDoc);
- if (frameResult) {
+ if (HTMLFormElement *frameResult = scanForForm(childDoc))
return frameResult;
- }
}
}
return 0;
fillWithRed = false; // Subframe, don't fill with red.
else if (view() && view()->isTransparent())
fillWithRed = false; // Transparent, don't fill with red.
- else if (_drawSelectionOnly)
+ else if (d->m_drawSelectionOnly)
fillWithRed = false; // Selections are transparent, don't fill with red.
- else if (_elementToDraw)
+ else if (d->m_elementToDraw)
fillWithRed = false; // Element images are transparent, don't fill with red.
else
fillWithRed = true;
#endif
if (renderer()) {
- // _elementToDraw is used to draw only one element
- RenderObject *eltRenderer = _elementToDraw ? _elementToDraw->renderer() : 0;
- renderer()->layer()->paint(p, rect, _drawSelectionOnly, eltRenderer);
+ // d->m_elementToDraw is used to draw only one element
+ RenderObject *eltRenderer = d->m_elementToDraw ? d->m_elementToDraw->renderer() : 0;
+ renderer()->layer()->paint(p, rect, d->m_drawSelectionOnly, eltRenderer);
#if __APPLE__
// Regions may have changed as a result of the visibility/z-index of element changing.
void Frame::setWindowHasFocus(bool flag)
{
- if (m_windowHasFocus == flag)
+ if (d->m_windowHasFocus == flag)
return;
- m_windowHasFocus = flag;
+ d->m_windowHasFocus = flag;
if (Document *doc = document())
doc->dispatchWindowEvent(flag ? focusEvent : blurEvent, false, false);
bool Frame::markedTextUsesUnderlines() const
{
- return m_markedTextUsesUnderlines;
+ return d->m_markedTextUsesUnderlines;
}
DeprecatedValueList<MarkedTextUnderline> Frame::markedTextUnderlines() const
{
- return m_markedTextUnderlines;
+ return d->m_markedTextUnderlines;
}
unsigned Frame::highlightAllMatchesForString(const DeprecatedString &target, bool caseFlag)
{
// Reset the multiple form submission protection code.
// We'll let you submit the same form twice if you do two separate user actions.
- _submittedFormURL = KURL();
+ d->m_submittedFormURL = KURL();
}
Node *Frame::mousePressNode()
virtual DeprecatedString userAgent() const = 0;
virtual DeprecatedString incomingReferrer() const = 0;
virtual DeprecatedString mimeTypeForFileName(const DeprecatedString &) const = 0;
- virtual void clearRecordedFormValues() = 0;
- virtual void recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element) = 0;
virtual KJS::Bindings::Instance *getEmbedInstanceForWidget(Widget*) = 0;
virtual KJS::Bindings::Instance *getObjectInstanceForWidget(Widget*) = 0;
virtual KJS::Bindings::Instance *getAppletInstanceForWidget(Widget*) = 0;
// Currently, all this does is clear the "don't submit form twice" data member.
void prepareForUserAction();
Node *mousePressNode();
+
+ void clearRecordedFormValues();
+ void recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement>);
bool isComplete() const;
bool isLoadingMainResource() const;
private:
friend class FramePrivate;
FramePrivate* d;
-
- mutable RefPtr<Node> _elementToDraw;
- mutable bool _drawSelectionOnly;
- KURL _submittedFormURL;
- bool m_markedTextUsesUnderlines;
- DeprecatedValueList<MarkedTextUnderline> m_markedTextUnderlines;
- bool m_windowHasFocus;
- int frameCount;
};
}
, m_userStyleSheetLoader(0)
, m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
, m_autoscrollLayer(0)
+ , m_drawSelectionOnly(false)
+ , m_markedTextUsesUnderlines(false)
+ , m_windowHasFocus(false)
+ , frameCount(0)
{
}
Timer<Frame> m_autoscrollTimer;
RenderLayer* m_autoscrollLayer;
+
+ RefPtr<Node> m_elementToDraw;
+ bool m_drawSelectionOnly;
+
+ HashMap<String, String> m_formValuesAboutToBeSubmitted;
+ RefPtr<Element> m_formAboutToBeSubmitted;
+ KURL m_submittedFormURL;
+
+ bool m_markedTextUsesUnderlines;
+ DeprecatedValueList<MarkedTextUnderline> m_markedTextUnderlines;
+ bool m_windowHasFocus;
+
+ unsigned frameCount;
};
-
}
#endif
#include "config.h"
#include "GraphicsContext.h"
+#include "FloatRect.h"
+#include "Font.h"
#include "IntRect.h"
#include "DeprecatedString.h"
-#include "Font.h"
#include "Widget.h"
namespace WebCore {
+struct GraphicsContextState {
+ GraphicsContextState() : paintingDisabled(false) { }
+ Font font;
+ Pen pen;
+ Brush brush;
+ bool paintingDisabled;
+};
+
+struct GraphicsContextPrivate {
+ GraphicsContextPrivate(bool isForPrinting);
+
+ GraphicsContextState state;
+ Vector<GraphicsContextState> stack;
+ Vector<IntRect> m_focusRingRects;
+ int m_focusRingWidth;
+ int m_focusRingOffset;
+ bool m_isForPrinting;
+ bool m_usesInactiveTextBackgroundColor;
+ bool m_updatingControlTints;
+};
+
+GraphicsContextPrivate::GraphicsContextPrivate(bool isForPrinting)
+ : m_focusRingWidth(0)
+ , m_focusRingOffset(0)
+ , m_isForPrinting(isForPrinting)
+ , m_usesInactiveTextBackgroundColor(false)
+ , m_updatingControlTints(false)
+{
+}
+
+GraphicsContextPrivate* GraphicsContext::createGraphicsContextPrivate(bool isForPrinting)
+{
+ return new GraphicsContextPrivate(isForPrinting);
+}
+
+void GraphicsContext::destroyGraphicsContextPrivate(GraphicsContextPrivate* deleteMe)
+{
+ delete deleteMe;
+}
+
+void GraphicsContext::save()
+{
+ if (paintingDisabled())
+ return;
+
+ m_common->stack.append(m_common->state);
+
+ savePlatformState();
+}
+
+void GraphicsContext::restore()
+{
+ if (paintingDisabled())
+ return;
+
+ if (m_common->stack.isEmpty()) {
+ LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
+ return;
+ }
+ m_common->state = m_common->stack.last();
+ m_common->stack.removeLast();
+
+ restorePlatformState();
+}
+
+const Font& GraphicsContext::font() const
+{
+ return m_common->state.font;
+}
+
+void GraphicsContext::setFont(const Font& aFont)
+{
+ m_common->state.font = aFont;
+}
+
+const Pen& GraphicsContext::pen() const
+{
+ return m_common->state.pen;
+}
+
+void GraphicsContext::setPen(const Pen& pen)
+{
+ m_common->state.pen = pen;
+}
+
+void GraphicsContext::setPen(Pen::PenStyle style)
+{
+ m_common->state.pen.setStyle(style);
+ m_common->state.pen.setColor(Color::black);
+ m_common->state.pen.setWidth(0);
+}
+
+void GraphicsContext::setPen(RGBA32 rgb)
+{
+ m_common->state.pen.setStyle(Pen::SolidLine);
+ m_common->state.pen.setColor(rgb);
+ m_common->state.pen.setWidth(0);
+}
+
+void GraphicsContext::setBrush(const Brush& brush)
+{
+ m_common->state.brush = brush;
+}
+
+void GraphicsContext::setBrush(Brush::BrushStyle style)
+{
+ m_common->state.brush.setStyle(style);
+ m_common->state.brush.setColor(Color::black);
+}
+
+void GraphicsContext::setBrush(RGBA32 rgb)
+{
+ m_common->state.brush.setStyle(Brush::SolidPattern);
+ m_common->state.brush.setColor(rgb);
+}
+
+const Brush& GraphicsContext::brush() const
+{
+ return m_common->state.brush;
+}
+
+void GraphicsContext::setUsesInactiveTextBackgroundColor(bool u)
+{
+ m_common->m_usesInactiveTextBackgroundColor = u;
+}
+
+bool GraphicsContext::usesInactiveTextBackgroundColor() const
+{
+ return m_common->m_usesInactiveTextBackgroundColor;
+}
+
+bool GraphicsContext::updatingControlTints() const
+{
+ return m_common->m_updatingControlTints;
+}
+
+void GraphicsContext::setUpdatingControlTints(bool b)
+{
+ setPaintingDisabled(b);
+ m_common->m_updatingControlTints = b;
+}
+
+void GraphicsContext::setPaintingDisabled(bool f)
+{
+ m_common->state.paintingDisabled = f;
+}
+
+bool GraphicsContext::paintingDisabled() const
+{
+ return m_common->state.paintingDisabled;
+}
+
+bool GraphicsContext::printing() const
+{
+ return m_common->m_isForPrinting;
+}
+
void GraphicsContext::drawImageAtPoint(Image* image, const IntPoint& p, Image::CompositeOperator compositeOperator)
{
- drawImage(image, p.x(), p.y(), 0, 0, -1, -1, compositeOperator);
+ drawImage(image, p, 0, 0, -1, -1, compositeOperator);
}
void GraphicsContext::drawImageInRect(Image* image, const IntRect& r, Image::CompositeOperator compositeOperator)
{
- drawImage(image, r.x(), r.y(), r.width(), r.height(), 0, 0, -1, -1, compositeOperator);
+ drawImage(image, r, 0, 0, -1, -1, compositeOperator);
}
-void GraphicsContext::drawImage(Image* image, int x, int y,
+void GraphicsContext::drawImage(Image* image, const IntPoint& dest,
int sx, int sy, int sw, int sh, Image::CompositeOperator compositeOperator, void* context)
{
- drawImage(image, x, y, sw, sh, sx, sy, sw, sh, compositeOperator, context);
+ drawImage(image, IntRect(dest, IntSize(sw, sh)), sx, sy, sw, sh, compositeOperator, context);
}
-void GraphicsContext::drawImage(Image* image, int x, int y, int w, int h,
+void GraphicsContext::drawImage(Image* image, const IntRect& dest,
int sx, int sy, int sw, int sh, Image::CompositeOperator compositeOperator, void* context)
{
- drawFloatImage(image, (float)x, (float)y, (float)w, (float)h, (float)sx, (float)sy, (float)sw, (float)sh, compositeOperator, context);
+ drawImage(image, FloatRect(dest), (float)sx, (float)sy, (float)sw, (float)sh, compositeOperator, context);
}
// FIXME: We should consider removing this function and having callers just call the lower-level drawText directly.
return;
clearFocusRing();
- m_focusRingWidth = width;
- m_focusRingOffset = offset;
+ m_common->m_focusRingWidth = width;
+ m_common->m_focusRingOffset = offset;
}
void GraphicsContext::clearFocusRing()
{
- m_focusRingRects.clear();
+ m_common->m_focusRingRects.clear();
}
void GraphicsContext::addFocusRingRect(const IntRect& rect)
{
if (paintingDisabled())
return;
- m_focusRingRects.append(rect);
+ m_common->m_focusRingRects.append(rect);
+}
+
+int GraphicsContext::focusRingWidth() const
+{
+ return m_common->m_focusRingWidth;
+}
+
+int GraphicsContext::focusRingOffset() const
+{
+ return m_common->m_focusRingOffset;
+}
+
+const Vector<IntRect>& GraphicsContext::focusRingRects() const
+{
+ return m_common->m_focusRingRects;
}
}
class Font;
class GraphicsContextPrivate;
+ class GraphicsContextPlatformPrivate;
class IntPoint;
class IntPointArray;
void save();
void restore();
- void drawRect(int, int, int, int);
- void drawLine(int, int, int, int);
- void drawEllipse(int, int, int, int);
+ void drawRect(const IntRect&);
+ void drawLine(const IntPoint&, const IntPoint&);
+ void drawEllipse(const IntRect&);
void drawArc(int, int, int, int, int, int);
void drawConvexPolygon(const IntPointArray&);
- void fillRect(int, int, int, int, const Brush&);
void fillRect(const IntRect&, const Brush&);
void drawImageAtPoint(Image*, const IntPoint&, Image::CompositeOperator = Image::CompositeSourceOver);
void drawImageInRect(Image*, const IntRect&, Image::CompositeOperator = Image::CompositeSourceOver);
- void drawImage(Image*, int x, int y,
+ void drawImage(Image*, const IntPoint&,
int sx = 0, int sy = 0, int sw = -1, int sh = -1,
Image::CompositeOperator = Image::CompositeSourceOver,
void* nativeData = 0);
- void drawImage(Image*, int x, int y, int w, int h,
+ void drawImage(Image*, const IntRect&,
int sx = 0, int sy = 0, int sw = -1, int sh = -1,
Image::CompositeOperator = Image::CompositeSourceOver,
void* nativeData = 0);
- void drawFloatImage(Image*, float x, float y, float w, float h,
+ void drawImage(Image*, const FloatRect&,
float sx = 0, float sy = 0, float sw = -1, float sh = -1,
Image::CompositeOperator = Image::CompositeSourceOver,
void* nativeData = 0);
- void drawTiledImage(Image*, int, int, int, int, int sx = 0, int sy = 0, void* nativeData = 0);
- void drawScaledAndTiledImage(Image*, int, int, int, int, int, int, int, int,
+ void drawTiledImage(Image*, const IntRect& dest, int sx = 0, int sy = 0, void* nativeData = 0);
+ void drawScaledAndTiledImage(Image*, const IntRect&, int, int, int, int,
Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
void* nativeData = 0);
int misspellingLineThickness() const;
Color selectedTextBackgroundColor() const;
- void setUsesInactiveTextBackgroundColor(bool u) { m_usesInactiveTextBackgroundColor = u; }
+ void setUsesInactiveTextBackgroundColor(bool);
+ bool usesInactiveTextBackgroundColor() const;
bool paintingDisabled() const;
void setPaintingDisabled(bool);
- bool updatingControlTints() const { return m_updatingControlTints; }
- void setUpdatingControlTints(bool b) { setPaintingDisabled(b); m_updatingControlTints = b; }
+ bool updatingControlTints() const;
+ void setUpdatingControlTints(bool);
void beginTransparencyLayer(float opacity);
void endTransparencyLayer();
static KRenderingDevice* renderingDevice();
#endif
- bool printing() const { return m_isForPrinting; }
+ bool printing() const;
private:
void setColorFromBrush();
void setColorFromPen();
-
- GraphicsContextPrivate* m_data;
- Vector<IntRect> m_focusRingRects;
- int m_focusRingWidth;
- int m_focusRingOffset;
- bool m_isForPrinting;
- bool m_usesInactiveTextBackgroundColor;
- bool m_updatingControlTints;
+
+ void savePlatformState();
+ void restorePlatformState();
+
+ int focusRingWidth() const;
+ int focusRingOffset() const;
+ const Vector<IntRect>& focusRingRects() const;
+
+ static GraphicsContextPrivate* createGraphicsContextPrivate(bool isForPrinting = false);
+ static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
+
+ GraphicsContextPrivate* m_common;
+ GraphicsContextPlatformPrivate* m_data;
};
}
namespace WebCore {
-struct GraphicsContextState {
- GraphicsContextState() : paintingDisabled(false) { }
- Font font;
- Pen pen;
- Brush brush;
- bool paintingDisabled;
-};
-
-struct GraphicsContextPrivate {
- GraphicsContextPrivate();
- ~GraphicsContextPrivate();
+struct GraphicsContextPlatformPrivate {
+ GraphicsContextPlatformPrivate();
+ ~GraphicsContextPlatformPrivate();
- GraphicsContextState state;
- Vector<GraphicsContextState> stack;
cairo_t* context;
};
}
// A fillRect helper
-static inline void fillRectSourceOver(cairo_t* cr, float x, float y, float w, float h, const Color& col)
+static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const Color& col)
{
setColor(cr, col);
cairo_rectangle(cr, x, y, w, h);
cairo_fill(cr);
}
-GraphicsContextPrivate::GraphicsContextPrivate()
+GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
: context(0)
{
}
-GraphicsContextPrivate::~GraphicsContextPrivate()
+GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
{
cairo_destroy(context);
}
GraphicsContext::GraphicsContext(HDC dc)
- : m_data(new GraphicsContextPrivate)
- , m_isForPrinting(false)
- , m_usesInactiveTextBackgroundColor(false)
- , m_updatingControlTints(false)
+ : m_common(createGraphicsContextPrivate())
+ , m_data(new GraphicsContextPlatformPrivate)
{
cairo_surface_t* surface = cairo_win32_surface_create(dc);
m_data->context = cairo_create(surface);
}
GraphicsContext::GraphicsContext(cairo_t* context)
- : m_data(new GraphicsContextPrivate)
- , m_isForPrinting(false)
- , m_usesInactiveTextBackgroundColor(false)
- , m_updatingControlTints(false)
+ : m_common(createGraphicsContextPrivate())
+ , m_data(new GraphicsContextPlatformPrivate)
{
m_data->context = cairo_reference(context);
}
GraphicsContext::GraphicsContext(bool forPrinting)
- : m_data(new GraphicsContextPrivate)
- , m_isForPrinting(forPrinting)
- , m_usesInactiveTextBackgroundColor(false)
- , m_updatingControlTints(false)
+ : m_common(createGraphicsContextPrivate(forPrinting))
+ , m_data(new GraphicsContextPlatformPrivate)
{
}
GraphicsContext::~GraphicsContext()
{
+ destroyGraphicsContextPrivate(m_common);
delete m_data;
}
return m_data->context;
}
-const Pen& GraphicsContext::pen() const
-{
- return m_data->state.pen;
-}
-
-void GraphicsContext::setPen(const Pen& pen)
-{
- m_data->state.pen = pen;
-}
-
-void GraphicsContext::setPen(Pen::PenStyle style)
-{
- m_data->state.pen.setStyle(style);
- m_data->state.pen.setColor(Color::black);
- m_data->state.pen.setWidth(0);
-}
-
-void GraphicsContext::setPen(RGBA32 rgb)
+void GraphicsContext::savePlatformState()
{
- m_data->state.pen.setStyle(Pen::SolidLine);
- m_data->state.pen.setColor(rgb);
- m_data->state.pen.setWidth(0);
-}
-
-void GraphicsContext::setBrush(const Brush& brush)
-{
- m_data->state.brush = brush;
-}
-
-void GraphicsContext::setBrush(Brush::BrushStyle style)
-{
- m_data->state.brush.setStyle(style);
- m_data->state.brush.setColor(Color::black);
-}
-
-void GraphicsContext::setBrush(RGBA32 rgb)
-{
- m_data->state.brush.setStyle(Brush::SolidPattern);
- m_data->state.brush.setColor(rgb);
-}
-
-const Brush& GraphicsContext::brush() const
-{
- return m_data->state.brush;
-}
-
-const Font& GraphicsContext::font() const
-{
- return m_data->state.font;
-}
-
-void GraphicsContext::setFont(const Font& aFont)
-{
- m_data->state.font = aFont;
-}
-
-void GraphicsContext::save()
-{
- if (m_data->state.paintingDisabled)
- return;
-
- m_data->stack.append(m_data->state);
-
cairo_save(m_data->context);
}
-void GraphicsContext::restore()
+void GraphicsContext::restorePlatformState()
{
- if (m_data->state.paintingDisabled)
- return;
-
- if (m_data->stack.isEmpty()) {
- LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
- return;
- }
- m_data->state = m_data->stack.last();
- m_data->stack.removeLast();
-
cairo_restore(m_data->context);
}
// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(int x, int y, int w, int h)
+void GraphicsContext::drawRect(const IntRect& rect)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
cairo_t* context = m_data->context;
- if (m_data->state.brush.style() != Brush::NoBrush)
- fillRectSourceOver(context, x, y, w, h, m_data->state.brush.color());
+ if (brush().style() != Brush::NoBrush)
+ fillRectSourceOver(context, rect, brush().color());
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setColorFromPen();
- cairo_rectangle(context, x+.5, y+.5 , w-.5 , h-.5);
+ FloatRect r(rect);
+ r.inflate(-.5f);
+ cairo_rectangle(context, r.x(), r.y(), r.width(), r.height());
cairo_set_line_width(context, 1.0);
cairo_stroke(context);
}
void GraphicsContext::setColorFromBrush()
{
- setColor(m_data->context, m_data->state.brush.color());
+ setColor(m_data->context, brush().color());
}
void GraphicsContext::setColorFromPen()
{
- setColor(m_data->context, m_data->state.brush.color());
+ setColor(m_data->context, pen().color());
}
// FIXME: Now that this is refactored, it should be shared by all contexts.
}
// This is only used to draw borders.
-void GraphicsContext::drawLine(int x1, int y1, int x2, int y2)
+void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
cairo_t* context = m_data->context;
cairo_save(context);
- Pen::PenStyle penStyle = m_data->state.pen.style();
+ Pen::PenStyle penStyle = pen().style();
if (penStyle == Pen::NoPen)
return;
- float width = m_data->state.pen.width();
+ float width = pen().width();
if (width < 1)
width = 1;
- FloatPoint p1 = FloatPoint(x1, y1);
- FloatPoint p2 = FloatPoint(x2, y2);
+ FloatPoint p1 = point1;
+ FloatPoint p2 = point2;
+ bool isVerticalLine = (p1.x() == p2.x());
adjustLineToPixelBounderies(p1, p2, width, penStyle);
cairo_set_line_width(context, width);
// Do a rect fill of our endpoints. This ensures we always have the
// appearance of being a border. We then draw the actual dotted/dashed line.
if (x1 == x2) {
- fillRectSourceOver(context, p1.x()-width/2, p1.y()-width, width, width, m_data->state.pen.color());
- fillRectSourceOver(context, p2.x()-width/2, p2.y(), width, width, m_data->state.pen.color());
+ fillRectSourceOver(context, FloatRect(p1.x()-width/2, p1.y()-width, width, width), pen().color());
+ fillRectSourceOver(context, FloatRect(p2.x()-width/2, p2.y(), width, width), pen().color());
} else {
- fillRectSourceOver(context, p1.x()-width, p1.y()-width/2, width, width, m_data->state.pen.color());
- fillRectSourceOver(context, p2.x(), p2.y()-width/2, width, width, m_data->state.pen.color());
+ fillRectSourceOver(context, FloatRect(p1.x()-width, p1.y()-width/2, width, width), pen().color());
+ fillRectSourceOver(context, FloatRect(p2.x(), p2.y()-width/2, width, width), pen().color());
}
// Example: 80 pixels with a width of 30 pixels.
// Remainder is 20. The maximum pixels of line we could paint
// will be 50 pixels.
- int distance = ((x1 == x2) ? (y2 - y1) : (x2 - x1)) - 2*(int)width;
+ int distance = (isVerticalLine ? (p2.y() - p1.y()) : (p2.x() - p1.x())) - 2*(int)width;
int remainder = distance%patWidth;
int coverage = distance-remainder;
int numSegments = coverage/patWidth;
}
// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(int x, int y, int width, int height)
+void GraphicsContext::drawEllipse(const IntRect& rect)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
cairo_t* context = m_data->context;
cairo_save(context);
- float yRadius = .5 * height;
- float xRadius = .5 * width;
- cairo_translate(context, x + xRadius, y + yRadius);
+ float yRadius = .5 * rect.height();
+ float xRadius = .5 * rect.width();
+ cairo_translate(context, rect.x() + xRadius, rect.y() + yRadius);
cairo_scale(context, xRadius, yRadius);
cairo_arc(context, 0., 0., 1., 0., 2 * M_PI);
cairo_restore(context);
- if (m_data->state.brush.style() != Brush::NoBrush) {
+ if (brush().style() != Brush::NoBrush) {
setColorFromBrush();
cairo_fill(context);
}
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setColorFromPen();
- unsigned penWidth = m_data->state.pen.width();
+ unsigned penWidth = pen().width();
if (penWidth == 0)
penWidth++;
cairo_set_line_width(context, penWidth);
// Only supports arc on circles. That's all khtml needs.
ASSERT(w == h);
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
cairo_t* context = m_data->context;
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
float r = (float)w / 2;
float fa = (float)a / 16;
float falen = fa + (float)alen / 16;
cairo_arc(context, x + r, y + r, r, -fa * M_PI/180, -falen * M_PI/180);
setColorFromPen();
- cairo_set_line_width(context, m_data->state.pen.width());
+ cairo_set_line_width(context, pen().width());
cairo_stroke(context);
}
}
void GraphicsContext::drawConvexPolygon(const IntPointArray& points)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
int npoints = points.size();
cairo_line_to(context, points[i].x(), points[i].y());
cairo_close_path(context);
- if (m_data->state.brush.style() != Brush::NoBrush) {
+ if (brush().style() != Brush::NoBrush) {
setColorFromBrush();
cairo_set_fill_rule(context, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill(context);
}
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setColorFromPen();
- cairo_set_line_width(context, m_data->state.pen.width());
+ cairo_set_line_width(context, pen().width());
cairo_stroke(context);
}
cairo_restore(context);
}
-void GraphicsContext::drawFloatImage(Image* image, float x, float y, float w, float h,
+void GraphicsContext::drawImage(Image* image, const FloatRect& destRect,
float sx, float sy, float sw, float sh, Image::CompositeOperator compositeOperator, void* context)
{
if (!context)
context = m_data->context;
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
float tsw = sw;
float tsh = sh;
- float tw = w;
- float th = h;
-
+ FloatRect dest = destRect;
+
if (tsw == -1)
tsw = image->width();
if (tsh == -1)
tsh = image->height();
- if (tw == -1)
- tw = image->width();
- if (th == -1)
- th = image->height();
+ if (dest.width() == -1)
+ dest.setWidth(image->width());
+ if (dest.height() == -1)
+ dest.setHeight(image->height());
- image->drawInRect(FloatRect(x, y, tw, th), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
+ image->drawInRect(dest, FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
}
-void GraphicsContext::drawTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, void* context)
+void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, int sx, int sy, void* context)
{
if (!context)
context = m_data->context;
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- image->tileInRect(FloatRect(x, y, w, h), FloatPoint(sx, sy), context);
+ image->tileInRect(dest, FloatPoint(sx, sy), context);
}
-void GraphicsContext::drawScaledAndTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, int sw, int sh,
+void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh,
Image::TileRule hRule, Image::TileRule vRule, void* context)
{
if (!context)
context = m_data->context;
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
if (hRule == Image::StretchTile && vRule == Image::StretchTile)
// Just do a scale.
- return drawImage(image, x, y, w, h, sx, sy, sw, sh, Image::CompositeSourceOver, context);
+ return drawImage(image, dest, sx, sy, sw, sh, Image::CompositeSourceOver, context);
- image->scaleAndTileInRect(FloatRect(x, y, w, h), FloatRect(sx, sy, sw, sh), hRule, vRule, context);
+ image->scaleAndTileInRect(dest, FloatRect(sx, sy, sw, sh), hRule, vRule, context);
}
-void GraphicsContext::fillRect(int x, int y, int w, int h, const Brush& brush)
+void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
if (brush.style() == Brush::SolidPattern)
- fillRectSourceOver(m_data->context, x, y, w, h, brush.color());
+ fillRectSourceOver(m_data->context, rect, brush.color());
}
void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
void GraphicsContext::addClip(const IntRect& rect)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
cairo_t* context = m_data->context;
void GraphicsContext::setPaintingDisabled(bool f)
{
- m_data->state.paintingDisabled = f;
+ paintingDisabled() = f;
}
bool GraphicsContext::paintingDisabled() const
{
- return m_data->state.paintingDisabled;
+ return paintingDisabled();
}
void GraphicsContext::drawFocusRing(const Color& color)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
int radius = (m_focusRingWidth - 1) / 2;
int offset = radius + m_focusRingOffset;
// calls in this file are all exception-safe, so we don't block
// exceptions for those.
-struct GraphicsContextState {
- GraphicsContextState() : paintingDisabled(false) { }
- Font font;
- Pen pen;
- Brush brush;
- bool paintingDisabled;
-};
-
-struct GraphicsContextPrivate {
- GraphicsContextPrivate();
- ~GraphicsContextPrivate();
- GraphicsContextState state;
- Vector<GraphicsContextState> stack;
+struct GraphicsContextPlatformPrivate {
+ GraphicsContextPlatformPrivate();
+ ~GraphicsContextPlatformPrivate();
+
id <WebCoreTextRenderer> textRenderer;
Font textRendererFont;
#if SVG_SUPPORT
};
// A fillRect helper to work around the fact that NSRectFill uses copy mode, not source over.
-static inline void fillRectSourceOver(float x, float y, float w, float h, const Color& col)
+static inline void fillRectSourceOver(const FloatRect& rect, const Color& col)
{
[nsColor(col) set];
- NSRectFillUsingOperation(NSMakeRect(x, y, w, h), NSCompositeSourceOver);
+ NSRectFillUsingOperation(rect, NSCompositeSourceOver);
}
-
-GraphicsContextPrivate::GraphicsContextPrivate()
+GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
: textRenderer(0)
{
}
-GraphicsContextPrivate::~GraphicsContextPrivate()
+GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
{
KWQRelease(textRenderer);
}
GraphicsContext::GraphicsContext()
- : m_data(new GraphicsContextPrivate)
- , m_focusRingWidth(0)
- , m_focusRingOffset(0)
- , m_isForPrinting(false)
- , m_usesInactiveTextBackgroundColor(false)
- , m_updatingControlTints(false)
+ : m_common(createGraphicsContextPrivate())
+ , m_data(new GraphicsContextPlatformPrivate)
{
}
GraphicsContext::GraphicsContext(bool forPrinting)
- : m_data(new GraphicsContextPrivate)
- , m_focusRingWidth(0)
- , m_focusRingOffset(0)
- , m_isForPrinting(forPrinting)
- , m_usesInactiveTextBackgroundColor(false)
- , m_updatingControlTints(false)
+ : m_common(createGraphicsContextPrivate(forPrinting))
+ , m_data(new GraphicsContextPlatformPrivate)
{
}
GraphicsContext::~GraphicsContext()
{
+ destroyGraphicsContextPrivate(m_common);
delete m_data;
}
-const Font& GraphicsContext::font() const
-{
- return m_data->state.font;
-}
-
-void GraphicsContext::setFont(const Font& aFont)
-{
- m_data->state.font = aFont;
-}
-
-const Pen& GraphicsContext::pen() const
-{
- return m_data->state.pen;
-}
-
-void GraphicsContext::setPen(const Pen& pen)
-{
- m_data->state.pen = pen;
-}
-
-void GraphicsContext::setPen(Pen::PenStyle style)
-{
- m_data->state.pen.setStyle(style);
- m_data->state.pen.setColor(Color::black);
- m_data->state.pen.setWidth(0);
-}
-
-void GraphicsContext::setPen(RGBA32 rgb)
-{
- m_data->state.pen.setStyle(Pen::SolidLine);
- m_data->state.pen.setColor(rgb);
- m_data->state.pen.setWidth(0);
-}
-
-void GraphicsContext::setBrush(const Brush& brush)
-{
- m_data->state.brush = brush;
-}
-
-void GraphicsContext::setBrush(Brush::BrushStyle style)
-{
- m_data->state.brush.setStyle(style);
- m_data->state.brush.setColor(Color::black);
-}
-
-void GraphicsContext::setBrush(RGBA32 rgb)
-{
- m_data->state.brush.setStyle(Brush::SolidPattern);
- m_data->state.brush.setColor(rgb);
-}
-
-const Brush& GraphicsContext::brush() const
+void GraphicsContext::savePlatformState()
{
- return m_data->state.brush;
+ [NSGraphicsContext saveGraphicsState];
}
-void GraphicsContext::save()
+void GraphicsContext::restorePlatformState()
{
- if (m_data->state.paintingDisabled)
- return;
-
- m_data->stack.append(m_data->state);
-
- [NSGraphicsContext saveGraphicsState];
-}
-
-void GraphicsContext::restore()
-{
- if (m_data->state.paintingDisabled)
- return;
-
- if (m_data->stack.isEmpty()) {
- LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
- return;
- }
- m_data->state = m_data->stack.last();
- m_data->stack.removeLast();
-
[NSGraphicsContext restoreGraphicsState];
}
// Draws a filled rectangle with a stroked border.
-void GraphicsContext::drawRect(int x, int y, int w, int h)
+void GraphicsContext::drawRect(const IntRect& rect)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- if (m_data->state.brush.style() != Brush::NoBrush)
- fillRectSourceOver(x, y, w, h, m_data->state.brush.color());
+ if (brush().style() != Brush::NoBrush)
+ fillRectSourceOver(rect, brush().color());
- if (m_data->state.pen.style() != Pen::Pen::NoPen) {
+ if (pen().style() != Pen::Pen::NoPen) {
setColorFromPen();
- NSFrameRect(NSMakeRect(x, y, w, h));
+ NSFrameRect(rect);
}
}
void GraphicsContext::setColorFromBrush()
{
- [nsColor(m_data->state.brush.color()) set];
+ [nsColor(brush().color()) set];
}
void GraphicsContext::setColorFromPen()
{
- [nsColor(m_data->state.pen.color()) set];
+ [nsColor(pen().color()) set];
}
// This is only used to draw borders.
-void GraphicsContext::drawLine(int x1, int y1, int x2, int y2)
+void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- Pen::PenStyle penStyle = m_data->state.pen.style();
+ Pen::PenStyle penStyle = pen().style();
if (penStyle == Pen::Pen::NoPen)
return;
- float width = m_data->state.pen.width();
+ float width = pen().width();
if (width < 1)
width = 1;
- NSPoint p1 = NSMakePoint(x1, y1);
- NSPoint p2 = NSMakePoint(x2, y2);
+ NSPoint p1 = point1;
+ NSPoint p2 = point2;
+ bool isVerticalLine = (p1.x == p2.x);
// For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
// works out. For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
// (50+53)/2 = 103/2 = 51 when we want 51.5. It is always true that an even width gave
// us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
if (penStyle == Pen::DotLine || penStyle == Pen::DashLine) {
- if (x1 == x2) {
+ if (isVerticalLine) {
p1.y += width;
p2.y -= width;
- }
- else {
+ } else {
p1.x += width;
p2.x -= width;
}
}
if (((int)width)%2) {
- if (x1 == x2) {
+ if (isVerticalLine) {
// We're a vertical line. Adjust our x.
p1.x += 0.5;
p2.x += 0.5;
- }
- else {
+ } else {
// We're a horizontal line. Adjust our y.
p1.y += 0.5;
p2.y += 0.5;
if (patWidth) {
// Do a rect fill of our endpoints. This ensures we always have the
// appearance of being a border. We then draw the actual dotted/dashed line.
- if (x1 == x2) {
- fillRectSourceOver(p1.x-width/2, p1.y-width, width, width, m_data->state.pen.color());
- fillRectSourceOver(p2.x-width/2, p2.y, width, width, m_data->state.pen.color());
+ const Color& penColor = pen().color();
+ if (isVerticalLine) {
+ fillRectSourceOver(FloatRect(p1.x-width/2, p1.y-width, width, width), penColor);
+ fillRectSourceOver(FloatRect(p2.x-width/2, p2.y, width, width), penColor);
} else {
- fillRectSourceOver(p1.x-width, p1.y-width/2, width, width, m_data->state.pen.color());
- fillRectSourceOver(p2.x, p2.y-width/2, width, width, m_data->state.pen.color());
+ fillRectSourceOver(FloatRect(p1.x-width, p1.y-width/2, width, width), penColor);
+ fillRectSourceOver(FloatRect(p2.x, p2.y-width/2, width, width), penColor);
}
// Example: 80 pixels with a width of 30 pixels.
// Remainder is 20. The maximum pixels of line we could paint
// will be 50 pixels.
- int distance = ((x1 == x2) ? (y2 - y1) : (x2 - x1)) - 2*(int)width;
+ int distance = (isVerticalLine ? (int)(p2.y - p1.y) : (int)(p2.x - p1.x)) - 2*(int)width;
int remainder = distance%patWidth;
int coverage = distance-remainder;
int numSegments = coverage/patWidth;
// This method is only used to draw the little circles used in lists.
-void GraphicsContext::drawEllipse(int x, int y, int w, int h)
+void GraphicsContext::drawEllipse(const IntRect& rect)
{
// FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse.
// This code can only handle circles, not ellipses. But khtml only
// uses it for circles.
- ASSERT(w == h);
+ ASSERT(rect.width() == rect.height());
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextBeginPath(context);
- float r = (float)w / 2;
- CGContextAddArc(context, x + r, y + r, r, 0, 2*M_PI, true);
+ float r = (float)rect.width() / 2;
+ CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0, 2*M_PI, true);
CGContextClosePath(context);
- if (m_data->state.brush.style() != Brush::NoBrush) {
+ if (brush().style() != Brush::NoBrush) {
setColorFromBrush();
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
// stroke and fill
setColorFromPen();
- unsigned penWidth = m_data->state.pen.width();
+ unsigned penWidth = pen().width();
if (penWidth == 0)
penWidth++;
CGContextSetLineWidth(context, penWidth);
CGContextDrawPath(context, kCGPathFillStroke);
- } else {
+ } else
CGContextFillPath(context);
- }
}
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setColorFromPen();
- unsigned penWidth = m_data->state.pen.width();
+ unsigned penWidth = pen().width();
if (penWidth == 0)
penWidth++;
CGContextSetLineWidth(context, penWidth);
}
-void GraphicsContext::drawArc (int x, int y, int w, int h, int a, int alen)
+void GraphicsContext::drawArc(int x, int y, int w, int h, int a, int alen)
{
// Only supports arc on circles. That's all khtml needs.
ASSERT(w == h);
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextBeginPath(context);
CGContextAddArc(context, x + r, y + r, r, -fa * M_PI/180, -falen * M_PI/180, true);
setColorFromPen();
- CGContextSetLineWidth(context, m_data->state.pen.width());
+ CGContextSetLineWidth(context, pen().width());
CGContextStrokePath(context);
}
}
void GraphicsContext::drawConvexPolygon(const IntPointArray& points)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
int npoints = points.size();
CGContextAddLineToPoint(context, points[i].x(), points[i].y());
CGContextClosePath(context);
- if (m_data->state.brush.style() != Brush::NoBrush) {
+ if (brush().style() != Brush::NoBrush) {
setColorFromBrush();
CGContextEOFillPath(context);
}
- if (m_data->state.pen.style() != Pen::NoPen) {
+ if (pen().style() != Pen::NoPen) {
setColorFromPen();
- CGContextSetLineWidth(context, m_data->state.pen.width());
+ CGContextSetLineWidth(context, pen().width());
CGContextStrokePath(context);
}
[[WebCoreImageRendererFactory sharedFactory] setCGCompositeOperation:op inContext:context];
}
-void GraphicsContext::drawFloatImage(Image* image, float x, float y, float w, float h,
+void GraphicsContext::drawImage(Image* image, const FloatRect& dest,
float sx, float sy, float sw, float sh, Image::CompositeOperator compositeOperator, void* context)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
float tsw = sw;
float tsh = sh;
- float tw = w;
- float th = h;
+ float tw = dest.width();
+ float th = dest.height();
if (tsw == -1)
tsw = image->width();
if (th == -1)
th = image->height();
- image->drawInRect(FloatRect(x, y, tw, th), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
+ image->drawInRect(FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
}
-void GraphicsContext::drawTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, void* context)
+void GraphicsContext::drawTiledImage(Image* image, const IntRect& rect, int sx, int sy, void* context)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- image->tileInRect(FloatRect(x, y, w, h), FloatPoint(sx, sy), context);
+ image->tileInRect(rect, FloatPoint(sx, sy), context);
}
-void GraphicsContext::drawScaledAndTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, int sw, int sh,
+void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh,
Image::TileRule hRule, Image::TileRule vRule, void* context)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
if (hRule == Image::StretchTile && vRule == Image::StretchTile)
// Just do a scale.
- return drawImage(image, x, y, w, h, sx, sy, sw, sh, Image::CompositeSourceOver, context);
+ return drawImage(image, dest, sx, sy, sw, sh, Image::CompositeSourceOver, context);
- image->scaleAndTileInRect(FloatRect(x, y, w, h), FloatRect(sx, sy, sw, sh), hRule, vRule, context);
+ image->scaleAndTileInRect(dest, FloatRect(sx, sy, sw, sh), hRule, vRule, context);
}
static int getBlendedColorComponent(int c, int a)
Color GraphicsContext::selectedTextBackgroundColor() const
{
- NSColor *color = m_usesInactiveTextBackgroundColor ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
+ NSColor *color = usesInactiveTextBackgroundColor() ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
// this needs to always use device colorspace so it can de-calibrate the color for
// Color to possibly recalibrate it
color = [color colorUsingColorSpaceName:NSDeviceRGBColorSpace];
return col;
}
-void GraphicsContext::fillRect(int x, int y, int w, int h, const Brush& brush)
+void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
if (brush.style() == Brush::SolidPattern)
- fillRectSourceOver(x, y, w, h, brush.color());
-}
-
-void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
-{
- fillRect(rect.x(), rect.y(), rect.width(), rect.height(), brush);
+ fillRectSourceOver(rect, brush.color());
}
void GraphicsContext::addClip(const IntRect& rect)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
[NSBezierPath clipRect:rect];
void GraphicsContext::addRoundedRectClip(const IntRect& rect, const IntSize& topLeft, const IntSize& topRight,
const IntSize& bottomLeft, const IntSize& bottomRight)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
// Need sufficient width and height to contain these curves. Sanity check our top/bottom
CGContextClip(context);
}
-void GraphicsContext::setPaintingDisabled(bool f)
-{
- m_data->state.paintingDisabled = f;
-}
-
-bool GraphicsContext::paintingDisabled() const
-{
- return m_data->state.paintingDisabled;
-}
-
CGContextRef GraphicsContext::currentCGContext()
{
return (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
void GraphicsContext::beginTransparencyLayer(float opacity)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
CGContextRef context = currentCGContext();
CGContextSaveGState(context);
void GraphicsContext::endTransparencyLayer()
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
CGContextRef context = currentCGContext();
CGContextEndTransparencyLayer(context);
void GraphicsContext::setShadow(int x, int y, int blur, const Color& color)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
// Check for an invalid color, as this means that the color was not set for the shadow
// and we should therefore just use the default shadow color.
void GraphicsContext::clearShadow()
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
CGContextRef context = currentCGContext();
CGContextSetShadowWithColor(context, CGSizeZero, 0, NULL);
void GraphicsContext::drawFocusRing(const Color& color)
{
- if (m_data->state.paintingDisabled)
+ if (paintingDisabled())
return;
- int radius = (m_focusRingWidth - 1) / 2;
- int offset = radius + m_focusRingOffset;
+ int radius = (focusRingWidth() - 1) / 2;
+ int offset = radius + focusRingOffset();
CGColorRef colorRef = color.isValid() ? cgColor(color) : 0;
CGMutablePathRef focusRingPath = CGPathCreateMutable();
- unsigned rectCount = m_focusRingRects.size();
+ const Vector<IntRect>& rects = focusRingRects();
+ unsigned rectCount = rects.size();
for (unsigned i = 0; i < rectCount; i++)
- CGPathAddRect(focusRingPath, 0, CGRectInset(m_focusRingRects[i], -offset, -offset));
+ CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));
[[WebCoreGraphicsBridge sharedBridge] drawFocusRingWithPath:focusRingPath radius:radius color:colorRef];
CGColorRelease(colorRef);
// Paint the color first underneath all images.
if (!bgLayer->next() && bgColor.isValid() && bgColor.alpha() > 0) {
+ IntRect rect(_tx, clipy, w, cliph);
// If we have an alpha and we are painting the root element, go ahead and blend with white.
if (bgColor.alpha() < 0xFF && isRoot() && !canvas()->view()->isTransparent())
- p->fillRect(_tx, clipy, w, cliph, Color(Color::white));
- p->fillRect(_tx, clipy, w, cliph, bgColor);
+ p->fillRect(rect, Color(Color::white));
+ p->fillRect(rect, bgColor);
}
// no progressive loading of the background image
}
if (cw>0 && ch>0)
- p->drawTiledImage(bg->image(), cx, cy, cw, ch, sx, sy);
+ p->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), sx, sy);
}
if (bgLayer->backgroundClip() != BGBORDER)
p->restore(); // Undo the border radius clip
}
-void RenderBox::outlineBox(GraphicsContext* p, int _tx, int _ty, const char *color)
+void RenderBox::outlineBox(GraphicsContext* p, int _tx, int _ty, const char* color)
{
p->setPen(Pen(Color(color), 1, Pen::DotLine));
p->setBrush(WebCore::Brush::NoBrush);
- p->drawRect(_tx, _ty, m_width, m_height);
+ p->drawRect(IntRect(_tx, _ty, m_width, m_height));
}
IntRect RenderBox::getOverflowClipRect(int tx, int ty)
bool isPrinting = i.p->printing();
bool drawSelectionTint = isSelected() && !isPrinting;
if (i.phase == PaintActionSelection) {
- if (selectionState() == SelectionNone) {
+ if (selectionState() == SelectionNone)
return;
- }
drawSelectionTint = false;
}
if (!errorOccurred()) {
p->setPen (Color::lightGray);
p->setBrush (WebCore::Brush::NoBrush);
- p->drawRect (_tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight);
+ p->drawRect (IntRect(_tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight));
}
bool errorPictureDrawn = false;
{
case BSBottom:
case BSTop:
- p->drawLine(x1, (y1+y2)/2, x2, (y1+y2)/2);
+ p->drawLine(IntPoint(x1, (y1+y2)/2), IntPoint(x2, (y1+y2)/2));
break;
case BSRight:
case BSLeft:
- p->drawLine((x1+x2)/2, y1, (x1+x2)/2, y2);
+ p->drawLine(IntPoint((x1+x2)/2, y1), IntPoint((x1+x2)/2, y2));
break;
}
{
case BSTop:
case BSBottom:
- p->drawRect(x1, y1 , x2-x1, third);
- p->drawRect(x1, y2-third, x2-x1, third);
+ p->drawRect(IntRect(x1, y1 , x2-x1, third));
+ p->drawRect(IntRect(x1, y2-third, x2-x1, third));
break;
case BSLeft:
- p->drawRect(x1 , y1+1, third, y2-y1-1);
- p->drawRect(x2-third, y1+1, third, y2-y1-1);
+ p->drawRect(IntRect(x1 , y1+1, third, y2-y1-1));
+ p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
break;
case BSRight:
- p->drawRect(x1 , y1+1, third, y2-y1-1);
- p->drawRect(x2-third, y1+1, third, y2-y1-1);
+ p->drawRect(IntRect(x1 , y1+1, third, y2-y1-1));
+ p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
break;
}
}
else
{
int adjbw1bigthird;
- if (adjbw1>0) adjbw1bigthird = adjbw1+1;
- else adjbw1bigthird = adjbw1 - 1;
+ if (adjbw1>0)
+ adjbw1bigthird = adjbw1+1;
+ else
+ adjbw1bigthird = adjbw1 - 1;
adjbw1bigthird /= 3;
int adjbw2bigthird;
- if (adjbw2>0) adjbw2bigthird = adjbw2 + 1;
- else adjbw2bigthird = adjbw2 - 1;
+ if (adjbw2>0)
+ adjbw2bigthird = adjbw2 + 1;
+ else
+ adjbw2bigthird = adjbw2 - 1;
adjbw2bigthird /= 3;
switch(s)
p->setBrush(c);
ASSERT(x2 >= x1);
ASSERT(y2 >= y1);
- if (adjbw1==0 && adjbw2 == 0)
- {
- p->drawRect(x1,y1,x2-x1,y2-y1);
+ if (adjbw1==0 && adjbw2 == 0) {
+ p->drawRect(IntRect(x1,y1,x2-x1,y2-y1));
return;
- }
+ }
switch(s) {
case BSTop:
quad.setPoints(4,
// The top left corner rect is (_tx, _ty, leftWidth, topWidth)
// The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
if (drawTop)
- p->drawImage(borderImage->image(), _tx, _ty, style->borderLeftWidth(), style->borderTopWidth(),
+ p->drawImage(borderImage->image(), IntRect(_tx, _ty, style->borderLeftWidth(), style->borderTopWidth()),
0, 0, leftSlice, topSlice);
// The bottom left corner rect is (_tx, _ty + h - bottomWidth, leftWidth, bottomWidth)
// The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
if (drawBottom)
- p->drawImage(borderImage->image(), _tx, _ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth(),
+ p->drawImage(borderImage->image(), IntRect(_tx, _ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth()),
0, imageHeight - bottomSlice, leftSlice, bottomSlice);
// Paint the left edge.
// Have to scale and tile into the border rect.
- p->drawScaledAndTiledImage(borderImage->image(), _tx, _ty + style->borderTopWidth(), style->borderLeftWidth(),
- h - style->borderTopWidth() - style->borderBottomWidth(),
+ p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx, _ty + style->borderTopWidth(), style->borderLeftWidth(),
+ h - style->borderTopWidth() - style->borderBottomWidth()),
0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice,
Image::StretchTile, (Image::TileRule)vRule);
}
// The top right corner rect is (_tx + w - rightWidth, _ty, rightWidth, topWidth)
// The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
if (drawTop)
- p->drawImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty, style->borderRightWidth(), style->borderTopWidth(),
+ p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty, style->borderRightWidth(), style->borderTopWidth()),
imageWidth - rightSlice, 0, rightSlice, topSlice);
// The bottom right corner rect is (_tx + w - rightWidth, _ty + h - bottomWidth, rightWidth, bottomWidth)
// The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, botomSlice)
if (drawBottom)
- p->drawImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth(),
+ p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth()),
imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice);
// Paint the right edge.
- p->drawScaledAndTiledImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty + style->borderTopWidth(), style->borderRightWidth(),
- h - style->borderTopWidth() - style->borderBottomWidth(),
+ p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + style->borderTopWidth(), style->borderRightWidth(),
+ h - style->borderTopWidth() - style->borderBottomWidth()),
imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice,
Image::StretchTile, (Image::TileRule)vRule);
}
// Paint the top edge.
if (drawTop)
- p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty, w - style->borderLeftWidth() - style->borderRightWidth(),
- style->borderTopWidth(),
+ p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty, w - style->borderLeftWidth() - style->borderRightWidth(), style->borderTopWidth()),
leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice,
(Image::TileRule)hRule, Image::StretchTile);
// Paint the bottom edge.
if (drawBottom)
- p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty + h - style->borderBottomWidth(),
- w - style->borderLeftWidth() - style->borderRightWidth(),
- style->borderBottomWidth(),
+ p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + h - style->borderBottomWidth(),
+ w - style->borderLeftWidth() - style->borderRightWidth(), style->borderBottomWidth()),
leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice,
(Image::TileRule)hRule, Image::StretchTile);
// Paint the middle.
if (drawMiddle)
- p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
- h - style->borderTopWidth() - style->borderBottomWidth(),
+ p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
+ h - style->borderTopWidth() - style->borderBottomWidth()),
leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice,
(Image::TileRule)hRule, (Image::TileRule)vRule);
paint.setPen(Pen::NoPen);
paint.setBrush(Color::gray);
v->setDrawingAlpha(0.25);
- paint.drawRect(p + sw/2 - rBord, r.y(), 2*rBord, r.height());
+ paint.drawRect(IntRect(p + sw/2 - rBord, r.y(), 2 * rBord, r.height()));
v->setDrawingAlpha(1.0);
}
} else {
if (m_oldpos >= 0)
- v->updateContents(IntRect(r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord), true);
+ v->updateContents(IntRect(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(0.25);
- paint.drawRect(r.x(), p + sw/2 - rBord, r.width(), 2 * rBord);
+ paint.drawRect(IntRect(r.x(), p + sw/2 - rBord, r.width(), 2 * rBord));
v->setDrawingAlpha(1.0);
}
}
switch(style()->listStyleType()) {
case DISC:
p->setBrush(color);
- p->drawEllipse(marker.x(), marker.y(), marker.width(), marker.height());
+ p->drawEllipse(marker);
return;
case CIRCLE:
p->setBrush(WebCore::Brush::NoBrush);
- p->drawEllipse(marker.x(), marker.y(), marker.width(), marker.height());
+ p->drawEllipse(marker);
return;
case SQUARE:
p->setBrush(color);
- p->drawRect(marker.x(), marker.y(), marker.width(), marker.height());
+ p->drawRect(marker);
return;
case LNONE:
return;