Show
Ignore:
Timestamp:
04/29/07 13:32:51 (21 months ago)
Author:
darin
Message:

Reviewed by Adele.

This patch changes things so that resizing can make things larger than their
initial size, but not smaller. I believe this resolves the problem for Gmail,
but you can still get strange behavior if you have a small right-aligned <textarea>.

  • rendering/RenderLayer.cpp: (WebCore::RenderLayer::resize): Rewrote to use more IntPoint and IntSize and add in a new minimum-size algorithm. This function now has the side effect of storing a new minimumSizeForResizing in the element being resized, and respects any existing minimum as well. (WebCore::RenderLayer::offsetFromResizeCorner): Reversed this so it converts the point into coordinates relative to the resize corner, hence negative numbers mean the point is above and to the left. This is used only in the algorithm above.
  • dom/Element.h: Removed unneeded include of Attr.h, and added forward declarations as needed. Removed all friend declarations; there was no need for any of them. Tweaked formatting of various declarations and removed unneeded parameter names. Made as much as possible private, and a couple things public to avoid the need for friend classes. Added minimumSizeForResizing, setMinimumSizeForResizing, rareData, and createRareData functions.
  • dom/Element.cpp: (WebCore::rareDataMap): Added. Function to return the single global map. (WebCore::rareDataFromMap): Added. For use by inlined functions to get the data from the map in the case where it's present. (WebCore::ElementRareData::ElementRareData): Added. (WebCore::Element::~Element): Added code to delete the element from the rare data map when appropriate. (WebCore::Element::rareData): Added. (WebCore::Element::createRareData): Added. (WebCore::Element::setAttributeNodeNS): Got rid of the old inline version of this, since it was the sole reason we had to include Attr.h in Element.h. (WebCore::Element::minimumSizeForResizing): Added. Accesses rare data. (WebCore::Element::setMinimumSizeForResizing): Ditto.
  • dom/Node.h: Renamed the m_specified bit since it's now used for two purposes. Its new long name is m_attrWasSpecifiedOrElementHasRareData.
  • dom/Attr.cpp: (WebCore::Attr::Attr): Updated for bit name change.
  • dom/Attr.h: (WebCore::Attr::specified): Ditto. (WebCore::Attr::setSpecified): Added, since setting the bit directly is pretty ugly now.
  • dom/Document.cpp: (WebCore::Document::adoptNode): Updated for bit name change.
  • dom/Node.cpp: (WebCore::Node::Node): Ditto. (WebCore::Node::dump): Ditto.
  • dom/NamedAttrMap.cpp: (WebCore::NamedAttrMap::isReadOnlyNode): Moved out of line, since this was the sole reason we had to include Element.h in NamedAttrMap.h.
  • html/HTMLElement.cpp: (WebCore::HTMLElement::nodeName): Changed to use tagQName() since that's a public way to do something that's now private. (WebCore::HTMLElement::cloneNode): Ditto.
  • dom/Attribute.cpp:
  • dom/NamedAttrMap.h:
  • dom/NamedMappedAttrMap.cpp:
  • dom/StyledElement.h:
  • html/HTMLTokenizer.h:
  • xml/XPathFunctions.cpp:
  • xml/XPathStep.cpp: Updated includes, and other administrivia.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/dom/Element.h

    r20072 r21184  
    11/* 
    2  * This file is part of the DOM implementation for KDE. 
    3  * 
    42 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 
    53 *           (C) 1999 Antti Koivisto (koivisto@kde.org) 
    64 *           (C) 2001 Peter Kelly (pmk@post.com) 
    75 *           (C) 2001 Dirk Mueller (mueller@kde.org) 
    8  * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. 
     6 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 
    97 * 
    108 * This library is free software; you can redistribute it and/or 
     
    2826#define Element_h 
    2927 
    30 #include "Attr.h" 
     28#include "ContainerNode.h" 
     29#include "QualifiedName.h" 
    3130#include "ScrollTypes.h" 
    3231#include "Timer.h" 
     
    3534 
    3635class AtomicStringList; 
     36class Attr; 
    3737class Attribute; 
     38class CSSStyleDeclaration; 
     39class ElementRareData; 
     40class IntSize; 
    3841 
    3942class Element : public ContainerNode { 
    40     friend class Document; 
    41     friend class NamedAttrMap; 
    42     friend class Attr; 
    43     friend class Node; 
    44     friend class CSSStyleSelector; 
    4543public: 
    4644    Element(const QualifiedName&, Document*); 
     
    5048    virtual const AtomicStringList* getClassList() const; 
    5149    const AtomicString& getIDAttribute() const; 
    52     bool hasAttribute(const QualifiedName& name) const; 
    53     const AtomicString& getAttribute(const QualifiedName& name) const; 
    54     void setAttribute(const QualifiedName& name, StringImpl* value, ExceptionCode&); 
    55     void removeAttribute(const QualifiedName& name, ExceptionCode&); 
     50    bool hasAttribute(const QualifiedName&) const; 
     51    const AtomicString& getAttribute(const QualifiedName&) const; 
     52    void setAttribute(const QualifiedName&, StringImpl* value, ExceptionCode&); 
     53    void removeAttribute(const QualifiedName&, ExceptionCode&); 
    5654 
    5755    bool hasAttributes() const; 
     
    8987    int scrollHeight(); 
    9088 
    91     void removeAttribute(const String &name, ExceptionCode& ec); 
    92     void removeAttributeNS(const String &namespaceURI, const String& localName, ExceptionCode&); 
     89    void removeAttribute(const String& name, ExceptionCode&); 
     90    void removeAttributeNS(const String& namespaceURI, const String& localName, ExceptionCode&); 
    9391 
    9492    PassRefPtr<Attr> getAttributeNode(const String& name); 
    9593    PassRefPtr<Attr> getAttributeNodeNS(const String& namespaceURI, const String& localName); 
    9694    PassRefPtr<Attr> setAttributeNode(Attr*, ExceptionCode&); 
    97     PassRefPtr<Attr> setAttributeNodeNS(Attr* newAttr, ExceptionCode& ec) { return setAttributeNode(newAttr, ec); } 
     95    PassRefPtr<Attr> setAttributeNodeNS(Attr*, ExceptionCode&); 
    9896    PassRefPtr<Attr> removeAttributeNode(Attr*, ExceptionCode&); 
    9997     
    100     virtual CSSStyleDeclaration *style(); 
     98    virtual CSSStyleDeclaration* style(); 
    10199 
    102100    const QualifiedName& tagQName() const { return m_tagName; } 
     
    126124 
    127125    // convenience methods which ignore exceptions 
    128     void setAttribute(const QualifiedName& name, const String& value); 
    129  
    130     virtual NamedAttrMap *attributes() const; 
     126    void setAttribute(const QualifiedName&, const String& value); 
     127 
     128    virtual NamedAttrMap* attributes() const; 
    131129    NamedAttrMap* attributes(bool readonly) const; 
    132130 
    133131    // This method is called whenever an attribute is added, changed or removed. 
    134     virtual void attributeChanged(Attribute* attr, bool preserveDecls = false) {} 
     132    virtual void attributeChanged(Attribute*, bool preserveDecls = false) {} 
    135133 
    136134    // not part of the DOM 
    137135    void setAttributeMap(NamedAttrMap*); 
    138136 
    139     virtual void copyNonAttributeProperties(const Element *source) {} 
     137    virtual void copyNonAttributeProperties(const Element* source) {} 
    140138 
    141139    virtual void attach(); 
    142140    virtual void detach(); 
    143     virtual RenderStyle *styleForRenderer(RenderObject *parent); 
    144     virtual RenderObject *createRenderer(RenderArena *, RenderStyle *); 
    145     virtual void recalcStyle( StyleChange = NoChange ); 
     141    virtual RenderStyle* styleForRenderer(RenderObject* parent); 
     142    virtual RenderObject* createRenderer(RenderArena*, RenderStyle*); 
     143    virtual void recalcStyle(StyleChange = NoChange); 
    146144 
    147145    virtual bool childTypeAllowed(NodeType); 
     
    149147    virtual Attribute* createAttribute(const QualifiedName& name, StringImpl* value); 
    150148     
    151     void dispatchAttrRemovalEvent(Attribute *attr); 
    152     void dispatchAttrAdditionEvent(Attribute *attr); 
     149    void dispatchAttrRemovalEvent(Attribute*); 
     150    void dispatchAttrAdditionEvent(Attribute*); 
    153151 
    154152    virtual void accessKeyAction(bool sendToAnyEvent) { } 
     
    156154    virtual String toString() const; 
    157155 
    158     virtual bool isURLAttribute(Attribute *attr) const; 
     156    virtual bool isURLAttribute(Attribute*) const; 
    159157    virtual String target() const { return String(); } 
    160158         
     
    164162    bool needsFocusAppearanceUpdate() const { return m_needsFocusAppearanceUpdate; } 
    165163    void setNeedsFocusAppearanceUpdate(bool b) { m_needsFocusAppearanceUpdate = b; } 
    166      
     164 
    167165#ifndef NDEBUG 
    168     virtual void dump(TextStream *stream, DeprecatedString ind = "") const; 
    169     virtual void formatForDebugger(char *buffer, unsigned length) const; 
     166    virtual void dump(TextStream* , DeprecatedString ind = "") const; 
     167    virtual void formatForDebugger(char* buffer, unsigned length) const; 
    170168#endif 
    171169 
    172     Node* insertAdjacentElement(const String& where, Node* newChild, int& exception); 
     170    Node* insertAdjacentElement(const String& where, Node* newChild, ExceptionCode&); 
    173171    bool contains(const Node*) const; 
    174172 
     
    178176    virtual String title() const; 
    179177 
    180 protected: 
     178    String openTagStartToString() const; 
     179 
     180    void updateId(const AtomicString& oldId, const AtomicString& newId); 
     181 
     182    IntSize minimumSizeForResizing() const; 
     183    void setMinimumSizeForResizing(const IntSize&); 
     184 
     185private: 
     186    ElementRareData* rareData(); 
     187    const ElementRareData* rareData() const; 
     188    ElementRareData* createRareData(); 
     189 
    181190    virtual void createAttributeMap() const; 
    182     String openTagStartToString() const; 
    183  
    184 private: 
    185     void updateId(const AtomicString& oldId, const AtomicString& newId); 
    186191 
    187192    virtual void updateStyleAttributeIfNeeded() const {} 
     
    192197    bool m_needsFocusAppearanceUpdate; 
    193198 
    194 protected: // member variables 
     199protected: 
    195200    mutable RefPtr<NamedAttrMap> namedAttrMap; 
     201 
     202private: 
    196203    QualifiedName m_tagName; 
    197204};