Changeset 35640 in webkit


Ignore:
Timestamp:
Aug 8, 2008 5:59:30 AM (16 years ago)
Author:
jchaffraix@webkit.org
Message:

WebCore:

2008-08-08 Julien Chaffraix <jchaffraix@webkit.org>

Reviewed by Eric.

Tests: fast/xbl/xbl-crash-inline.xhtml

fast/xbl/xbl-document-sheets-modification.xhtml
fast/xbl/xbl-element-binding.xhtml

Bug 20212: [XBL] Add full support for element="" attachment

  • Add attributeChanged method to XBLBindingElement to catch "element" changes and update the bindings.
  • Translate "element" attribute to a stylesheet that is added to the bound document's sheets.
  • GNUmakefile.am: Add XBLBindingElement.cpp.
  • WebCore.pro: Ditto.
  • WebCore.xcodeproj/project.pbxproj: Ditto.
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::CSSStyleSelector): Add binding sheets.
  • dom/Document.cpp: (WebCore::Document::~Document): Remove binding sheet information.

(WebCore::Document::recalcStyleSelector): When
recalculating the style selector, remove all the bindings
as the removed sheets would never remove theirs.

(WebCore::Document::addBindingSheet): Update binding manager
information.
(WebCore::Document::removeBindingSheet): Ditto.

  • dom/Document.h:
  • xbl/XBLBindingElement.cpp: Added. (WebCore::XBLBindingElement::XBLBindingElement): (WebCore::XBLBindingElement::attributeChanged): Check for "element" changes and update the cached sheet and the bound element's bindings style sheets.

(WebCore::XBLBindingElement::generateBindingSheet): Create
the style sheet from the "element" attribute.

  • xbl/XBLBindingElement.h:
  • xbl/XBLBindingManager.cpp: (WebCore::XBLBindingManager::addBindingSheet): (WebCore::XBLBindingManager::removeBindingSheet): (WebCore::XBLBindingManager::clearBindingSheets): (WebCore::XBLBindingManager::getBindingSheets): All 4 previous methods are used to manage the binding sheets.
  • xbl/XBLBindingManager.h:

LayoutTests:

2008-08-08 Julien Chaffraix <jchaffraix@webkit.org>

Reviewed by Eric.

Test case for bug 20212: [XBL] Add full support for element="" attachment


  • fast/xbl/xbl-crash-inline-expected.txt: Added.
  • fast/xbl/xbl-crash-inline.xhtml: Added.
  • fast/xbl/xbl-document-sheets-modification-expected.txt: Added.
  • fast/xbl/xbl-document-sheets-modification.xhtml: Added.
  • fast/xbl/xbl-element-binding-expected.txt: Added.
  • fast/xbl/xbl-element-binding.xhtml: Added.


Location:
branches/XBL2
Files:
7 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/XBL2/LayoutTests/ChangeLog

    r35416 r35640  
     12008-08-08  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Eric.
     4
     5        Test case for bug 20212: [XBL] Add full support for element="" attachment
     6
     7        * fast/xbl/xbl-crash-inline-expected.txt: Added.
     8        * fast/xbl/xbl-crash-inline.xhtml: Added.
     9        * fast/xbl/xbl-document-sheets-modification-expected.txt: Added.
     10        * fast/xbl/xbl-document-sheets-modification.xhtml: Added.
     11        * fast/xbl/xbl-element-binding-expected.txt: Added.
     12        * fast/xbl/xbl-element-binding.xhtml: Added.
     13
    1142008-07-28  Julien Chaffraix  <jchaffraix@webkit.org>
    215
  • branches/XBL2/WebCore/ChangeLog

    r35637 r35640  
     12008-08-08  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Eric.
     4
     5        Tests: fast/xbl/xbl-crash-inline.xhtml
     6               fast/xbl/xbl-document-sheets-modification.xhtml
     7               fast/xbl/xbl-element-binding.xhtml
     8
     9        Bug 20212: [XBL] Add full support for element="" attachment
     10
     11        - Add attributeChanged method to XBLBindingElement to catch "element"
     12        changes and update the bindings.
     13
     14        - Translate "element" attribute to a stylesheet that is added to the bound
     15        document's sheets.
     16
     17        * GNUmakefile.am: Add XBLBindingElement.cpp.
     18        * WebCore.pro: Ditto.
     19        * WebCore.xcodeproj/project.pbxproj: Ditto.
     20
     21        * css/CSSStyleSelector.cpp:
     22        (WebCore::CSSStyleSelector::CSSStyleSelector): Add binding
     23        sheets.
     24
     25        * dom/Document.cpp:
     26        (WebCore::Document::~Document): Remove binding
     27        sheet information.
     28
     29        (WebCore::Document::recalcStyleSelector): When
     30        recalculating the style selector, remove all the bindings
     31        as the removed sheets would never remove theirs.
     32
     33        (WebCore::Document::addBindingSheet): Update binding manager
     34        information.
     35        (WebCore::Document::removeBindingSheet): Ditto.
     36
     37        * dom/Document.h:
     38        * xbl/XBLBindingElement.cpp: Added.
     39        (WebCore::XBLBindingElement::XBLBindingElement):
     40        (WebCore::XBLBindingElement::attributeChanged): Check
     41        for "element" changes and update the cached sheet and the
     42        bound element's bindings style sheets.
     43
     44        (WebCore::XBLBindingElement::generateBindingSheet): Create
     45        the style sheet from the "element" attribute.
     46
     47        * xbl/XBLBindingElement.h:
     48        * xbl/XBLBindingManager.cpp:
     49        (WebCore::XBLBindingManager::addBindingSheet):
     50        (WebCore::XBLBindingManager::removeBindingSheet):
     51        (WebCore::XBLBindingManager::clearBindingSheets):
     52        (WebCore::XBLBindingManager::getBindingSheets): All 4 previous
     53        methods are used to manage the binding sheets.
     54
     55        * xbl/XBLBindingManager.h:
     56
    1572008-08-08  Julien Chaffraix  <jchaffraix@webkit.org>
    258
  • branches/XBL2/WebCore/GNUmakefile.am

    r35412 r35640  
    14451445webcore_sources += \
    14461446        WebCore/loader/CachedXBLDocument.cpp \
     1447        WebCore/xbl/XBLBindingElement.cpp \
    14471448        WebCore/xbl/XBLBindingManager.cpp \
    14481449        WebCore/xbl/XBLXBLElement.cpp
  • branches/XBL2/WebCore/WebCore.pro

    r35412 r35640  
    12371237    SOURCES += \
    12381238        loader/CachedXBLDocument.cpp \
     1239        xbl/XBLBindingElement.cpp \
    12391240        xbl/XBLBindingManager.cpp \
    12401241        xbl/XBLXBLElement.cpp
  • branches/XBL2/WebCore/WebCore.xcodeproj/project.pbxproj

    r35325 r35640  
    18301830                A10D21420E389A18007E500B /* XBLTemplateElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A10D21410E389A18007E500B /* XBLTemplateElement.h */; };
    18311831                A1172D6E0E0C539E00175C88 /* XBLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = A1172D6D0E0C539E00175C88 /* XBLDocument.h */; };
     1832                A14EF7AC0E3F106900DA9F39 /* XBLBindingElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A14EF7AB0E3F106900DA9F39 /* XBLBindingElement.cpp */; };
    18321833                A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18331834                A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; };
     
    63046305                A10D21410E389A18007E500B /* XBLTemplateElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBLTemplateElement.h; sourceTree = "<group>"; };
    63056306                A1172D6D0E0C539E00175C88 /* XBLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBLDocument.h; sourceTree = "<group>"; };
     6307                A14EF7AB0E3F106900DA9F39 /* XBLBindingElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBLBindingElement.cpp; sourceTree = "<group>"; };
    63066308                A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = "<group>"; };
    63076309                A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = "<group>"; };
     
    1330613308                                A10D21410E389A18007E500B /* XBLTemplateElement.h */,
    1330713309                                A10D213F0E389A0D007E500B /* XBLBindingElement.h */,
     13310                                A14EF7AB0E3F106900DA9F39 /* XBLBindingElement.cpp */,
    1330813311                                A10D20A30E386DCF007E500B /* XBLBinding.h */,
    1330913312                                A10D20A40E386DCF007E500B /* XBLBindingManager.cpp */,
     
    1710417107                                F9C6760B0DEC7903008D0C2F /* XBLNames.cpp in Sources */,
    1710517108                                A10D20A70E386DCF007E500B /* XBLBindingManager.cpp in Sources */,
     17109                                A14EF7AC0E3F106900DA9F39 /* XBLBindingElement.cpp in Sources */,
    1710617110                        );
    1710717111                        runOnlyForDeploymentPostprocessing = 0;
  • branches/XBL2/WebCore/css/CSSStyleSelector.cpp

    r35416 r35640  
    378378            m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(sheet), *m_medium, this);
    379379    }
     380
     381#if ENABLE(XBL)
     382    // Add bindings's style sheets.
     383    XBLBindingManager* manager = XBLBindingManager::sharedInstance();
     384    StyleSheetVector* bindingSheets = manager->getBindingSheets(doc);
     385
     386    if (!bindingSheets)
     387        return;
     388
     389    for (StyleSheetVector::iterator it = bindingSheets->begin(); it != bindingSheets->end(); ++it)
     390        if ((*it)->isCSSStyleSheet() && !(*it)->disabled())
     391            m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>((*it).get()), *m_medium, this);
     392#endif
    380393}
    381394
  • branches/XBL2/WebCore/dom/Document.cpp

    r35324 r35640  
    128128
    129129#if ENABLE(XBL)
     130#include "XBLBindingManager.h"
    130131#include "XBLElement.h"
    131132#include "XBLElementFactory.h"
     
    403404    delete m_svgExtensions;
    404405#endif
     406#if ENABLE(XBL)
     407    XBLBindingManager* manager = XBLBindingManager::sharedInstance();
     408    manager->clearBindingSheets(this);
     409#endif
    405410
    406411    XMLHttpRequest::detachRequests(this);
     
    22692274            sheets.append(sheet);
    22702275
     2276#if ENABLE(XBL)
     2277        // Remove all bindings as some binding sheets may be removed
     2278        // and they wouldn't update their bindings.
     2279        // FIXME: This should be done only if a binding sheet was removed instead of always.
     2280        if (n->isElementNode()) {
     2281            XBLBindingManager* manager = XBLBindingManager::sharedInstance();
     2282            manager->removeAllBindings(static_cast<Element*>(n));
     2283        }
     2284#endif
    22712285        // For HTML documents, stylesheets are not allowed within/after the <BODY> tag. So we
    22722286        // can stop searching here.
     
    36363650#endif
    36373651
     3652#if ENABLE(XBL)
     3653void Document::addBindingSheet(PassRefPtr<CSSStyleSheet> sheet)
     3654{
     3655    XBLBindingManager* manager = XBLBindingManager::sharedInstance();
     3656    manager->addBindingSheet(this, sheet);
     3657}
     3658
     3659void Document::removeBindingSheet(CSSStyleSheet* sheet)
     3660{
     3661    XBLBindingManager* manager = XBLBindingManager::sharedInstance();
     3662    manager->removeBindingSheet(this, sheet);
     3663}
     3664#endif
     3665
    36383666PassRefPtr<HTMLCollection> Document::images()
    36393667{
  • branches/XBL2/WebCore/dom/Document.h

    r35324 r35640  
    935935#endif
    936936
     937#if ENABLE(XBL)
     938    void addBindingSheet(PassRefPtr<CSSStyleSheet>);
     939    void removeBindingSheet(CSSStyleSheet*);
     940#endif
     941
    937942    void initSecurityContext();
    938943    SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
     
    9951000    SVGDocumentExtensions* m_svgExtensions;
    9961001#endif
    997    
     1002
    9981003#if ENABLE(DASHBOARD_SUPPORT)
    9991004    Vector<DashboardRegionValue> m_dashboardRegions;
  • branches/XBL2/WebCore/xbl/XBLBindingElement.h

    r35325 r35640  
    3434namespace WebCore {
    3535
     36    class Attribute;
     37    class CSSStyleSheet;
     38
    3639    class XBLBindingElement : public XBLElement {
    3740    public:
    38         XBLBindingElement(const WebCore::QualifiedName& qName, WebCore::Document* doc)
    39             : XBLElement(qName, doc)
    40         {
    41         }
     41        XBLBindingElement(const QualifiedName&, Document*);
     42
     43        virtual void attributeChanged(Attribute*, bool preserveDecls = false);
     44
     45         // Generate the binding sheet associated by this element.
     46        PassRefPtr<CSSStyleSheet> generateBindingSheet();
     47
     48    private:
     49        // FIXME: This should be moved to the XBLBindingPrototype when it is created.
     50        RefPtr<CSSStyleSheet> m_bindingSheet;
    4251    };
    4352
  • branches/XBL2/WebCore/xbl/XBLBindingManager.cpp

    r35416 r35640  
    2929#if ENABLE(XBL)
    3030
     31#include "CSSStyleSheet.h"
    3132#include "XBLBinding.h"
    3233
     
    8990}
    9091
     92
     93void XBLBindingManager::addBindingSheet(Document* document, PassRefPtr<CSSStyleSheet> sheet)
     94{
     95    StyleSheetVector* documentSheets = m_bindingSheets.get(document);
     96    if (!documentSheets) {
     97        documentSheets = new StyleSheetVector();
     98        m_bindingSheets.add(document, documentSheets);
     99    }
     100    documentSheets->append(sheet);
     101}
     102
     103void XBLBindingManager::removeBindingSheet(Document* document, PassRefPtr<CSSStyleSheet> sheet)
     104{
     105    StyleSheetVector* documentSheets = m_bindingSheets.get(document);
     106
     107    // documentSheets is null if no sheets were added for this document.
     108    if (documentSheets) {
     109        for (StyleSheetVector::iterator it = documentSheets->begin(); it != documentSheets->end(); ++it)
     110            if (*it == sheet) {
     111                documentSheets->remove(it - documentSheets->begin());
     112                return;
     113            }
     114    }
     115
     116    // If we arrive here, it means that we did not find the sheet to remove, which
     117    // should NEVER occur.
     118    ASSERT_NOT_REACHED();
     119}
     120
     121void XBLBindingManager::clearBindingSheets(Document* document)
     122{
     123    delete m_bindingSheets.take(document);
     124}
     125
     126StyleSheetVector* XBLBindingManager::getBindingSheets(Document* document)
     127{
     128    return m_bindingSheets.get(document);
     129}
     130
    91131};
    92132
  • branches/XBL2/WebCore/xbl/XBLBindingManager.h

    r35324 r35640  
    3131#if ENABLE(XBL)
    3232
     33#include "StyleSheetList.h"
    3334#include "wtf/HashMap.h"
    3435#include "wtf/Vector.h"
     
    3637namespace WebCore {
    3738
     39    class CSSStyleSheet;
     40    class Document;
    3841    class Element;
    3942    class XBLBinding;
     
    5053        // Used by Element destructor to prevent leakage.
    5154        void removeAllBindings(Element* boundElement);
     55
     56        // Binding style sheets management.
     57        void addBindingSheet(Document*, PassRefPtr<CSSStyleSheet>);
     58        void removeBindingSheet(Document*, PassRefPtr<CSSStyleSheet>);
     59        void clearBindingSheets(Document*);
     60        StyleSheetVector* getBindingSheets(Document*);
     61
    5262    private:
    5363        XBLBindingManager();
    5464
    5565        HashMap<Element*, Vector<XBLBinding>* > m_bindings;
     66        HashMap<Document*, StyleSheetVector*> m_bindingSheets;
    5667    };
    5768
Note: See TracChangeset for help on using the changeset viewer.