Changeset 13396 in webkit


Ignore:
Timestamp:
Mar 19, 2006 11:30:24 PM (18 years ago)
Author:
eseidel
Message:

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):
Location:
trunk/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r13395 r13396  
     12006-03-17  Eric Seidel  <eseidel@apple.com>
     2
     3        Reviewed by darin.
     4
     5        Move Form code from MacFrame to Frame.
     6        Move GraphicsContext code from GraphicsContextMac to GraphicsContext.
     7        Use IntRect, FloatRect in more places throughout the code.
     8        http://bugzilla.opendarwin.org/show_bug.cgi?id=7824
     9
     10        * bridge/mac/MacFrame.h:
     11        * bridge/mac/MacFrame.mm:
     12        (WebCore::MacFrame::MacFrame):
     13        (WebCore::MacFrame::searchForLabelsAboveCell):
     14        (WebCore::MacFrame::searchForLabelsBeforeElement):
     15        (WebCore::dictionaryFromHashMap):
     16        (WebCore::MacFrame::submitForm):
     17        (WebCore::MacFrame::setView):
     18        (WebCore::MacFrame::currentEventIsMouseDownInWidget):
     19        (WebCore::MacFrame::currentEventIsKeyboardOptionTab):
     20        (WebCore::MacFrame::handleKeyboardOptionTabInView):
     21        (WebCore::MacFrame::tabsToAllControls):
     22        (WebCore::MacFrame::shouldDragAutoNode):
     23        (WebCore::MacFrame::selectionImage):
     24        (WebCore::MacFrame::snapshotDragImage):
     25        * bridge/mac/WebCoreFrameBridge.mm:
     26        (-[WebCoreFrameBridge nextKeyView]):
     27        (-[WebCoreFrameBridge previousKeyView]):
     28        (-[WebCoreFrameBridge nextKeyViewInsideWebFrameViews]):
     29        (-[WebCoreFrameBridge previousKeyViewInsideWebFrameViews]):
     30        * kcanvas/RenderSVGImage.cpp:
     31        (WebCore::RenderSVGImage::paint):
     32        * page/Frame.cpp:
     33        (WebCore::Frame::Frame):
     34        (WebCore::Frame::clearRecordedFormValues):
     35        (WebCore::Frame::recordFormValue):
     36        (WebCore::Frame::didNotOpenURL):
     37        (WebCore::scanForForm):
     38        (WebCore::Frame::paint):
     39        (WebCore::Frame::prepareForUserAction):
     40        * page/Frame.h:
     41        * platform/GraphicsContext.cpp:
     42        (WebCore::GraphicsContextState::GraphicsContextState):
     43        (WebCore::GraphicsContextPrivate::GraphicsContextPrivate):
     44        (WebCore::GraphicsContextPrivate::~GraphicsContextPrivate):
     45        (WebCore::GraphicsContext::save):
     46        (WebCore::GraphicsContext::restore):
     47        (WebCore::GraphicsContext::font):
     48        (WebCore::GraphicsContext::setFont):
     49        (WebCore::GraphicsContext::pen):
     50        (WebCore::GraphicsContext::setPen):
     51        (WebCore::GraphicsContext::setBrush):
     52        (WebCore::GraphicsContext::brush):
     53        (WebCore::GraphicsContext::setUsesInactiveTextBackgroundColor):
     54        (WebCore::GraphicsContext::usesInactiveTextBackgroundColor):
     55        (WebCore::GraphicsContext::updatingControlTints):
     56        (WebCore::GraphicsContext::setUpdatingControlTints):
     57        (WebCore::GraphicsContext::setPaintingDisabled):
     58        (WebCore::GraphicsContext::paintingDisabled):
     59        (WebCore::GraphicsContext::printing):
     60        (WebCore::GraphicsContext::drawImageAtPoint):
     61        (WebCore::GraphicsContext::drawImageInRect):
     62        (WebCore::GraphicsContext::drawImage):
     63        (WebCore::GraphicsContext::initFocusRing):
     64        (WebCore::GraphicsContext::clearFocusRing):
     65        (WebCore::GraphicsContext::addFocusRingRect):
     66        (WebCore::GraphicsContext::focusRingWidth):
     67        (WebCore::GraphicsContext::focusRingOffset):
     68        (WebCore::GraphicsContext::focusRingRects):
     69        * platform/GraphicsContext.h:
     70        * platform/mac/GraphicsContextMac.mm:
     71        (WebCore::fillRectSourceOver):
     72        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
     73        (WebCore::GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate):
     74        (WebCore::GraphicsContext::GraphicsContext):
     75        (WebCore::GraphicsContext::~GraphicsContext):
     76        (WebCore::GraphicsContext::savePlatformState):
     77        (WebCore::GraphicsContext::restorePlatformState):
     78        (WebCore::GraphicsContext::drawRect):
     79        (WebCore::GraphicsContext::setColorFromBrush):
     80        (WebCore::GraphicsContext::setColorFromPen):
     81        (WebCore::GraphicsContext::drawLine):
     82        (WebCore::GraphicsContext::drawEllipse):
     83        (WebCore::GraphicsContext::drawArc):
     84        (WebCore::GraphicsContext::drawConvexPolygon):
     85        (WebCore::GraphicsContext::drawFloatImage):
     86        (WebCore::GraphicsContext::drawTiledImage):
     87        (WebCore::GraphicsContext::drawScaledAndTiledImage):
     88        (WebCore::GraphicsContext::selectedTextBackgroundColor):
     89        (WebCore::GraphicsContext::fillRect):
     90        (WebCore::GraphicsContext::addClip):
     91        (WebCore::GraphicsContext::addRoundedRectClip):
     92        (WebCore::GraphicsContext::beginTransparencyLayer):
     93        (WebCore::GraphicsContext::endTransparencyLayer):
     94        (WebCore::GraphicsContext::setShadow):
     95        (WebCore::GraphicsContext::clearShadow):
     96        (WebCore::GraphicsContext::drawFocusRing):
     97        * rendering/render_box.cpp:
     98        (WebCore::RenderBox::paintBackgroundExtended):
     99        (WebCore::RenderBox::outlineBox):
     100        * rendering/render_frames.cpp:
     101        (WebCore::RenderFrameSet::userResize):
     102        * rendering/render_image.cpp:
     103        (WebCore::RenderImage::paint):
     104        * rendering/render_list.cpp:
     105        (WebCore::RenderListMarker::paint):
     106        * rendering/render_object.cpp:
     107        (WebCore::RenderObject::drawBorder):
     108        (WebCore::RenderObject::paintBorderImage):
     109
    11102006-03-19  Darin Adler  <darin@apple.com>
    2111
  • trunk/WebCore/bridge/mac/FrameMac.h

    r13393 r13396  
    233233    virtual bool passWheelEventToChildWidget(Node *);
    234234   
    235     virtual void clearRecordedFormValues();
    236     virtual void recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element);
    237 
    238235    NSString *searchForLabelsAboveCell(RegularExpression *regExp, HTMLTableCellElement *cell);
    239236    NSString *searchForLabelsBeforeElement(NSArray *labels, Element *element);
  • trunk/WebCore/bridge/mac/FrameMac.mm

    r13393 r13396  
    443443}
    444444
    445 void FrameMac::clearRecordedFormValues()
    446 {
    447     // It's safe to assume that our own classes and Foundation data
    448     // structures won't raise exceptions in dealloc
    449 
    450     KWQRelease(_formValuesAboutToBeSubmitted);
    451     _formValuesAboutToBeSubmitted = nil;
    452     KWQRelease(_formAboutToBeSubmitted);
    453     _formAboutToBeSubmitted = nil;
    454 }
    455 
    456 void FrameMac::recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element)
    457 {
    458     // It's safe to assume that our own classes and basic Foundation
    459     // data structures won't raise exceptions
    460 
    461     if (!_formValuesAboutToBeSubmitted) {
    462         _formValuesAboutToBeSubmitted = KWQRetainNSRelease([[NSMutableDictionary alloc] init]);
    463         ASSERT(!_formAboutToBeSubmitted);
    464         _formAboutToBeSubmitted = KWQRetain([DOMElement _elementWith:element]);
    465     } else {
    466         ASSERT([_formAboutToBeSubmitted _element] == element);
    467     }
    468     [_formValuesAboutToBeSubmitted setObject:value.getNSString() forKey:name.getNSString()];
    469 }
    470 
    471445void FrameMac::submitForm(const ResourceRequest& request)
    472446{
     
    482456    // FIXME: Frame targeting is only one of the ways the submission could end up doing something other
    483457    // than replacing this frame's content, so this check is flawed. On the other hand, the check is hardly
    484     // needed any more now that we reset _submittedFormURL on each mouse or key down event.
     458    // needed any more now that we reset d->m_submittedFormURL on each mouse or key down event.
    485459    WebCoreFrameBridge *target = request.frameName.isEmpty() ? _bridge : [_bridge findFrameNamed:request.frameName.getNSString()];
    486460    Frame *targetPart = [target impl];
     
    493467    }
    494468    if (willReplaceThisFrame) {
    495         if (_submittedFormURL == request.url()) {
     469        if (d->m_submittedFormURL == request.url())
    496470            return;
    497         }
    498         _submittedFormURL = request.url();
     471        d->m_submittedFormURL = request.url();
    499472    }
    500473
     
    630603    // Since this part may be getting reused as a result of being
    631604    // pulled from the back/forward cache, reset this flag.
    632     _submittedFormURL = KURL();
     605    d->m_submittedFormURL = KURL();
    633606}
    634607
     
    27062679NSImage *FrameMac::selectionImage() const
    27072680{
    2708     _drawSelectionOnly = true;  // invoke special drawing mode
     2681    d->m_drawSelectionOnly = true;  // invoke special drawing mode
    27092682    NSImage *result = imageFromRect(visibleSelectionRect());
    2710     _drawSelectionOnly = false;
     2683    d->m_drawSelectionOnly = false;
    27112684    return result;
    27122685}
     
    27152688{
    27162689    RenderObject *renderer = node->renderer();
    2717     if (!renderer) {
     2690    if (!renderer)
    27182691        return nil;
    2719     }
    27202692   
    27212693    renderer->updateDragState(true);    // mark dragged nodes (so they pick up the right CSS)
     
    27252697    NSRect paintingRect = renderer->paintingRootRect(topLevelRect);
    27262698
    2727     _elementToDraw = node;              // invoke special sub-tree drawing mode
     2699    d->m_elementToDraw = node;              // invoke special sub-tree drawing mode
    27282700    NSImage *result = imageFromRect(paintingRect);
    27292701    renderer->updateDragState(false);
    27302702    d->m_doc->updateLayout();
    2731     _elementToDraw = 0;
    2732 
    2733     if (elementRect) {
     2703    d->m_elementToDraw = 0;
     2704
     2705    if (elementRect)
    27342706        *elementRect = topLevelRect;
    2735     }
    2736     if (imageRect) {
     2707    if (imageRect)
    27372708        *imageRect = paintingRect;
    2738     }
    27392709    return result;
    27402710}
     
    33063276
    33073277    if (attributes == nil) {
    3308         m_markedTextUsesUnderlines = false;
    3309         m_markedTextUnderlines.clear();
     3278        d->m_markedTextUsesUnderlines = false;
     3279        d->m_markedTextUnderlines.clear();
    33103280    } else {
    3311         m_markedTextUsesUnderlines = true;
    3312         m_markedTextUnderlines = convertAttributesToUnderlines(range, attributes, ranges);
     3281        d->m_markedTextUsesUnderlines = true;
     3282        d->m_markedTextUnderlines = convertAttributesToUnderlines(range, attributes, ranges);
    33133283    }
    33143284
     
    33163286        m_markedTextRange->startContainer(exception)->renderer()->repaint();
    33173287
    3318     if ( range && range->collapsed(exception) ) {
     3288    if (range && range->collapsed(exception))
    33193289        m_markedTextRange = 0;
    3320     } else {
     3290    else
    33213291        m_markedTextRange = const_cast<Range *>(range);
    3322     }
    3323 
    3324     if (m_markedTextRange.get() && document() && m_markedTextRange->startContainer(exception)->renderer()) {
     3292
     3293    if (m_markedTextRange.get() && document() && m_markedTextRange->startContainer(exception)->renderer())
    33253294        m_markedTextRange->startContainer(exception)->renderer()->repaint();
    3326     }
    33273295}
    33283296
     
    33403308{
    33413309    Document *doc = document();
    3342     if (!doc) {
     3310    if (!doc)
    33433311        return nil;
    3344     }
    33453312
    33463313    const DeprecatedValueList<DashboardRegionValue> regions = doc->dashboardRegions();
  • trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm

    r13393 r13396  
    12631263{
    12641264    Document *doc = m_frame->document();
    1265     if (!doc) {
     1265    if (!doc)
    12661266        return nil;
    1267     }
    12681267    return m_frame->nextKeyView(doc->focusNode(), KWQSelectingNext);
    12691268}
     
    12721271{
    12731272    Document *doc = m_frame->document();
    1274     if (!doc) {
     1273    if (!doc)
    12751274        return nil;
    1276     }
    12771275    return m_frame->nextKeyView(doc->focusNode(), KWQSelectingPrevious);
    12781276}
     
    12811279{
    12821280    Document *doc = m_frame->document();
    1283     if (!doc) {
     1281    if (!doc)
    12841282        return nil;
    1285     }
    1286    
    12871283    return m_frame->nextKeyViewInFrameHierarchy(doc->focusNode(), KWQSelectingNext);
    12881284}
     
    12911287{
    12921288    Document *doc = m_frame->document();
    1293     if (!doc) {
     1289    if (!doc)
    12941290        return nil;
    1295     }
    1296 
    12971291    return m_frame->nextKeyViewInFrameHierarchy(doc->focusNode(), KWQSelectingPrevious);
    12981292}
  • trunk/WebCore/kcanvas/RenderSVGImage.cpp

    r13393 r13396  
    171171        FloatRect srcRect(0, 0, image()->width(), image()->height());
    172172        adjustRectsForAspectRatio(destRect, srcRect, imageElt->preserveAspectRatio()->baseVal());
    173         paintInfo.p->drawFloatImage(image(),
    174                                     destRect.x(), destRect.y(), destRect.width(), destRect.height(),
     173        paintInfo.p->drawImage(image(), destRect,
    175174                                    srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(),
    176175                                    Image::CompositeSourceOver);
  • trunk/WebCore/khtml/html/HTMLFormElement.cpp

    r13393 r13396  
    353353            if (input->inputType() == HTMLInputElement::TEXT
    354354                || input->inputType() ==  HTMLInputElement::PASSWORD
    355                 || input->inputType() == HTMLInputElement::SEARCH)
    356             {
     355                || input->inputType() == HTMLInputElement::SEARCH) {
    357356                frame->recordFormValue(input->name().deprecatedString(), input->value().deprecatedString(), this);
    358357                if (input->renderer() && input->inputType() == HTMLInputElement::SEARCH)
     
    362361
    363362        if (needButtonActivation) {
    364             if (current->isActivatedSubmit()) {
     363            if (current->isActivatedSubmit())
    365364                needButtonActivation = false;
    366             } else if (firstSuccessfulSubmitButton == 0 && current->isSuccessfulSubmitButton()) {
     365            else if (firstSuccessfulSubmitButton == 0 && current->isSuccessfulSubmitButton())
    367366                firstSuccessfulSubmitButton = current;
    368             }
    369         }
    370     }
    371 
    372     if (needButtonActivation && firstSuccessfulSubmitButton) {
     367        }
     368    }
     369
     370    if (needButtonActivation && firstSuccessfulSubmitButton)
    373371        firstSuccessfulSubmitButton->setActivatedSubmit(true);
    374     }
    375372
    376373    if (!m_post)
     
    379376    FormData form_data;
    380377    if (formData(form_data)) {
    381         if(m_post) {
    382             frame->submitForm( "post", m_url.deprecatedString(), form_data,
     378        if(m_post)
     379            frame->submitForm("post", m_url.deprecatedString(), form_data,
    383380                                      m_target.deprecatedString(),
    384381                                      enctype().deprecatedString(),
    385                                       boundary().deprecatedString() );
    386         }
    387         else {
    388             frame->submitForm( "get", m_url.deprecatedString(), form_data,
    389                                       m_target.deprecatedString() );
    390         }
    391     }
    392 
    393     if (needButtonActivation && firstSuccessfulSubmitButton) {
     382                                      boundary().deprecatedString());
     383        else
     384            frame->submitForm("get", m_url.deprecatedString(), form_data, m_target.deprecatedString());
     385    }
     386
     387    if (needButtonActivation && firstSuccessfulSubmitButton)
    394388        firstSuccessfulSubmitButton->setActivatedSubmit(false);
    395     }
    396389   
    397390    m_doingsubmit = m_insubmit = false;
    398391}
    399392
    400 void HTMLFormElement::reset(  )
     393void HTMLFormElement::reset()
    401394{
    402395    Frame *frame = getDocument()->frame();
    403     if(m_inreset || !frame) return;
     396    if (m_inreset || !frame)
     397        return;
    404398
    405399    m_inreset = true;
     
    420414void HTMLFormElement::parseMappedAttribute(MappedAttribute *attr)
    421415{
    422     if (attr->name() == actionAttr)
    423     {
     416    if (attr->name() == actionAttr) {
    424417        bool oldURLWasSecure = formWouldHaveSecureSubmission(m_url);
    425418        m_url = WebCore::parseURL(attr->value());
     
    432425                getDocument()->secureFormRemoved();
    433426    }
    434     else if (attr->name() == targetAttr) {
     427    else if (attr->name() == targetAttr)
    435428        m_target = attr->value();
    436     } else if (attr->name() == methodAttr) {
     429    else if (attr->name() == methodAttr) {
    437430        if (equalIgnoringCase(attr->value(), "post"))
    438431            m_post = true;
    439432        else if (equalIgnoringCase(attr->value(), "get"))
    440433            m_post = false;
    441     } else if (attr->name() == enctypeAttr) {
     434    } else if (attr->name() == enctypeAttr)
    442435        parseEnctype(attr->value());
    443     } else if (attr->name() == accept_charsetAttr) {
     436    else if (attr->name() == accept_charsetAttr)
    444437        // space separated list of charsets the server
    445438        // accepts - see rfc2045
    446439        m_acceptcharset = attr->value();
    447     } else if (attr->name() == acceptAttr) {
     440    else if (attr->name() == acceptAttr) {
    448441        // ignore this one for the moment...
    449     } else if (attr->name() == autocompleteAttr) {
     442    } else if (attr->name() == autocompleteAttr)
    450443        m_autocomplete = !equalIgnoringCase(attr->value(), "off");
    451     } else if (attr->name() == onsubmitAttr) {
     444    else if (attr->name() == onsubmitAttr)
    452445        setHTMLEventListener(submitEvent, attr);
    453     } else if (attr->name() == onresetAttr) {
     446    else if (attr->name() == onresetAttr)
    454447        setHTMLEventListener(resetEvent, attr);
    455     } else if (attr->name() == nameAttr) {
     448    else if (attr->name() == nameAttr) {
    456449        String newNameAttr = attr->value();
    457450        if (inDocument() && getDocument()->isHTMLDocument()) {
  • trunk/WebCore/page/Frame.cpp

    r13393 r13396  
    147147Frame::Frame(Page* page, RenderPart* ownerRenderer)
    148148    : d(new FramePrivate(page, parentFromOwnerRenderer(ownerRenderer), this, ownerRenderer))
    149     , _drawSelectionOnly(false)
    150     , m_markedTextUsesUnderlines(false)
    151     , m_windowHasFocus(false)
    152     , frameCount(0)
    153149{
    154150    AtomicString::init();
     
    14661462}
    14671463
     1464void Frame::clearRecordedFormValues()
     1465{
     1466    d->m_formAboutToBeSubmitted = 0;
     1467    d->m_formValuesAboutToBeSubmitted.clear();
     1468}
     1469
     1470void Frame::recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement> element)
     1471{
     1472    d->m_formAboutToBeSubmitted = element;
     1473    d->m_formValuesAboutToBeSubmitted.set(name, value);
     1474}
     1475
    14681476void Frame::submitFormAgain()
    14691477{
     
    15701578  }
    15711579}
    1572 
    15731580
    15741581void Frame::parentCompleted()
     
    25702577void Frame::didNotOpenURL(const KURL &URL)
    25712578{
    2572     if (_submittedFormURL == URL) {
    2573         _submittedFormURL = KURL();
    2574     }
     2579    if (d->m_submittedFormURL == URL)
     2580        d->m_submittedFormURL = KURL();
    25752581}
    25762582
     
    25802586    Node *n;
    25812587    for (n = start; n; n = n->traverseNextNode()) {
    2582         if (n->hasTagName(formTag)) {
     2588        if (n->hasTagName(formTag))
    25832589            return static_cast<HTMLFormElement *>(n);
    2584         } else if (n->isHTMLElement()
    2585                    && static_cast<HTMLElement *>(n)->isGenericFormElement()) {
    2586             return static_cast<HTMLGenericFormElement *>(n)->form();
    2587         } else if (n->hasTagName(frameTag) || n->hasTagName(iframeTag)) {
     2590        else if (n->isHTMLElement() && static_cast<HTMLElement*>(n)->isGenericFormElement())
     2591            return static_cast<HTMLGenericFormElement*>(n)->form();
     2592        else if (n->hasTagName(frameTag) || n->hasTagName(iframeTag)) {
    25882593            Node *childDoc = static_cast<HTMLFrameElement *>(n)->contentDocument();
    2589             HTMLFormElement *frameResult = scanForForm(childDoc);
    2590             if (frameResult) {
     2594            if (HTMLFormElement *frameResult = scanForForm(childDoc))
    25912595                return frameResult;
    2592             }
    25932596        }
    25942597    }
     
    27282731    else if (view() && view()->isTransparent())
    27292732        fillWithRed = false; // Transparent, don't fill with red.
    2730     else if (_drawSelectionOnly)
     2733    else if (d->m_drawSelectionOnly)
    27312734        fillWithRed = false; // Selections are transparent, don't fill with red.
    2732     else if (_elementToDraw)
     2735    else if (d->m_elementToDraw)
    27332736        fillWithRed = false; // Element images are transparent, don't fill with red.
    27342737    else
     
    27402743   
    27412744    if (renderer()) {
    2742         // _elementToDraw is used to draw only one element
    2743         RenderObject *eltRenderer = _elementToDraw ? _elementToDraw->renderer() : 0;
    2744         renderer()->layer()->paint(p, rect, _drawSelectionOnly, eltRenderer);
     2745        // d->m_elementToDraw is used to draw only one element
     2746        RenderObject *eltRenderer = d->m_elementToDraw ? d->m_elementToDraw->renderer() : 0;
     2747        renderer()->layer()->paint(p, rect, d->m_drawSelectionOnly, eltRenderer);
    27452748
    27462749#if __APPLE__
     
    32163219void Frame::setWindowHasFocus(bool flag)
    32173220{
    3218     if (m_windowHasFocus == flag)
    3219         return;
    3220     m_windowHasFocus = flag;
     3221    if (d->m_windowHasFocus == flag)
     3222        return;
     3223    d->m_windowHasFocus = flag;
    32213224   
    32223225    if (Document *doc = document())
     
    32383241bool Frame::markedTextUsesUnderlines() const
    32393242{
    3240     return m_markedTextUsesUnderlines;
     3243    return d->m_markedTextUsesUnderlines;
    32413244}
    32423245
    32433246DeprecatedValueList<MarkedTextUnderline> Frame::markedTextUnderlines() const
    32443247{
    3245     return m_markedTextUnderlines;
     3248    return d->m_markedTextUnderlines;
    32463249}
    32473250
     
    32743277    // Reset the multiple form submission protection code.
    32753278    // We'll let you submit the same form twice if you do two separate user actions.
    3276     _submittedFormURL = KURL();
     3279    d->m_submittedFormURL = KURL();
    32773280}
    32783281
  • trunk/WebCore/page/Frame.h

    r13393 r13396  
    554554  virtual DeprecatedString incomingReferrer() const = 0;
    555555  virtual DeprecatedString mimeTypeForFileName(const DeprecatedString &) const = 0;
    556   virtual void clearRecordedFormValues() = 0;
    557   virtual void recordFormValue(const DeprecatedString &name, const DeprecatedString &value, HTMLFormElement *element) = 0;
    558556  virtual KJS::Bindings::Instance *getEmbedInstanceForWidget(Widget*) = 0;
    559557  virtual KJS::Bindings::Instance *getObjectInstanceForWidget(Widget*) = 0;
     
    765763  void prepareForUserAction();
    766764  Node *mousePressNode();
     765 
     766  void clearRecordedFormValues();
     767  void recordFormValue(const String& name, const String& value, PassRefPtr<HTMLFormElement>);
    767768
    768769  bool isComplete() const;
     
    829830  friend class FramePrivate;
    830831  FramePrivate* d;
    831      
    832   mutable RefPtr<Node> _elementToDraw;
    833   mutable bool _drawSelectionOnly;
    834   KURL _submittedFormURL;
    835   bool m_markedTextUsesUnderlines;
    836   DeprecatedValueList<MarkedTextUnderline> m_markedTextUnderlines;
    837   bool m_windowHasFocus;
    838   int frameCount;
    839832};
    840833
  • trunk/WebCore/page/FramePrivate.h

    r13393 r13396  
    9797            , m_autoscrollTimer(thisFrame, &Frame::autoscrollTimerFired)
    9898            , m_autoscrollLayer(0)
     99            , m_drawSelectionOnly(false)
     100            , m_markedTextUsesUnderlines(false)
     101            , m_windowHasFocus(false)
     102            , frameCount(0)
    99103        {
    100104        }
     
    208212        Timer<Frame> m_autoscrollTimer;
    209213        RenderLayer* m_autoscrollLayer;
     214       
     215        RefPtr<Node> m_elementToDraw;
     216        bool m_drawSelectionOnly;
     217       
     218        HashMap<String, String> m_formValuesAboutToBeSubmitted;
     219        RefPtr<Element> m_formAboutToBeSubmitted;
     220        KURL m_submittedFormURL;
     221       
     222        bool m_markedTextUsesUnderlines;
     223        DeprecatedValueList<MarkedTextUnderline> m_markedTextUnderlines;
     224        bool m_windowHasFocus;
     225       
     226        unsigned frameCount;
    210227    };
    211 
    212228}
    213229
  • trunk/WebCore/platform/GraphicsContext.cpp

    r13393 r13396  
    2727#include "GraphicsContext.h"
    2828
     29#include "FloatRect.h"
     30#include "Font.h"
    2931#include "IntRect.h"
    3032#include "DeprecatedString.h"
    31 #include "Font.h"
    3233#include "Widget.h"
    3334
    3435namespace WebCore {
     36
     37struct GraphicsContextState {
     38    GraphicsContextState() : paintingDisabled(false) { }
     39    Font font;
     40    Pen pen;
     41    Brush brush;
     42    bool paintingDisabled;
     43};
     44       
     45struct GraphicsContextPrivate {
     46    GraphicsContextPrivate(bool isForPrinting);
     47   
     48    GraphicsContextState state;
     49    Vector<GraphicsContextState> stack;
     50    Vector<IntRect> m_focusRingRects;
     51    int m_focusRingWidth;
     52    int m_focusRingOffset;
     53    bool m_isForPrinting;
     54    bool m_usesInactiveTextBackgroundColor;
     55    bool m_updatingControlTints;
     56};
     57
     58GraphicsContextPrivate::GraphicsContextPrivate(bool isForPrinting)
     59    : m_focusRingWidth(0)
     60    , m_focusRingOffset(0)
     61    , m_isForPrinting(isForPrinting)
     62    , m_usesInactiveTextBackgroundColor(false)
     63    , m_updatingControlTints(false)
     64{
     65}
     66
     67GraphicsContextPrivate* GraphicsContext::createGraphicsContextPrivate(bool isForPrinting)
     68{
     69    return new GraphicsContextPrivate(isForPrinting);
     70}
     71
     72void GraphicsContext::destroyGraphicsContextPrivate(GraphicsContextPrivate* deleteMe)
     73{
     74    delete deleteMe;
     75}
     76
     77void GraphicsContext::save()
     78{
     79    if (paintingDisabled())
     80        return;
     81
     82    m_common->stack.append(m_common->state);
     83   
     84    savePlatformState();
     85}
     86
     87void GraphicsContext::restore()
     88{
     89    if (paintingDisabled())
     90        return;
     91
     92    if (m_common->stack.isEmpty()) {
     93        LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
     94        return;
     95    }
     96    m_common->state = m_common->stack.last();
     97    m_common->stack.removeLast();
     98   
     99    restorePlatformState();
     100}
     101
     102const Font& GraphicsContext::font() const
     103{
     104    return m_common->state.font;
     105}
     106
     107void GraphicsContext::setFont(const Font& aFont)
     108{
     109    m_common->state.font = aFont;
     110}
     111
     112const Pen& GraphicsContext::pen() const
     113{
     114    return m_common->state.pen;
     115}
     116
     117void GraphicsContext::setPen(const Pen& pen)
     118{
     119    m_common->state.pen = pen;
     120}
     121
     122void GraphicsContext::setPen(Pen::PenStyle style)
     123{
     124    m_common->state.pen.setStyle(style);
     125    m_common->state.pen.setColor(Color::black);
     126    m_common->state.pen.setWidth(0);
     127}
     128
     129void GraphicsContext::setPen(RGBA32 rgb)
     130{
     131    m_common->state.pen.setStyle(Pen::SolidLine);
     132    m_common->state.pen.setColor(rgb);
     133    m_common->state.pen.setWidth(0);
     134}
     135
     136void GraphicsContext::setBrush(const Brush& brush)
     137{
     138    m_common->state.brush = brush;
     139}
     140
     141void GraphicsContext::setBrush(Brush::BrushStyle style)
     142{
     143    m_common->state.brush.setStyle(style);
     144    m_common->state.brush.setColor(Color::black);
     145}
     146
     147void GraphicsContext::setBrush(RGBA32 rgb)
     148{
     149    m_common->state.brush.setStyle(Brush::SolidPattern);
     150    m_common->state.brush.setColor(rgb);
     151}
     152
     153const Brush& GraphicsContext::brush() const
     154{
     155    return m_common->state.brush;
     156}
     157
     158void GraphicsContext::setUsesInactiveTextBackgroundColor(bool u)
     159{
     160    m_common->m_usesInactiveTextBackgroundColor = u;
     161}
     162
     163bool GraphicsContext::usesInactiveTextBackgroundColor() const
     164{
     165    return m_common->m_usesInactiveTextBackgroundColor;
     166}
     167
     168bool GraphicsContext::updatingControlTints() const
     169{
     170    return m_common->m_updatingControlTints;
     171}
     172
     173void GraphicsContext::setUpdatingControlTints(bool b)
     174{
     175    setPaintingDisabled(b);
     176    m_common->m_updatingControlTints = b;
     177}
     178
     179void GraphicsContext::setPaintingDisabled(bool f)
     180{
     181    m_common->state.paintingDisabled = f;
     182}
     183
     184bool GraphicsContext::paintingDisabled() const
     185{
     186    return m_common->state.paintingDisabled;
     187}
     188
     189bool GraphicsContext::printing() const
     190{
     191    return m_common->m_isForPrinting;
     192}
    35193
    36194void GraphicsContext::drawImageAtPoint(Image* image, const IntPoint& p, Image::CompositeOperator compositeOperator)
    37195{       
    38     drawImage(image, p.x(), p.y(), 0, 0, -1, -1, compositeOperator);
     196    drawImage(image, p, 0, 0, -1, -1, compositeOperator);
    39197}
    40198
    41199void GraphicsContext::drawImageInRect(Image* image, const IntRect& r, Image::CompositeOperator compositeOperator)
    42200{
    43     drawImage(image, r.x(), r.y(), r.width(), r.height(), 0, 0, -1, -1, compositeOperator);
    44 }
    45 
    46 void GraphicsContext::drawImage(Image* image, int x, int y,
     201    drawImage(image, r, 0, 0, -1, -1, compositeOperator);
     202}
     203
     204void GraphicsContext::drawImage(Image* image, const IntPoint& dest,
    47205                         int sx, int sy, int sw, int sh, Image::CompositeOperator compositeOperator, void* context)
    48206{
    49     drawImage(image, x, y, sw, sh, sx, sy, sw, sh, compositeOperator, context);
    50 }
    51 
    52 void GraphicsContext::drawImage(Image* image, int x, int y, int w, int h,
     207    drawImage(image, IntRect(dest, IntSize(sw, sh)), sx, sy, sw, sh, compositeOperator, context);
     208}
     209
     210void GraphicsContext::drawImage(Image* image, const IntRect& dest,
    53211                         int sx, int sy, int sw, int sh, Image::CompositeOperator compositeOperator, void* context)
    54212{
    55     drawFloatImage(image, (float)x, (float)y, (float)w, (float)h, (float)sx, (float)sy, (float)sw, (float)sh, compositeOperator, context);
     213    drawImage(image, FloatRect(dest), (float)sx, (float)sy, (float)sw, (float)sh, compositeOperator, context);
    56214}
    57215
     
    125283    clearFocusRing();
    126284   
    127     m_focusRingWidth = width;
    128     m_focusRingOffset = offset;
     285    m_common->m_focusRingWidth = width;
     286    m_common->m_focusRingOffset = offset;
    129287}
    130288
    131289void GraphicsContext::clearFocusRing()
    132290{
    133     m_focusRingRects.clear();
     291    m_common->m_focusRingRects.clear();
    134292}
    135293
     
    138296    if (paintingDisabled())
    139297        return;
    140     m_focusRingRects.append(rect);
    141 }
    142 
    143 }
     298    m_common->m_focusRingRects.append(rect);
     299}
     300
     301int GraphicsContext::focusRingWidth() const
     302{
     303    return m_common->m_focusRingWidth;
     304}
     305
     306int GraphicsContext::focusRingOffset() const
     307{
     308    return m_common->m_focusRingOffset;
     309}
     310
     311const Vector<IntRect>& GraphicsContext::focusRingRects() const
     312{
     313    return m_common->m_focusRingRects;
     314}
     315
     316}
  • trunk/WebCore/platform/GraphicsContext.h

    r13393 r13396  
    4949    class Font;
    5050    class GraphicsContextPrivate;
     51    class GraphicsContextPlatformPrivate;
    5152    class IntPoint;
    5253    class IntPointArray;
     
    9293        void restore();
    9394       
    94         void drawRect(int, int, int, int);
    95         void drawLine(int, int, int, int);
    96         void drawEllipse(int, int, int, int);
     95        void drawRect(const IntRect&);
     96        void drawLine(const IntPoint&, const IntPoint&);
     97        void drawEllipse(const IntRect&);
    9798        void drawArc(int, int, int, int, int, int);
    9899        void drawConvexPolygon(const IntPointArray&);
    99100
    100         void fillRect(int, int, int, int, const Brush&);
    101101        void fillRect(const IntRect&, const Brush&);
    102102
     
    104104        void drawImageInRect(Image*, const IntRect&, Image::CompositeOperator = Image::CompositeSourceOver);
    105105
    106         void drawImage(Image*, int x, int y,
     106        void drawImage(Image*, const IntPoint&,
    107107            int sx = 0, int sy = 0, int sw = -1, int sh = -1,
    108108            Image::CompositeOperator = Image::CompositeSourceOver,
    109109            void* nativeData = 0);
    110         void drawImage(Image*, int x, int y, int w, int h,
     110        void drawImage(Image*, const IntRect&,
    111111            int sx = 0, int sy = 0, int sw = -1, int sh = -1,
    112112            Image::CompositeOperator = Image::CompositeSourceOver,
    113113            void* nativeData = 0);
    114         void drawFloatImage(Image*, float x, float y, float w, float h,
     114        void drawImage(Image*, const FloatRect&,
    115115            float sx = 0, float sy = 0, float sw = -1, float sh = -1,
    116116            Image::CompositeOperator = Image::CompositeSourceOver,
    117117            void* nativeData = 0);
    118         void drawTiledImage(Image*, int, int, int, int, int sx = 0, int sy = 0, void* nativeData = 0);
    119         void drawScaledAndTiledImage(Image*, int, int, int, int, int, int, int, int,
     118        void drawTiledImage(Image*, const IntRect& dest, int sx = 0, int sy = 0, void* nativeData = 0);
     119        void drawScaledAndTiledImage(Image*, const IntRect&, int, int, int, int,
    120120            Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile,
    121121            void* nativeData = 0);
     
    137137
    138138        Color selectedTextBackgroundColor() const;
    139         void setUsesInactiveTextBackgroundColor(bool u) { m_usesInactiveTextBackgroundColor = u; }
     139        void setUsesInactiveTextBackgroundColor(bool);
     140        bool usesInactiveTextBackgroundColor() const;
    140141       
    141142        bool paintingDisabled() const;
    142143        void setPaintingDisabled(bool);
    143144       
    144         bool updatingControlTints() const { return m_updatingControlTints; }
    145         void setUpdatingControlTints(bool b) { setPaintingDisabled(b); m_updatingControlTints = b; }
     145        bool updatingControlTints() const;
     146        void setUpdatingControlTints(bool);
    146147
    147148        void beginTransparencyLayer(float opacity);
     
    175176#endif
    176177
    177         bool printing() const { return m_isForPrinting; }
     178        bool printing() const;
    178179
    179180private:
    180181        void setColorFromBrush();
    181182        void setColorFromPen();
    182 
    183         GraphicsContextPrivate* m_data;
    184         Vector<IntRect> m_focusRingRects;
    185         int m_focusRingWidth;
    186         int m_focusRingOffset;
    187         bool m_isForPrinting;
    188         bool m_usesInactiveTextBackgroundColor;
    189         bool m_updatingControlTints;
     183       
     184        void savePlatformState();
     185        void restorePlatformState();
     186       
     187        int focusRingWidth() const;
     188        int focusRingOffset() const;
     189        const Vector<IntRect>& focusRingRects() const;
     190       
     191        static GraphicsContextPrivate* createGraphicsContextPrivate(bool isForPrinting = false);
     192        static void destroyGraphicsContextPrivate(GraphicsContextPrivate*);
     193       
     194        GraphicsContextPrivate* m_common;
     195        GraphicsContextPlatformPrivate* m_data;
    190196    };
    191197
  • trunk/WebCore/platform/cairo/GraphicsContextCairo.cpp

    r13393 r13396  
    4242namespace WebCore {
    4343
    44 struct GraphicsContextState {
    45     GraphicsContextState() : paintingDisabled(false) { }
    46     Font font;
    47     Pen pen;
    48     Brush brush;
    49     bool paintingDisabled;
    50 };
    51 
    52 struct GraphicsContextPrivate {
    53     GraphicsContextPrivate();
    54     ~GraphicsContextPrivate();
    55 
    56     GraphicsContextState state;   
    57     Vector<GraphicsContextState> stack;
     44struct GraphicsContextPlatformPrivate {
     45    GraphicsContextPlatformPrivate();
     46    ~GraphicsContextPlatformPrivate();
     47
    5848    cairo_t* context;
    5949};
     
    6757
    6858// A fillRect helper
    69 static inline void fillRectSourceOver(cairo_t* cr, float x, float y, float w, float h, const Color& col)
     59static inline void fillRectSourceOver(cairo_t* cr, const FloatRect& rect, const Color& col)
    7060{
    7161    setColor(cr, col);
     
    7565}
    7666
    77 GraphicsContextPrivate::GraphicsContextPrivate()
     67GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
    7868    :  context(0)
    7969{
    8070}
    8171
    82 GraphicsContextPrivate::~GraphicsContextPrivate()
     72GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
    8373{
    8474    cairo_destroy(context);
     
    8676
    8777GraphicsContext::GraphicsContext(HDC dc)
    88     : m_data(new GraphicsContextPrivate)
    89     , m_isForPrinting(false)
    90     , m_usesInactiveTextBackgroundColor(false)
    91     , m_updatingControlTints(false)
     78    : m_common(createGraphicsContextPrivate())
     79    , m_data(new GraphicsContextPlatformPrivate)
    9280{
    9381    cairo_surface_t* surface = cairo_win32_surface_create(dc);
     
    9684
    9785GraphicsContext::GraphicsContext(cairo_t* context)
    98     : m_data(new GraphicsContextPrivate)
    99     , m_isForPrinting(false)
    100     , m_usesInactiveTextBackgroundColor(false)
    101     , m_updatingControlTints(false)
     86    : m_common(createGraphicsContextPrivate())
     87    , m_data(new GraphicsContextPlatformPrivate)
    10288{
    10389    m_data->context = cairo_reference(context);
     
    10591
    10692GraphicsContext::GraphicsContext(bool forPrinting)
    107     : m_data(new GraphicsContextPrivate)
    108     , m_isForPrinting(forPrinting)
    109     , m_usesInactiveTextBackgroundColor(false)
    110     , m_updatingControlTints(false)
     93    : m_common(createGraphicsContextPrivate(forPrinting))
     94    , m_data(new GraphicsContextPlatformPrivate)
    11195{
    11296}
     
    11498GraphicsContext::~GraphicsContext()
    11599{
     100    destroyGraphicsContextPrivate(m_common);
    116101    delete m_data;
    117102}
     
    122107}
    123108
    124 const Pen& GraphicsContext::pen() const
    125 {
    126     return m_data->state.pen;
    127 }
    128 
    129 void GraphicsContext::setPen(const Pen& pen)
    130 {
    131     m_data->state.pen = pen;
    132 }
    133 
    134 void GraphicsContext::setPen(Pen::PenStyle style)
    135 {
    136     m_data->state.pen.setStyle(style);
    137     m_data->state.pen.setColor(Color::black);
    138     m_data->state.pen.setWidth(0);
    139 }
    140 
    141 void GraphicsContext::setPen(RGBA32 rgb)
    142 {
    143     m_data->state.pen.setStyle(Pen::SolidLine);
    144     m_data->state.pen.setColor(rgb);
    145     m_data->state.pen.setWidth(0);
    146 }
    147 
    148 void GraphicsContext::setBrush(const Brush& brush)
    149 {
    150     m_data->state.brush = brush;
    151 }
    152 
    153 void GraphicsContext::setBrush(Brush::BrushStyle style)
    154 {
    155     m_data->state.brush.setStyle(style);
    156     m_data->state.brush.setColor(Color::black);
    157 }
    158 
    159 void GraphicsContext::setBrush(RGBA32 rgb)
    160 {
    161     m_data->state.brush.setStyle(Brush::SolidPattern);
    162     m_data->state.brush.setColor(rgb);
    163 }
    164 
    165 const Brush& GraphicsContext::brush() const
    166 {
    167     return m_data->state.brush;
    168 }
    169 
    170 const Font& GraphicsContext::font() const
    171 {
    172     return m_data->state.font;
    173 }
    174 
    175 void GraphicsContext::setFont(const Font& aFont)
    176 {
    177     m_data->state.font = aFont;
    178 }
    179 
    180 void GraphicsContext::save()
    181 {
    182     if (m_data->state.paintingDisabled)
    183         return;
    184 
    185     m_data->stack.append(m_data->state);
    186 
     109void GraphicsContext::savePlatformState()
     110{
    187111    cairo_save(m_data->context);
    188112}
    189113
    190 void GraphicsContext::restore()
    191 {
    192     if (m_data->state.paintingDisabled)
    193         return;
    194 
    195     if (m_data->stack.isEmpty()) {
    196         LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
    197         return;
    198     }
    199     m_data->state = m_data->stack.last();
    200     m_data->stack.removeLast();
    201      
     114void GraphicsContext::restorePlatformState()
     115{
    202116    cairo_restore(m_data->context);
    203117}
    204118
    205119// Draws a filled rectangle with a stroked border.
    206 void GraphicsContext::drawRect(int x, int y, int w, int h)
    207 {
    208     if (m_data->state.paintingDisabled)
    209         return;
    210    
    211     cairo_t* context = m_data->context;
    212     if (m_data->state.brush.style() != Brush::NoBrush)
    213         fillRectSourceOver(context, x, y, w, h, m_data->state.brush.color());
    214 
    215     if (m_data->state.pen.style() != Pen::NoPen) {
     120void GraphicsContext::drawRect(const IntRect& rect)
     121{
     122    if (paintingDisabled())
     123        return;
     124   
     125    cairo_t* context = m_data->context;
     126    if (brush().style() != Brush::NoBrush)
     127        fillRectSourceOver(context, rect, brush().color());
     128
     129    if (pen().style() != Pen::NoPen) {
    216130        setColorFromPen();
    217         cairo_rectangle(context, x+.5, y+.5 , w-.5 , h-.5);
     131        FloatRect r(rect);
     132        r.inflate(-.5f);
     133        cairo_rectangle(context, r.x(), r.y(), r.width(), r.height());
    218134        cairo_set_line_width(context, 1.0);
    219135        cairo_stroke(context);
     
    223139void GraphicsContext::setColorFromBrush()
    224140{
    225     setColor(m_data->context, m_data->state.brush.color());
     141    setColor(m_data->context, brush().color());
    226142}
    227143 
    228144void GraphicsContext::setColorFromPen()
    229145{
    230     setColor(m_data->context, m_data->state.brush.color());
     146    setColor(m_data->context, pen().color());
    231147}
    232148
     
    264180
    265181// This is only used to draw borders.
    266 void GraphicsContext::drawLine(int x1, int y1, int x2, int y2)
    267 {
    268     if (m_data->state.paintingDisabled)
     182void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
     183{
     184    if (paintingDisabled())
    269185        return;
    270186
     
    272188    cairo_save(context);
    273189
    274     Pen::PenStyle penStyle = m_data->state.pen.style();
     190    Pen::PenStyle penStyle = pen().style();
    275191    if (penStyle == Pen::NoPen)
    276192        return;
    277     float width = m_data->state.pen.width();
     193    float width = pen().width();
    278194    if (width < 1)
    279195        width = 1;
    280196
    281     FloatPoint p1 = FloatPoint(x1, y1);
    282     FloatPoint p2 = FloatPoint(x2, y2);
     197    FloatPoint p1 = point1;
     198    FloatPoint p2 = point2;
     199    bool isVerticalLine = (p1.x() == p2.x());
    283200   
    284201    adjustLineToPixelBounderies(p1, p2, width, penStyle);
     
    306223        // appearance of being a border.  We then draw the actual dotted/dashed line.
    307224        if (x1 == x2) {
    308             fillRectSourceOver(context, p1.x()-width/2, p1.y()-width, width, width, m_data->state.pen.color());
    309             fillRectSourceOver(context, p2.x()-width/2, p2.y(), width, width, m_data->state.pen.color());
     225            fillRectSourceOver(context, FloatRect(p1.x()-width/2, p1.y()-width, width, width), pen().color());
     226            fillRectSourceOver(context, FloatRect(p2.x()-width/2, p2.y(), width, width), pen().color());
    310227        } else {
    311             fillRectSourceOver(context, p1.x()-width, p1.y()-width/2, width, width, m_data->state.pen.color());
    312             fillRectSourceOver(context, p2.x(), p2.y()-width/2, width, width, m_data->state.pen.color());
     228            fillRectSourceOver(context, FloatRect(p1.x()-width, p1.y()-width/2, width, width), pen().color());
     229            fillRectSourceOver(context, FloatRect(p2.x(), p2.y()-width/2, width, width), pen().color());
    313230        }
    314231       
     
    316233        // Remainder is 20.  The maximum pixels of line we could paint
    317234        // will be 50 pixels.
    318         int distance = ((x1 == x2) ? (y2 - y1) : (x2 - x1)) - 2*(int)width;
     235        int distance = (isVerticalLine ? (p2.y() - p1.y()) : (p2.x() - p1.x())) - 2*(int)width;
    319236        int remainder = distance%patWidth;
    320237        int coverage = distance-remainder;
     
    355272
    356273// This method is only used to draw the little circles used in lists.
    357 void GraphicsContext::drawEllipse(int x, int y, int width, int height)
    358 {
    359     if (m_data->state.paintingDisabled)
     274void GraphicsContext::drawEllipse(const IntRect& rect)
     275{
     276    if (paintingDisabled())
    360277        return;
    361278   
    362279    cairo_t* context = m_data->context;
    363280    cairo_save(context);
    364     float yRadius = .5 * height;
    365     float xRadius = .5 * width;
    366     cairo_translate(context, x + xRadius, y + yRadius);
     281    float yRadius = .5 * rect.height();
     282    float xRadius = .5 * rect.width();
     283    cairo_translate(context, rect.x() + xRadius, rect.y() + yRadius);
    367284    cairo_scale(context, xRadius, yRadius);
    368285    cairo_arc(context, 0., 0., 1., 0., 2 * M_PI);
    369286    cairo_restore(context);
    370287
    371     if (m_data->state.brush.style() != Brush::NoBrush) {
     288    if (brush().style() != Brush::NoBrush) {
    372289        setColorFromBrush();
    373290        cairo_fill(context);
    374291    }
    375     if (m_data->state.pen.style() != Pen::NoPen) {
     292    if (pen().style() != Pen::NoPen) {
    376293        setColorFromPen();
    377         unsigned penWidth = m_data->state.pen.width();
     294        unsigned penWidth = pen().width();
    378295        if (penWidth == 0)
    379296            penWidth++;
     
    388305    ASSERT(w == h);
    389306
    390     if (m_data->state.paintingDisabled)
    391         return;
    392    
    393     cairo_t* context = m_data->context;
    394     if (m_data->state.pen.style() != Pen::NoPen) {       
     307    if (paintingDisabled())
     308        return;
     309   
     310    cairo_t* context = m_data->context;
     311    if (pen().style() != Pen::NoPen) {       
    395312        float r = (float)w / 2;
    396313        float fa = (float)a / 16;
     
    399316       
    400317        setColorFromPen();
    401         cairo_set_line_width(context, m_data->state.pen.width());
     318        cairo_set_line_width(context, pen().width());
    402319        cairo_stroke(context);
    403320    }
     
    406323void GraphicsContext::drawConvexPolygon(const IntPointArray& points)
    407324{
    408     if (m_data->state.paintingDisabled)
     325    if (paintingDisabled())
    409326        return;
    410327
     
    422339    cairo_close_path(context);
    423340
    424     if (m_data->state.brush.style() != Brush::NoBrush) {
     341    if (brush().style() != Brush::NoBrush) {
    425342        setColorFromBrush();
    426343        cairo_set_fill_rule(context, CAIRO_FILL_RULE_EVEN_ODD);
     
    428345    }
    429346
    430     if (m_data->state.pen.style() != Pen::NoPen) {
     347    if (pen().style() != Pen::NoPen) {
    431348        setColorFromPen();
    432         cairo_set_line_width(context, m_data->state.pen.width());
     349        cairo_set_line_width(context, pen().width());
    433350        cairo_stroke(context);
    434351    }
     
    436353}
    437354
    438 void GraphicsContext::drawFloatImage(Image* image, float x, float y, float w, float h,
     355void GraphicsContext::drawImage(Image* image, const FloatRect& destRect,
    439356                              float sx, float sy, float sw, float sh, Image::CompositeOperator compositeOperator, void* context)
    440357{
     
    442359        context = m_data->context;
    443360
    444     if (m_data->state.paintingDisabled)
     361    if (paintingDisabled())
    445362        return;
    446363
    447364    float tsw = sw;
    448365    float tsh = sh;
    449     float tw = w;
    450     float th = h;
    451        
     366    FloatRect dest = destRect;
     367           
    452368    if (tsw == -1)
    453369        tsw = image->width();
     
    455371        tsh = image->height();
    456372
    457     if (tw == -1)
    458         tw = image->width();
    459     if (th == -1)
    460         th = image->height();
    461 
    462     image->drawInRect(FloatRect(x, y, tw, th), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
    463 }
    464 
    465 void GraphicsContext::drawTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, void* context)
     373    if (dest.width() == -1)
     374        dest.setWidth(image->width());
     375    if (dest.height() == -1)
     376        dest.setHeight(image->height());
     377
     378    image->drawInRect(dest, FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
     379}
     380
     381void GraphicsContext::drawTiledImage(Image* image, const IntRect& dest, int sx, int sy, void* context)
    466382{
    467383    if (!context)
    468384        context = m_data->context;
    469385
    470     if (m_data->state.paintingDisabled)
    471         return;
    472    
    473     image->tileInRect(FloatRect(x, y, w, h), FloatPoint(sx, sy), context);
    474 }
    475 
    476 void GraphicsContext::drawScaledAndTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, int sw, int sh,
     386    if (paintingDisabled())
     387        return;
     388   
     389    image->tileInRect(dest, FloatPoint(sx, sy), context);
     390}
     391
     392void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh,
    477393    Image::TileRule hRule, Image::TileRule vRule, void* context)
    478394{
     
    480396        context = m_data->context;
    481397
    482     if (m_data->state.paintingDisabled)
     398    if (paintingDisabled())
    483399        return;
    484400
    485401    if (hRule == Image::StretchTile && vRule == Image::StretchTile)
    486402        // Just do a scale.
    487         return drawImage(image, x, y, w, h, sx, sy, sw, sh, Image::CompositeSourceOver, context);
    488 
    489     image->scaleAndTileInRect(FloatRect(x, y, w, h), FloatRect(sx, sy, sw, sh), hRule, vRule, context);
    490 }
    491 
    492 void GraphicsContext::fillRect(int x, int y, int w, int h, const Brush& brush)
    493 {
    494     if (m_data->state.paintingDisabled)
     403        return drawImage(image, dest, sx, sy, sw, sh, Image::CompositeSourceOver, context);
     404
     405    image->scaleAndTileInRect(dest, FloatRect(sx, sy, sw, sh), hRule, vRule, context);
     406}
     407
     408void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
     409{
     410    if (paintingDisabled())
    495411        return;
    496412
    497413    if (brush.style() == Brush::SolidPattern)
    498         fillRectSourceOver(m_data->context, x, y, w, h, brush.color());
     414        fillRectSourceOver(m_data->context, rect, brush.color());
    499415}
    500416
     
    506422void GraphicsContext::addClip(const IntRect& rect)
    507423{
    508     if (m_data->state.paintingDisabled)
     424    if (paintingDisabled())
    509425        return;
    510426
     
    516432void GraphicsContext::setPaintingDisabled(bool f)
    517433{
    518     m_data->state.paintingDisabled = f;
     434    paintingDisabled() = f;
    519435}
    520436
    521437bool GraphicsContext::paintingDisabled() const
    522438{
    523     return m_data->state.paintingDisabled;
     439    return paintingDisabled();
    524440}
    525441
    526442void GraphicsContext::drawFocusRing(const Color& color)
    527443{
    528     if (m_data->state.paintingDisabled)
     444    if (paintingDisabled())
    529445        return;
    530446    int radius = (m_focusRingWidth - 1) / 2;
  • trunk/WebCore/platform/mac/GraphicsContextMac.mm

    r13393 r13396  
    4949// exceptions for those.
    5050
    51 struct GraphicsContextState {
    52     GraphicsContextState() : paintingDisabled(false) { }
    53     Font font;
    54     Pen pen;
    55     Brush brush;
    56     bool paintingDisabled;
    57 };
    58 
    59 struct GraphicsContextPrivate {
    60     GraphicsContextPrivate();
    61     ~GraphicsContextPrivate();
    62 
    63     GraphicsContextState state;   
    64     Vector<GraphicsContextState> stack;
     51
     52struct GraphicsContextPlatformPrivate {
     53    GraphicsContextPlatformPrivate();
     54    ~GraphicsContextPlatformPrivate();
     55   
    6556    id <WebCoreTextRenderer> textRenderer;
    6657    Font textRendererFont;
     
    7162
    7263// A fillRect helper to work around the fact that NSRectFill uses copy mode, not source over.
    73 static inline void fillRectSourceOver(float x, float y, float w, float h, const Color& col)
     64static inline void fillRectSourceOver(const FloatRect& rect, const Color& col)
    7465{
    7566    [nsColor(col) set];
    76     NSRectFillUsingOperation(NSMakeRect(x, y, w, h), NSCompositeSourceOver);
    77 }
    78 
    79 
    80 GraphicsContextPrivate::GraphicsContextPrivate()
     67    NSRectFillUsingOperation(rect, NSCompositeSourceOver);
     68}
     69
     70GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate()
    8171    : textRenderer(0)
    8272{
    8373}
    8474
    85 GraphicsContextPrivate::~GraphicsContextPrivate()
     75GraphicsContextPlatformPrivate::~GraphicsContextPlatformPrivate()
    8676{
    8777    KWQRelease(textRenderer);
     
    8979
    9080GraphicsContext::GraphicsContext()
    91     : m_data(new GraphicsContextPrivate)
    92     , m_focusRingWidth(0)
    93     , m_focusRingOffset(0)
    94     , m_isForPrinting(false)
    95     , m_usesInactiveTextBackgroundColor(false)
    96     , m_updatingControlTints(false)
     81    : m_common(createGraphicsContextPrivate())
     82    , m_data(new GraphicsContextPlatformPrivate)
    9783{
    9884}
    9985
    10086GraphicsContext::GraphicsContext(bool forPrinting)
    101     : m_data(new GraphicsContextPrivate)
    102     , m_focusRingWidth(0)
    103     , m_focusRingOffset(0)
    104     , m_isForPrinting(forPrinting)
    105     , m_usesInactiveTextBackgroundColor(false)
    106     , m_updatingControlTints(false)
     87    : m_common(createGraphicsContextPrivate(forPrinting))
     88    , m_data(new GraphicsContextPlatformPrivate)
    10789{
    10890}
     
    11092GraphicsContext::~GraphicsContext()
    11193{
     94    destroyGraphicsContextPrivate(m_common);
    11295    delete m_data;
    11396}
    11497
    115 const Font& GraphicsContext::font() const
    116 {
    117     return m_data->state.font;
    118 }
    119 
    120 void GraphicsContext::setFont(const Font& aFont)
    121 {
    122     m_data->state.font = aFont;
    123 }
    124 
    125 const Pen& GraphicsContext::pen() const
    126 {
    127     return m_data->state.pen;
    128 }
    129 
    130 void GraphicsContext::setPen(const Pen& pen)
    131 {
    132     m_data->state.pen = pen;
    133 }
    134 
    135 void GraphicsContext::setPen(Pen::PenStyle style)
    136 {
    137     m_data->state.pen.setStyle(style);
    138     m_data->state.pen.setColor(Color::black);
    139     m_data->state.pen.setWidth(0);
    140 }
    141 
    142 void GraphicsContext::setPen(RGBA32 rgb)
    143 {
    144     m_data->state.pen.setStyle(Pen::SolidLine);
    145     m_data->state.pen.setColor(rgb);
    146     m_data->state.pen.setWidth(0);
    147 }
    148 
    149 void GraphicsContext::setBrush(const Brush& brush)
    150 {
    151     m_data->state.brush = brush;
    152 }
    153 
    154 void GraphicsContext::setBrush(Brush::BrushStyle style)
    155 {
    156     m_data->state.brush.setStyle(style);
    157     m_data->state.brush.setColor(Color::black);
    158 }
    159 
    160 void GraphicsContext::setBrush(RGBA32 rgb)
    161 {
    162     m_data->state.brush.setStyle(Brush::SolidPattern);
    163     m_data->state.brush.setColor(rgb);
    164 }
    165 
    166 const Brush& GraphicsContext::brush() const
    167 {
    168     return m_data->state.brush;
    169 }
    170 
    171 void GraphicsContext::save()
    172 {
    173     if (m_data->state.paintingDisabled)
    174         return;
    175 
    176     m_data->stack.append(m_data->state);
    177 
    178     [NSGraphicsContext saveGraphicsState];
    179 }
    180 
    181 void GraphicsContext::restore()
    182 {
    183     if (m_data->state.paintingDisabled)
    184         return;
    185 
    186     if (m_data->stack.isEmpty()) {
    187         LOG_ERROR("ERROR void GraphicsContext::restore() stack is empty");
    188         return;
    189     }
    190     m_data->state = m_data->stack.last();
    191     m_data->stack.removeLast();
    192      
     98void GraphicsContext::savePlatformState()
     99{
     100    [NSGraphicsContext saveGraphicsState];
     101}
     102
     103void GraphicsContext::restorePlatformState()
     104{
    193105    [NSGraphicsContext restoreGraphicsState];
    194106}
    195107
    196108// Draws a filled rectangle with a stroked border.
    197 void GraphicsContext::drawRect(int x, int y, int w, int h)
    198 {
    199     if (m_data->state.paintingDisabled)
     109void GraphicsContext::drawRect(const IntRect& rect)
     110{
     111    if (paintingDisabled())
    200112        return;
    201113         
    202     if (m_data->state.brush.style() != Brush::NoBrush)
    203         fillRectSourceOver(x, y, w, h, m_data->state.brush.color());
    204 
    205     if (m_data->state.pen.style() != Pen::Pen::NoPen) {
     114    if (brush().style() != Brush::NoBrush)
     115        fillRectSourceOver(rect, brush().color());
     116
     117    if (pen().style() != Pen::Pen::NoPen) {
    206118        setColorFromPen();
    207         NSFrameRect(NSMakeRect(x, y, w, h));
     119        NSFrameRect(rect);
    208120    }
    209121}
     
    211123void GraphicsContext::setColorFromBrush()
    212124{
    213     [nsColor(m_data->state.brush.color()) set];
     125    [nsColor(brush().color()) set];
    214126}
    215127 
    216128void GraphicsContext::setColorFromPen()
    217129{
    218     [nsColor(m_data->state.pen.color()) set];
     130    [nsColor(pen().color()) set];
    219131}
    220132 
    221133  // This is only used to draw borders.
    222 void GraphicsContext::drawLine(int x1, int y1, int x2, int y2)
    223 {
    224     if (m_data->state.paintingDisabled)
    225         return;
    226 
    227     Pen::PenStyle penStyle = m_data->state.pen.style();
     134void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2)
     135{
     136    if (paintingDisabled())
     137        return;
     138
     139    Pen::PenStyle penStyle = pen().style();
    228140    if (penStyle == Pen::Pen::NoPen)
    229141        return;
    230     float width = m_data->state.pen.width();
     142    float width = pen().width();
    231143    if (width < 1)
    232144        width = 1;
    233145
    234     NSPoint p1 = NSMakePoint(x1, y1);
    235     NSPoint p2 = NSMakePoint(x2, y2);
     146    NSPoint p1 = point1;
     147    NSPoint p2 = point2;
     148    bool isVerticalLine = (p1.x == p2.x);
    236149   
    237150    // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
     
    240153    // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
    241154    if (penStyle == Pen::DotLine || penStyle == Pen::DashLine) {
    242         if (x1 == x2) {
     155        if (isVerticalLine) {
    243156            p1.y += width;
    244157            p2.y -= width;
    245         }
    246         else {
     158        } else {
    247159            p1.x += width;
    248160            p2.x -= width;
     
    251163   
    252164    if (((int)width)%2) {
    253         if (x1 == x2) {
     165        if (isVerticalLine) {
    254166            // We're a vertical line.  Adjust our x.
    255167            p1.x += 0.5;
    256168            p2.x += 0.5;
    257         }
    258         else {
     169        } else {
    259170            // We're a horizontal line. Adjust our y.
    260171            p1.y += 0.5;
     
    288199        // Do a rect fill of our endpoints.  This ensures we always have the
    289200        // appearance of being a border.  We then draw the actual dotted/dashed line.
    290         if (x1 == x2) {
    291             fillRectSourceOver(p1.x-width/2, p1.y-width, width, width, m_data->state.pen.color());
    292             fillRectSourceOver(p2.x-width/2, p2.y, width, width, m_data->state.pen.color());
     201        const Color& penColor = pen().color();
     202        if (isVerticalLine) {
     203            fillRectSourceOver(FloatRect(p1.x-width/2, p1.y-width, width, width), penColor);
     204            fillRectSourceOver(FloatRect(p2.x-width/2, p2.y, width, width), penColor);
    293205        } else {
    294             fillRectSourceOver(p1.x-width, p1.y-width/2, width, width, m_data->state.pen.color());
    295             fillRectSourceOver(p2.x, p2.y-width/2, width, width, m_data->state.pen.color());
     206            fillRectSourceOver(FloatRect(p1.x-width, p1.y-width/2, width, width), penColor);
     207            fillRectSourceOver(FloatRect(p2.x, p2.y-width/2, width, width), penColor);
    296208        }
    297209       
     
    299211        // Remainder is 20.  The maximum pixels of line we could paint
    300212        // will be 50 pixels.
    301         int distance = ((x1 == x2) ? (y2 - y1) : (x2 - x1)) - 2*(int)width;
     213        int distance = (isVerticalLine ? (int)(p2.y - p1.y) : (int)(p2.x - p1.x)) - 2*(int)width;
    302214        int remainder = distance%patWidth;
    303215        int coverage = distance-remainder;
     
    342254
    343255// This method is only used to draw the little circles used in lists.
    344 void GraphicsContext::drawEllipse(int x, int y, int w, int h)
     256void GraphicsContext::drawEllipse(const IntRect& rect)
    345257{
    346258    // FIXME: CG added CGContextAddEllipseinRect in Tiger, so we should be able to quite easily draw an ellipse.
    347259    // This code can only handle circles, not ellipses. But khtml only
    348260    // uses it for circles.
    349     ASSERT(w == h);
    350 
    351     if (m_data->state.paintingDisabled)
     261    ASSERT(rect.width() == rect.height());
     262
     263    if (paintingDisabled())
    352264        return;
    353265       
    354266    CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    355267    CGContextBeginPath(context);
    356     float r = (float)w / 2;
    357     CGContextAddArc(context, x + r, y + r, r, 0, 2*M_PI, true);
     268    float r = (float)rect.width() / 2;
     269    CGContextAddArc(context, rect.x() + r, rect.y() + r, r, 0, 2*M_PI, true);
    358270    CGContextClosePath(context);
    359271
    360     if (m_data->state.brush.style() != Brush::NoBrush) {
     272    if (brush().style() != Brush::NoBrush) {
    361273        setColorFromBrush();
    362         if (m_data->state.pen.style() != Pen::NoPen) {
     274        if (pen().style() != Pen::NoPen) {
    363275            // stroke and fill
    364276            setColorFromPen();
    365             unsigned penWidth = m_data->state.pen.width();
     277            unsigned penWidth = pen().width();
    366278            if (penWidth == 0)
    367279                penWidth++;
    368280            CGContextSetLineWidth(context, penWidth);
    369281            CGContextDrawPath(context, kCGPathFillStroke);
    370         } else {
     282        } else
    371283            CGContextFillPath(context);
    372         }
    373     }
    374     if (m_data->state.pen.style() != Pen::NoPen) {
     284    }
     285    if (pen().style() != Pen::NoPen) {
    375286        setColorFromPen();
    376         unsigned penWidth = m_data->state.pen.width();
     287        unsigned penWidth = pen().width();
    377288        if (penWidth == 0)
    378289            penWidth++;
     
    383294
    384295
    385 void GraphicsContext::drawArc (int x, int y, int w, int h, int a, int alen)
     296void GraphicsContext::drawArc(int x, int y, int w, int h, int a, int alen)
    386297{
    387298    // Only supports arc on circles.  That's all khtml needs.
    388299    ASSERT(w == h);
    389300
    390     if (m_data->state.paintingDisabled)
    391         return;
    392    
    393     if (m_data->state.pen.style() != Pen::NoPen) {
     301    if (paintingDisabled())
     302        return;
     303   
     304    if (pen().style() != Pen::NoPen) {
    394305        CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
    395306        CGContextBeginPath(context);
     
    401312       
    402313        setColorFromPen();
    403         CGContextSetLineWidth(context, m_data->state.pen.width());
     314        CGContextSetLineWidth(context, pen().width());
    404315        CGContextStrokePath(context);
    405316    }
     
    408319void GraphicsContext::drawConvexPolygon(const IntPointArray& points)
    409320{
    410     if (m_data->state.paintingDisabled)
     321    if (paintingDisabled())
    411322        return;
    412323
     
    427338    CGContextClosePath(context);
    428339
    429     if (m_data->state.brush.style() != Brush::NoBrush) {
     340    if (brush().style() != Brush::NoBrush) {
    430341        setColorFromBrush();
    431342        CGContextEOFillPath(context);
    432343    }
    433344
    434     if (m_data->state.pen.style() != Pen::NoPen) {
     345    if (pen().style() != Pen::NoPen) {
    435346        setColorFromPen();
    436         CGContextSetLineWidth(context, m_data->state.pen.width());
     347        CGContextSetLineWidth(context, pen().width());
    437348        CGContextStrokePath(context);
    438349    }
     
    456367}
    457368
    458 void GraphicsContext::drawFloatImage(Image* image, float x, float y, float w, float h,
     369void GraphicsContext::drawImage(Image* image, const FloatRect& dest,
    459370                              float sx, float sy, float sw, float sh, Image::CompositeOperator compositeOperator, void* context)
    460371{
    461     if (m_data->state.paintingDisabled)
     372    if (paintingDisabled())
    462373        return;
    463374
    464375    float tsw = sw;
    465376    float tsh = sh;
    466     float tw = w;
    467     float th = h;
     377    float tw = dest.width();
     378    float th = dest.height();
    468379       
    469380    if (tsw == -1)
     
    477388        th = image->height();
    478389
    479     image->drawInRect(FloatRect(x, y, tw, th), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
    480 }
    481 
    482 void GraphicsContext::drawTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, void* context)
    483 {
    484     if (m_data->state.paintingDisabled)
    485         return;
    486    
    487     image->tileInRect(FloatRect(x, y, w, h), FloatPoint(sx, sy), context);
    488 }
    489 
    490 void GraphicsContext::drawScaledAndTiledImage(Image* image, int x, int y, int w, int h, int sx, int sy, int sw, int sh,
     390    image->drawInRect(FloatRect(dest.location(), FloatSize(tw, th)), FloatRect(sx, sy, tsw, tsh), compositeOperator, context);
     391}
     392
     393void GraphicsContext::drawTiledImage(Image* image, const IntRect& rect, int sx, int sy, void* context)
     394{
     395    if (paintingDisabled())
     396        return;
     397   
     398    image->tileInRect(rect, FloatPoint(sx, sy), context);
     399}
     400
     401void GraphicsContext::drawScaledAndTiledImage(Image* image, const IntRect& dest, int sx, int sy, int sw, int sh,
    491402    Image::TileRule hRule, Image::TileRule vRule, void* context)
    492403{
    493     if (m_data->state.paintingDisabled)
     404    if (paintingDisabled())
    494405        return;
    495406
    496407    if (hRule == Image::StretchTile && vRule == Image::StretchTile)
    497408        // Just do a scale.
    498         return drawImage(image, x, y, w, h, sx, sy, sw, sh, Image::CompositeSourceOver, context);
    499 
    500     image->scaleAndTileInRect(FloatRect(x, y, w, h), FloatRect(sx, sy, sw, sh), hRule, vRule, context);
     409        return drawImage(image, dest, sx, sy, sw, sh, Image::CompositeSourceOver, context);
     410
     411    image->scaleAndTileInRect(dest, FloatRect(sx, sy, sw, sh), hRule, vRule, context);
    501412}
    502413
     
    512423Color GraphicsContext::selectedTextBackgroundColor() const
    513424{
    514     NSColor *color = m_usesInactiveTextBackgroundColor ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
     425    NSColor *color = usesInactiveTextBackgroundColor() ? [NSColor secondarySelectedControlColor] : [NSColor selectedTextBackgroundColor];
    515426    // this needs to always use device colorspace so it can de-calibrate the color for
    516427    // Color to possibly recalibrate it
     
    530441}
    531442
    532 void GraphicsContext::fillRect(int x, int y, int w, int h, const Brush& brush)
    533 {
    534     if (m_data->state.paintingDisabled)
     443void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
     444{
     445    if (paintingDisabled())
    535446        return;
    536447
    537448    if (brush.style() == Brush::SolidPattern)
    538         fillRectSourceOver(x, y, w, h, brush.color());
    539 }
    540 
    541 void GraphicsContext::fillRect(const IntRect& rect, const Brush& brush)
    542 {
    543     fillRect(rect.x(), rect.y(), rect.width(), rect.height(), brush);
     449        fillRectSourceOver(rect, brush.color());
    544450}
    545451
    546452void GraphicsContext::addClip(const IntRect& rect)
    547453{
    548     if (m_data->state.paintingDisabled)
     454    if (paintingDisabled())
    549455        return;
    550456
     
    555461                                  const IntSize& bottomLeft, const IntSize& bottomRight)
    556462{
    557     if (m_data->state.paintingDisabled)
     463    if (paintingDisabled())
    558464        return;
    559465
     
    606512}
    607513
    608 void GraphicsContext::setPaintingDisabled(bool f)
    609 {
    610     m_data->state.paintingDisabled = f;
    611 }
    612 
    613 bool GraphicsContext::paintingDisabled() const
    614 {
    615     return m_data->state.paintingDisabled;
    616 }
    617 
    618514CGContextRef GraphicsContext::currentCGContext()
    619515{
     
    630526void GraphicsContext::beginTransparencyLayer(float opacity)
    631527{
    632     if (m_data->state.paintingDisabled)
     528    if (paintingDisabled())
    633529        return;
    634530    CGContextRef context = currentCGContext();
     
    640536void GraphicsContext::endTransparencyLayer()
    641537{
    642     if (m_data->state.paintingDisabled)
     538    if (paintingDisabled())
    643539        return;
    644540    CGContextRef context = currentCGContext();
     
    649545void GraphicsContext::setShadow(int x, int y, int blur, const Color& color)
    650546{
    651     if (m_data->state.paintingDisabled)
     547    if (paintingDisabled())
    652548        return;
    653549    // Check for an invalid color, as this means that the color was not set for the shadow
     
    668564void GraphicsContext::clearShadow()
    669565{
    670     if (m_data->state.paintingDisabled)
     566    if (paintingDisabled())
    671567        return;
    672568    CGContextRef context = currentCGContext();
     
    676572void GraphicsContext::drawFocusRing(const Color& color)
    677573{
    678     if (m_data->state.paintingDisabled)
    679         return;
    680     int radius = (m_focusRingWidth - 1) / 2;
    681     int offset = radius + m_focusRingOffset;
     574    if (paintingDisabled())
     575        return;
     576    int radius = (focusRingWidth() - 1) / 2;
     577    int offset = radius + focusRingOffset();
    682578    CGColorRef colorRef = color.isValid() ? cgColor(color) : 0;
    683579   
    684580    CGMutablePathRef focusRingPath = CGPathCreateMutable();
    685     unsigned rectCount = m_focusRingRects.size();
     581    const Vector<IntRect>& rects = focusRingRects();
     582    unsigned rectCount = rects.size();
    686583   
    687584    for (unsigned i = 0; i < rectCount; i++)
    688         CGPathAddRect(focusRingPath, 0, CGRectInset(m_focusRingRects[i], -offset, -offset));
     585        CGPathAddRect(focusRingPath, 0, CGRectInset(rects[i], -offset, -offset));
    689586   
    690587    [[WebCoreGraphicsBridge sharedBridge] drawFocusRingWithPath:focusRingPath radius:radius color:colorRef];
  • trunk/WebCore/rendering/RenderBox.cpp

    r13393 r13396  
    432432    // Paint the color first underneath all images.
    433433    if (!bgLayer->next() && bgColor.isValid() && bgColor.alpha() > 0) {
     434        IntRect rect(_tx, clipy, w, cliph);
    434435        // If we have an alpha and we are painting the root element, go ahead and blend with white.
    435436        if (bgColor.alpha() < 0xFF && isRoot() && !canvas()->view()->isTransparent())
    436             p->fillRect(_tx, clipy, w, cliph, Color(Color::white));
    437         p->fillRect(_tx, clipy, w, cliph, bgColor);
     437            p->fillRect(rect, Color(Color::white));
     438        p->fillRect(rect, bgColor);
    438439    }
    439440   
     
    568569
    569570        if (cw>0 && ch>0)
    570             p->drawTiledImage(bg->image(), cx, cy, cw, ch, sx, sy);
     571            p->drawTiledImage(bg->image(), IntRect(cx, cy, cw, ch), sx, sy);
    571572    }
    572573   
     
    578579}
    579580
    580 void RenderBox::outlineBox(GraphicsContext* p, int _tx, int _ty, const char *color)
     581void RenderBox::outlineBox(GraphicsContext* p, int _tx, int _ty, const char* color)
    581582{
    582583    p->setPen(Pen(Color(color), 1, Pen::DotLine));
    583584    p->setBrush(WebCore::Brush::NoBrush);
    584     p->drawRect(_tx, _ty, m_width, m_height);
     585    p->drawRect(IntRect(_tx, _ty, m_width, m_height));
    585586}
    586587
  • trunk/WebCore/rendering/RenderImage.cpp

    r13393 r13396  
    190190    bool drawSelectionTint = isSelected() && !isPrinting;
    191191    if (i.phase == PaintActionSelection) {
    192         if (selectionState() == SelectionNone) {
     192        if (selectionState() == SelectionNone)
    193193            return;
    194         }
    195194        drawSelectionTint = false;
    196195    }
     
    214213                p->setPen (Color::lightGray);
    215214                p->setBrush (WebCore::Brush::NoBrush);
    216                 p->drawRect (_tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight);
     215                p->drawRect (IntRect(_tx + leftBorder + leftPad, _ty + topBorder + topPad, cWidth, cHeight));
    217216            }
    218217           
  • trunk/WebCore/rendering/RenderObject.cpp

    r13393 r13396  
    829829            case BSBottom:
    830830            case BSTop:
    831                 p->drawLine(x1, (y1+y2)/2, x2, (y1+y2)/2);
     831                p->drawLine(IntPoint(x1, (y1+y2)/2), IntPoint(x2, (y1+y2)/2));
    832832                break;
    833833            case BSRight:
    834834            case BSLeft:
    835                 p->drawLine((x1+x2)/2, y1, (x1+x2)/2, y2);
     835                p->drawLine(IntPoint((x1+x2)/2, y1), IntPoint((x1+x2)/2, y2));
    836836                break;
    837837            }
     
    851851            case BSTop:
    852852            case BSBottom:
    853                 p->drawRect(x1, y1      , x2-x1, third);
    854                 p->drawRect(x1, y2-third, x2-x1, third);
     853                p->drawRect(IntRect(x1, y1      , x2-x1, third));
     854                p->drawRect(IntRect(x1, y2-third, x2-x1, third));
    855855                break;
    856856            case BSLeft:
    857                 p->drawRect(x1      , y1+1, third, y2-y1-1);
    858                 p->drawRect(x2-third, y1+1, third, y2-y1-1);
     857                p->drawRect(IntRect(x1      , y1+1, third, y2-y1-1));
     858                p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
    859859                break;
    860860            case BSRight:
    861                 p->drawRect(x1      , y1+1, third, y2-y1-1);
    862                 p->drawRect(x2-third, y1+1, third, y2-y1-1);
     861                p->drawRect(IntRect(x1      , y1+1, third, y2-y1-1));
     862                p->drawRect(IntRect(x2-third, y1+1, third, y2-y1-1));
    863863                break;
    864864            }
     
    867867        {
    868868            int adjbw1bigthird;
    869             if (adjbw1>0) adjbw1bigthird = adjbw1+1;
    870             else adjbw1bigthird = adjbw1 - 1;
     869            if (adjbw1>0)
     870                adjbw1bigthird = adjbw1+1;
     871            else
     872                adjbw1bigthird = adjbw1 - 1;
    871873            adjbw1bigthird /= 3;
    872874
    873875            int adjbw2bigthird;
    874             if (adjbw2>0) adjbw2bigthird = adjbw2 + 1;
    875             else adjbw2bigthird = adjbw2 - 1;
     876            if (adjbw2>0)
     877                adjbw2bigthird = adjbw2 + 1;
     878            else
     879                adjbw2bigthird = adjbw2 - 1;
    876880            adjbw2bigthird /= 3;
    877881
     
    962966        ASSERT(x2 >= x1);
    963967        ASSERT(y2 >= y1);
    964         if (adjbw1==0 && adjbw2 == 0)
    965           {
    966             p->drawRect(x1,y1,x2-x1,y2-y1);
     968        if (adjbw1==0 && adjbw2 == 0) {
     969            p->drawRect(IntRect(x1,y1,x2-x1,y2-y1));
    967970            return;
    968           }
     971        }
    969972        switch(s) {
    970973        case BSTop:
     
    10431046        // The rect to use from within the image is obtained from our slice, and is (0, 0, leftSlice, topSlice)
    10441047        if (drawTop)
    1045             p->drawImage(borderImage->image(), _tx, _ty, style->borderLeftWidth(), style->borderTopWidth(),
     1048            p->drawImage(borderImage->image(), IntRect(_tx, _ty, style->borderLeftWidth(), style->borderTopWidth()),
    10461049                         0, 0, leftSlice, topSlice);
    10471050       
     
    10491052        // The rect to use from within the image is (0, imageHeight - bottomSlice, leftSlice, botomSlice)
    10501053        if (drawBottom)
    1051             p->drawImage(borderImage->image(), _tx, _ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth(),
     1054            p->drawImage(borderImage->image(), IntRect(_tx, _ty + h - style->borderBottomWidth(), style->borderLeftWidth(), style->borderBottomWidth()),
    10521055                         0, imageHeight - bottomSlice, leftSlice, bottomSlice);
    10531056                     
    10541057        // Paint the left edge.
    10551058        // Have to scale and tile into the border rect.
    1056         p->drawScaledAndTiledImage(borderImage->image(), _tx, _ty + style->borderTopWidth(), style->borderLeftWidth(),
    1057                                     h - style->borderTopWidth() - style->borderBottomWidth(),
     1059        p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx, _ty + style->borderTopWidth(), style->borderLeftWidth(),
     1060                                    h - style->borderTopWidth() - style->borderBottomWidth()),
    10581061                                    0, topSlice, leftSlice, imageHeight - topSlice - bottomSlice,
    10591062                                    Image::StretchTile, (Image::TileRule)vRule);
     
    10651068        // The rect to use from within the image is obtained from our slice, and is (imageWidth - rightSlice, 0, rightSlice, topSlice)
    10661069        if (drawTop)
    1067             p->drawImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty, style->borderRightWidth(), style->borderTopWidth(),
     1070            p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty, style->borderRightWidth(), style->borderTopWidth()),
    10681071                         imageWidth - rightSlice, 0, rightSlice, topSlice);
    10691072       
     
    10711074        // The rect to use from within the image is (imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, botomSlice)
    10721075        if (drawBottom)
    1073             p->drawImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth(),
     1076            p->drawImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + h - style->borderBottomWidth(), style->borderRightWidth(), style->borderBottomWidth()),
    10741077                         imageWidth - rightSlice, imageHeight - bottomSlice, rightSlice, bottomSlice);
    10751078                     
    10761079        // Paint the right edge.
    1077         p->drawScaledAndTiledImage(borderImage->image(), _tx + w - style->borderRightWidth(), _ty + style->borderTopWidth(), style->borderRightWidth(),
    1078                           h - style->borderTopWidth() - style->borderBottomWidth(),
     1080        p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + w - style->borderRightWidth(), _ty + style->borderTopWidth(), style->borderRightWidth(),
     1081                          h - style->borderTopWidth() - style->borderBottomWidth()),
    10791082                          imageWidth - rightSlice, topSlice, rightSlice, imageHeight - topSlice - bottomSlice,
    10801083                          Image::StretchTile, (Image::TileRule)vRule);
     
    10831086    // Paint the top edge.
    10841087    if (drawTop)
    1085         p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty, w - style->borderLeftWidth() - style->borderRightWidth(),
    1086                           style->borderTopWidth(),
     1088        p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty, w - style->borderLeftWidth() - style->borderRightWidth(), style->borderTopWidth()),
    10871089                          leftSlice, 0, imageWidth - rightSlice - leftSlice, topSlice,
    10881090                          (Image::TileRule)hRule, Image::StretchTile);
     
    10901092    // Paint the bottom edge.
    10911093    if (drawBottom)
    1092         p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty + h - style->borderBottomWidth(),
    1093                           w - style->borderLeftWidth() - style->borderRightWidth(),
    1094                           style->borderBottomWidth(),
     1094        p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + h - style->borderBottomWidth(),
     1095                          w - style->borderLeftWidth() - style->borderRightWidth(), style->borderBottomWidth()),
    10951096                          leftSlice, imageHeight - bottomSlice, imageWidth - rightSlice - leftSlice, bottomSlice,
    10961097                          (Image::TileRule)hRule, Image::StretchTile);
     
    10981099    // Paint the middle.
    10991100    if (drawMiddle)
    1100         p->drawScaledAndTiledImage(borderImage->image(), _tx + style->borderLeftWidth(), _ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
    1101                           h - style->borderTopWidth() - style->borderBottomWidth(),
     1101        p->drawScaledAndTiledImage(borderImage->image(), IntRect(_tx + style->borderLeftWidth(), _ty + style->borderTopWidth(), w - style->borderLeftWidth() - style->borderRightWidth(),
     1102                          h - style->borderTopWidth() - style->borderBottomWidth()),
    11021103                          leftSlice, topSlice, imageWidth - rightSlice - leftSlice, imageHeight - topSlice - bottomSlice,
    11031104                          (Image::TileRule)hRule, (Image::TileRule)vRule);
  • trunk/WebCore/rendering/render_frames.cpp

    r13393 r13396  
    516516                paint.setBrush(Color::gray);
    517517                v->setDrawingAlpha(0.25);
    518                 paint.drawRect(p + sw/2 - rBord, r.y(), 2*rBord, r.height());
     518                paint.drawRect(IntRect(p + sw/2 - rBord, r.y(), 2 * rBord, r.height()));
    519519                v->setDrawingAlpha(1.0);
    520520            }
    521521        } else {
    522522            if (m_oldpos >= 0)
    523                 v->updateContents(IntRect(r.x(), m_oldpos + sw/2 - rBord, r.width(), 2*rBord), true);
     523                v->updateContents(IntRect(r.x(), m_oldpos + sw/2 - rBord, r.width(), 2 * rBord), true);
    524524            if (p >= 0) {
    525525                paint.setPen(Pen::NoPen);
    526526                paint.setBrush(Color::gray);
    527527                v->setDrawingAlpha(0.25);
    528                 paint.drawRect(r.x(), p + sw/2 - rBord, r.width(), 2 * rBord);
     528                paint.drawRect(IntRect(r.x(), p + sw/2 - rBord, r.width(), 2 * rBord));
    529529                v->setDrawingAlpha(1.0);
    530530            }
  • trunk/WebCore/rendering/render_list.cpp

    r13393 r13396  
    431431    case DISC:
    432432        p->setBrush(color);
    433         p->drawEllipse(marker.x(), marker.y(), marker.width(), marker.height());
     433        p->drawEllipse(marker);
    434434        return;
    435435    case CIRCLE:
    436436        p->setBrush(WebCore::Brush::NoBrush);
    437         p->drawEllipse(marker.x(), marker.y(), marker.width(), marker.height());
     437        p->drawEllipse(marker);
    438438        return;
    439439    case SQUARE:
    440440        p->setBrush(color);
    441         p->drawRect(marker.x(), marker.y(), marker.width(), marker.height());
     441        p->drawRect(marker);
    442442        return;
    443443    case LNONE:
Note: See TracChangeset for help on using the changeset viewer.