Custom version of webkit with @tmm1's stack trace patch

This commit is contained in:
Corey Johnson
2012-01-30 11:03:35 -08:00
parent c87f37997b
commit 84f6a1ca01
2376 changed files with 314816 additions and 8 deletions

View File

@@ -0,0 +1 @@
Versions/Current/PrivateHeaders

View File

@@ -0,0 +1 @@
Versions/Current/Resources

View File

@@ -0,0 +1,218 @@
/*
* Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AXObjectCache_h
#define AXObjectCache_h
#include "AccessibilityObject.h"
#include "Timer.h"
#include <limits.h>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class Document;
class HTMLAreaElement;
class Node;
class Page;
class RenderObject;
class ScrollView;
class VisiblePosition;
class Widget;
struct TextMarkerData {
AXID axID;
Node* node;
int offset;
EAffinity affinity;
};
enum PostType { PostSynchronously, PostAsynchronously };
class AXObjectCache {
WTF_MAKE_NONCOPYABLE(AXObjectCache); WTF_MAKE_FAST_ALLOCATED;
public:
AXObjectCache(const Document*);
~AXObjectCache();
static AccessibilityObject* focusedUIElementForPage(const Page*);
// Returns the root object for the entire document.
AccessibilityObject* rootObject();
// Returns the root object for a specific frame.
AccessibilityObject* rootObjectForFrame(Frame*);
// For AX objects with elements that back them.
AccessibilityObject* getOrCreate(RenderObject*);
AccessibilityObject* getOrCreate(Widget*);
// used for objects without backing elements
AccessibilityObject* getOrCreate(AccessibilityRole);
// will only return the AccessibilityObject if it already exists
AccessibilityObject* get(RenderObject*);
AccessibilityObject* get(Widget*);
void remove(RenderObject*);
void remove(Widget*);
void remove(AXID);
void detachWrapper(AccessibilityObject*);
void attachWrapper(AccessibilityObject*);
void childrenChanged(RenderObject*);
void checkedStateChanged(RenderObject*);
void selectedChildrenChanged(RenderObject*);
// Called by a node when text or a text equivalent (e.g. alt) attribute is changed.
void contentChanged(RenderObject*);
void handleActiveDescendantChanged(RenderObject*);
void handleAriaRoleChanged(RenderObject*);
void handleFocusedUIElementChanged(RenderObject* oldFocusedRenderer, RenderObject* newFocusedRenderer);
void handleScrolledToAnchor(const Node* anchorNode);
void handleAriaExpandedChange(RenderObject*);
void handleScrollbarUpdate(ScrollView*);
static void enableAccessibility() { gAccessibilityEnabled = true; }
// Enhanced user interface accessibility can be toggled by the assistive technology.
static void setEnhancedUserInterfaceAccessibility(bool flag) { gAccessibilityEnhancedUserInterfaceEnabled = flag; }
static bool accessibilityEnabled() { return gAccessibilityEnabled; }
static bool accessibilityEnhancedUserInterfaceEnabled() { return gAccessibilityEnhancedUserInterfaceEnabled; }
void removeAXID(AccessibilityObject*);
bool isIDinUse(AXID id) const { return m_idsInUse.contains(id); }
Element* rootAXEditableElement(Node*);
const Element* rootAXEditableElement(const Node*);
bool nodeIsTextControl(const Node*);
AXID platformGenerateAXID() const;
AccessibilityObject* objectFromAXID(AXID id) const { return m_objects.get(id).get(); }
// This is a weak reference cache for knowing if Nodes used by TextMarkers are valid.
void setNodeInUse(Node* n) { m_textMarkerNodes.add(n); }
void removeNodeForUse(Node* n) { m_textMarkerNodes.remove(n); }
bool isNodeInUse(Node* n) { return m_textMarkerNodes.contains(n); }
// Text marker utilities.
void textMarkerDataForVisiblePosition(TextMarkerData&, const VisiblePosition&);
VisiblePosition visiblePositionForTextMarkerData(TextMarkerData&);
enum AXNotification {
AXActiveDescendantChanged,
AXAutocorrectionOccured,
AXCheckedStateChanged,
AXChildrenChanged,
AXFocusedUIElementChanged,
AXLayoutComplete,
AXLoadComplete,
AXSelectedChildrenChanged,
AXSelectedTextChanged,
AXValueChanged,
AXScrolledToAnchor,
AXLiveRegionChanged,
AXMenuListItemSelected,
AXMenuListValueChanged,
AXRowCountChanged,
AXRowCollapsed,
AXRowExpanded,
AXInvalidStatusChanged,
};
void postNotification(RenderObject*, AXNotification, bool postToElement, PostType = PostAsynchronously);
void postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType = PostAsynchronously);
enum AXTextChange {
AXTextInserted,
AXTextDeleted,
};
void nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned offset, const String&);
enum AXLoadingEvent {
AXLoadingStarted,
AXLoadingReloaded,
AXLoadingFailed,
AXLoadingFinished
};
void frameLoadingEventNotification(Frame*, AXLoadingEvent);
bool nodeHasRole(Node*, const AtomicString& role);
protected:
void postPlatformNotification(AccessibilityObject*, AXNotification);
void nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned offset, const String&);
void frameLoadingEventPlatformNotification(AccessibilityObject*, AXLoadingEvent);
private:
Document* m_document;
HashMap<AXID, RefPtr<AccessibilityObject> > m_objects;
HashMap<RenderObject*, AXID> m_renderObjectMapping;
HashMap<Widget*, AXID> m_widgetObjectMapping;
HashSet<Node*> m_textMarkerNodes;
static bool gAccessibilityEnabled;
static bool gAccessibilityEnhancedUserInterfaceEnabled;
HashSet<AXID> m_idsInUse;
Timer<AXObjectCache> m_notificationPostTimer;
Vector<pair<RefPtr<AccessibilityObject>, AXNotification> > m_notificationsToPost;
void notificationPostTimerFired(Timer<AXObjectCache>*);
static AccessibilityObject* focusedImageMapUIElement(HTMLAreaElement*);
AXID getAXID(AccessibilityObject*);
};
bool nodeHasRole(Node*, const String& role);
#if !HAVE(ACCESSIBILITY)
inline void AXObjectCache::handleActiveDescendantChanged(RenderObject*) { }
inline void AXObjectCache::handleAriaRoleChanged(RenderObject*) { }
inline void AXObjectCache::detachWrapper(AccessibilityObject*) { }
inline void AXObjectCache::attachWrapper(AccessibilityObject*) { }
inline void AXObjectCache::checkedStateChanged(RenderObject*) { }
inline void AXObjectCache::selectedChildrenChanged(RenderObject*) { }
inline void AXObjectCache::postNotification(RenderObject*, AXNotification, bool postToElement, PostType) { }
inline void AXObjectCache::postNotification(AccessibilityObject*, Document*, AXNotification, bool postToElement, PostType) { }
inline void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { }
inline void AXObjectCache::nodeTextChangeNotification(RenderObject*, AXTextChange, unsigned, const String&) { }
inline void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) { }
inline void AXObjectCache::frameLoadingEventNotification(Frame*, AXLoadingEvent) { }
inline void AXObjectCache::frameLoadingEventPlatformNotification(AccessibilityObject*, AXLoadingEvent) { }
inline void AXObjectCache::handleFocusedUIElementChanged(RenderObject*, RenderObject*) { }
inline void AXObjectCache::handleScrolledToAnchor(const Node*) { }
inline void AXObjectCache::contentChanged(RenderObject*) { }
inline void AXObjectCache::handleAriaExpandedChange(RenderObject*) { }
inline void AXObjectCache::handleScrollbarUpdate(ScrollView*) { }
#endif
}
#endif

View File

@@ -0,0 +1,155 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AbstractDatabase_h
#define AbstractDatabase_h
#if ENABLE(SQL_DATABASE)
#include "PlatformString.h"
#include "SQLiteDatabase.h"
#include <wtf/Forward.h>
#include <wtf/ThreadSafeRefCounted.h>
#if !LOG_DISABLED || !ERROR_DISABLED
#include "SecurityOrigin.h"
#endif
namespace WebCore {
class DatabaseAuthorizer;
class ScriptExecutionContext;
class SecurityOrigin;
typedef int ExceptionCode;
class AbstractDatabase : public ThreadSafeRefCounted<AbstractDatabase> {
public:
static bool isAvailable();
static void setIsAvailable(bool available);
virtual ~AbstractDatabase();
virtual String version() const;
bool opened() const { return m_opened; }
bool isNew() const { return m_new; }
bool isSyncDatabase() const { return m_isSyncDatabase; }
virtual ScriptExecutionContext* scriptExecutionContext() const;
virtual SecurityOrigin* securityOrigin() const;
virtual String stringIdentifier() const;
virtual String displayName() const;
virtual unsigned long estimatedSize() const;
virtual String fileName() const;
SQLiteDatabase& sqliteDatabase() { return m_sqliteDatabase; }
unsigned long long maximumSize() const;
void incrementalVacuumIfNeeded();
void interrupt();
bool isInterrupted();
void disableAuthorizer();
void enableAuthorizer();
void setAuthorizerReadOnly();
void setAuthorizerPermissions(int permissions);
bool lastActionChangedDatabase();
bool lastActionWasInsert();
void resetDeletes();
bool hadDeletes();
void resetAuthorizer();
virtual void markAsDeletedAndClose() = 0;
virtual void closeImmediately() = 0;
protected:
friend class ChangeVersionWrapper;
friend class SQLStatement;
friend class SQLStatementSync;
friend class SQLTransactionSync;
friend class SQLTransaction;
enum DatabaseType {
AsyncDatabase,
SyncDatabase
};
AbstractDatabase(ScriptExecutionContext*, const String& name, const String& expectedVersion,
const String& displayName, unsigned long estimatedSize, DatabaseType);
void closeDatabase();
virtual bool performOpenAndVerify(bool shouldSetVersionInNewDatabase, ExceptionCode&, String& errorMessage);
bool getVersionFromDatabase(String& version, bool shouldCacheVersion = true);
bool setVersionInDatabase(const String& version, bool shouldCacheVersion = true);
void setExpectedVersion(const String&);
const String& expectedVersion() const { return m_expectedVersion; }
String getCachedVersion()const;
void setCachedVersion(const String&);
bool getActualVersionForTransaction(String& version);
void logErrorMessage(const String& message);
void reportOpenDatabaseResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportChangeVersionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportStartTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportCommitTransactionResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportExecuteStatementResult(int errorSite, int webSqlErrorCode, int sqliteErrorCode);
void reportVacuumDatabaseResult(int sqliteErrorCode);
static const char* databaseInfoTableName();
RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
RefPtr<SecurityOrigin> m_contextThreadSecurityOrigin;
String m_name;
String m_expectedVersion;
String m_displayName;
unsigned long m_estimatedSize;
String m_filename;
#if !LOG_DISABLED || !ERROR_DISABLED
String databaseDebugName() const { return m_contextThreadSecurityOrigin->toString() + "::" + m_name; }
#endif
private:
int m_guid;
bool m_opened;
bool m_new;
const bool m_isSyncDatabase;
SQLiteDatabase m_sqliteDatabase;
RefPtr<DatabaseAuthorizer> m_databaseAuthorizer;
};
} // namespace WebCore
#endif // ENABLE(SQL_DATABASE)
#endif // AbstractDatabase_h

View File

@@ -0,0 +1,719 @@
/*
* Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved.
* Copyright (C) 2008 Nuanti Ltd.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AccessibilityObject_h
#define AccessibilityObject_h
#include "FloatQuad.h"
#include "LayoutTypes.h"
#include "VisiblePosition.h"
#include "VisibleSelection.h"
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#elif PLATFORM(WIN) && !OS(WINCE)
#include "AccessibilityObjectWrapperWin.h"
#include "COMPtr.h"
#elif PLATFORM(CHROMIUM)
#include "AccessibilityObjectWrapper.h"
#endif
#if PLATFORM(MAC)
typedef struct _NSRange NSRange;
OBJC_CLASS NSArray;
OBJC_CLASS NSAttributedString;
OBJC_CLASS NSData;
OBJC_CLASS NSMutableAttributedString;
OBJC_CLASS NSString;
OBJC_CLASS NSValue;
OBJC_CLASS NSView;
OBJC_CLASS WebAccessibilityObjectWrapper;
typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper;
#elif PLATFORM(GTK)
typedef struct _AtkObject AtkObject;
typedef struct _AtkObject AccessibilityObjectWrapper;
#else
class AccessibilityObjectWrapper;
#endif
namespace WebCore {
class AccessibilityObject;
class AXObjectCache;
class Element;
class Frame;
class FrameView;
class HTMLAnchorElement;
class HTMLAreaElement;
class IntPoint;
class IntSize;
class Node;
class Page;
class RenderObject;
class RenderListItem;
class ScrollableArea;
class VisibleSelection;
class Widget;
typedef unsigned AXID;
enum AccessibilityRole {
AnnotationRole = 1,
ApplicationRole,
ApplicationAlertRole,
ApplicationAlertDialogRole,
ApplicationDialogRole,
ApplicationLogRole,
ApplicationMarqueeRole,
ApplicationStatusRole,
ApplicationTimerRole,
BrowserRole,
BusyIndicatorRole,
ButtonRole,
CellRole,
CheckBoxRole,
ColorWellRole,
ColumnRole,
ColumnHeaderRole,
ComboBoxRole,
DefinitionListTermRole,
DefinitionListDefinitionRole,
DirectoryRole,
DisclosureTriangleRole,
DivRole,
DocumentRole,
DocumentArticleRole,
DocumentMathRole,
DocumentNoteRole,
DocumentRegionRole,
DrawerRole,
EditableTextRole,
FormRole,
GridRole,
GroupRole,
GrowAreaRole,
HeadingRole,
HelpTagRole,
IgnoredRole,
ImageRole,
ImageMapRole,
ImageMapLinkRole,
IncrementorRole,
LabelRole,
LandmarkApplicationRole,
LandmarkBannerRole,
LandmarkComplementaryRole,
LandmarkContentInfoRole,
LandmarkMainRole,
LandmarkNavigationRole,
LandmarkSearchRole,
LinkRole,
ListRole,
ListBoxRole,
ListBoxOptionRole,
ListItemRole,
ListMarkerRole,
MatteRole,
MenuRole,
MenuBarRole,
MenuButtonRole,
MenuItemRole,
MenuListPopupRole,
MenuListOptionRole,
OutlineRole,
ParagraphRole,
PopUpButtonRole,
PresentationalRole,
ProgressIndicatorRole,
RadioButtonRole,
RadioGroupRole,
RowHeaderRole,
RowRole,
RulerRole,
RulerMarkerRole,
ScrollAreaRole,
ScrollBarRole,
SheetRole,
SliderRole,
SliderThumbRole,
SpinButtonRole,
SpinButtonPartRole,
SplitGroupRole,
SplitterRole,
StaticTextRole,
SystemWideRole,
TabGroupRole,
TabListRole,
TabPanelRole,
TabRole,
TableRole,
TableHeaderContainerRole,
TextAreaRole,
TreeRole,
TreeGridRole,
TreeItemRole,
TextFieldRole,
ToolbarRole,
UnknownRole,
UserInterfaceTooltipRole,
ValueIndicatorRole,
WebAreaRole,
WebCoreLinkRole,
WindowRole,
};
enum AccessibilityOrientation {
AccessibilityOrientationVertical,
AccessibilityOrientationHorizontal,
};
enum AccessibilityObjectInclusion {
IncludeObject,
IgnoreObject,
DefaultBehavior,
};
enum AccessibilityButtonState {
ButtonStateOff = 0,
ButtonStateOn,
ButtonStateMixed,
};
enum AccessibilitySortDirection {
SortDirectionNone,
SortDirectionAscending,
SortDirectionDescending,
};
enum AccessibilitySearchDirection {
SearchDirectionNext = 1,
SearchDirectionPrevious
};
enum AccessibilitySearchKey {
AnyTypeSearchKey = 1,
BlockquoteSameLevelSearchKey,
BlockquoteSearchKey,
BoldFontSearchKey,
ButtonSearchKey,
CheckBoxSearchKey,
ControlSearchKey,
DifferentTypeSearchKey,
FontChangeSearchKey,
FontColorChangeSearchKey,
FrameSearchKey,
GraphicSearchKey,
HeadingLevel1SearchKey,
HeadingLevel2SearchKey,
HeadingLevel3SearchKey,
HeadingLevel4SearchKey,
HeadingLevel5SearchKey,
HeadingLevel6SearchKey,
HeadingSameLevelSearchKey,
HeadingSearchKey,
ItalicFontSearchKey,
LandmarkSearchKey,
LinkSearchKey,
ListSearchKey,
LiveRegionSearchKey,
MisspelledWordSearchKey,
PlainTextSearchKey,
RadioGroupSearchKey,
SameTypeSearchKey,
StaticTextSearchKey,
StyleChangeSearchKey,
TableSameLevelSearchKey,
TableSearchKey,
TextFieldSearchKey,
UnderlineSearchKey,
UnvisitedLinkSearchKey,
VisitedLinkSearchKey
};
struct AccessibilitySearchCriteria {
AccessibilityObject* startObject;
AccessibilitySearchDirection searchDirection;
AccessibilitySearchKey searchKey;
String* searchText;
unsigned resultsLimit;
};
struct VisiblePositionRange {
VisiblePosition start;
VisiblePosition end;
VisiblePositionRange() {}
VisiblePositionRange(const VisiblePosition& s, const VisiblePosition& e)
: start(s)
, end(e)
{ }
bool isNull() const { return start.isNull() || end.isNull(); }
};
struct PlainTextRange {
unsigned start;
unsigned length;
PlainTextRange()
: start(0)
, length(0)
{ }
PlainTextRange(unsigned s, unsigned l)
: start(s)
, length(l)
{ }
bool isNull() const { return !start && !length; }
};
class AccessibilityObject : public RefCounted<AccessibilityObject> {
protected:
AccessibilityObject();
public:
virtual ~AccessibilityObject();
virtual void detach();
typedef Vector<RefPtr<AccessibilityObject> > AccessibilityChildrenVector;
virtual bool isAccessibilityRenderObject() const { return false; }
virtual bool isAccessibilityScrollbar() const { return false; }
virtual bool isAccessibilityScrollView() const { return false; }
bool accessibilityObjectContainsText(String *) const;
virtual bool isAnchor() const { return false; }
virtual bool isAttachment() const { return false; }
virtual bool isHeading() const { return false; }
virtual bool isLink() const { return false; }
virtual bool isImage() const { return false; }
virtual bool isNativeImage() const { return false; }
virtual bool isImageButton() const { return false; }
virtual bool isPasswordField() const { return false; }
virtual bool isNativeTextControl() const { return false; }
virtual bool isWebArea() const { return false; }
virtual bool isCheckbox() const { return roleValue() == CheckBoxRole; }
virtual bool isRadioButton() const { return roleValue() == RadioButtonRole; }
virtual bool isListBox() const { return roleValue() == ListBoxRole; }
virtual bool isMediaTimeline() const { return false; }
virtual bool isMenuRelated() const { return false; }
virtual bool isMenu() const { return false; }
virtual bool isMenuBar() const { return false; }
virtual bool isMenuButton() const { return false; }
virtual bool isMenuItem() const { return false; }
virtual bool isFileUploadButton() const { return false; }
virtual bool isInputImage() const { return false; }
virtual bool isProgressIndicator() const { return false; }
virtual bool isSlider() const { return false; }
virtual bool isInputSlider() const { return false; }
virtual bool isControl() const { return false; }
virtual bool isList() const { return false; }
virtual bool isAccessibilityTable() const { return false; }
virtual bool isDataTable() const { return false; }
virtual bool isTableRow() const { return false; }
virtual bool isTableColumn() const { return false; }
virtual bool isTableCell() const { return false; }
virtual bool isFieldset() const { return false; }
virtual bool isGroup() const { return false; }
virtual bool isARIATreeGridRow() const { return false; }
virtual bool isImageMapLink() const { return false; }
virtual bool isMenuList() const { return false; }
virtual bool isMenuListPopup() const { return false; }
virtual bool isMenuListOption() const { return false; }
virtual bool isSpinButton() const { return false; }
virtual bool isSpinButtonPart() const { return false; }
virtual bool isMockObject() const { return false; }
bool isTextControl() const { return roleValue() == TextAreaRole || roleValue() == TextFieldRole; }
bool isARIATextControl() const;
bool isTabList() const { return roleValue() == TabListRole; }
bool isTabItem() const { return roleValue() == TabRole; }
bool isRadioGroup() const { return roleValue() == RadioGroupRole; }
bool isComboBox() const { return roleValue() == ComboBoxRole; }
bool isTree() const { return roleValue() == TreeRole; }
bool isTreeItem() const { return roleValue() == TreeItemRole; }
bool isScrollbar() const { return roleValue() == ScrollBarRole; }
bool isButton() const { return roleValue() == ButtonRole; }
bool isListItem() const { return roleValue() == ListItemRole; }
bool isCheckboxOrRadio() const { return isCheckbox() || isRadioButton(); }
bool isScrollView() const { return roleValue() == ScrollAreaRole; }
bool isBlockquote() const;
bool isLandmark() const;
virtual bool isChecked() const { return false; }
virtual bool isEnabled() const { return false; }
virtual bool isSelected() const { return false; }
virtual bool isFocused() const { return false; }
virtual bool isHovered() const { return false; }
virtual bool isIndeterminate() const { return false; }
virtual bool isLoaded() const { return false; }
virtual bool isMultiSelectable() const { return false; }
virtual bool isOffScreen() const { return false; }
virtual bool isPressed() const { return false; }
virtual bool isReadOnly() const { return false; }
virtual bool isUnvisited() const { return false; }
virtual bool isVisited() const { return false; }
virtual bool isRequired() const { return false; }
virtual bool isLinked() const { return false; }
virtual bool isExpanded() const;
virtual bool isVisible() const { return true; }
virtual bool isCollapsed() const { return false; }
virtual void setIsExpanded(bool) { }
// In a multi-select list, many items can be selected but only one is active at a time.
virtual bool isSelectedOptionActive() const { return false; }
virtual bool hasBoldFont() const { return false; }
virtual bool hasItalicFont() const { return false; }
bool hasMisspelling() const;
virtual bool hasPlainText() const { return false; }
virtual bool hasSameFont(RenderObject*) const { return false; }
virtual bool hasSameFontColor(RenderObject*) const { return false; }
virtual bool hasSameStyle(RenderObject*) const { return false; }
bool hasStaticText() const { return roleValue() == StaticTextRole; }
virtual bool hasUnderline() const { return false; }
virtual bool canSetFocusAttribute() const { return false; }
virtual bool canSetTextRangeAttributes() const { return false; }
virtual bool canSetValueAttribute() const { return false; }
virtual bool canSetNumericValue() const { return false; }
virtual bool canSetSelectedAttribute() const { return false; }
virtual bool canSetSelectedChildrenAttribute() const { return false; }
virtual bool canSetExpandedAttribute() const { return false; }
// A programmatic way to set a name on an AccessibleObject.
virtual void setAccessibleName(const AtomicString&) { }
virtual Node* node() const { return 0; }
virtual RenderObject* renderer() const { return 0; }
virtual bool accessibilityIsIgnored() const { return true; }
int blockquoteLevel() const;
virtual int headingLevel() const { return 0; }
virtual int tableLevel() const { return 0; }
virtual AccessibilityButtonState checkboxOrRadioValue() const;
virtual String valueDescription() const { return String(); }
virtual float valueForRange() const { return 0.0f; }
virtual float maxValueForRange() const { return 0.0f; }
virtual float minValueForRange() const { return 0.0f; }
virtual float stepValueForRange() const { return 0.0f; }
virtual AccessibilityObject* selectedRadioButton() { return 0; }
virtual AccessibilityObject* selectedTabItem() { return 0; }
virtual int layoutCount() const { return 0; }
virtual double estimatedLoadingProgress() const { return 0; }
static bool isARIAControl(AccessibilityRole);
static bool isARIAInput(AccessibilityRole);
virtual bool supportsARIAOwns() const { return false; }
virtual void ariaOwnsElements(AccessibilityChildrenVector&) const { }
virtual bool supportsARIAFlowTo() const { return false; }
virtual void ariaFlowToElements(AccessibilityChildrenVector&) const { }
virtual bool ariaHasPopup() const { return false; }
bool ariaIsMultiline() const;
virtual const AtomicString& invalidStatus() const;
bool supportsARIAExpanded() const;
AccessibilitySortDirection sortDirection() const;
// ARIA drag and drop
virtual bool supportsARIADropping() const { return false; }
virtual bool supportsARIADragging() const { return false; }
virtual bool isARIAGrabbed() { return false; }
virtual void setARIAGrabbed(bool) { }
virtual void determineARIADropEffects(Vector<String>&) { }
// Called on the root AX object to return the deepest available element.
virtual AccessibilityObject* accessibilityHitTest(const LayoutPoint&) const { return 0; }
// Called on the AX object after the render tree determines which is the right AccessibilityRenderObject.
virtual AccessibilityObject* elementAccessibilityHitTest(const LayoutPoint&) const;
virtual AccessibilityObject* focusedUIElement() const;
virtual AccessibilityObject* firstChild() const { return 0; }
virtual AccessibilityObject* lastChild() const { return 0; }
virtual AccessibilityObject* previousSibling() const { return 0; }
virtual AccessibilityObject* nextSibling() const { return 0; }
virtual AccessibilityObject* parentObject() const = 0;
virtual AccessibilityObject* parentObjectUnignored() const;
virtual AccessibilityObject* parentObjectIfExists() const { return 0; }
static AccessibilityObject* firstAccessibleObjectFromNode(const Node*);
void findMatchingObjects(AccessibilitySearchCriteria*, AccessibilityChildrenVector&);
virtual AccessibilityObject* observableObject() const { return 0; }
virtual void linkedUIElements(AccessibilityChildrenVector&) const { }
virtual AccessibilityObject* titleUIElement() const { return 0; }
virtual bool exposesTitleUIElement() const { return true; }
virtual AccessibilityObject* correspondingLabelForControlElement() const { return 0; }
virtual AccessibilityObject* correspondingControlForLabelElement() const { return 0; }
virtual AccessibilityObject* scrollBar(AccessibilityOrientation) { return 0; }
virtual AccessibilityRole ariaRoleAttribute() const { return UnknownRole; }
virtual bool isPresentationalChildOfAriaRole() const { return false; }
virtual bool ariaRoleHasPresentationalChildren() const { return false; }
void setRoleValue(AccessibilityRole role) { m_role = role; }
virtual AccessibilityRole roleValue() const { return m_role; }
virtual String ariaLabeledByAttribute() const { return String(); }
virtual String ariaDescribedByAttribute() const { return String(); }
virtual String accessibilityDescription() const { return String(); }
virtual AXObjectCache* axObjectCache() const;
AXID axObjectID() const { return m_id; }
void setAXObjectID(AXID axObjectID) { m_id = axObjectID; }
static AccessibilityObject* anchorElementForNode(Node*);
virtual Element* anchorElement() const { return 0; }
virtual Element* actionElement() const { return 0; }
virtual LayoutRect boundingBoxRect() const { return LayoutRect(); }
virtual LayoutRect elementRect() const = 0;
virtual LayoutSize size() const { return elementRect().size(); }
virtual LayoutPoint clickPoint();
static LayoutRect boundingBoxForQuads(RenderObject*, const Vector<FloatQuad>&);
virtual PlainTextRange selectedTextRange() const { return PlainTextRange(); }
unsigned selectionStart() const { return selectedTextRange().start; }
unsigned selectionEnd() const { return selectedTextRange().length; }
virtual KURL url() const { return KURL(); }
virtual VisibleSelection selection() const { return VisibleSelection(); }
virtual String stringValue() const { return String(); }
virtual String title() const { return String(); }
virtual String helpText() const { return String(); }
virtual String textUnderElement() const { return String(); }
virtual String text() const { return String(); }
virtual int textLength() const { return 0; }
virtual String selectedText() const { return String(); }
virtual const AtomicString& accessKey() const { return nullAtom; }
const String& actionVerb() const;
virtual Widget* widget() const { return 0; }
virtual Widget* widgetForAttachmentView() const { return 0; }
Page* page() const;
virtual Document* document() const;
virtual FrameView* topDocumentFrameView() const { return 0; }
virtual FrameView* documentFrameView() const;
String language() const;
virtual unsigned hierarchicalLevel() const { return 0; }
const AtomicString& placeholderValue() const;
virtual void setFocused(bool) { }
virtual void setSelectedText(const String&) { }
virtual void setSelectedTextRange(const PlainTextRange&) { }
virtual void setValue(const String&) { }
virtual void setValue(float) { }
virtual void setSelected(bool) { }
virtual void setSelectedRows(AccessibilityChildrenVector&) { }
virtual void makeRangeVisible(const PlainTextRange&) { }
virtual bool press() const;
bool performDefaultAction() const { return press(); }
virtual AccessibilityOrientation orientation() const;
virtual void increment() { }
virtual void decrement() { }
virtual void childrenChanged() { }
virtual void contentChanged() { }
const AccessibilityChildrenVector& children();
virtual void addChildren() { }
virtual bool canHaveChildren() const { return true; }
virtual bool hasChildren() const { return m_haveChildren; }
virtual void updateChildrenIfNecessary();
virtual void setNeedsToUpdateChildren() { }
virtual void clearChildren();
virtual void detachFromParent() { }
virtual void selectedChildren(AccessibilityChildrenVector&) { }
virtual void visibleChildren(AccessibilityChildrenVector&) { }
virtual void tabChildren(AccessibilityChildrenVector&) { }
virtual bool shouldFocusActiveDescendant() const { return false; }
virtual AccessibilityObject* activeDescendant() const { return 0; }
virtual void handleActiveDescendantChanged() { }
virtual void handleAriaExpandedChanged() { }
bool isDescendantOfObject(const AccessibilityObject*) const;
bool isAncestorOfObject(const AccessibilityObject*) const;
static AccessibilityRole ariaRoleToWebCoreRole(const String&);
const AtomicString& getAttribute(const QualifiedName&) const;
virtual VisiblePositionRange visiblePositionRange() const { return VisiblePositionRange(); }
virtual VisiblePositionRange visiblePositionRangeForLine(unsigned) const { return VisiblePositionRange(); }
VisiblePositionRange visiblePositionRangeForUnorderedPositions(const VisiblePosition&, const VisiblePosition&) const;
VisiblePositionRange positionOfLeftWord(const VisiblePosition&) const;
VisiblePositionRange positionOfRightWord(const VisiblePosition&) const;
VisiblePositionRange leftLineVisiblePositionRange(const VisiblePosition&) const;
VisiblePositionRange rightLineVisiblePositionRange(const VisiblePosition&) const;
VisiblePositionRange sentenceForPosition(const VisiblePosition&) const;
VisiblePositionRange paragraphForPosition(const VisiblePosition&) const;
VisiblePositionRange styleRangeForPosition(const VisiblePosition&) const;
VisiblePositionRange visiblePositionRangeForRange(const PlainTextRange&) const;
String stringForVisiblePositionRange(const VisiblePositionRange&) const;
virtual LayoutRect boundsForVisiblePositionRange(const VisiblePositionRange&) const { return LayoutRect(); }
int lengthForVisiblePositionRange(const VisiblePositionRange&) const;
virtual void setSelectedVisiblePositionRange(const VisiblePositionRange&) const { }
virtual VisiblePosition visiblePositionForPoint(const IntPoint&) const { return VisiblePosition(); }
VisiblePosition nextVisiblePosition(const VisiblePosition& visiblePos) const { return visiblePos.next(); }
VisiblePosition previousVisiblePosition(const VisiblePosition& visiblePos) const { return visiblePos.previous(); }
VisiblePosition nextWordEnd(const VisiblePosition&) const;
VisiblePosition previousWordStart(const VisiblePosition&) const;
VisiblePosition nextLineEndPosition(const VisiblePosition&) const;
VisiblePosition previousLineStartPosition(const VisiblePosition&) const;
VisiblePosition nextSentenceEndPosition(const VisiblePosition&) const;
VisiblePosition previousSentenceStartPosition(const VisiblePosition&) const;
VisiblePosition nextParagraphEndPosition(const VisiblePosition&) const;
VisiblePosition previousParagraphStartPosition(const VisiblePosition&) const;
virtual VisiblePosition visiblePositionForIndex(unsigned, bool /*lastIndexOK */) const { return VisiblePosition(); }
virtual VisiblePosition visiblePositionForIndex(int) const { return VisiblePosition(); }
virtual int indexForVisiblePosition(const VisiblePosition&) const { return 0; }
AccessibilityObject* accessibilityObjectForPosition(const VisiblePosition&) const;
int lineForPosition(const VisiblePosition&) const;
PlainTextRange plainTextRangeForVisiblePositionRange(const VisiblePositionRange&) const;
virtual int index(const VisiblePosition&) const { return -1; }
virtual PlainTextRange doAXRangeForLine(unsigned) const { return PlainTextRange(); }
PlainTextRange doAXRangeForPosition(const IntPoint&) const;
virtual PlainTextRange doAXRangeForIndex(unsigned) const { return PlainTextRange(); }
PlainTextRange doAXStyleRangeForIndex(unsigned) const;
virtual String doAXStringForRange(const PlainTextRange&) const { return String(); }
virtual LayoutRect doAXBoundsForRange(const PlainTextRange&) const { return LayoutRect(); }
String listMarkerTextForNodeAndPosition(Node*, const VisiblePosition&) const;
unsigned doAXLineForIndex(unsigned);
virtual String stringValueForMSAA() const { return String(); }
virtual String stringRoleForMSAA() const { return String(); }
virtual String nameForMSAA() const { return String(); }
virtual String descriptionForMSAA() const { return String(); }
virtual AccessibilityRole roleValueForMSAA() const { return roleValue(); }
// Used by an ARIA tree to get all its rows.
void ariaTreeRows(AccessibilityChildrenVector&);
// Used by an ARIA tree item to get all of its direct rows that it can disclose.
void ariaTreeItemDisclosedRows(AccessibilityChildrenVector&);
// Used by an ARIA tree item to get only its content, and not its child tree items and groups.
void ariaTreeItemContent(AccessibilityChildrenVector&);
// ARIA live-region features.
bool supportsARIALiveRegion() const;
bool isInsideARIALiveRegion() const;
virtual const AtomicString& ariaLiveRegionStatus() const { return nullAtom; }
virtual const AtomicString& ariaLiveRegionRelevant() const { return nullAtom; }
virtual bool ariaLiveRegionAtomic() const { return false; }
virtual bool ariaLiveRegionBusy() const { return false; }
bool supportsARIAAttributes() const;
// CSS3 Speech properties.
virtual ESpeak speakProperty() const { return SpeakNormal; }
// Make this object visible by scrolling as many nested scrollable views as needed.
virtual void scrollToMakeVisible() const;
// Same, but if the whole object can't be made visible, try for this subrect, in local coordinates.
virtual void scrollToMakeVisibleWithSubFocus(const IntRect&) const;
// Scroll this object to a given point in global coordinates of the top-level window.
virtual void scrollToGlobalPoint(const IntPoint&) const;
#if HAVE(ACCESSIBILITY)
#if PLATFORM(GTK)
AccessibilityObjectWrapper* wrapper() const;
void setWrapper(AccessibilityObjectWrapper*);
#else
AccessibilityObjectWrapper* wrapper() const { return m_wrapper.get(); }
void setWrapper(AccessibilityObjectWrapper* wrapper)
{
m_wrapper = wrapper;
}
#endif
#endif
#if HAVE(ACCESSIBILITY)
// a platform-specific method for determining if an attachment is ignored
bool accessibilityIgnoreAttachment() const;
// gives platforms the opportunity to indicate if and how an object should be included
AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const;
#else
bool accessibilityIgnoreAttachment() const { return true; }
AccessibilityObjectInclusion accessibilityPlatformIncludesObject() const { return DefaultBehavior; }
#endif
// allows for an AccessibilityObject to update its render tree or perform
// other operations update type operations
void updateBackingStore();
protected:
AXID m_id;
AccessibilityChildrenVector m_children;
mutable bool m_haveChildren;
AccessibilityRole m_role;
// If this object itself scrolls, return its ScrollableArea.
virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; }
virtual void scrollTo(const IntPoint&) const { }
virtual bool isDetached() const { return true; }
static bool isAccessibilityObjectSearchMatch(AccessibilityObject*, AccessibilitySearchCriteria*);
static bool isAccessibilityTextSearchMatch(AccessibilityObject*, AccessibilitySearchCriteria*);
static bool objectMatchesSearchCriteriaWithResultLimit(AccessibilityObject*, AccessibilitySearchCriteria*, AccessibilityChildrenVector&);
#if PLATFORM(GTK)
bool allowsTextRanges() const;
unsigned getLengthForTextRange() const;
#else
bool allowsTextRanges() const { return isTextControl(); }
unsigned getLengthForTextRange() const { return text().length(); }
#endif
#if PLATFORM(MAC)
RetainPtr<WebAccessibilityObjectWrapper> m_wrapper;
#elif PLATFORM(WIN) && !OS(WINCE)
COMPtr<AccessibilityObjectWrapper> m_wrapper;
#elif PLATFORM(GTK)
AtkObject* m_wrapper;
#elif PLATFORM(CHROMIUM)
RefPtr<AccessibilityObjectWrapper> m_wrapper;
#endif
};
} // namespace WebCore
#endif // AccessibilityObject_h

View File

@@ -0,0 +1,95 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ActiveDOMObject_h
#define ActiveDOMObject_h
#include <wtf/Assertions.h>
namespace WebCore {
class ScriptExecutionContext;
// FIXME: Move this class to it's own file.
class ContextDestructionObserver {
public:
explicit ContextDestructionObserver(ScriptExecutionContext*);
virtual void contextDestroyed();
ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
protected:
virtual ~ContextDestructionObserver();
ScriptExecutionContext* m_scriptExecutionContext;
};
class ActiveDOMObject : public ContextDestructionObserver {
public:
ActiveDOMObject(ScriptExecutionContext*, void* upcastPointer);
virtual bool hasPendingActivity() const;
// canSuspend() is used by the caller if there is a choice between suspending and stopping.
// For example, a page won't be suspended and placed in the back/forward cache if it has
// the objects that can not be suspended.
// However, 'suspend' can be called even if canSuspend() would return 'false'. That
// happens in step-by-step JS debugging for example - in this case it would be incorrect
// to stop the object. Exact semantics of suspend is up to the object then.
enum ReasonForSuspension {
JavaScriptDebuggerPaused,
WillShowDialog,
DocumentWillBecomeInactive
};
virtual bool canSuspend() const;
virtual void suspend(ReasonForSuspension);
virtual void resume();
virtual void stop();
template<class T> void setPendingActivity(T* thisObject)
{
ASSERT(thisObject == this);
thisObject->ref();
m_pendingActivityCount++;
}
template<class T> void unsetPendingActivity(T* thisObject)
{
ASSERT(m_pendingActivityCount > 0);
--m_pendingActivityCount;
thisObject->deref();
}
protected:
virtual ~ActiveDOMObject();
private:
unsigned m_pendingActivityCount;
};
} // namespace WebCore
#endif // ActiveDOMObject_h

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AdjustViewSizeOrNot_h
#define AdjustViewSizeOrNot_h
namespace WebCore {
enum AdjustViewSizeOrNot {
DoNotAdjustViewSize,
AdjustViewSize
};
} // namespace WebCore
#endif // AdjustViewSizeOrNot_h

View File

@@ -0,0 +1,217 @@
/*
* Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
* 2010 Dirk Schulze <krit@webkit.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AffineTransform_h
#define AffineTransform_h
#include "TransformationMatrix.h"
#include <string.h> // for memcpy
#include <wtf/FastAllocBase.h>
#if USE(CG)
#include <CoreGraphics/CGAffineTransform.h>
#elif USE(CAIRO)
#include <cairo.h>
#elif PLATFORM(OPENVG)
#include "VGUtils.h"
#elif PLATFORM(QT)
#include <QTransform>
#elif USE(SKIA)
#include <SkMatrix.h>
#elif PLATFORM(WX) && USE(WXGC)
#include <wx/graphics.h>
#endif
namespace WebCore {
class FloatPoint;
class FloatQuad;
class FloatRect;
class IntPoint;
class IntRect;
class TransformationMatrix;
class AffineTransform {
WTF_MAKE_FAST_ALLOCATED;
public:
typedef double Transform[6];
AffineTransform();
AffineTransform(double a, double b, double c, double d, double e, double f);
#if USE(CG)
AffineTransform(const CGAffineTransform&);
#endif
void setMatrix(double a, double b, double c, double d, double e, double f);
void map(double x, double y, double& x2, double& y2) const;
// Rounds the mapped point to the nearest integer value.
IntPoint mapPoint(const IntPoint&) const;
FloatPoint mapPoint(const FloatPoint&) const;
IntSize mapSize(const IntSize&) const;
FloatSize mapSize(const FloatSize&) const;
// Rounds the resulting mapped rectangle out. This is helpful for bounding
// box computations but may not be what is wanted in other contexts.
IntRect mapRect(const IntRect&) const;
FloatRect mapRect(const FloatRect&) const;
FloatQuad mapQuad(const FloatQuad&) const;
bool isIdentity() const;
double a() const { return m_transform[0]; }
void setA(double a) { m_transform[0] = a; }
double b() const { return m_transform[1]; }
void setB(double b) { m_transform[1] = b; }
double c() const { return m_transform[2]; }
void setC(double c) { m_transform[2] = c; }
double d() const { return m_transform[3]; }
void setD(double d) { m_transform[3] = d; }
double e() const { return m_transform[4]; }
void setE(double e) { m_transform[4] = e; }
double f() const { return m_transform[5]; }
void setF(double f) { m_transform[5] = f; }
void makeIdentity();
AffineTransform& multiply(const AffineTransform& other);
AffineTransform& scale(double);
AffineTransform& scale(double sx, double sy);
AffineTransform& scaleNonUniform(double sx, double sy);
AffineTransform& rotate(double d);
AffineTransform& rotateFromVector(double x, double y);
AffineTransform& translate(double tx, double ty);
AffineTransform& shear(double sx, double sy);
AffineTransform& flipX();
AffineTransform& flipY();
AffineTransform& skew(double angleX, double angleY);
AffineTransform& skewX(double angle);
AffineTransform& skewY(double angle);
double xScale() const;
double yScale() const;
double det() const;
bool isInvertible() const;
AffineTransform inverse() const;
void blend(const AffineTransform& from, double progress);
TransformationMatrix toTransformationMatrix() const;
bool isIdentityOrTranslation() const
{
return m_transform[0] == 1 && m_transform[1] == 0 && m_transform[2] == 0 && m_transform[3] == 1;
}
bool isIdentityOrTranslationOrFlipped() const
{
return m_transform[0] == 1 && m_transform[1] == 0 && m_transform[2] == 0 && (m_transform[3] == 1 || m_transform[3] == -1);
}
bool preservesAxisAlignment() const
{
return (m_transform[1] == 0 && m_transform[2] == 0) || (m_transform[0] == 0 && m_transform[3] == 0);
}
bool operator== (const AffineTransform& m2) const
{
return (m_transform[0] == m2.m_transform[0]
&& m_transform[1] == m2.m_transform[1]
&& m_transform[2] == m2.m_transform[2]
&& m_transform[3] == m2.m_transform[3]
&& m_transform[4] == m2.m_transform[4]
&& m_transform[5] == m2.m_transform[5]);
}
bool operator!=(const AffineTransform& other) const { return !(*this == other); }
// *this = *this * t (i.e., a multRight)
AffineTransform& operator*=(const AffineTransform& t)
{
return multiply(t);
}
// result = *this * t (i.e., a multRight)
AffineTransform operator*(const AffineTransform& t) const
{
AffineTransform result = *this;
result *= t;
return result;
}
#if USE(CG)
operator CGAffineTransform() const;
#elif USE(CAIRO)
operator cairo_matrix_t() const;
#elif PLATFORM(OPENVG)
operator VGMatrix() const;
#elif PLATFORM(QT)
operator QTransform() const;
#elif USE(SKIA)
operator SkMatrix() const;
#elif PLATFORM(WX) && USE(WXGC)
operator wxGraphicsMatrix() const;
#endif
static AffineTransform translation(double x, double y)
{
return AffineTransform(1, 0, 0, 1, x, y);
}
// decompose the matrix into its component parts
typedef struct {
double scaleX, scaleY;
double angle;
double remainderA, remainderB, remainderC, remainderD;
double translateX, translateY;
} DecomposedType;
bool decompose(DecomposedType&) const;
void recompose(const DecomposedType&);
private:
void setMatrix(const Transform m)
{
if (m && m != m_transform)
memcpy(m_transform, m, sizeof(Transform));
}
Transform m_transform;
};
AffineTransform makeMapBetweenRects(const FloatRect& source, const FloatRect& dest);
}
#endif

View File

@@ -0,0 +1,178 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef Animation_h
#define Animation_h
#include "PlatformString.h"
#include "RenderStyleConstants.h"
#include "TimingFunction.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
const int cAnimateNone = 0;
const int cAnimateAll = -2;
class Animation : public RefCounted<Animation> {
public:
~Animation();
static PassRefPtr<Animation> create() { return adoptRef(new Animation); }
static PassRefPtr<Animation> create(const Animation* o) { return adoptRef(new Animation(*o)); }
bool isDelaySet() const { return m_delaySet; }
bool isDirectionSet() const { return m_directionSet; }
bool isDurationSet() const { return m_durationSet; }
bool isFillModeSet() const { return m_fillModeSet; }
bool isIterationCountSet() const { return m_iterationCountSet; }
bool isNameSet() const { return m_nameSet; }
bool isPlayStateSet() const { return m_playStateSet; }
bool isPropertySet() const { return m_propertySet; }
bool isTimingFunctionSet() const { return m_timingFunctionSet; }
// Flags this to be the special "none" animation (animation-name: none)
bool isNoneAnimation() const { return m_isNone; }
// We can make placeholder Animation objects to keep the comma-separated lists
// of properties in sync. isValidAnimation means this is not a placeholder.
bool isValidAnimation() const { return !m_isNone && !m_name.isEmpty(); }
bool isEmpty() const
{
return (!m_directionSet && !m_durationSet && !m_fillModeSet
&& !m_nameSet && !m_playStateSet && !m_iterationCountSet
&& !m_delaySet && !m_timingFunctionSet && !m_propertySet);
}
bool isEmptyOrZeroDuration() const
{
return isEmpty() || (m_duration == 0 && m_delay <= 0);
}
void clearDelay() { m_delaySet = false; }
void clearDirection() { m_directionSet = false; }
void clearDuration() { m_durationSet = false; }
void clearFillMode() { m_fillModeSet = false; }
void clearIterationCount() { m_iterationCountSet = false; }
void clearName() { m_nameSet = false; }
void clearPlayState() { m_playStateSet = AnimPlayStatePlaying; }
void clearProperty() { m_propertySet = false; }
void clearTimingFunction() { m_timingFunctionSet = false; }
void clearAll()
{
clearDelay();
clearDirection();
clearDuration();
clearFillMode();
clearIterationCount();
clearName();
clearPlayState();
clearProperty();
clearTimingFunction();
}
double delay() const { return m_delay; }
enum AnimationDirection { AnimationDirectionNormal, AnimationDirectionAlternate };
AnimationDirection direction() const { return static_cast<AnimationDirection>(m_direction); }
unsigned fillMode() const { return m_fillMode; }
double duration() const { return m_duration; }
enum { IterationCountInfinite = -1 };
int iterationCount() const { return m_iterationCount; }
const String& name() const { return m_name; }
EAnimPlayState playState() const { return static_cast<EAnimPlayState>(m_playState); }
int property() const { return m_property; }
const PassRefPtr<TimingFunction> timingFunction() const { return m_timingFunction; }
void setDelay(double c) { m_delay = c; m_delaySet = true; }
void setDirection(AnimationDirection d) { m_direction = d; m_directionSet = true; }
void setDuration(double d) { ASSERT(d >= 0); m_duration = d; m_durationSet = true; }
void setFillMode(unsigned f) { m_fillMode = f; m_fillModeSet = true; }
void setIterationCount(int c) { m_iterationCount = c; m_iterationCountSet = true; }
void setName(const String& n) { m_name = n; m_nameSet = true; }
void setPlayState(EAnimPlayState d) { m_playState = d; m_playStateSet = true; }
void setProperty(int t) { m_property = t; m_propertySet = true; }
void setTimingFunction(PassRefPtr<TimingFunction> f) { m_timingFunction = f; m_timingFunctionSet = true; }
void setIsNoneAnimation(bool n) { m_isNone = n; }
Animation& operator=(const Animation& o);
// return true if all members of this class match (excluding m_next)
bool animationsMatch(const Animation*, bool matchPlayStates = true) const;
// return true every Animation in the chain (defined by m_next) match
bool operator==(const Animation& o) const { return animationsMatch(&o); }
bool operator!=(const Animation& o) const { return !(*this == o); }
bool fillsBackwards() const { return m_fillModeSet && (m_fillMode == AnimationFillModeBackwards || m_fillMode == AnimationFillModeBoth); }
bool fillsForwards() const { return m_fillModeSet && (m_fillMode == AnimationFillModeForwards || m_fillMode == AnimationFillModeBoth); }
private:
Animation();
Animation(const Animation& o);
String m_name;
int m_property;
int m_iterationCount;
double m_delay;
double m_duration;
RefPtr<TimingFunction> m_timingFunction;
unsigned m_direction : 1; // AnimationDirection
unsigned m_fillMode : 2;
unsigned m_playState : 2;
bool m_delaySet : 1;
bool m_directionSet : 1;
bool m_durationSet : 1;
bool m_fillModeSet : 1;
bool m_iterationCountSet : 1;
bool m_nameSet : 1;
bool m_playStateSet : 1;
bool m_propertySet : 1;
bool m_timingFunctionSet : 1;
bool m_isNone : 1;
public:
static double initialAnimationDelay() { return 0; }
static AnimationDirection initialAnimationDirection() { return AnimationDirectionNormal; }
static double initialAnimationDuration() { return 0; }
static unsigned initialAnimationFillMode() { return AnimationFillModeNone; }
static int initialAnimationIterationCount() { return 1; }
static const String& initialAnimationName();
static EAnimPlayState initialAnimationPlayState() { return AnimPlayStatePlaying; }
static int initialAnimationProperty() { return cAnimateAll; }
static const PassRefPtr<TimingFunction> initialAnimationTimingFunction() { return CubicBezierTimingFunction::create(); }
};
} // namespace WebCore
#endif // Animation_h

View File

@@ -0,0 +1,86 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AnimationController_h
#define AnimationController_h
#include "CSSPropertyNames.h"
#include <wtf/Forward.h>
#include <wtf/OwnPtr.h>
namespace WebCore {
class AnimationBase;
class AnimationControllerPrivate;
class Document;
class Element;
class Frame;
class Node;
class RenderObject;
class RenderStyle;
class WebKitAnimationList;
class AnimationController {
public:
AnimationController(Frame*);
~AnimationController();
void cancelAnimations(RenderObject*);
PassRefPtr<RenderStyle> updateAnimations(RenderObject*, RenderStyle* newStyle);
PassRefPtr<RenderStyle> getAnimatedStyleForRenderer(RenderObject*);
// This is called when an accelerated animation or transition has actually started to animate.
void notifyAnimationStarted(RenderObject*, double startTime);
bool pauseAnimationAtTime(RenderObject*, const String& name, double t); // To be used only for testing
bool pauseTransitionAtTime(RenderObject*, const String& property, double t); // To be used only for testing
unsigned numberOfActiveAnimations(Document*) const; // To be used only for testing
bool isRunningAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow = true) const;
bool isRunningAcceleratedAnimationOnRenderer(RenderObject*, CSSPropertyID, bool isRunningNow = true) const;
void suspendAnimations();
void resumeAnimations();
void suspendAnimationsForDocument(Document*);
void resumeAnimationsForDocument(Document*);
void beginAnimationUpdate();
void endAnimationUpdate();
static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
PassRefPtr<WebKitAnimationList> animationsForRenderer(RenderObject*) const;
private:
OwnPtr<AnimationControllerPrivate> m_data;
};
} // namespace WebCore
#endif // AnimationController_h

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef AnimationList_h
#define AnimationList_h
#include "Animation.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class AnimationList {
WTF_MAKE_FAST_ALLOCATED;
public:
AnimationList() { }
AnimationList(const AnimationList&);
void fillUnsetProperties();
bool operator==(const AnimationList& o) const;
bool operator!=(const AnimationList& o) const
{
return !(*this == o);
}
size_t size() const { return m_animations.size(); }
bool isEmpty() const { return m_animations.isEmpty(); }
void resize(size_t n) { m_animations.resize(n); }
void remove(size_t i) { m_animations.remove(i); }
void append(PassRefPtr<Animation> anim) { m_animations.append(anim); }
Animation* animation(size_t i) { return m_animations[i].get(); }
const Animation* animation(size_t i) const { return m_animations[i].get(); }
private:
AnimationList& operator=(const AnimationList&);
Vector<RefPtr<Animation> > m_animations;
};
} // namespace WebCore
#endif // AnimationList_h

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AnimationUtilities_h
#define AnimationUtilities_h
#include <wtf/MathExtras.h>
namespace WebCore {
inline int blend(int from, int to, double progress)
{
return static_cast<int>(lround(static_cast<double>(from) + static_cast<double>(to - from) * progress));
}
inline unsigned blend(unsigned from, unsigned to, double progress)
{
return static_cast<unsigned>(lround(static_cast<double>(from) + static_cast<double>(to - from) * progress));
}
inline double blend(double from, double to, double progress)
{
return from + (to - from) * progress;
}
inline float blend(float from, float to, double progress)
{
return static_cast<float>(from + (to - from) * progress);
}
} // namespace WebCore
#endif // AnimationUtilities_h

View File

@@ -0,0 +1,118 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ApplicationCache_h
#define ApplicationCache_h
#include "PlatformString.h"
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class ApplicationCacheGroup;
class ApplicationCacheResource;
class DocumentLoader;
class KURL;
class ResourceRequest;
class SecurityOrigin;
typedef Vector<std::pair<KURL, KURL> > FallbackURLVector;
class ApplicationCache : public RefCounted<ApplicationCache> {
public:
static PassRefPtr<ApplicationCache> create() { return adoptRef(new ApplicationCache); }
static void deleteCacheForOrigin(SecurityOrigin*);
~ApplicationCache();
void addResource(PassRefPtr<ApplicationCacheResource> resource);
unsigned removeResource(const String& url);
void setManifestResource(PassRefPtr<ApplicationCacheResource> manifest);
ApplicationCacheResource* manifestResource() const { return m_manifest; }
void setGroup(ApplicationCacheGroup*);
ApplicationCacheGroup* group() const { return m_group; }
bool isComplete() const;
ApplicationCacheResource* resourceForRequest(const ResourceRequest&);
ApplicationCacheResource* resourceForURL(const String& url);
void setAllowsAllNetworkRequests(bool value) { m_allowAllNetworkRequests = value; }
bool allowsAllNetworkRequests() const { return m_allowAllNetworkRequests; }
void setOnlineWhitelist(const Vector<KURL>& onlineWhitelist);
const Vector<KURL>& onlineWhitelist() const { return m_onlineWhitelist; }
bool isURLInOnlineWhitelist(const KURL&); // There is an entry in online whitelist that has the same origin as the resource's URL and that is a prefix match for the resource's URL.
void setFallbackURLs(const FallbackURLVector&);
const FallbackURLVector& fallbackURLs() const { return m_fallbackURLs; }
bool urlMatchesFallbackNamespace(const KURL&, KURL* fallbackURL = 0);
#ifndef NDEBUG
void dump();
#endif
typedef HashMap<String, RefPtr<ApplicationCacheResource> > ResourceMap;
ResourceMap::const_iterator begin() const { return m_resources.begin(); }
ResourceMap::const_iterator end() const { return m_resources.end(); }
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID();
static bool requestIsHTTPOrHTTPSGet(const ResourceRequest&);
static int64_t diskUsageForOrigin(SecurityOrigin*);
int64_t estimatedSizeInStorage() const { return m_estimatedSizeInStorage; }
private:
ApplicationCache();
ApplicationCacheGroup* m_group;
ResourceMap m_resources;
ApplicationCacheResource* m_manifest;
bool m_allowAllNetworkRequests;
Vector<KURL> m_onlineWhitelist;
FallbackURLVector m_fallbackURLs;
// The total size of the resources belonging to this Application Cache instance.
// This is an estimation of the size this Application Cache occupies in the
// database file.
int64_t m_estimatedSizeInStorage;
unsigned m_storageID;
};
} // namespace WebCore
#endif // ApplicationCache_h

View File

@@ -0,0 +1,156 @@
/*
* Copyright (C) 2008, 2010, 2011 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ApplicationCacheStorage_h
#define ApplicationCacheStorage_h
#include "PlatformString.h"
#include "SecurityOriginHash.h"
#include "SQLiteDatabase.h"
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class ApplicationCache;
class ApplicationCacheGroup;
class ApplicationCacheHost;
class ApplicationCacheResource;
class KURL;
template <class T>
class StorageIDJournal;
class SecurityOrigin;
class ApplicationCacheStorage {
WTF_MAKE_NONCOPYABLE(ApplicationCacheStorage); WTF_MAKE_FAST_ALLOCATED;
public:
enum FailureReason {
OriginQuotaReached,
TotalQuotaReached,
DiskOrOperationFailure
};
void setCacheDirectory(const String&);
const String& cacheDirectory() const;
void setMaximumSize(int64_t size);
int64_t maximumSize() const;
bool isMaximumSizeReached() const;
int64_t spaceNeeded(int64_t cacheToSave);
int64_t defaultOriginQuota() const { return m_defaultOriginQuota; }
void setDefaultOriginQuota(int64_t quota);
bool calculateUsageForOrigin(const SecurityOrigin*, int64_t& usage);
bool calculateQuotaForOrigin(const SecurityOrigin*, int64_t& quota);
bool calculateRemainingSizeForOriginExcludingCache(const SecurityOrigin*, ApplicationCache*, int64_t& remainingSize);
bool storeUpdatedQuotaForOrigin(const SecurityOrigin*, int64_t quota);
bool checkOriginQuota(ApplicationCacheGroup*, ApplicationCache* oldCache, ApplicationCache* newCache, int64_t& totalSpaceNeeded);
ApplicationCacheGroup* cacheGroupForURL(const KURL&); // Cache to load a main resource from.
ApplicationCacheGroup* fallbackCacheGroupForURL(const KURL&); // Cache that has a fallback entry to load a main resource from if normal loading fails.
ApplicationCacheGroup* findOrCreateCacheGroup(const KURL& manifestURL);
ApplicationCacheGroup* findInMemoryCacheGroup(const KURL& manifestURL) const;
void cacheGroupDestroyed(ApplicationCacheGroup*);
void cacheGroupMadeObsolete(ApplicationCacheGroup*);
bool storeNewestCache(ApplicationCacheGroup*, ApplicationCache* oldCache, FailureReason& failureReason);
bool storeNewestCache(ApplicationCacheGroup*); // Updates the cache group, but doesn't remove old cache.
bool store(ApplicationCacheResource*, ApplicationCache*);
bool storeUpdatedType(ApplicationCacheResource*, ApplicationCache*);
// Removes the group if the cache to be removed is the newest one (so, storeNewestCache() needs to be called beforehand when updating).
void remove(ApplicationCache*);
void empty();
static bool storeCopyOfCache(const String& cacheDirectory, ApplicationCacheHost*);
bool manifestURLs(Vector<KURL>* urls);
bool cacheGroupSize(const String& manifestURL, int64_t* size);
bool deleteCacheGroup(const String& manifestURL);
void vacuumDatabaseFile();
void getOriginsWithCache(HashSet<RefPtr<SecurityOrigin>, SecurityOriginHash>&);
void deleteAllEntries();
static int64_t unknownQuota() { return -1; }
static int64_t noQuota() { return std::numeric_limits<int64_t>::max(); }
private:
ApplicationCacheStorage();
PassRefPtr<ApplicationCache> loadCache(unsigned storageID);
ApplicationCacheGroup* loadCacheGroup(const KURL& manifestURL);
typedef StorageIDJournal<ApplicationCacheResource> ResourceStorageIDJournal;
typedef StorageIDJournal<ApplicationCacheGroup> GroupStorageIDJournal;
bool store(ApplicationCacheGroup*, GroupStorageIDJournal*);
bool store(ApplicationCache*, ResourceStorageIDJournal*);
bool store(ApplicationCacheResource*, unsigned cacheStorageID);
bool ensureOriginRecord(const SecurityOrigin*);
bool shouldStoreResourceAsFlatFile(ApplicationCacheResource*);
void deleteTables();
bool writeDataToUniqueFileInDirectory(SharedBuffer*, const String& directory, String& outFilename, const String& fileExtension);
void loadManifestHostHashes();
void verifySchemaVersion();
void openDatabase(bool createIfDoesNotExist);
bool executeStatement(SQLiteStatement&);
bool executeSQLCommand(const String&);
void checkForMaxSizeReached();
void checkForDeletedResources();
long long flatFileAreaSize();
String m_cacheDirectory;
String m_cacheFile;
int64_t m_maximumSize;
bool m_isMaximumSizeReached;
int64_t m_defaultOriginQuota;
SQLiteDatabase m_database;
// In order to quickly determine if a given resource exists in an application cache,
// we keep a hash set of the hosts of the manifest URLs of all non-obsolete cache groups.
HashCountedSet<unsigned, AlreadyHashed> m_cacheHostSet;
typedef HashMap<String, ApplicationCacheGroup*> CacheGroupMap;
CacheGroupMap m_cachesInMemory; // Excludes obsolete cache groups.
friend ApplicationCacheStorage& cacheStorage();
};
ApplicationCacheStorage& cacheStorage();
} // namespace WebCore
#endif // ApplicationCacheStorage_h

View File

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ApplyBlockElementCommand_h
#define ApplyBlockElementCommand_h
#include "CompositeEditCommand.h"
#include "QualifiedName.h"
namespace WebCore {
class ApplyBlockElementCommand : public CompositeEditCommand {
protected:
ApplyBlockElementCommand(Document*, const QualifiedName& tagName, const AtomicString& inlineStyle);
ApplyBlockElementCommand(Document*, const QualifiedName& tagName);
virtual void formatSelection(const VisiblePosition& startOfSelection, const VisiblePosition& endOfSelection);
PassRefPtr<Element> createBlockElement() const;
const QualifiedName tagName() const { return m_tagName; }
private:
virtual void doApply();
virtual void formatRange(const Position& start, const Position& end, const Position& endOfSelection, RefPtr<Element>&) = 0;
void rangeForParagraphSplittingTextNodesIfNeeded(const VisiblePosition&, Position&, Position&);
VisiblePosition endOfNextParagrahSplittingTextNodesIfNeeded(VisiblePosition&, Position&, Position&);
QualifiedName m_tagName;
AtomicString m_inlineStyle;
Position m_endOfLastParagraph;
};
}
#endif

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Archive_h
#define Archive_h
#include "ArchiveResource.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class Archive : public RefCounted<Archive> {
public:
enum Type {
WebArchive,
MHTML
};
virtual ~Archive();
virtual Type type() const = 0;
ArchiveResource* mainResource() { return m_mainResource.get(); }
const Vector<RefPtr<ArchiveResource> >& subresources() const { return m_subresources; }
const Vector<RefPtr<Archive> >& subframeArchives() const { return m_subframeArchives; }
protected:
// These methods are meant for subclasses for different archive types to add resources in to the archive,
// and should not be exposed as archives should be immutable to clients
void setMainResource(PassRefPtr<ArchiveResource> mainResource) { m_mainResource = mainResource; }
void addSubresource(PassRefPtr<ArchiveResource> subResource) { m_subresources.append(subResource); }
void addSubframeArchive(PassRefPtr<Archive> subframeArchive) { m_subframeArchives.append(subframeArchive); }
private:
RefPtr<ArchiveResource> m_mainResource;
Vector<RefPtr<ArchiveResource> > m_subresources;
Vector<RefPtr<Archive> > m_subframeArchives;
};
}
#endif // Archive

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ArchiveResource_h
#define ArchiveResource_h
#include "SubstituteResource.h"
namespace WebCore {
class ArchiveResource : public SubstituteResource {
public:
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&, const ResourceResponse&);
static PassRefPtr<ArchiveResource> create(PassRefPtr<SharedBuffer>, const KURL&,
const String& mimeType, const String& textEncoding, const String& frameName,
const ResourceResponse& = ResourceResponse());
const String& mimeType() const { return m_mimeType; }
const String& textEncoding() const { return m_textEncoding; }
const String& frameName() const { return m_frameName; }
void ignoreWhenUnarchiving() { m_shouldIgnoreWhenUnarchiving = true; }
bool shouldIgnoreWhenUnarchiving() const { return m_shouldIgnoreWhenUnarchiving; }
private:
ArchiveResource(PassRefPtr<SharedBuffer>, const KURL&, const String& mimeType, const String& textEncoding, const String& frameName, const ResourceResponse&);
String m_mimeType;
String m_textEncoding;
String m_frameName;
bool m_shouldIgnoreWhenUnarchiving;
};
}
#endif // ArchiveResource_h

View File

@@ -0,0 +1,139 @@
/*
* Copyright (C) 1998-2000 Netscape Communications Corporation.
* Copyright (C) 2003-6 Apple Computer
* Copyright (C) Research In Motion Limited 2010. All rights reserved.
*
* Other contributors:
* Nick Blievers <nickb@adacel.com.au>
* Jeff Hostetler <jeff@nerdone.com>
* Tom Rini <trini@kernel.crashing.org>
* Raffaele Sena <raff@netwinder.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Alternatively, the contents of this file may be used under the terms
* of either the Mozilla Public License Version 1.1, found at
* http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
* License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
* (the "GPL"), in which case the provisions of the MPL or the GPL are
* applicable instead of those above. If you wish to allow use of your
* version of this file only under the terms of one of those two
* licenses (the MPL or the GPL) and not to allow others to use your
* version of this file under the LGPL, indicate your decision by
* deletingthe provisions above and replace them with the notice and
* other provisions required by the MPL or the GPL, as the case may be.
* If you do not delete the provisions above, a recipient may use your
* version of this file under any of the LGPL, the MPL or the GPL.
*/
#ifndef Arena_h
#define Arena_h
#include <wtf/FastMalloc.h>
// FIXME: We'd always like to use AllocAlignmentInteger for Arena alignment
// but there is concern over the memory growth this may cause.
#ifdef WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER
#define ARENA_ALIGN_MASK (sizeof(WTF::AllocAlignmentInteger) - 1)
#else
#define ARENA_ALIGN_MASK 3
#endif
namespace WebCore {
typedef uintptr_t uword;
struct Arena {
Arena* next; // next arena
uword base; // aligned base address
uword limit; // end of arena (1+last byte)
uword avail; // points to next available byte in arena
};
struct ArenaPool {
Arena first; // first arena in pool list.
Arena* current; // current arena.
unsigned int arenasize;
uword mask; // Mask (power-of-2 - 1)
};
void InitArenaPool(ArenaPool *pool, const char *name,
unsigned int size, unsigned int align);
void FinishArenaPool(ArenaPool *pool);
void FreeArenaPool(ArenaPool *pool);
void* ArenaAllocate(ArenaPool *pool, unsigned int nb);
#define ARENA_ALIGN(n) (((uword)(n) + ARENA_ALIGN_MASK) & ~ARENA_ALIGN_MASK)
#define INIT_ARENA_POOL(pool, name, size) \
InitArenaPool(pool, name, size, ARENA_ALIGN_MASK + 1)
#define ARENA_ALLOCATE(p, pool, nb) \
Arena *_a = (pool)->current; \
unsigned int _nb = ARENA_ALIGN(nb); \
uword _p = _a->avail; \
uword _q = _p + _nb; \
if (_q > _a->limit) \
_p = (uword)ArenaAllocate(pool, _nb); \
else \
_a->avail = _q; \
p = (void *)_p;
#define ARENA_GROW(p, pool, size, incr) \
Arena *_a = (pool)->current; \
unsigned int _incr = ARENA_ALIGN(incr); \
uword _p = _a->avail; \
uword _q = _p + _incr; \
if (_p == (uword)(p) + ARENA_ALIGN(size) && \
_q <= _a->limit) { \
_a->avail = _q; \
} else { \
p = ArenaGrow(pool, p, size, incr); \
}
#define ARENA_MARK(pool) ((void *) (pool)->current->avail)
#define UPTRDIFF(p,q) ((uword)(p) - (uword)(q))
#ifdef DEBUG
#define FREE_PATTERN 0xDA
#define CLEAR_UNUSED(a) ASSERT((a)->avail <= (a)->limit); \
memset((void*)(a)->avail, FREE_PATTERN, \
(a)->limit - (a)->avail)
#define CLEAR_ARENA(a) memset((void*)(a), FREE_PATTERN, \
(a)->limit - (uword)(a))
#else
#define CLEAR_UNUSED(a)
#define CLEAR_ARENA(a)
#endif
#define ARENA_RELEASE(pool, mark) \
char *_m = (char *)(mark); \
Arena *_a = (pool)->current; \
if (UPTRDIFF(_m, _a->base) <= UPTRDIFF(_a->avail, _a->base)) { \
_a->avail = (uword)ARENA_ALIGN(_m); \
CLEAR_UNUSED(_a); \
} else { \
ArenaRelease(pool, _m); \
}
#define ARENA_DESTROY(pool, a, pnext) \
if ((pool)->current == (a)) (pool)->current = &(pool)->first; \
*(pnext) = (a)->next; \
CLEAR_ARENA(a); \
fastFree(a); \
(a) = 0;
}
#endif

View File

@@ -0,0 +1,74 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AsyncFileStream_h
#define AsyncFileStream_h
#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
#include "FileStreamClient.h"
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class KURL;
class AsyncFileStream : public RefCounted<AsyncFileStream> {
public:
virtual ~AsyncFileStream() { }
virtual void getSize(const String& path, double expectedModificationTime) = 0;
virtual void openForRead(const String& path, long long offset, long long length) = 0;
virtual void openForWrite(const String& path) = 0;
virtual void close() = 0;
virtual void read(char* buffer, int length) = 0;
virtual void write(const KURL& blobURL, long long position, int length) = 0;
virtual void truncate(long long position) = 0;
virtual void stop() = 0;
FileStreamClient* client() const { return m_client; }
void setClient(FileStreamClient* client) { m_client = client; }
protected:
AsyncFileStream(FileStreamClient* client)
: m_client(client)
{
}
private:
FileStreamClient* m_client;
};
} // namespace WebCore
#endif // ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
#endif // AsyncFileStream_h

View File

@@ -0,0 +1,98 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef Attr_h
#define Attr_h
#include "ContainerNode.h"
#include "Attribute.h"
namespace WebCore {
// Attr can have Text and EntityReference children
// therefore it has to be a fullblown Node. The plan
// is to dynamically allocate a textchild and store the
// resulting nodevalue in the Attribute upon
// destruction. however, this is not yet implemented.
class Attr : public ContainerNode {
friend class NamedNodeMap;
public:
static PassRefPtr<Attr> create(Element*, Document*, PassRefPtr<Attribute>);
virtual ~Attr();
String name() const { return qualifiedName().toString(); }
bool specified() const { return m_specified; }
Element* ownerElement() const { return m_element; }
const AtomicString& value() const { return m_attribute->value(); }
void setValue(const AtomicString&, ExceptionCode&);
void setValue(const AtomicString&);
Attribute* attr() const { return m_attribute.get(); }
const QualifiedName& qualifiedName() const { return m_attribute->name(); }
bool isId() const;
// An extension to get presentational information for attributes.
CSSStyleDeclaration* style() { return m_attribute->decl(); }
void setSpecified(bool specified) { m_specified = specified; }
private:
Attr(Element*, Document*, PassRefPtr<Attribute>);
void createTextChild();
virtual String nodeName() const;
virtual NodeType nodeType() const;
const AtomicString& localName() const;
const AtomicString& namespaceURI() const;
const AtomicString& prefix() const;
virtual void setPrefix(const AtomicString&, ExceptionCode&);
virtual String nodeValue() const;
virtual void setNodeValue(const String&, ExceptionCode&);
virtual PassRefPtr<Node> cloneNode(bool deep);
virtual bool isAttributeNode() const { return true; }
virtual bool childTypeAllowed(NodeType) const;
virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
virtual const AtomicString& virtualPrefix() const { return prefix(); }
virtual const AtomicString& virtualLocalName() const { return localName(); }
virtual const AtomicString& virtualNamespaceURI() const { return namespaceURI(); }
Element* m_element;
RefPtr<Attribute> m_attribute;
unsigned m_ignoreChildrenChanged : 31;
bool m_specified : 1;
};
} // namespace WebCore
#endif // Attr_h

View File

@@ -0,0 +1,118 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef Attribute_h
#define Attribute_h
#include "CSSMappedAttributeDeclaration.h"
#include "QualifiedName.h"
namespace WebCore {
class Attr;
class CSSStyleDeclaration;
class Element;
class NamedNodeMap;
// This has no counterpart in DOM.
// It is an internal representation of the node value of an Attr.
// The actual Attr with its value as a Text child is allocated only if needed.
class Attribute : public RefCounted<Attribute> {
friend class Attr;
public:
static PassRefPtr<Attribute> create(const QualifiedName& name, const AtomicString& value)
{
return adoptRef(new Attribute(name, value, false, 0));
}
static PassRefPtr<Attribute> createMapped(const QualifiedName& name, const AtomicString& value)
{
return adoptRef(new Attribute(name, value, true, 0));
}
static PassRefPtr<Attribute> createMapped(const AtomicString& name, const AtomicString& value)
{
return adoptRef(new Attribute(name, value, true, 0));
}
const AtomicString& value() const { return m_value; }
const AtomicString& prefix() const { return m_name.prefix(); }
const AtomicString& localName() const { return m_name.localName(); }
const AtomicString& namespaceURI() const { return m_name.namespaceURI(); }
const QualifiedName& name() const { return m_name; }
Attr* attr() const;
PassRefPtr<Attr> createAttrIfNeeded(Element*);
bool isNull() const { return m_value.isNull(); }
bool isEmpty() const { return m_value.isEmpty(); }
PassRefPtr<Attribute> clone() const;
CSSMappedAttributeDeclaration* decl() const { return m_styleDecl.get(); }
void setDecl(PassRefPtr<CSSMappedAttributeDeclaration> decl) { m_styleDecl = decl; }
void setValue(const AtomicString& value) { m_value = value; }
void setPrefix(const AtomicString& prefix) { m_name.setPrefix(prefix); }
// Note: This API is only for HTMLTreeBuilder. It is not safe to change the
// name of an attribute once parseMappedAttribute has been called as DOM
// elements may have placed the Attribute in a hash by name.
void parserSetName(const QualifiedName& name) { m_name = name; }
bool isMappedAttribute() { return m_isMappedAttribute; }
private:
Attribute(const QualifiedName& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
: m_isMappedAttribute(isMappedAttribute)
, m_hasAttr(false)
, m_name(name)
, m_value(value)
, m_styleDecl(styleDecl)
{
}
Attribute(const AtomicString& name, const AtomicString& value, bool isMappedAttribute, CSSMappedAttributeDeclaration* styleDecl)
: m_isMappedAttribute(isMappedAttribute)
, m_hasAttr(false)
, m_name(nullAtom, name, nullAtom)
, m_value(value)
, m_styleDecl(styleDecl)
{
}
void bindAttr(Attr*);
void unbindAttr(Attr*);
// These booleans will go into the spare 32-bits of padding from RefCounted in 64-bit.
bool m_isMappedAttribute;
bool m_hasAttr;
QualifiedName m_name;
AtomicString m_value;
RefPtr<CSSMappedAttributeDeclaration> m_styleDecl;
};
} // namespace WebCore
#endif // Attribute_h

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AuthenticationCF_h
#define AuthenticationCF_h
#if USE(CFNETWORK)
#include <CFNetwork/CFURLCredentialPriv.h>
typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef;
typedef struct _CFURLProtectionSpace* CFURLProtectionSpaceRef;
namespace WebCore {
class AuthenticationChallenge;
class Credential;
class ProtectionSpace;
CFURLAuthChallengeRef createCF(const AuthenticationChallenge&);
CFURLCredentialRef createCF(const Credential&);
CFURLProtectionSpaceRef createCF(const ProtectionSpace&);
#if PLATFORM(MAC)
AuthenticationChallenge core(CFURLAuthChallengeRef);
#endif
Credential core(CFURLCredentialRef);
ProtectionSpace core(CFURLProtectionSpaceRef);
}
#endif // USE(CFNETWORK)
#endif // AuthenticationCF_h

View File

@@ -0,0 +1,85 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AuthenticationChallenge_h
#define AuthenticationChallenge_h
#include "AuthenticationChallengeBase.h"
#include "AuthenticationClient.h"
#include <wtf/RefPtr.h>
#if USE(CFNETWORK)
typedef struct _CFURLAuthChallenge* CFURLAuthChallengeRef;
#else
#ifndef __OBJC__
typedef struct objc_object *id;
#endif
OBJC_CLASS NSURLAuthenticationChallenge;
#endif
namespace WebCore {
class AuthenticationChallenge : public AuthenticationChallengeBase {
public:
AuthenticationChallenge() {}
AuthenticationChallenge(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
#if USE(CFNETWORK)
AuthenticationChallenge(CFURLAuthChallengeRef, AuthenticationClient*);
AuthenticationClient* authenticationClient() const;
void setAuthenticationClient(AuthenticationClient* client) { m_authenticationClient = client; }
CFURLAuthChallengeRef cfURLAuthChallengeRef() const { return m_cfChallenge.get(); }
#else
AuthenticationChallenge(NSURLAuthenticationChallenge *);
id sender() const { return m_sender.get(); }
NSURLAuthenticationChallenge *nsURLAuthenticationChallenge() const { return m_nsChallenge.get(); }
void setAuthenticationClient(AuthenticationClient*); // Changes sender to one that invokes client methods.
AuthenticationClient* authenticationClient() const;
#endif
private:
friend class AuthenticationChallengeBase;
static bool platformCompare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
#if USE(CFNETWORK)
RefPtr<AuthenticationClient> m_authenticationClient;
RetainPtr<CFURLAuthChallengeRef> m_cfChallenge;
#else
RetainPtr<id> m_sender; // Always the same as [m_macChallenge.get() sender], cached here for performance.
RetainPtr<NSURLAuthenticationChallenge *> m_nsChallenge;
#endif
};
}
#endif

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AuthenticationChallengeBase_h
#define AuthenticationChallengeBase_h
#include "Credential.h"
#include "ProtectionSpace.h"
#include "ResourceResponse.h"
#include "ResourceError.h"
namespace WebCore {
class AuthenticationChallenge;
class AuthenticationChallengeBase {
public:
AuthenticationChallengeBase();
AuthenticationChallengeBase(const ProtectionSpace& protectionSpace, const Credential& proposedCredential, unsigned previousFailureCount, const ResourceResponse& response, const ResourceError& error);
unsigned previousFailureCount() const;
const Credential& proposedCredential() const;
const ProtectionSpace& protectionSpace() const;
const ResourceResponse& failureResponse() const;
const ResourceError& error() const;
bool isNull() const;
void nullify();
static bool compare(const AuthenticationChallenge& a, const AuthenticationChallenge& b);
protected:
// The AuthenticationChallenge subclass may "shadow" this method to compare platform specific fields
static bool platformCompare(const AuthenticationChallengeBase&, const AuthenticationChallengeBase&) { return true; }
bool m_isNull;
ProtectionSpace m_protectionSpace;
Credential m_proposedCredential;
unsigned m_previousFailureCount;
ResourceResponse m_failureResponse;
ResourceError m_error;
};
inline bool operator==(const AuthenticationChallenge& a, const AuthenticationChallenge& b) { return AuthenticationChallengeBase::compare(a, b); }
inline bool operator!=(const AuthenticationChallenge& a, const AuthenticationChallenge& b) { return !(a == b); }
}
#endif

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AuthenticationClient_h
#define AuthenticationClient_h
namespace WebCore {
class AuthenticationChallenge;
class Credential;
class AuthenticationClient {
public:
virtual void receivedCredential(const AuthenticationChallenge&, const Credential&) = 0;
virtual void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&) = 0;
virtual void receivedCancellation(const AuthenticationChallenge&) = 0;
void ref() { refAuthenticationClient(); }
void deref() { derefAuthenticationClient(); }
protected:
virtual ~AuthenticationClient() { }
private:
virtual void refAuthenticationClient() = 0;
virtual void derefAuthenticationClient() = 0;
};
}
#endif

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AuthenticationMac_h
#define AuthenticationMac_h
#ifdef __OBJC__
@class NSURLAuthenticationChallenge;
@class NSURLCredential;
@class NSURLProtectionSpace;
namespace WebCore {
class AuthenticationChallenge;
class Credential;
class ProtectionSpace;
NSURLAuthenticationChallenge *mac(const AuthenticationChallenge&);
NSURLProtectionSpace *mac(const ProtectionSpace&);
NSURLCredential *mac(const Credential&);
AuthenticationChallenge core(NSURLAuthenticationChallenge *);
ProtectionSpace core(NSURLProtectionSpace *);
Credential core(NSURLCredential *);
}
#endif // __OBJC__
#endif // AuthenticationMac_h

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BackForwardController_h
#define BackForwardController_h
#include <wtf/Noncopyable.h>
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class BackForwardList;
class HistoryItem;
class Page;
class BackForwardController {
WTF_MAKE_NONCOPYABLE(BackForwardController); WTF_MAKE_FAST_ALLOCATED;
public:
~BackForwardController();
static PassOwnPtr<BackForwardController> create(Page*, PassRefPtr<BackForwardList>);
BackForwardList* client() const { return m_client.get(); }
bool canGoBackOrForward(int distance) const;
void goBackOrForward(int distance);
bool goBack();
bool goForward();
void addItem(PassRefPtr<HistoryItem>);
void setCurrentItem(HistoryItem*);
int count() const;
int backCount() const;
int forwardCount() const;
HistoryItem* itemAtIndex(int);
bool isActive();
void close();
HistoryItem* backItem() { return itemAtIndex(-1); }
HistoryItem* currentItem() { return itemAtIndex(0); }
HistoryItem* forwardItem() { return itemAtIndex(1); }
void markPagesForFullStyleRecalc();
private:
BackForwardController(Page*, PassRefPtr<BackForwardList>);
Page* m_page;
RefPtr<BackForwardList> m_client;
};
} // namespace WebCore
#endif // BackForwardController_h

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2009 Google, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BackForwardList_h
#define BackForwardList_h
#include <wtf/Forward.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class HistoryItem;
// FIXME: Rename this class to BackForwardClient, and rename the
// getter in Page accordingly.
class BackForwardList : public RefCounted<BackForwardList> {
public:
virtual ~BackForwardList()
{
}
virtual void addItem(PassRefPtr<HistoryItem>) = 0;
virtual void goToItem(HistoryItem*) = 0;
virtual HistoryItem* itemAtIndex(int) = 0;
virtual int backListCount() = 0;
virtual int forwardListCount() = 0;
virtual bool isActive() = 0;
virtual void close() = 0;
// FIXME: Delete these once all callers are using BackForwardController
// instead of calling this directly.
HistoryItem* backItem() { return itemAtIndex(-1); }
HistoryItem* currentItem() { return itemAtIndex(0); }
HistoryItem* forwardItem() { return itemAtIndex(1); }
};
} // namespace WebCore
#endif // BackForwardList_h

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2006, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2008 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
* Copyright (C) 2009 Google, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BackForwardListImpl_h
#define BackForwardListImpl_h
#include "BackForwardList.h"
#include <wtf/HashSet.h>
#include <wtf/Vector.h>
namespace WebCore {
class Page;
typedef Vector<RefPtr<HistoryItem> > HistoryItemVector;
typedef HashSet<RefPtr<HistoryItem> > HistoryItemHashSet;
// FIXME: After renaming BackForwardList to BackForwardClient,
// rename this to BackForwardList.
class BackForwardListImpl : public BackForwardList {
public:
static PassRefPtr<BackForwardListImpl> create(Page* page) { return adoptRef(new BackForwardListImpl(page)); }
virtual ~BackForwardListImpl();
Page* page() { return m_page; }
virtual void addItem(PassRefPtr<HistoryItem>);
void goBack();
void goForward();
virtual void goToItem(HistoryItem*);
HistoryItem* backItem();
HistoryItem* currentItem();
HistoryItem* forwardItem();
virtual HistoryItem* itemAtIndex(int);
void backListWithLimit(int, HistoryItemVector&);
void forwardListWithLimit(int, HistoryItemVector&);
int capacity();
void setCapacity(int);
bool enabled();
void setEnabled(bool);
virtual int backListCount();
virtual int forwardListCount();
bool containsItem(HistoryItem*);
virtual void close();
bool closed();
void removeItem(HistoryItem*);
HistoryItemVector& entries();
private:
BackForwardListImpl(Page*);
virtual bool isActive() { return enabled() && capacity(); }
Page* m_page;
HistoryItemVector m_entries;
HistoryItemHashSet m_entryHash;
unsigned m_current;
unsigned m_capacity;
bool m_closed;
bool m_enabled;
};
} // namespace WebCore
#endif // BackForwardListImpl_h

View File

@@ -0,0 +1,71 @@
/*
* Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
* Copyright (C) 2010 Patrick Gansterer <paroga@paroga.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Base64_h
#define Base64_h
#include <wtf/Vector.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
enum Base64DecodePolicy { FailOnInvalidCharacter, IgnoreWhitespace, IgnoreInvalidCharacters };
void base64Encode(const char*, unsigned, Vector<char>&, bool insertLFs = false);
void base64Encode(const Vector<char>&, Vector<char>&, bool insertLFs = false);
void base64Encode(const CString&, Vector<char>&, bool insertLFs = false);
String base64Encode(const char*, unsigned, bool insertLFs = false);
String base64Encode(const Vector<char>&, bool insertLFs = false);
String base64Encode(const CString&, bool insertLFs = false);
bool base64Decode(const String&, Vector<char>&, Base64DecodePolicy = FailOnInvalidCharacter);
bool base64Decode(const Vector<char>&, Vector<char>&, Base64DecodePolicy = FailOnInvalidCharacter);
bool base64Decode(const char*, unsigned, Vector<char>&, Base64DecodePolicy = FailOnInvalidCharacter);
inline void base64Encode(const Vector<char>& in, Vector<char>& out, bool insertLFs)
{
base64Encode(in.data(), in.size(), out, insertLFs);
}
inline void base64Encode(const CString& in, Vector<char>& out, bool insertLFs)
{
base64Encode(in.data(), in.length(), out, insertLFs);
}
inline String base64Encode(const Vector<char>& in, bool insertLFs)
{
return base64Encode(in.data(), in.size(), insertLFs);
}
inline String base64Encode(const CString& in, bool insertLFs)
{
return base64Encode(in.data(), in.length(), insertLFs);
}
} // namespace WebCore
#endif // Base64_h

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2006, 2007, 2009, 2010 Apple Inc. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef BidiContext_h
#define BidiContext_h
#include <wtf/Assertions.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/unicode/Unicode.h>
namespace WebCore {
enum BidiEmbeddingSource {
FromStyleOrDOM,
FromUnicode
};
// Used to keep track of explicit embeddings.
class BidiContext : public RefCounted<BidiContext> {
public:
static PassRefPtr<BidiContext> create(unsigned char level, WTF::Unicode::Direction, bool override = false, BidiEmbeddingSource = FromStyleOrDOM, BidiContext* parent = 0);
BidiContext* parent() const { return m_parent.get(); }
unsigned char level() const { return m_level; }
WTF::Unicode::Direction dir() const { return static_cast<WTF::Unicode::Direction>(m_direction); }
bool override() const { return m_override; }
BidiEmbeddingSource source() const { return static_cast<BidiEmbeddingSource>(m_source); }
PassRefPtr<BidiContext> copyStackRemovingUnicodeEmbeddingContexts();
private:
BidiContext(unsigned char level, WTF::Unicode::Direction direction, bool override, BidiEmbeddingSource source, BidiContext* parent)
: m_level(level)
, m_direction(direction)
, m_override(override)
, m_source(source)
, m_parent(parent)
{
}
static PassRefPtr<BidiContext> createUncached(unsigned char level, WTF::Unicode::Direction, bool override, BidiEmbeddingSource, BidiContext* parent);
unsigned char m_level;
unsigned m_direction : 5; // Direction
bool m_override : 1;
unsigned m_source : 1; // BidiEmbeddingSource
RefPtr<BidiContext> m_parent;
};
inline unsigned char nextGreaterOddLevel(unsigned char level)
{
return (level + 1) | 1;
}
inline unsigned char nextGreaterEvenLevel(unsigned char level)
{
return (level + 2) & ~1;
}
bool operator==(const BidiContext&, const BidiContext&);
} // namespace WebCore
#endif // BidiContext_h

View File

@@ -0,0 +1,920 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* Copyright (C) 2003, 2004, 2006, 2007, 2008 Apple Inc. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef BidiResolver_h
#define BidiResolver_h
#include "BidiContext.h"
#include "BidiRunList.h"
#include "TextDirection.h"
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
template <class Iterator> struct MidpointState {
MidpointState()
{
reset();
}
void reset()
{
numMidpoints = 0;
currentMidpoint = 0;
betweenMidpoints = false;
}
// The goal is to reuse the line state across multiple
// lines so we just keep an array around for midpoints and never clear it across multiple
// lines. We track the number of items and position using the two other variables.
Vector<Iterator> midpoints;
unsigned numMidpoints;
unsigned currentMidpoint;
bool betweenMidpoints;
};
// The BidiStatus at a given position (typically the end of a line) can
// be cached and then used to restart bidi resolution at that position.
struct BidiStatus {
BidiStatus()
: eor(WTF::Unicode::OtherNeutral)
, lastStrong(WTF::Unicode::OtherNeutral)
, last(WTF::Unicode::OtherNeutral)
{
}
// Creates a BidiStatus representing a new paragraph root with a default direction.
// Uses TextDirection as it only has two possibilities instead of WTF::Unicode::Direction which has 19.
BidiStatus(TextDirection textDirection, bool isOverride)
{
WTF::Unicode::Direction direction = textDirection == LTR ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
eor = lastStrong = last = direction;
context = BidiContext::create(textDirection == LTR ? 0 : 1, direction, isOverride);
}
BidiStatus(WTF::Unicode::Direction eorDir, WTF::Unicode::Direction lastStrongDir, WTF::Unicode::Direction lastDir, PassRefPtr<BidiContext> bidiContext)
: eor(eorDir)
, lastStrong(lastStrongDir)
, last(lastDir)
, context(bidiContext)
{
}
WTF::Unicode::Direction eor;
WTF::Unicode::Direction lastStrong;
WTF::Unicode::Direction last;
RefPtr<BidiContext> context;
};
class BidiEmbedding {
public:
BidiEmbedding(WTF::Unicode::Direction direction, BidiEmbeddingSource source)
: m_direction(direction)
, m_source(source)
{
}
WTF::Unicode::Direction direction() const { return m_direction; }
BidiEmbeddingSource source() const { return m_source; }
private:
WTF::Unicode::Direction m_direction;
BidiEmbeddingSource m_source;
};
inline bool operator==(const BidiStatus& status1, const BidiStatus& status2)
{
return status1.eor == status2.eor && status1.last == status2.last && status1.lastStrong == status2.lastStrong && *(status1.context) == *(status2.context);
}
inline bool operator!=(const BidiStatus& status1, const BidiStatus& status2)
{
return !(status1 == status2);
}
struct BidiCharacterRun {
BidiCharacterRun(int start, int stop, BidiContext* context, WTF::Unicode::Direction dir)
: m_start(start)
, m_stop(stop)
, m_override(context->override())
, m_next(0)
{
if (dir == WTF::Unicode::OtherNeutral)
dir = context->dir();
m_level = context->level();
// add level of run (cases I1 & I2)
if (m_level % 2) {
if (dir == WTF::Unicode::LeftToRight || dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
m_level++;
} else {
if (dir == WTF::Unicode::RightToLeft)
m_level++;
else if (dir == WTF::Unicode::ArabicNumber || dir == WTF::Unicode::EuropeanNumber)
m_level += 2;
}
}
void destroy() { delete this; }
int start() const { return m_start; }
int stop() const { return m_stop; }
unsigned char level() const { return m_level; }
bool reversed(bool visuallyOrdered) { return m_level % 2 && !visuallyOrdered; }
bool dirOverride(bool visuallyOrdered) { return m_override || visuallyOrdered; }
BidiCharacterRun* next() const { return m_next; }
void setNext(BidiCharacterRun* next) { m_next = next; }
unsigned char m_level;
int m_start;
int m_stop;
bool m_override;
BidiCharacterRun* m_next;
};
enum VisualDirectionOverride {
NoVisualOverride,
VisualLeftToRightOverride,
VisualRightToLeftOverride
};
// BidiResolver is WebKit's implementation of the Unicode Bidi Algorithm
// http://unicode.org/reports/tr9
template <class Iterator, class Run> class BidiResolver {
WTF_MAKE_NONCOPYABLE(BidiResolver);
public:
BidiResolver()
: m_direction(WTF::Unicode::OtherNeutral)
, m_reachedEndOfLine(false)
, m_emptyRun(true)
, m_nestedIsolateCount(0)
{
}
#ifndef NDEBUG
~BidiResolver();
#endif
const Iterator& position() const { return m_current; }
void setPositionIgnoringNestedIsolates(const Iterator& position) { m_current = position; }
void setPosition(const Iterator& position, unsigned nestedIsolatedCount)
{
m_current = position;
m_nestedIsolateCount = nestedIsolatedCount;
}
void increment() { m_current.increment(); }
BidiContext* context() const { return m_status.context.get(); }
void setContext(PassRefPtr<BidiContext> c) { m_status.context = c; }
void setLastDir(WTF::Unicode::Direction lastDir) { m_status.last = lastDir; }
void setLastStrongDir(WTF::Unicode::Direction lastStrongDir) { m_status.lastStrong = lastStrongDir; }
void setEorDir(WTF::Unicode::Direction eorDir) { m_status.eor = eorDir; }
WTF::Unicode::Direction dir() const { return m_direction; }
void setDir(WTF::Unicode::Direction d) { m_direction = d; }
const BidiStatus& status() const { return m_status; }
void setStatus(const BidiStatus s) { m_status = s; }
MidpointState<Iterator>& midpointState() { return m_midpointState; }
// The current algorithm handles nested isolates one layer of nesting at a time.
// But when we layout each isolated span, we will walk into (and ignore) all
// child isolated spans.
void enterIsolate() { m_nestedIsolateCount++; }
void exitIsolate() { ASSERT(m_nestedIsolateCount >= 1); m_nestedIsolateCount--; }
bool inIsolate() const { return m_nestedIsolateCount; }
void embed(WTF::Unicode::Direction, BidiEmbeddingSource);
bool commitExplicitEmbedding();
void createBidiRunsForLine(const Iterator& end, VisualDirectionOverride = NoVisualOverride, bool hardLineBreak = false);
BidiRunList<Run>& runs() { return m_runs; }
// FIXME: This used to be part of deleteRuns() but was a layering violation.
// It's unclear if this is still needed.
void markCurrentRunEmpty() { m_emptyRun = true; }
Vector<Run*>& isolatedRuns() { return m_isolatedRuns; }
protected:
// FIXME: Instead of InlineBidiResolvers subclassing this method, we should
// pass in some sort of Traits object which knows how to create runs for appending.
void appendRun();
Iterator m_current;
// sor and eor are "start of run" and "end of run" respectively and correpond
// to abreviations used in UBA spec: http://unicode.org/reports/tr9/#BD7
Iterator m_sor; // Points to the first character in the current run.
Iterator m_eor; // Points to the last character in the current run.
Iterator m_last;
BidiStatus m_status;
WTF::Unicode::Direction m_direction;
Iterator endOfLine;
bool m_reachedEndOfLine;
Iterator m_lastBeforeET; // Before a EuropeanNumberTerminator
bool m_emptyRun;
// FIXME: This should not belong to the resolver, but rather be passed
// into createBidiRunsForLine by the caller.
BidiRunList<Run> m_runs;
MidpointState<Iterator> m_midpointState;
unsigned m_nestedIsolateCount;
Vector<Run*> m_isolatedRuns;
private:
void raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode::Direction to);
void lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from);
void checkDirectionInLowerRaiseEmbeddingLevel();
void updateStatusLastFromCurrentDirection(WTF::Unicode::Direction);
void reorderRunsFromLevels();
Vector<BidiEmbedding, 8> m_currentExplicitEmbeddingSequence;
};
#ifndef NDEBUG
template <class Iterator, class Run>
BidiResolver<Iterator, Run>::~BidiResolver()
{
// The owner of this resolver should have handled the isolated runs
// or should never have called enterIsolate().
ASSERT(m_isolatedRuns.isEmpty());
ASSERT(!m_nestedIsolateCount);
}
#endif
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::appendRun()
{
if (!m_emptyRun && !m_eor.atEnd()) {
unsigned startOffset = m_sor.offset();
unsigned endOffset = m_eor.offset();
if (!endOfLine.atEnd() && endOffset >= endOfLine.offset()) {
m_reachedEndOfLine = true;
endOffset = endOfLine.offset();
}
if (endOffset >= startOffset)
m_runs.addRun(new Run(startOffset, endOffset + 1, context(), m_direction));
m_eor.increment();
m_sor = m_eor;
}
m_direction = WTF::Unicode::OtherNeutral;
m_status.eor = WTF::Unicode::OtherNeutral;
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::embed(WTF::Unicode::Direction dir, BidiEmbeddingSource source)
{
// Isolated spans compute base directionality during their own UBA run.
// Do not insert fake embed characters once we enter an isolated span.
ASSERT(!inIsolate());
using namespace WTF::Unicode;
ASSERT(dir == PopDirectionalFormat || dir == LeftToRightEmbedding || dir == LeftToRightOverride || dir == RightToLeftEmbedding || dir == RightToLeftOverride);
m_currentExplicitEmbeddingSequence.append(BidiEmbedding(dir, source));
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::checkDirectionInLowerRaiseEmbeddingLevel()
{
using namespace WTF::Unicode;
ASSERT(m_status.eor != OtherNeutral || m_eor.atEnd());
ASSERT(m_status.last != NonSpacingMark
&& m_status.last != BoundaryNeutral
&& m_status.last != RightToLeftEmbedding
&& m_status.last != LeftToRightEmbedding
&& m_status.last != RightToLeftOverride
&& m_status.last != LeftToRightOverride
&& m_status.last != PopDirectionalFormat);
if (m_direction == OtherNeutral)
m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft;
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::lowerExplicitEmbeddingLevel(WTF::Unicode::Direction from)
{
using namespace WTF::Unicode;
if (!m_emptyRun && m_eor != m_last) {
checkDirectionInLowerRaiseEmbeddingLevel();
// bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
if (from == LeftToRight) {
// bidi.sor ... bidi.eor ... bidi.last L
if (m_status.eor == EuropeanNumber) {
if (m_status.lastStrong != LeftToRight) {
m_direction = EuropeanNumber;
appendRun();
}
} else if (m_status.eor == ArabicNumber) {
m_direction = ArabicNumber;
appendRun();
} else if (m_status.lastStrong != LeftToRight) {
appendRun();
m_direction = LeftToRight;
}
} else if (m_status.eor == EuropeanNumber || m_status.eor == ArabicNumber || m_status.lastStrong == LeftToRight) {
appendRun();
m_direction = RightToLeft;
}
m_eor = m_last;
}
appendRun();
m_emptyRun = true;
// sor for the new run is determined by the higher level (rule X10)
setLastDir(from);
setLastStrongDir(from);
m_eor = Iterator();
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::raiseExplicitEmbeddingLevel(WTF::Unicode::Direction from, WTF::Unicode::Direction to)
{
using namespace WTF::Unicode;
if (!m_emptyRun && m_eor != m_last) {
checkDirectionInLowerRaiseEmbeddingLevel();
// bidi.sor ... bidi.eor ... bidi.last eor; need to append the bidi.sor-bidi.eor run or extend it through bidi.last
if (to == LeftToRight) {
// bidi.sor ... bidi.eor ... bidi.last L
if (m_status.eor == EuropeanNumber) {
if (m_status.lastStrong != LeftToRight) {
m_direction = EuropeanNumber;
appendRun();
}
} else if (m_status.eor == ArabicNumber) {
m_direction = ArabicNumber;
appendRun();
} else if (m_status.lastStrong != LeftToRight && from == LeftToRight) {
appendRun();
m_direction = LeftToRight;
}
} else if (m_status.eor == ArabicNumber
|| (m_status.eor == EuropeanNumber && (m_status.lastStrong != LeftToRight || from == RightToLeft))
|| (m_status.eor != EuropeanNumber && m_status.lastStrong == LeftToRight && from == RightToLeft)) {
appendRun();
m_direction = RightToLeft;
}
m_eor = m_last;
}
appendRun();
m_emptyRun = true;
setLastDir(to);
setLastStrongDir(to);
m_eor = Iterator();
}
template <class Iterator, class Run>
bool BidiResolver<Iterator, Run>::commitExplicitEmbedding()
{
// This gets called from bidiFirst when setting up our start position.
ASSERT(!inIsolate() || m_currentExplicitEmbeddingSequence.isEmpty());
using namespace WTF::Unicode;
unsigned char fromLevel = context()->level();
RefPtr<BidiContext> toContext = context();
for (size_t i = 0; i < m_currentExplicitEmbeddingSequence.size(); ++i) {
BidiEmbedding embedding = m_currentExplicitEmbeddingSequence[i];
if (embedding.direction() == PopDirectionalFormat) {
if (BidiContext* parentContext = toContext->parent())
toContext = parentContext;
} else {
Direction direction = (embedding.direction() == RightToLeftEmbedding || embedding.direction() == RightToLeftOverride) ? RightToLeft : LeftToRight;
bool override = embedding.direction() == LeftToRightOverride || embedding.direction() == RightToLeftOverride;
unsigned char level = toContext->level();
if (direction == RightToLeft)
level = nextGreaterOddLevel(level);
else
level = nextGreaterEvenLevel(level);
if (level < 61)
toContext = BidiContext::create(level, direction, override, embedding.source(), toContext.get());
}
}
unsigned char toLevel = toContext->level();
if (toLevel > fromLevel)
raiseExplicitEmbeddingLevel(fromLevel % 2 ? RightToLeft : LeftToRight, toLevel % 2 ? RightToLeft : LeftToRight);
else if (toLevel < fromLevel)
lowerExplicitEmbeddingLevel(fromLevel % 2 ? RightToLeft : LeftToRight);
setContext(toContext);
m_currentExplicitEmbeddingSequence.clear();
return fromLevel != toLevel;
}
template <class Iterator, class Run>
inline void BidiResolver<Iterator, Run>::updateStatusLastFromCurrentDirection(WTF::Unicode::Direction dirCurrent)
{
using namespace WTF::Unicode;
switch (dirCurrent) {
case EuropeanNumberTerminator:
if (m_status.last != EuropeanNumber)
m_status.last = EuropeanNumberTerminator;
break;
case EuropeanNumberSeparator:
case CommonNumberSeparator:
case SegmentSeparator:
case WhiteSpaceNeutral:
case OtherNeutral:
switch (m_status.last) {
case LeftToRight:
case RightToLeft:
case RightToLeftArabic:
case EuropeanNumber:
case ArabicNumber:
m_status.last = dirCurrent;
break;
default:
m_status.last = OtherNeutral;
}
break;
case NonSpacingMark:
case BoundaryNeutral:
case RightToLeftEmbedding:
case LeftToRightEmbedding:
case RightToLeftOverride:
case LeftToRightOverride:
case PopDirectionalFormat:
// ignore these
break;
case EuropeanNumber:
// fall through
default:
m_status.last = dirCurrent;
}
}
template <class Iterator, class Run>
inline void BidiResolver<Iterator, Run>::reorderRunsFromLevels()
{
unsigned char levelLow = 128;
unsigned char levelHigh = 0;
for (Run* run = m_runs.firstRun(); run; run = run->next()) {
levelHigh = std::max(run->level(), levelHigh);
levelLow = std::min(run->level(), levelLow);
}
// This implements reordering of the line (L2 according to Bidi spec):
// http://unicode.org/reports/tr9/#L2
// L2. From the highest level found in the text to the lowest odd level on each line,
// reverse any contiguous sequence of characters that are at that level or higher.
// Reversing is only done up to the lowest odd level.
if (!(levelLow % 2))
levelLow++;
unsigned count = m_runs.runCount() - 1;
while (levelHigh >= levelLow) {
unsigned i = 0;
Run* run = m_runs.firstRun();
while (i < count) {
for (;i < count && run && run->level() < levelHigh; i++)
run = run->next();
unsigned start = i;
for (;i <= count && run && run->level() >= levelHigh; i++)
run = run->next();
unsigned end = i - 1;
m_runs.reverseRuns(start, end);
}
levelHigh--;
}
}
template <class Iterator, class Run>
void BidiResolver<Iterator, Run>::createBidiRunsForLine(const Iterator& end, VisualDirectionOverride override, bool hardLineBreak)
{
using namespace WTF::Unicode;
ASSERT(m_direction == OtherNeutral);
if (override != NoVisualOverride) {
m_emptyRun = false;
m_sor = m_current;
m_eor = Iterator();
while (m_current != end && !m_current.atEnd()) {
m_eor = m_current;
increment();
}
m_direction = override == VisualLeftToRightOverride ? LeftToRight : RightToLeft;
appendRun();
m_runs.setLogicallyLastRun(m_runs.lastRun());
if (override == VisualRightToLeftOverride)
m_runs.reverseRuns(0, m_runs.runCount() - 1);
return;
}
m_emptyRun = true;
m_eor = Iterator();
m_last = m_current;
bool pastEnd = false;
BidiResolver<Iterator, Run> stateAtEnd;
while (true) {
Direction dirCurrent;
if (pastEnd && (hardLineBreak || m_current.atEnd())) {
BidiContext* c = context();
if (hardLineBreak) {
// A deviation from the Unicode Bidi Algorithm in order to match
// WinIE and user expectations: hard line breaks reset bidi state
// coming from unicode bidi control characters, but not those from
// DOM nodes with specified directionality
stateAtEnd.setContext(c->copyStackRemovingUnicodeEmbeddingContexts());
dirCurrent = stateAtEnd.context()->dir();
stateAtEnd.setEorDir(dirCurrent);
stateAtEnd.setLastDir(dirCurrent);
stateAtEnd.setLastStrongDir(dirCurrent);
} else {
while (c->parent())
c = c->parent();
dirCurrent = c->dir();
}
} else {
dirCurrent = m_current.direction();
if (context()->override()
&& dirCurrent != RightToLeftEmbedding
&& dirCurrent != LeftToRightEmbedding
&& dirCurrent != RightToLeftOverride
&& dirCurrent != LeftToRightOverride
&& dirCurrent != PopDirectionalFormat)
dirCurrent = context()->dir();
else if (dirCurrent == NonSpacingMark)
dirCurrent = m_status.last;
}
// We ignore all character directionality while in unicode-bidi: isolate spans.
// We'll handle ordering the isolated characters in a second pass.
if (inIsolate())
dirCurrent = OtherNeutral;
ASSERT(m_status.eor != OtherNeutral || m_eor.atEnd());
switch (dirCurrent) {
// embedding and overrides (X1-X9 in the Bidi specs)
case RightToLeftEmbedding:
case LeftToRightEmbedding:
case RightToLeftOverride:
case LeftToRightOverride:
case PopDirectionalFormat:
embed(dirCurrent, FromUnicode);
commitExplicitEmbedding();
break;
// strong types
case LeftToRight:
switch(m_status.last) {
case RightToLeft:
case RightToLeftArabic:
case EuropeanNumber:
case ArabicNumber:
if (m_status.last != EuropeanNumber || m_status.lastStrong != LeftToRight)
appendRun();
break;
case LeftToRight:
break;
case EuropeanNumberSeparator:
case EuropeanNumberTerminator:
case CommonNumberSeparator:
case BoundaryNeutral:
case BlockSeparator:
case SegmentSeparator:
case WhiteSpaceNeutral:
case OtherNeutral:
if (m_status.eor == EuropeanNumber) {
if (m_status.lastStrong != LeftToRight) {
// the numbers need to be on a higher embedding level, so let's close that run
m_direction = EuropeanNumber;
appendRun();
if (context()->dir() != LeftToRight) {
// the neutrals take the embedding direction, which is R
m_eor = m_last;
m_direction = RightToLeft;
appendRun();
}
}
} else if (m_status.eor == ArabicNumber) {
// Arabic numbers are always on a higher embedding level, so let's close that run
m_direction = ArabicNumber;
appendRun();
if (context()->dir() != LeftToRight) {
// the neutrals take the embedding direction, which is R
m_eor = m_last;
m_direction = RightToLeft;
appendRun();
}
} else if (m_status.lastStrong != LeftToRight) {
//last stuff takes embedding dir
if (context()->dir() == RightToLeft) {
m_eor = m_last;
m_direction = RightToLeft;
}
appendRun();
}
default:
break;
}
m_eor = m_current;
m_status.eor = LeftToRight;
m_status.lastStrong = LeftToRight;
m_direction = LeftToRight;
break;
case RightToLeftArabic:
case RightToLeft:
switch (m_status.last) {
case LeftToRight:
case EuropeanNumber:
case ArabicNumber:
appendRun();
case RightToLeft:
case RightToLeftArabic:
break;
case EuropeanNumberSeparator:
case EuropeanNumberTerminator:
case CommonNumberSeparator:
case BoundaryNeutral:
case BlockSeparator:
case SegmentSeparator:
case WhiteSpaceNeutral:
case OtherNeutral:
if (m_status.eor == EuropeanNumber) {
if (m_status.lastStrong == LeftToRight && context()->dir() == LeftToRight)
m_eor = m_last;
appendRun();
} else if (m_status.eor == ArabicNumber)
appendRun();
else if (m_status.lastStrong == LeftToRight) {
if (context()->dir() == LeftToRight)
m_eor = m_last;
appendRun();
}
default:
break;
}
m_eor = m_current;
m_status.eor = RightToLeft;
m_status.lastStrong = dirCurrent;
m_direction = RightToLeft;
break;
// weak types:
case EuropeanNumber:
if (m_status.lastStrong != RightToLeftArabic) {
// if last strong was AL change EN to AN
switch (m_status.last) {
case EuropeanNumber:
case LeftToRight:
break;
case RightToLeft:
case RightToLeftArabic:
case ArabicNumber:
m_eor = m_last;
appendRun();
m_direction = EuropeanNumber;
break;
case EuropeanNumberSeparator:
case CommonNumberSeparator:
if (m_status.eor == EuropeanNumber)
break;
case EuropeanNumberTerminator:
case BoundaryNeutral:
case BlockSeparator:
case SegmentSeparator:
case WhiteSpaceNeutral:
case OtherNeutral:
if (m_status.eor == EuropeanNumber) {
if (m_status.lastStrong == RightToLeft) {
// ENs on both sides behave like Rs, so the neutrals should be R.
// Terminate the EN run.
appendRun();
// Make an R run.
m_eor = m_status.last == EuropeanNumberTerminator ? m_lastBeforeET : m_last;
m_direction = RightToLeft;
appendRun();
// Begin a new EN run.
m_direction = EuropeanNumber;
}
} else if (m_status.eor == ArabicNumber) {
// Terminate the AN run.
appendRun();
if (m_status.lastStrong == RightToLeft || context()->dir() == RightToLeft) {
// Make an R run.
m_eor = m_status.last == EuropeanNumberTerminator ? m_lastBeforeET : m_last;
m_direction = RightToLeft;
appendRun();
// Begin a new EN run.
m_direction = EuropeanNumber;
}
} else if (m_status.lastStrong == RightToLeft) {
// Extend the R run to include the neutrals.
m_eor = m_status.last == EuropeanNumberTerminator ? m_lastBeforeET : m_last;
m_direction = RightToLeft;
appendRun();
// Begin a new EN run.
m_direction = EuropeanNumber;
}
default:
break;
}
m_eor = m_current;
m_status.eor = EuropeanNumber;
if (m_direction == OtherNeutral)
m_direction = LeftToRight;
break;
}
case ArabicNumber:
dirCurrent = ArabicNumber;
switch (m_status.last) {
case LeftToRight:
if (context()->dir() == LeftToRight)
appendRun();
break;
case ArabicNumber:
break;
case RightToLeft:
case RightToLeftArabic:
case EuropeanNumber:
m_eor = m_last;
appendRun();
break;
case CommonNumberSeparator:
if (m_status.eor == ArabicNumber)
break;
case EuropeanNumberSeparator:
case EuropeanNumberTerminator:
case BoundaryNeutral:
case BlockSeparator:
case SegmentSeparator:
case WhiteSpaceNeutral:
case OtherNeutral:
if (m_status.eor == ArabicNumber
|| (m_status.eor == EuropeanNumber && (m_status.lastStrong == RightToLeft || context()->dir() == RightToLeft))
|| (m_status.eor != EuropeanNumber && m_status.lastStrong == LeftToRight && context()->dir() == RightToLeft)) {
// Terminate the run before the neutrals.
appendRun();
// Begin an R run for the neutrals.
m_direction = RightToLeft;
} else if (m_direction == OtherNeutral)
m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : RightToLeft;
m_eor = m_last;
appendRun();
default:
break;
}
m_eor = m_current;
m_status.eor = ArabicNumber;
if (m_direction == OtherNeutral)
m_direction = ArabicNumber;
break;
case EuropeanNumberSeparator:
case CommonNumberSeparator:
break;
case EuropeanNumberTerminator:
if (m_status.last == EuropeanNumber) {
dirCurrent = EuropeanNumber;
m_eor = m_current;
m_status.eor = dirCurrent;
} else if (m_status.last != EuropeanNumberTerminator)
m_lastBeforeET = m_emptyRun ? m_eor : m_last;
break;
// boundary neutrals should be ignored
case BoundaryNeutral:
if (m_eor == m_last)
m_eor = m_current;
break;
// neutrals
case BlockSeparator:
// ### what do we do with newline and paragraph seperators that come to here?
break;
case SegmentSeparator:
// ### implement rule L1
break;
case WhiteSpaceNeutral:
break;
case OtherNeutral:
break;
default:
break;
}
if (pastEnd && m_eor == m_current) {
if (!m_reachedEndOfLine) {
m_eor = endOfLine;
switch (m_status.eor) {
case LeftToRight:
case RightToLeft:
case ArabicNumber:
m_direction = m_status.eor;
break;
case EuropeanNumber:
m_direction = m_status.lastStrong == LeftToRight ? LeftToRight : EuropeanNumber;
break;
default:
ASSERT(false);
}
appendRun();
}
m_current = end;
m_status = stateAtEnd.m_status;
m_sor = stateAtEnd.m_sor;
m_eor = stateAtEnd.m_eor;
m_last = stateAtEnd.m_last;
m_reachedEndOfLine = stateAtEnd.m_reachedEndOfLine;
m_lastBeforeET = stateAtEnd.m_lastBeforeET;
m_emptyRun = stateAtEnd.m_emptyRun;
m_direction = OtherNeutral;
break;
}
updateStatusLastFromCurrentDirection(dirCurrent);
m_last = m_current;
if (m_emptyRun) {
m_sor = m_current;
m_emptyRun = false;
}
increment();
if (!m_currentExplicitEmbeddingSequence.isEmpty()) {
bool committed = commitExplicitEmbedding();
if (committed && pastEnd) {
m_current = end;
m_status = stateAtEnd.m_status;
m_sor = stateAtEnd.m_sor;
m_eor = stateAtEnd.m_eor;
m_last = stateAtEnd.m_last;
m_reachedEndOfLine = stateAtEnd.m_reachedEndOfLine;
m_lastBeforeET = stateAtEnd.m_lastBeforeET;
m_emptyRun = stateAtEnd.m_emptyRun;
m_direction = OtherNeutral;
break;
}
}
if (!pastEnd && (m_current == end || m_current.atEnd())) {
if (m_emptyRun)
break;
stateAtEnd.m_status = m_status;
stateAtEnd.m_sor = m_sor;
stateAtEnd.m_eor = m_eor;
stateAtEnd.m_last = m_last;
stateAtEnd.m_reachedEndOfLine = m_reachedEndOfLine;
stateAtEnd.m_lastBeforeET = m_lastBeforeET;
stateAtEnd.m_emptyRun = m_emptyRun;
endOfLine = m_last;
pastEnd = true;
}
}
m_runs.setLogicallyLastRun(m_runs.lastRun());
reorderRunsFromLevels();
endOfLine = Iterator();
}
} // namespace WebCore
#endif // BidiResolver_h

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BinaryPropertyList_h
#define BinaryPropertyList_h
#include <CoreFoundation/CoreFoundation.h>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebCore {
// Writes a limited subset of binary property lists.
// Covers only what's needed for writing browser history as of this writing.
class BinaryPropertyListObjectStream {
public:
// Call writeBooleanTrue to write the boolean true value.
// A single shared object will be used in the serialized list.
virtual void writeBooleanTrue() = 0;
// Call writeInteger to write an integer value.
// A single shared object will be used for each integer in the serialized list.
virtual void writeInteger(int) = 0;
// Call writeString to write a string value.
// A single shared object will be used for each string in the serialized list.
virtual void writeString(const String&) = 0;
// Call writeUniqueString instead of writeString when it's unlikely the
// string will be written twice in the same property list; this saves hash
// table overhead for such strings. A separate object will be used for each
// of these strings in the serialized list.
virtual void writeUniqueString(const String&) = 0;
virtual void writeUniqueString(const char*) = 0;
// Call writeIntegerArray instead of writeArrayStart/writeArrayEnd for
// arrays entirely composed of integers. A single shared object will be used
// for each identical array in the serialized list. Warning: The integer
// pointer must remain valid until the writeBinaryPropertyList function
// returns, because these lists are put into a hash table without copying
// them -- that's OK if the client already has a Vector<int>.
virtual void writeIntegerArray(const int*, size_t) = 0;
// After calling writeArrayStart, write array elements.
// Then call writeArrayEnd, passing in the result from writeArrayStart.
// A separate object will be used for each of these arrays in the serialized list.
virtual size_t writeArrayStart() = 0;
virtual void writeArrayEnd(size_t resultFromWriteArrayStart) = 0;
// After calling writeDictionaryStart, write all keys, then all values.
// Then call writeDictionaryEnd, passing in the result from writeDictionaryStart.
// A separate object will be used for each dictionary in the serialized list.
virtual size_t writeDictionaryStart() = 0;
virtual void writeDictionaryEnd(size_t resultFromWriteDictionaryStart) = 0;
protected:
virtual ~BinaryPropertyListObjectStream() { }
};
class BinaryPropertyListWriter {
public:
// Calls writeObjects once to prepare for writing and determine how big a
// buffer is required. Then calls buffer to get the appropriately-sized
// buffer, then calls writeObjects a second time and writes the property list.
void writePropertyList();
protected:
virtual ~BinaryPropertyListWriter() { }
private:
// Called by writePropertyList.
// Must call the object stream functions for the objects to be written
// into the property list.
virtual void writeObjects(BinaryPropertyListObjectStream&) = 0;
// Called by writePropertyList.
// Returns the buffer that the writer should write into.
virtual UInt8* buffer(size_t) = 0;
friend class BinaryPropertyListPlan;
friend class BinaryPropertyListSerializer;
};
}
#endif

View File

@@ -0,0 +1,293 @@
/*
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2008-2009 Torch Mobile, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BitmapImage_h
#define BitmapImage_h
#include "Image.h"
#include "Color.h"
#include "IntSize.h"
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSImage;
#endif
#if PLATFORM(WIN)
typedef struct HBITMAP__ *HBITMAP;
#endif
namespace WebCore {
struct FrameData;
}
namespace WTF {
// FIXME: This declaration gives FrameData a default constructor that zeroes
// all its data members, even though FrameData's default constructor defined
// below does not zero all its data members. One of these must be wrong!
template<> struct VectorTraits<WebCore::FrameData> : public SimpleClassVectorTraits { };
}
namespace WebCore {
template <typename T> class Timer;
// ================================================
// FrameData Class
// ================================================
struct FrameData {
WTF_MAKE_NONCOPYABLE(FrameData);
public:
FrameData()
: m_frame(0)
, m_duration(0)
, m_haveMetadata(false)
, m_isComplete(false)
, m_hasAlpha(true)
{
}
~FrameData()
{
clear(true);
}
// Clear the cached image data on the frame, and (optionally) the metadata.
// Returns whether there was cached image data to clear.
bool clear(bool clearMetadata);
NativeImagePtr m_frame;
float m_duration;
bool m_haveMetadata : 1;
bool m_isComplete : 1;
bool m_hasAlpha : 1;
};
// =================================================
// BitmapImage Class
// =================================================
class BitmapImage : public Image {
friend class GeneratedImage;
friend class CrossfadeGeneratedImage;
friend class GeneratorGeneratedImage;
friend class GraphicsContext;
public:
static PassRefPtr<BitmapImage> create(NativeImagePtr nativeImage, ImageObserver* observer = 0)
{
return adoptRef(new BitmapImage(nativeImage, observer));
}
static PassRefPtr<BitmapImage> create(ImageObserver* observer = 0)
{
return adoptRef(new BitmapImage(observer));
}
~BitmapImage();
virtual bool isBitmapImage() const { return true; }
virtual bool hasSingleSecurityOrigin() const { return true; }
virtual IntSize size() const;
IntSize currentFrameSize() const;
virtual bool getHotSpot(IntPoint&) const;
virtual bool dataChanged(bool allDataReceived);
virtual String filenameExtension() const;
// It may look unusual that there is no start animation call as public API. This is because
// we start and stop animating lazily. Animation begins whenever someone draws the image. It will
// automatically pause once all observers no longer want to render the image anywhere.
virtual void stopAnimation();
virtual void resetAnimation();
virtual unsigned decodedSize() const { return m_decodedSize; }
#if PLATFORM(MAC)
// Accessors for native image formats.
virtual NSImage* getNSImage();
virtual CFDataRef getTIFFRepresentation();
#endif
#if USE(CG)
virtual CGImageRef getCGImageRef();
virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&);
virtual RetainPtr<CFArrayRef> getCGImageArray();
#endif
#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
static PassRefPtr<BitmapImage> create(HBITMAP);
#endif
#if PLATFORM(WIN)
virtual bool getHBITMAP(HBITMAP);
virtual bool getHBITMAPOfSize(HBITMAP, LPSIZE);
#endif
#if PLATFORM(GTK)
virtual GdkPixbuf* getGdkPixbuf();
#endif
virtual NativeImagePtr nativeImageForCurrentFrame() { return frameAtIndex(currentFrame()); }
bool frameHasAlphaAtIndex(size_t);
virtual bool currentFrameHasAlpha() { return frameHasAlphaAtIndex(currentFrame()); }
#if !ASSERT_DISABLED
virtual bool notSolidColor()
{
return size().width() != 1 || size().height() != 1 || frameCount() > 1;
}
#endif
protected:
enum RepetitionCountStatus {
Unknown, // We haven't checked the source's repetition count.
Uncertain, // We have a repetition count, but it might be wrong (some GIFs have a count after the image data, and will report "loop once" until all data has been decoded).
Certain // The repetition count is known to be correct.
};
BitmapImage(NativeImagePtr, ImageObserver* = 0);
BitmapImage(ImageObserver* = 0);
#if PLATFORM(WIN)
virtual void drawFrameMatchingSourceSize(GraphicsContext*, const FloatRect& dstRect, const IntSize& srcSize, ColorSpace styleColorSpace, CompositeOperator);
#endif
virtual void draw(GraphicsContext*, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator);
#if (OS(WINCE) && !PLATFORM(QT))
virtual void drawPattern(GraphicsContext*, const FloatRect& srcRect, const AffineTransform& patternTransform,
const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator, const FloatRect& destRect);
#endif
size_t currentFrame() const { return m_currentFrame; }
size_t frameCount();
NativeImagePtr frameAtIndex(size_t);
bool frameIsCompleteAtIndex(size_t);
float frameDurationAtIndex(size_t);
// Decodes and caches a frame. Never accessed except internally.
void cacheFrame(size_t index);
// Called to invalidate cached data. When |destroyAll| is true, we wipe out
// the entire frame buffer cache and tell the image source to destroy
// everything; this is used when e.g. we want to free some room in the image
// cache. If |destroyAll| is false, we only delete frames up to the current
// one; this is used while animating large images to keep memory footprint
// low without redecoding the whole image on every frame.
virtual void destroyDecodedData(bool destroyAll = true);
// If the image is large enough, calls destroyDecodedData() and passes
// |destroyAll| along.
void destroyDecodedDataIfNecessary(bool destroyAll);
// Generally called by destroyDecodedData(), destroys whole-image metadata
// and notifies observers that the memory footprint has (hopefully)
// decreased by |framesCleared| times the size (in bytes) of a frame.
void destroyMetadataAndNotify(int framesCleared);
// Whether or not size is available yet.
bool isSizeAvailable();
// Called after asking the source for any information that may require
// decoding part of the image (e.g., the image size). We need to report
// the partially decoded data to our observer so it has an accurate
// account of the BitmapImage's memory usage.
void didDecodeProperties() const;
// Animation.
int repetitionCount(bool imageKnownToBeComplete); // |imageKnownToBeComplete| should be set if the caller knows the entire image has been decoded.
bool shouldAnimate();
virtual void startAnimation(bool catchUpIfNecessary = true);
void advanceAnimation(Timer<BitmapImage>*);
// Function that does the real work of advancing the animation. When
// skippingFrames is true, we're in the middle of a loop trying to skip over
// a bunch of animation frames, so we should not do things like decode each
// one or notify our observers.
// Returns whether the animation was advanced.
bool internalAdvanceAnimation(bool skippingFrames);
// Handle platform-specific data
void initPlatformData();
void invalidatePlatformData();
// Checks to see if the image is a 1x1 solid color. We optimize these images and just do a fill rect instead.
// This check should happen regardless whether m_checkedForSolidColor is already set, as the frame may have
// changed.
void checkForSolidColor();
virtual bool mayFillWithSolidColor()
{
if (!m_checkedForSolidColor && frameCount() > 0) {
checkForSolidColor();
// WINCE PORT: checkForSolidColor() doesn't set m_checkedForSolidColor until
// it gets enough information to make final decision.
#if !OS(WINCE)
ASSERT(m_checkedForSolidColor);
#endif
}
return m_isSolidColor && m_currentFrame == 0;
}
virtual Color solidColor() const { return m_solidColor; }
ImageSource m_source;
mutable IntSize m_size; // The size to use for the overall image (will just be the size of the first image).
size_t m_currentFrame; // The index of the current frame of animation.
Vector<FrameData> m_frames; // An array of the cached frames of the animation. We have to ref frames to pin them in the cache.
Timer<BitmapImage>* m_frameTimer;
int m_repetitionCount; // How many total animation loops we should do. This will be cAnimationNone if this image type is incapable of animation.
RepetitionCountStatus m_repetitionCountStatus;
int m_repetitionsComplete; // How many repetitions we've finished.
double m_desiredFrameStartTime; // The system time at which we hope to see the next call to startAnimation().
#if PLATFORM(MAC)
mutable RetainPtr<NSImage> m_nsImage; // A cached NSImage of frame 0. Only built lazily if someone actually queries for one.
mutable RetainPtr<CFDataRef> m_tiffRep; // Cached TIFF rep for frame 0. Only built lazily if someone queries for one.
#endif
Color m_solidColor; // If we're a 1x1 solid color, this is the color to use to fill.
unsigned m_decodedSize; // The current size of all decoded frames.
mutable unsigned m_decodedPropertiesSize; // The size of data decoded by the source to determine image properties (e.g. size, frame count, etc).
size_t m_frameCount;
bool m_isSolidColor : 1; // Whether or not we are a 1x1 solid image.
bool m_checkedForSolidColor : 1; // Whether we've checked the frame for solid color.
bool m_animationFinished : 1; // Whether or not we've completed the entire animation.
bool m_allDataReceived : 1; // Whether or not we've received all our data.
mutable bool m_haveSize : 1; // Whether or not our |m_size| member variable has the final overall image size yet.
bool m_sizeAvailable : 1; // Whether or not we can obtain the size of the first image frame yet from ImageIO.
mutable bool m_hasUniformFrameSize : 1;
mutable bool m_haveFrameCount : 1;
};
}
#endif

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#import <Foundation/NSException.h>
NO_RETURN_DUE_TO_ASSERT void ReportBlockedObjCException(NSException *);
#define BEGIN_BLOCK_OBJC_EXCEPTIONS @try {
#define END_BLOCK_OBJC_EXCEPTIONS } @catch(NSException *localException) { ReportBlockedObjCException(localException); }

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef BorderData_h
#define BorderData_h
#include "BorderValue.h"
#include "IntRect.h"
#include "LengthSize.h"
#include "NinePieceImage.h"
namespace WebCore {
class BorderData {
friend class RenderStyle;
public:
BorderData() : m_topLeft(Length(0, Fixed), Length(0, Fixed))
, m_topRight(Length(0, Fixed), Length(0, Fixed))
, m_bottomLeft(Length(0, Fixed), Length(0, Fixed))
, m_bottomRight(Length(0, Fixed), Length(0, Fixed))
{
}
bool hasBorder() const
{
bool haveImage = m_image.hasImage();
return m_left.nonZero(!haveImage) || m_right.nonZero(!haveImage) || m_top.nonZero(!haveImage) || m_bottom.nonZero(!haveImage);
}
bool hasBorderRadius() const
{
if (!m_topLeft.width().isZero())
return true;
if (!m_topRight.width().isZero())
return true;
if (!m_bottomLeft.width().isZero())
return true;
if (!m_bottomRight.width().isZero())
return true;
return false;
}
unsigned borderLeftWidth() const
{
if (!m_image.hasImage() && (m_left.style() == BNONE || m_left.style() == BHIDDEN))
return 0;
return m_left.width();
}
unsigned borderRightWidth() const
{
if (!m_image.hasImage() && (m_right.style() == BNONE || m_right.style() == BHIDDEN))
return 0;
return m_right.width();
}
unsigned borderTopWidth() const
{
if (!m_image.hasImage() && (m_top.style() == BNONE || m_top.style() == BHIDDEN))
return 0;
return m_top.width();
}
unsigned borderBottomWidth() const
{
if (!m_image.hasImage() && (m_bottom.style() == BNONE || m_bottom.style() == BHIDDEN))
return 0;
return m_bottom.width();
}
bool operator==(const BorderData& o) const
{
return m_left == o.m_left && m_right == o.m_right && m_top == o.m_top && m_bottom == o.m_bottom && m_image == o.m_image
&& m_topLeft == o.m_topLeft && m_topRight == o.m_topRight && m_bottomLeft == o.m_bottomLeft && m_bottomRight == o.m_bottomRight;
}
bool operator!=(const BorderData& o) const
{
return !(*this == o);
}
const BorderValue& left() const { return m_left; }
const BorderValue& right() const { return m_right; }
const BorderValue& top() const { return m_top; }
const BorderValue& bottom() const { return m_bottom; }
const NinePieceImage& image() const { return m_image; }
const LengthSize& topLeft() const { return m_topLeft; }
const LengthSize& topRight() const { return m_topRight; }
const LengthSize& bottomLeft() const { return m_bottomLeft; }
const LengthSize& bottomRight() const { return m_bottomRight; }
private:
BorderValue m_left;
BorderValue m_right;
BorderValue m_top;
BorderValue m_bottom;
NinePieceImage m_image;
LengthSize m_topLeft;
LengthSize m_topRight;
LengthSize m_bottomLeft;
LengthSize m_bottomRight;
};
} // namespace WebCore
#endif // BorderData_h

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef BorderValue_h
#define BorderValue_h
#include "Color.h"
#include "RenderStyleConstants.h"
namespace WebCore {
class BorderValue {
friend class RenderStyle;
public:
BorderValue()
: m_width(3)
, m_style(BNONE)
, m_isAuto(AUTO_OFF)
{
}
bool nonZero(bool checkStyle = true) const
{
return width() && (!checkStyle || m_style != BNONE);
}
bool isTransparent() const
{
return m_color.isValid() && !m_color.alpha();
}
bool isVisible(bool checkStyle = true) const
{
return nonZero(checkStyle) && !isTransparent() && (!checkStyle || m_style != BHIDDEN);
}
bool operator==(const BorderValue& o) const
{
return m_width == o.m_width && m_style == o.m_style && m_color == o.m_color;
}
bool operator!=(const BorderValue& o) const
{
return !(*this == o);
}
const Color& color() const { return m_color; }
unsigned width() const { return m_width; }
EBorderStyle style() const { return static_cast<EBorderStyle>(m_style); }
protected:
Color m_color;
unsigned m_width : 27;
unsigned m_style : 4; // EBorderStyle
// This is only used by OutlineValue but moved here to keep the bits packed.
unsigned m_isAuto : 1; // OutlineIsAuto
};
} // namespace WebCore
#endif // BorderValue_h

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
* Copyright 2010, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Bridge_h
#define Bridge_h
#include <wtf/FastAllocBase.h>
#include <wtf/Noncopyable.h>
namespace JSC {
namespace Bindings {
class Method {
WTF_MAKE_NONCOPYABLE(Method); WTF_MAKE_FAST_ALLOCATED;
public:
Method() { }
virtual int numParameters() const = 0;
virtual ~Method() { }
};
} // namespace Bindings
} // namespace JSC
#endif

View File

@@ -0,0 +1,152 @@
/*
* Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
* Copyright 2010, The Android Open Source Project
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef BridgeJSC_h
#define BridgeJSC_h
#include "Bridge.h"
#include <runtime/JSString.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace JSC {
class ArgList;
class Identifier;
class JSGlobalObject;
class PropertyNameArray;
class RuntimeMethod;
namespace Bindings {
class Instance;
class Method;
class RootObject;
class RuntimeObject;
typedef Vector<Method*> MethodList;
class Field {
public:
virtual JSValue valueFromInstance(ExecState*, const Instance*) const = 0;
virtual void setValueToInstance(ExecState*, const Instance*, JSValue) const = 0;
virtual ~Field() { }
};
class Class {
WTF_MAKE_NONCOPYABLE(Class); WTF_MAKE_FAST_ALLOCATED;
public:
Class() { }
virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0;
virtual Field* fieldNamed(const Identifier&, Instance*) const = 0;
virtual JSValue fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
virtual ~Class() { }
};
typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject);
class Instance : public RefCounted<Instance> {
public:
Instance(PassRefPtr<RootObject>);
static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
static KJSDidExecuteFunctionPtr didExecuteFunction();
// These functions are called before and after the main entry points into
// the native implementations. They can be used to establish and cleanup
// any needed state.
void begin();
void end();
virtual Class* getClass() const = 0;
JSObject* createRuntimeObject(ExecState*);
void willInvalidateRuntimeObject();
// Returns false if the value was not set successfully.
virtual bool setValueOfUndefinedField(ExecState*, const Identifier&, JSValue) { return false; }
virtual JSValue getMethod(ExecState* exec, const Identifier& propertyName) = 0;
virtual JSValue invokeMethod(ExecState*, RuntimeMethod* method) = 0;
virtual bool supportsInvokeDefaultMethod() const { return false; }
virtual JSValue invokeDefaultMethod(ExecState*) { return jsUndefined(); }
virtual bool supportsConstruct() const { return false; }
virtual JSValue invokeConstruct(ExecState*, const ArgList&) { return JSValue(); }
virtual void getPropertyNames(ExecState*, PropertyNameArray&) { }
virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const = 0;
virtual JSValue valueOf(ExecState* exec) const = 0;
RootObject* rootObject() const;
virtual ~Instance();
virtual bool getOwnPropertySlot(JSObject*, ExecState*, const Identifier&, PropertySlot&) { return false; }
virtual bool getOwnPropertyDescriptor(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&) { return false; }
virtual void put(JSObject*, ExecState*, const Identifier&, JSValue, PutPropertySlot&) { }
protected:
virtual void virtualBegin() { }
virtual void virtualEnd() { }
virtual RuntimeObject* newRuntimeObject(ExecState*);
RefPtr<RootObject> m_rootObject;
private:
Weak<RuntimeObject> m_runtimeObject;
};
class Array {
WTF_MAKE_NONCOPYABLE(Array);
public:
Array(PassRefPtr<RootObject>);
virtual ~Array();
virtual void setValueAt(ExecState*, unsigned index, JSValue) const = 0;
virtual JSValue valueAt(ExecState*, unsigned index) const = 0;
virtual unsigned int getLength() const = 0;
protected:
RefPtr<RootObject> m_rootObject;
};
const char* signatureForParameters(const ArgList&);
typedef HashMap<RefPtr<StringImpl>, MethodList*> MethodListMap;
typedef HashMap<RefPtr<StringImpl>, Method*> MethodMap;
typedef HashMap<RefPtr<StringImpl>, Field*> FieldMap;
} // namespace Bindings
} // namespace JSC
#endif

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2004 Zack Rusin <zack@kde.org>
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef CSSComputedStyleDeclaration_h
#define CSSComputedStyleDeclaration_h
#include "CSSStyleDeclaration.h"
#include "RenderStyleConstants.h"
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class Color;
class CSSMutableStyleDeclaration;
class CSSPrimitiveValue;
class CSSValueList;
class CSSValuePool;
class Node;
class RenderStyle;
class ShadowData;
class SVGPaint;
#if ENABLE(CSS_SHADERS)
class CustomFilterNumberParameter;
class CustomFilterParameter;
#endif
enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true };
class CSSComputedStyleDeclaration : public CSSStyleDeclaration {
public:
friend PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node>, bool allowVisitedStyle, const String& pseudoElementName);
virtual ~CSSComputedStyleDeclaration();
virtual String cssText() const;
virtual unsigned virtualLength() const;
virtual String item(unsigned index) const;
virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
virtual String getPropertyValue(int propertyID) const;
virtual bool getPropertyPriority(int propertyID) const;
virtual int getPropertyShorthand(int /*propertyID*/) const { return -1; }
virtual bool isPropertyImplicit(int /*propertyID*/) const { return false; }
virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
bool useFixedFontDefaultSize() const;
#if ENABLE(SVG)
PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
#endif
protected:
virtual bool cssPropertyMatches(const CSSProperty*) const;
private:
CSSComputedStyleDeclaration(PassRefPtr<Node>, bool allowVisitedStyle, const String&);
virtual void setCssText(const String&, ExceptionCode&);
virtual String removeProperty(int propertyID, ExceptionCode&);
virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int, RenderStyle*) const;
PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const;
#if ENABLE(SVG)
PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const;
#endif
#if ENABLE(CSS_SHADERS)
PassRefPtr<CSSValue> valueForCustomFilterNumberParameter(const CustomFilterNumberParameter*) const;
PassRefPtr<CSSValue> valueForCustomFilterParameter(const CustomFilterParameter*) const;
#endif
#if ENABLE(CSS_FILTERS)
PassRefPtr<CSSValue> valueForFilter(RenderStyle*) const;
#endif
PassRefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const int* properties, size_t) const;
PassRefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const int* properties) const;
RefPtr<Node> m_node;
PseudoId m_pseudoElementSpecifier;
bool m_allowVisitedStyle;
};
inline PassRefPtr<CSSComputedStyleDeclaration> computedStyle(PassRefPtr<Node> node, bool allowVisitedStyle = false, const String& pseudoElementName = String())
{
return adoptRef(new CSSComputedStyleDeclaration(node, allowVisitedStyle, pseudoElementName));
}
} // namespace WebCore
#endif // CSSComputedStyleDeclaration_h

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2006 Rob Buis <buis@kde.org>
* Copyright (C) 2008 Apple Inc. All right reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSCursorImageValue_h
#define CSSCursorImageValue_h
#include "CSSImageValue.h"
#include "IntPoint.h"
#include <wtf/HashSet.h>
namespace WebCore {
class Element;
class SVGElement;
class CSSCursorImageValue : public CSSImageValue {
public:
static PassRefPtr<CSSCursorImageValue> create(const String& url, const IntPoint& hotSpot)
{
return adoptRef(new CSSCursorImageValue(url, hotSpot));
}
~CSSCursorImageValue();
IntPoint hotSpot() const { return m_hotSpot; }
bool updateIfSVGCursorIsUsed(Element*);
StyleCachedImage* cachedImage(CachedResourceLoader*);
#if ENABLE(SVG)
void removeReferencedElement(SVGElement*);
#endif
private:
CSSCursorImageValue(const String& url, const IntPoint& hotSpot);
IntPoint m_hotSpot;
#if ENABLE(SVG)
HashSet<SVGElement*> m_referencedElements;
#endif
};
} // namespace WebCore
#endif // CSSCursorImageValue_h

View File

@@ -0,0 +1,36 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CSSHelper_h
#define CSSHelper_h
#include <wtf/Forward.h>
namespace WebCore {
// We always assume 96 CSS pixels in a CSS inch. This is the cold hard truth of the Web.
// At high DPI, we may scale a CSS pixel, but the ratio of the CSS pixel to the so-called
// "absolute" CSS length units like inch and pt is always fixed and never changes.
const float cssPixelsPerInch = 96;
} // namespace WebCore
#endif // CSSHelper_h

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CSSImageGeneratorValue_h
#define CSSImageGeneratorValue_h
#include "CSSValue.h"
#include "IntSizeHash.h"
#include <wtf/HashCountedSet.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CachedResourceLoader;
class Image;
class RenderObject;
struct SizeAndCount {
SizeAndCount(IntSize newSize = IntSize(), int newCount = 0)
: size(newSize)
, count(newCount)
{
}
IntSize size;
int count;
};
typedef HashMap<const RenderObject*, SizeAndCount> RenderObjectSizeCountMap;
class CSSImageGeneratorValue : public CSSValue {
public:
~CSSImageGeneratorValue();
void addClient(RenderObject*, const IntSize&);
void removeClient(RenderObject*);
PassRefPtr<Image> image(RenderObject*, const IntSize&);
bool isFixedSize() const;
IntSize fixedSize(const RenderObject*);
bool isPending() const;
void loadSubimages(CachedResourceLoader*);
protected:
CSSImageGeneratorValue(ClassType);
Image* getImage(RenderObject*, const IntSize&);
void putImage(const IntSize&, PassRefPtr<Image>);
const RenderObjectSizeCountMap& clients() const { return m_clients; }
HashCountedSet<IntSize> m_sizes; // A count of how many times a given image size is in use.
RenderObjectSizeCountMap m_clients; // A map from RenderObjects (with entry count) to image sizes.
HashMap<IntSize, RefPtr<Image> > m_images; // A cache of Image objects by image size.
};
} // namespace WebCore
#endif // CSSImageGeneratorValue_h

View File

@@ -0,0 +1,62 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSImageValue_h
#define CSSImageValue_h
#include "CSSPrimitiveValue.h"
#include <wtf/RefPtr.h>
namespace WebCore {
class CachedResourceLoader;
class StyleCachedImage;
class StyleImage;
class CSSImageValue : public CSSPrimitiveValue {
public:
static PassRefPtr<CSSImageValue> create() { return adoptRef(new CSSImageValue); }
static PassRefPtr<CSSImageValue> create(const String& url) { return adoptRef(new CSSImageValue(url)); }
static PassRefPtr<CSSImageValue> create(const String& url, StyleImage* image) { return adoptRef(new CSSImageValue(url, image)); }
~CSSImageValue();
StyleCachedImage* cachedImage(CachedResourceLoader*);
// Returns a StyleCachedImage if the image is cached already, otherwise a StylePendingImage.
StyleImage* cachedOrPendingImage();
protected:
CSSImageValue(ClassType, const String& url);
StyleCachedImage* cachedImage(CachedResourceLoader*, const String& url);
String cachedImageURL();
void clearCachedImage();
private:
CSSImageValue();
explicit CSSImageValue(const String& url);
explicit CSSImageValue(const String& url, StyleImage*);
RefPtr<StyleImage> m_image;
bool m_accessedImage;
};
} // namespace WebCore
#endif // CSSImageValue_h

View File

@@ -0,0 +1,88 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2002, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSImportRule_h
#define CSSImportRule_h
#include "CSSRule.h"
#include "CachedResourceHandle.h"
#include "CachedStyleSheetClient.h"
#include "MediaList.h"
#include "PlatformString.h"
namespace WebCore {
class CachedCSSStyleSheet;
class MediaList;
class CSSImportRule : public CSSRule {
public:
static PassRefPtr<CSSImportRule> create(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList> media)
{
return adoptRef(new CSSImportRule(parent, href, media));
}
~CSSImportRule();
String href() const { return m_strHref; }
MediaList* media() const { return m_lstMedia.get(); }
CSSStyleSheet* styleSheet() const { return m_styleSheet.get(); }
String cssText() const;
// Not part of the CSSOM
bool isLoading() const;
void addSubresourceStyleURLs(ListHashSet<KURL>& urls);
void requestStyleSheet();
private:
// NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it
// to avoid adding a vptr to CSSImportRule.
class ImportedStyleSheetClient : public CachedStyleSheetClient {
public:
ImportedStyleSheetClient(CSSImportRule* ownerRule) : m_ownerRule(ownerRule) { }
virtual ~ImportedStyleSheetClient() { }
virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
{
m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
}
private:
CSSImportRule* m_ownerRule;
};
void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CachedCSSStyleSheet*);
friend class ImportedStyleSheetClient;
CSSImportRule(CSSStyleSheet* parent, const String& href, PassRefPtr<MediaList>);
ImportedStyleSheetClient m_styleSheetClient;
String m_strHref;
RefPtr<MediaList> m_lstMedia;
RefPtr<CSSStyleSheet> m_styleSheet;
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
bool m_loading;
};
} // namespace WebCore
#endif // CSSImportRule_h

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CSSLineBoxContainValue_h
#define CSSLineBoxContainValue_h
#include "CSSValue.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CSSPrimitiveValue;
enum LineBoxContainFlags { LineBoxContainNone = 0x0, LineBoxContainBlock = 0x1, LineBoxContainInline = 0x2, LineBoxContainFont = 0x4, LineBoxContainGlyphs = 0x8,
LineBoxContainReplaced = 0x10, LineBoxContainInlineBox = 0x20 };
typedef unsigned LineBoxContain;
// Used for text-CSSLineBoxContain and box-CSSLineBoxContain
class CSSLineBoxContainValue : public CSSValue {
public:
static PassRefPtr<CSSLineBoxContainValue> create(LineBoxContain value)
{
return adoptRef(new CSSLineBoxContainValue(value));
}
String customCssText() const;
LineBoxContain value() const { return m_value; }
private:
LineBoxContain m_value;
private:
CSSLineBoxContainValue(LineBoxContain);
};
} // namespace
#endif

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Peter Kelly (pmk@post.com)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CSSMappedAttributeDeclaration_h
#define CSSMappedAttributeDeclaration_h
#include "CSSMutableStyleDeclaration.h"
#include "MappedAttributeEntry.h"
#include "QualifiedName.h"
namespace WebCore {
class StyledElement;
class CSSMappedAttributeDeclaration : public CSSMutableStyleDeclaration {
public:
static PassRefPtr<CSSMappedAttributeDeclaration> create()
{
return adoptRef(new CSSMappedAttributeDeclaration);
}
virtual ~CSSMappedAttributeDeclaration();
void setMappedState(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& val)
{
m_entryType = type;
m_attrName = name;
m_attrValue = val;
}
void setMappedProperty(StyledElement*, int propertyId, int value);
void setMappedProperty(StyledElement*, int propertyId, const String& value);
void setMappedImageProperty(StyledElement*, int propertyId, const String& url);
// NOTE: setMappedLengthProperty() treats integers as pixels! (Needed for conversion of HTML attributes.)
void setMappedLengthProperty(StyledElement*, int propertyId, const String& value);
void removeMappedProperty(StyledElement*, int propertyId);
private:
CSSMappedAttributeDeclaration()
: CSSMutableStyleDeclaration()
, m_entryType(eNone)
, m_attrName(anyQName())
{
}
void setNeedsStyleRecalc(StyledElement*);
MappedAttributeEntry m_entryType;
QualifiedName m_attrName;
AtomicString m_attrValue;
};
} //namespace
#endif

View File

@@ -0,0 +1,234 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSMutableStyleDeclaration_h
#define CSSMutableStyleDeclaration_h
#include "CSSStyleDeclaration.h"
#include "CSSPrimitiveValue.h"
#include "CSSProperty.h"
#include "KURLHash.h"
#include "PlatformString.h"
#include <wtf/ListHashSet.h>
#include <wtf/Vector.h>
namespace WebCore {
class StyledElement;
class CSSMutableStyleDeclarationConstIterator {
public:
CSSMutableStyleDeclarationConstIterator(const CSSMutableStyleDeclaration* decl, CSSProperty* current);
CSSMutableStyleDeclarationConstIterator(const CSSMutableStyleDeclarationConstIterator& o);
~CSSMutableStyleDeclarationConstIterator();
const CSSProperty& operator*() const { return *m_current; }
const CSSProperty* operator->() const { return m_current; }
bool operator!=(const CSSMutableStyleDeclarationConstIterator& o) { ASSERT(m_decl == o.m_decl); return m_current != o.m_current; }
bool operator==(const CSSMutableStyleDeclarationConstIterator& o) { ASSERT(m_decl == o.m_decl); return m_current == o.m_current; }
CSSMutableStyleDeclarationConstIterator& operator=(const CSSMutableStyleDeclarationConstIterator& o);
CSSMutableStyleDeclarationConstIterator& operator++();
CSSMutableStyleDeclarationConstIterator& operator--();
private:
const CSSMutableStyleDeclaration* m_decl;
CSSProperty* m_current;
};
class CSSMutableStyleDeclaration : public CSSStyleDeclaration {
public:
virtual ~CSSMutableStyleDeclaration();
static PassRefPtr<CSSMutableStyleDeclaration> create()
{
return adoptRef(new CSSMutableStyleDeclaration);
}
static PassRefPtr<CSSMutableStyleDeclaration> create(CSSRule* parentRule)
{
return adoptRef(new CSSMutableStyleDeclaration(parentRule));
}
static PassRefPtr<CSSMutableStyleDeclaration> create(CSSRule* parentRule, const CSSProperty* const* properties, int numProperties)
{
return adoptRef(new CSSMutableStyleDeclaration(parentRule, properties, numProperties));
}
static PassRefPtr<CSSMutableStyleDeclaration> create(const Vector<CSSProperty>& properties)
{
return adoptRef(new CSSMutableStyleDeclaration(0, properties));
}
static PassRefPtr<CSSMutableStyleDeclaration> createInline(StyledElement* element)
{
return adoptRef(new CSSMutableStyleDeclaration(element, true));
}
static PassRefPtr<CSSMutableStyleDeclaration> createForSVGFontFaceElement(StyledElement* element)
{
return adoptRef(new CSSMutableStyleDeclaration(element, false));
}
// Used by StyledElement::copyNonAttributeProperties().
void copyPropertiesFrom(const CSSMutableStyleDeclaration&);
typedef CSSMutableStyleDeclarationConstIterator const_iterator;
const_iterator begin() { return const_iterator(this, m_properties.begin()); }
const_iterator end() { return const_iterator(this, m_properties.end()); }
virtual String cssText() const;
virtual void setCssText(const String&, ExceptionCode&);
virtual unsigned virtualLength() const;
unsigned length() const { return m_properties.size(); }
virtual String item(unsigned index) const;
virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const;
virtual String getPropertyValue(int propertyID) const;
virtual bool getPropertyPriority(int propertyID) const;
virtual int getPropertyShorthand(int propertyID) const;
virtual bool isPropertyImplicit(int propertyID) const;
virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&);
virtual String removeProperty(int propertyID, ExceptionCode&);
virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const;
using CSSStyleDeclaration::getPropertyCSSValue;
bool setProperty(int propertyID, int value, bool important = false) { return setProperty(propertyID, value, important, true); }
bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes unit, bool important = false) { return setProperty(propertyId, value, unit, important, true); }
bool setProperty(int propertyID, const String& value, bool important = false) { return setProperty(propertyID, value, important, true); }
void removeProperty(int propertyID) { removeProperty(propertyID, true, false); }
// The following parses an entire new style declaration.
void parseDeclaration(const String& styleDeclaration);
// Besides adding the properties, this also removes any existing properties with these IDs.
// It does no notification since it's called by the parser.
void addParsedProperties(const CSSProperty* const *, int numProperties);
// This does no change notifications since it's only called by createMarkup.
void addParsedProperty(const CSSProperty&);
PassRefPtr<CSSMutableStyleDeclaration> copyBlockProperties() const;
void removeBlockProperties();
void removePropertiesInSet(const int* set, unsigned length) { removePropertiesInSet(set, length, true); }
void merge(const CSSMutableStyleDeclaration*, bool argOverridesOnConflict = true);
void setStrictParsing(bool b) { m_strictParsing = b; }
bool useStrictParsing() const { return m_strictParsing; }
void addSubresourceStyleURLs(ListHashSet<KURL>&);
protected:
CSSMutableStyleDeclaration();
void setPropertyInternal(const CSSProperty&, CSSProperty* slot = 0);
String removeProperty(int propertyID, bool notifyChanged, bool returnText);
private:
CSSMutableStyleDeclaration(CSSRule* parentRule);
CSSMutableStyleDeclaration(CSSRule* parentRule, const Vector<CSSProperty>&);
CSSMutableStyleDeclaration(CSSRule* parentRule, const CSSProperty* const *, int numProperties);
CSSMutableStyleDeclaration(StyledElement*, bool isInline);
virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
void setNeedsStyleRecalc();
String getShorthandValue(const int* properties, size_t) const;
String getCommonValue(const int* properties, size_t) const;
String getLayeredShorthandValue(const int* properties, size_t) const;
String get4Values(const int* properties) const;
String borderSpacingValue(const int properties[2]) const;
String fontValue() const;
bool appendFontLonghandValueIfExplicit(int propertyID, StringBuilder& result) const;
template<size_t size> String getShorthandValue(const int (&properties)[size]) const { return getShorthandValue(properties, size); }
template<size_t size> String getCommonValue(const int (&properties)[size]) const { return getCommonValue(properties, size); }
template<size_t size> String getLayeredShorthandValue(const int (&properties)[size]) const { return getLayeredShorthandValue(properties, size); }
bool setProperty(int propertyID, int value, bool important, bool notifyChanged);
bool setProperty(int propertyId, double value, CSSPrimitiveValue::UnitTypes, bool important, bool notifyChanged);
bool setProperty(int propertyID, const String& value, bool important, bool notifyChanged);
bool removeShorthandProperty(int propertyID, bool notifyChanged);
bool removePropertiesInSet(const int* set, unsigned length, bool notifyChanged);
Vector<CSSProperty>::const_iterator findPropertyWithId(int propertyId) const;
Vector<CSSProperty>::iterator findPropertyWithId(int propertyId);
Vector<CSSProperty, 4> m_properties;
friend class CSSMutableStyleDeclarationConstIterator;
};
inline CSSMutableStyleDeclarationConstIterator::CSSMutableStyleDeclarationConstIterator(const CSSMutableStyleDeclaration* decl, CSSProperty* current)
: m_decl(decl)
, m_current(current)
{
#ifndef NDEBUG
const_cast<CSSMutableStyleDeclaration*>(m_decl)->m_iteratorCount++;
#endif
}
inline CSSMutableStyleDeclarationConstIterator::CSSMutableStyleDeclarationConstIterator(const CSSMutableStyleDeclarationConstIterator& o)
: m_decl(o.m_decl)
, m_current(o.m_current)
{
#ifndef NDEBUG
const_cast<CSSMutableStyleDeclaration*>(m_decl)->m_iteratorCount++;
#endif
}
inline CSSMutableStyleDeclarationConstIterator::~CSSMutableStyleDeclarationConstIterator()
{
#ifndef NDEBUG
const_cast<CSSMutableStyleDeclaration*>(m_decl)->m_iteratorCount--;
#endif
}
inline CSSMutableStyleDeclarationConstIterator& CSSMutableStyleDeclarationConstIterator::operator=(const CSSMutableStyleDeclarationConstIterator& o)
{
m_decl = o.m_decl;
m_current = o.m_current;
#ifndef NDEBUG
const_cast<CSSMutableStyleDeclaration*>(m_decl)->m_iteratorCount++;
#endif
return *this;
}
inline CSSMutableStyleDeclarationConstIterator& CSSMutableStyleDeclarationConstIterator::operator++()
{
ASSERT(m_current != const_cast<CSSMutableStyleDeclaration*>(m_decl)->m_properties.end());
++m_current;
return *this;
}
inline CSSMutableStyleDeclarationConstIterator& CSSMutableStyleDeclarationConstIterator::operator--()
{
--m_current;
return *this;
}
} // namespace WebCore
#endif // CSSMutableStyleDeclaration_h

View File

@@ -0,0 +1,146 @@
/*
* Copyright (C) 2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSParserValues_h
#define CSSParserValues_h
#include "CSSSelector.h"
#include "CSSValueList.h"
#include <wtf/text/AtomicString.h>
namespace WebCore {
class CSSValue;
class QualifiedName;
struct CSSParserString {
UChar* characters;
int length;
void lower();
operator String() const { return String(characters, length); }
operator AtomicString() const { return AtomicString(characters, length); }
};
struct CSSParserFunction;
struct CSSParserValue {
int id;
bool isInt;
union {
double fValue;
int iValue;
CSSParserString string;
CSSParserFunction* function;
};
enum {
Operator = 0x100000,
Function = 0x100001,
Q_EMS = 0x100002
};
int unit;
PassRefPtr<CSSValue> createCSSValue();
};
class CSSParserValueList {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSParserValueList()
: m_current(0)
{
}
~CSSParserValueList();
void addValue(const CSSParserValue&);
void insertValueAt(unsigned, const CSSParserValue&);
void deleteValueAt(unsigned);
void extend(CSSParserValueList&);
unsigned size() const { return m_values.size(); }
CSSParserValue* current() { return m_current < m_values.size() ? &m_values[m_current] : 0; }
CSSParserValue* next() { ++m_current; return current(); }
CSSParserValue* previous()
{
if (!m_current)
return 0;
--m_current;
return current();
}
CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
void clear() { m_values.clear(); }
private:
unsigned m_current;
Vector<CSSParserValue, 4> m_values;
};
struct CSSParserFunction {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSParserString name;
OwnPtr<CSSParserValueList> args;
};
class CSSParserSelector {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSParserSelector();
~CSSParserSelector();
PassOwnPtr<CSSSelector> releaseSelector() { return m_selector.release(); }
void setTag(const QualifiedName& value) { m_selector->setTag(value); }
void setValue(const AtomicString& value) { m_selector->setValue(value); }
void setAttribute(const QualifiedName& value) { m_selector->setAttribute(value); }
void setArgument(const AtomicString& value) { m_selector->setArgument(value); }
void setMatch(CSSSelector::Match value) { m_selector->m_match = value; }
void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; }
void setForPage() { m_selector->setForPage(); }
void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector);
CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType(); }
bool isUnknownPseudoElement() const { return m_selector->isUnknownPseudoElement(); }
bool isSimple() const { return !m_tagHistory && m_selector->isSimple(); }
bool hasShadowDescendant() const;
CSSParserSelector* tagHistory() const { return m_tagHistory.get(); }
void setTagHistory(PassOwnPtr<CSSParserSelector> selector) { m_tagHistory = selector; }
void insertTagHistory(CSSSelector::Relation before, PassOwnPtr<CSSParserSelector>, CSSSelector::Relation after);
void appendTagHistory(CSSSelector::Relation, PassOwnPtr<CSSParserSelector>);
private:
OwnPtr<CSSSelector> m_selector;
OwnPtr<CSSParserSelector> m_tagHistory;
};
inline bool CSSParserSelector::hasShadowDescendant() const
{
return m_selector->relation() == CSSSelector::ShadowDescendant;
}
}
#endif

View File

@@ -0,0 +1,325 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSPrimitiveValue_h
#define CSSPrimitiveValue_h
#include "CSSValue.h"
#include "Color.h"
#include <wtf/Forward.h>
#include <wtf/MathExtras.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class Counter;
class DashboardRegion;
class Pair;
class Quad;
class RGBColor;
class Rect;
class RenderStyle;
class CSSWrapShape;
struct Length;
template<typename T, T max, T min> inline T roundForImpreciseConversion(double value)
{
// Dimension calculations are imprecise, often resulting in values of e.g.
// 44.99998. We need to go ahead and round if we're really close to the
// next integer value.
value += (value < 0) ? -0.01 : +0.01;
return ((value > max) || (value < min)) ? 0 : static_cast<T>(value);
}
class CSSPrimitiveValue : public CSSValue {
public:
enum UnitTypes {
CSS_UNKNOWN = 0,
CSS_NUMBER = 1,
CSS_PERCENTAGE = 2,
CSS_EMS = 3,
CSS_EXS = 4,
CSS_PX = 5,
CSS_CM = 6,
CSS_MM = 7,
CSS_IN = 8,
CSS_PT = 9,
CSS_PC = 10,
CSS_DEG = 11,
CSS_RAD = 12,
CSS_GRAD = 13,
CSS_MS = 14,
CSS_S = 15,
CSS_HZ = 16,
CSS_KHZ = 17,
CSS_DIMENSION = 18,
CSS_STRING = 19,
CSS_URI = 20,
CSS_IDENT = 21,
CSS_ATTR = 22,
CSS_COUNTER = 23,
CSS_RECT = 24,
CSS_RGBCOLOR = 25,
CSS_PAIR = 100, // We envision this being exposed as a means of getting computed style values for pairs (border-spacing/radius, background-position, etc.)
CSS_DASHBOARD_REGION = 101, // FIXME: Dashboard region should not be a primitive value.
CSS_UNICODE_RANGE = 102,
// These next types are just used internally to allow us to translate back and forth from CSSPrimitiveValues to CSSParserValues.
CSS_PARSER_OPERATOR = 103,
CSS_PARSER_INTEGER = 104,
CSS_PARSER_HEXCOLOR = 105,
// This is used internally for unknown identifiers
CSS_PARSER_IDENTIFIER = 106,
// These are from CSS3 Values and Units, but that isn't a finished standard yet
CSS_TURN = 107,
CSS_REMS = 108,
// This is used internally for counter names (as opposed to counter values)
CSS_COUNTER_NAME = 109,
// This is used by the CSS Exclusions draft
CSS_SHAPE = 110,
// Used by border images.
CSS_QUAD = 111
};
// This enum follows the CSSParser::Units enum augmented with UNIT_FREQUENCY for frequencies.
enum UnitCategory {
UNumber,
UPercent,
ULength,
UAngle,
UTime,
UFrequency,
UOther
};
bool isAngle() const
{
return m_primitiveUnitType == CSS_DEG
|| m_primitiveUnitType == CSS_RAD
|| m_primitiveUnitType == CSS_GRAD
|| m_primitiveUnitType == CSS_TURN;
}
bool isAttr() const { return m_primitiveUnitType == CSS_ATTR; }
bool isCounter() const { return m_primitiveUnitType == CSS_COUNTER; }
bool isFontIndependentLength() const { return m_primitiveUnitType >= CSS_PX && m_primitiveUnitType <= CSS_PC; }
bool isFontRelativeLength() const
{
return m_primitiveUnitType == CSS_EMS || m_primitiveUnitType == CSS_EXS || m_primitiveUnitType == CSS_REMS;
}
bool isIdent() const { return m_primitiveUnitType == CSS_IDENT; }
bool isLength() const
{
return (m_primitiveUnitType >= CSS_EMS && m_primitiveUnitType <= CSS_PC)
|| m_primitiveUnitType == CSS_REMS;
}
bool isNumber() const { return m_primitiveUnitType == CSS_NUMBER; }
bool isPercentage() const { return m_primitiveUnitType == CSS_PERCENTAGE; }
bool isPx() const { return m_primitiveUnitType == CSS_PX; }
bool isRect() const { return m_primitiveUnitType == CSS_RECT; }
bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; }
bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; }
bool isString() const { return m_primitiveUnitType == CSS_STRING; }
bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnitType == CSS_MS; }
bool isURI() const { return m_primitiveUnitType == CSS_URI; }
static PassRefPtr<CSSPrimitiveValue> createIdentifier(int identifier) { return adoptRef(new CSSPrimitiveValue(identifier)); }
static PassRefPtr<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(new CSSPrimitiveValue(rgbValue)); }
static PassRefPtr<CSSPrimitiveValue> create(double value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); }
static PassRefPtr<CSSPrimitiveValue> create(const String& value, UnitTypes type) { return adoptRef(new CSSPrimitiveValue(value, type)); }
template<typename T> static PassRefPtr<CSSPrimitiveValue> create(T value)
{
return adoptRef(new CSSPrimitiveValue(value));
}
// This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em.
// When the quirky value is used, if you're in quirks mode, the margin will collapse away
// inside a table cell.
static PassRefPtr<CSSPrimitiveValue> createAllowingMarginQuirk(double value, UnitTypes type)
{
CSSPrimitiveValue* quirkValue = new CSSPrimitiveValue(value, type);
quirkValue->m_isQuirkValue = true;
return adoptRef(quirkValue);
}
~CSSPrimitiveValue();
void cleanup();
unsigned short primitiveType() const { return m_primitiveUnitType; }
double computeDegrees();
enum TimeUnit { Seconds, Milliseconds };
template <typename T, TimeUnit timeUnit> T computeTime()
{
if (timeUnit == Seconds && m_primitiveUnitType == CSS_S)
return getValue<T>();
if (timeUnit == Seconds && m_primitiveUnitType == CSS_MS)
return getValue<T>() / 1000;
if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_MS)
return getValue<T>();
if (timeUnit == Milliseconds && m_primitiveUnitType == CSS_S)
return getValue<T>() * 1000;
ASSERT_NOT_REACHED();
return 0;
}
/*
* computes a length in pixels out of the given CSSValue. Need the RenderStyle to get
* the fontinfo in case val is defined in em or ex.
*
* The metrics have to be a bit different for screen and printer output.
* For screen output we assume 1 inch == 72 px, for printer we assume 300 dpi
*
* this is screen/printer dependent, so we probably need a config option for this,
* and some tool to calibrate.
*/
template<typename T> T computeLength(RenderStyle* currStyle, RenderStyle* rootStyle, float multiplier = 1.0f, bool computingFontSize = false);
// Converts to a Length, mapping various unit types appropriately.
template<int> Length convertToLength(RenderStyle* currStyle, RenderStyle* rootStyle, double multiplier = 1.0, bool computingFontSize = false);
// use with care!!!
void setPrimitiveType(unsigned short type) { m_primitiveUnitType = type; }
double getDoubleValue(unsigned short unitType, ExceptionCode&) const;
double getDoubleValue(unsigned short unitType) const;
double getDoubleValue() const { return m_value.num; }
void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&);
float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return getValue<float>(unitType, ec); }
float getFloatValue(unsigned short unitType) const { return getValue<float>(unitType); }
float getFloatValue() const { return getValue<float>(); }
int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return getValue<int>(unitType, ec); }
int getIntValue(unsigned short unitType) const { return getValue<int>(unitType); }
int getIntValue() const { return getValue<int>(); }
template<typename T> inline T getValue(unsigned short unitType, ExceptionCode& ec) const { return clampTo<T>(getDoubleValue(unitType, ec)); }
template<typename T> inline T getValue(unsigned short unitType) const { return clampTo<T>(getDoubleValue(unitType)); }
template<typename T> inline T getValue() const { return clampTo<T>(m_value.num); }
void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&);
String getStringValue(ExceptionCode&) const;
String getStringValue() const;
Counter* getCounterValue(ExceptionCode&) const;
Counter* getCounterValue() const { return m_primitiveUnitType != CSS_COUNTER ? 0 : m_value.counter; }
Rect* getRectValue(ExceptionCode&) const;
Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? 0 : m_value.rect; }
Quad* getQuadValue(ExceptionCode&) const;
Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0 : m_value.quad; }
PassRefPtr<RGBColor> getRGBColorValue(ExceptionCode&) const;
RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; }
Pair* getPairValue(ExceptionCode&) const;
Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_value.pair; }
DashboardRegion* getDashboardRegionValue() const { return m_primitiveUnitType != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
CSSWrapShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; }
int getIdent() const { return m_primitiveUnitType == CSS_IDENT ? m_value.ident : 0; }
template<typename T> inline operator T() const; // Defined in CSSPrimitiveValueMappings.h
String customCssText() const;
bool isQuirkValue() { return m_isQuirkValue; }
void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
protected:
CSSPrimitiveValue(ClassType, int ident);
CSSPrimitiveValue(ClassType, const String&, UnitTypes);
private:
CSSPrimitiveValue();
// FIXME: int vs. unsigned overloading is too subtle to distinguish the color and identifier cases.
CSSPrimitiveValue(int ident);
CSSPrimitiveValue(unsigned color); // RGB value
CSSPrimitiveValue(const Length&);
CSSPrimitiveValue(const String&, UnitTypes);
CSSPrimitiveValue(double, UnitTypes);
template<typename T> CSSPrimitiveValue(T); // Defined in CSSPrimitiveValueMappings.h
template<typename T> CSSPrimitiveValue(T* val)
: CSSValue(PrimitiveClass)
{
init(PassRefPtr<T>(val));
}
template<typename T> CSSPrimitiveValue(PassRefPtr<T> val)
: CSSValue(PrimitiveClass)
{
init(val);
}
static void create(int); // compile-time guard
static void create(unsigned); // compile-time guard
template<typename T> operator T*(); // compile-time guard
static PassRefPtr<CSSPrimitiveValue> createUncachedIdentifier(int identifier);
static PassRefPtr<CSSPrimitiveValue> createUncachedColor(unsigned rgbValue);
static PassRefPtr<CSSPrimitiveValue> createUncached(double value, UnitTypes type);
static UnitTypes canonicalUnitTypeForCategory(UnitCategory category);
void init(PassRefPtr<Counter>);
void init(PassRefPtr<Rect>);
void init(PassRefPtr<Pair>);
void init(PassRefPtr<Quad>);
void init(PassRefPtr<DashboardRegion>); // FIXME: Dashboard region should not be a primitive value.
void init(PassRefPtr<CSSWrapShape>);
bool getDoubleValueInternal(UnitTypes targetUnitType, double* result) const;
double computeLengthDouble(RenderStyle* currentStyle, RenderStyle* rootStyle, float multiplier, bool computingFontSize);
union {
int ident;
double num;
StringImpl* string;
Counter* counter;
Rect* rect;
Quad* quad;
unsigned rgbcolor;
Pair* pair;
DashboardRegion* region;
CSSWrapShape* shape;
} m_value;
};
} // namespace WebCore
#endif // CSSPrimitiveValue_h

View File

@@ -0,0 +1,76 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSProperty_h
#define CSSProperty_h
#include "CSSValue.h"
#include "RenderStyleConstants.h"
#include "TextDirection.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CSSProperty {
WTF_MAKE_FAST_ALLOCATED;
public:
CSSProperty(unsigned propID, PassRefPtr<CSSValue> value, bool important = false, int shorthandID = 0, bool implicit = false)
: m_id(propID)
, m_shorthandID(shorthandID)
, m_important(important)
, m_implicit(implicit)
, m_inherited(isInheritedProperty(propID))
, m_value(value)
{
}
int id() const { return m_id; }
int shorthandID() const { return m_shorthandID; }
bool isImportant() const { return m_important; }
bool isImplicit() const { return m_implicit; }
bool isInherited() const { return m_inherited; }
CSSValue* value() const { return m_value.get(); }
String cssText() const;
static int resolveDirectionAwareProperty(int propertyID, TextDirection, WritingMode);
static bool isInheritedProperty(unsigned propertyID);
// Make sure the following fits in 4 bytes. Really.
unsigned m_id : 14;
unsigned m_shorthandID : 14; // If this property was set as part of a shorthand, gives the shorthand.
bool m_important : 1;
bool m_implicit : 1; // Whether or not the property was set implicitly as the result of a shorthand.
bool m_inherited : 1;
RefPtr<CSSValue> m_value;
};
} // namespace WebCore
namespace WTF {
// Properties in Vector can be initialized with memset and moved using memcpy.
template<> struct VectorTraits<WebCore::CSSProperty> : SimpleClassVectorTraits { };
}
#endif // CSSProperty_h

View File

@@ -0,0 +1,772 @@
/* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
#ifndef CSSPropertyNames_h
#define CSSPropertyNames_h
#include <string.h>
namespace WTF {
class String;
}
namespace WebCore {
enum CSSPropertyID {
CSSPropertyInvalid = 0,
CSSPropertyColor = 1001,
CSSPropertyDirection = 1002,
CSSPropertyDisplay = 1003,
CSSPropertyFont = 1004,
CSSPropertyFontFamily = 1005,
CSSPropertyFontSize = 1006,
CSSPropertyFontStyle = 1007,
CSSPropertyFontVariant = 1008,
CSSPropertyFontWeight = 1009,
CSSPropertyTextRendering = 1010,
CSSPropertyWebkitFontFeatureSettings = 1011,
CSSPropertyWebkitFontKerning = 1012,
CSSPropertyWebkitFontSmoothing = 1013,
CSSPropertyWebkitFontVariantLigatures = 1014,
CSSPropertyWebkitLocale = 1015,
CSSPropertyWebkitTextOrientation = 1016,
CSSPropertyWebkitTextSizeAdjust = 1017,
CSSPropertyWebkitWritingMode = 1018,
CSSPropertyZoom = 1019,
CSSPropertyLineHeight = 1020,
CSSPropertyBackground = 1021,
CSSPropertyBackgroundAttachment = 1022,
CSSPropertyBackgroundClip = 1023,
CSSPropertyBackgroundColor = 1024,
CSSPropertyBackgroundImage = 1025,
CSSPropertyBackgroundOrigin = 1026,
CSSPropertyBackgroundPosition = 1027,
CSSPropertyBackgroundPositionX = 1028,
CSSPropertyBackgroundPositionY = 1029,
CSSPropertyBackgroundRepeat = 1030,
CSSPropertyBackgroundRepeatX = 1031,
CSSPropertyBackgroundRepeatY = 1032,
CSSPropertyBackgroundSize = 1033,
CSSPropertyBorder = 1034,
CSSPropertyBorderBottom = 1035,
CSSPropertyBorderBottomColor = 1036,
CSSPropertyBorderBottomLeftRadius = 1037,
CSSPropertyBorderBottomRightRadius = 1038,
CSSPropertyBorderBottomStyle = 1039,
CSSPropertyBorderBottomWidth = 1040,
CSSPropertyBorderCollapse = 1041,
CSSPropertyBorderColor = 1042,
CSSPropertyBorderImage = 1043,
CSSPropertyBorderImageOutset = 1044,
CSSPropertyBorderImageRepeat = 1045,
CSSPropertyBorderImageSlice = 1046,
CSSPropertyBorderImageSource = 1047,
CSSPropertyBorderImageWidth = 1048,
CSSPropertyBorderLeft = 1049,
CSSPropertyBorderLeftColor = 1050,
CSSPropertyBorderLeftStyle = 1051,
CSSPropertyBorderLeftWidth = 1052,
CSSPropertyBorderRadius = 1053,
CSSPropertyBorderRight = 1054,
CSSPropertyBorderRightColor = 1055,
CSSPropertyBorderRightStyle = 1056,
CSSPropertyBorderRightWidth = 1057,
CSSPropertyBorderSpacing = 1058,
CSSPropertyBorderStyle = 1059,
CSSPropertyBorderTop = 1060,
CSSPropertyBorderTopColor = 1061,
CSSPropertyBorderTopLeftRadius = 1062,
CSSPropertyBorderTopRightRadius = 1063,
CSSPropertyBorderTopStyle = 1064,
CSSPropertyBorderTopWidth = 1065,
CSSPropertyBorderWidth = 1066,
CSSPropertyBottom = 1067,
CSSPropertyBoxShadow = 1068,
CSSPropertyBoxSizing = 1069,
CSSPropertyCaptionSide = 1070,
CSSPropertyClear = 1071,
CSSPropertyClip = 1072,
CSSPropertyContent = 1073,
CSSPropertyCounterIncrement = 1074,
CSSPropertyCounterReset = 1075,
CSSPropertyCursor = 1076,
CSSPropertyEmptyCells = 1077,
CSSPropertyFloat = 1078,
CSSPropertyFontStretch = 1079,
CSSPropertyHeight = 1080,
CSSPropertyImageRendering = 1081,
CSSPropertyLeft = 1082,
CSSPropertyLetterSpacing = 1083,
CSSPropertyListStyle = 1084,
CSSPropertyListStyleImage = 1085,
CSSPropertyListStylePosition = 1086,
CSSPropertyListStyleType = 1087,
CSSPropertyMargin = 1088,
CSSPropertyMarginBottom = 1089,
CSSPropertyMarginLeft = 1090,
CSSPropertyMarginRight = 1091,
CSSPropertyMarginTop = 1092,
CSSPropertyMaxHeight = 1093,
CSSPropertyMaxWidth = 1094,
CSSPropertyMinHeight = 1095,
CSSPropertyMinWidth = 1096,
CSSPropertyOpacity = 1097,
CSSPropertyOrphans = 1098,
CSSPropertyOutline = 1099,
CSSPropertyOutlineColor = 1100,
CSSPropertyOutlineOffset = 1101,
CSSPropertyOutlineStyle = 1102,
CSSPropertyOutlineWidth = 1103,
CSSPropertyOverflow = 1104,
CSSPropertyOverflowX = 1105,
CSSPropertyOverflowY = 1106,
CSSPropertyPadding = 1107,
CSSPropertyPaddingBottom = 1108,
CSSPropertyPaddingLeft = 1109,
CSSPropertyPaddingRight = 1110,
CSSPropertyPaddingTop = 1111,
CSSPropertyPage = 1112,
CSSPropertyPageBreakAfter = 1113,
CSSPropertyPageBreakBefore = 1114,
CSSPropertyPageBreakInside = 1115,
CSSPropertyPointerEvents = 1116,
CSSPropertyPosition = 1117,
CSSPropertyQuotes = 1118,
CSSPropertyResize = 1119,
CSSPropertyRight = 1120,
CSSPropertySize = 1121,
CSSPropertySrc = 1122,
CSSPropertySpeak = 1123,
CSSPropertyTableLayout = 1124,
CSSPropertyTextAlign = 1125,
CSSPropertyTextDecoration = 1126,
CSSPropertyTextIndent = 1127,
CSSPropertyTextLineThrough = 1128,
CSSPropertyTextLineThroughColor = 1129,
CSSPropertyTextLineThroughMode = 1130,
CSSPropertyTextLineThroughStyle = 1131,
CSSPropertyTextLineThroughWidth = 1132,
CSSPropertyTextOverflow = 1133,
CSSPropertyTextOverline = 1134,
CSSPropertyTextOverlineColor = 1135,
CSSPropertyTextOverlineMode = 1136,
CSSPropertyTextOverlineStyle = 1137,
CSSPropertyTextOverlineWidth = 1138,
CSSPropertyTextShadow = 1139,
CSSPropertyTextTransform = 1140,
CSSPropertyTextUnderline = 1141,
CSSPropertyTextUnderlineColor = 1142,
CSSPropertyTextUnderlineMode = 1143,
CSSPropertyTextUnderlineStyle = 1144,
CSSPropertyTextUnderlineWidth = 1145,
CSSPropertyTop = 1146,
CSSPropertyUnicodeBidi = 1147,
CSSPropertyUnicodeRange = 1148,
CSSPropertyVerticalAlign = 1149,
CSSPropertyVisibility = 1150,
CSSPropertyWhiteSpace = 1151,
CSSPropertyWidows = 1152,
CSSPropertyWidth = 1153,
CSSPropertyWordBreak = 1154,
CSSPropertyWordSpacing = 1155,
CSSPropertyWordWrap = 1156,
CSSPropertyZIndex = 1157,
CSSPropertyWebkitAnimation = 1158,
CSSPropertyWebkitAnimationDelay = 1159,
CSSPropertyWebkitAnimationDirection = 1160,
CSSPropertyWebkitAnimationDuration = 1161,
CSSPropertyWebkitAnimationFillMode = 1162,
CSSPropertyWebkitAnimationIterationCount = 1163,
CSSPropertyWebkitAnimationName = 1164,
CSSPropertyWebkitAnimationPlayState = 1165,
CSSPropertyWebkitAnimationTimingFunction = 1166,
CSSPropertyWebkitAppearance = 1167,
CSSPropertyWebkitAspectRatio = 1168,
CSSPropertyWebkitBackfaceVisibility = 1169,
CSSPropertyWebkitBackgroundClip = 1170,
CSSPropertyWebkitBackgroundComposite = 1171,
CSSPropertyWebkitBackgroundOrigin = 1172,
CSSPropertyWebkitBackgroundSize = 1173,
CSSPropertyWebkitBorderAfter = 1174,
CSSPropertyWebkitBorderAfterColor = 1175,
CSSPropertyWebkitBorderAfterStyle = 1176,
CSSPropertyWebkitBorderAfterWidth = 1177,
CSSPropertyWebkitBorderBefore = 1178,
CSSPropertyWebkitBorderBeforeColor = 1179,
CSSPropertyWebkitBorderBeforeStyle = 1180,
CSSPropertyWebkitBorderBeforeWidth = 1181,
CSSPropertyWebkitBorderEnd = 1182,
CSSPropertyWebkitBorderEndColor = 1183,
CSSPropertyWebkitBorderEndStyle = 1184,
CSSPropertyWebkitBorderEndWidth = 1185,
CSSPropertyWebkitBorderFit = 1186,
CSSPropertyWebkitBorderHorizontalSpacing = 1187,
CSSPropertyWebkitBorderImage = 1188,
CSSPropertyWebkitBorderRadius = 1189,
CSSPropertyWebkitBorderStart = 1190,
CSSPropertyWebkitBorderStartColor = 1191,
CSSPropertyWebkitBorderStartStyle = 1192,
CSSPropertyWebkitBorderStartWidth = 1193,
CSSPropertyWebkitBorderVerticalSpacing = 1194,
CSSPropertyWebkitBoxAlign = 1195,
CSSPropertyWebkitBoxDirection = 1196,
CSSPropertyWebkitBoxFlex = 1197,
CSSPropertyWebkitBoxFlexGroup = 1198,
CSSPropertyWebkitBoxLines = 1199,
CSSPropertyWebkitBoxOrdinalGroup = 1200,
CSSPropertyWebkitBoxOrient = 1201,
CSSPropertyWebkitBoxPack = 1202,
CSSPropertyWebkitBoxReflect = 1203,
CSSPropertyWebkitBoxShadow = 1204,
CSSPropertyWebkitColorCorrection = 1205,
CSSPropertyWebkitColumnAxis = 1206,
CSSPropertyWebkitColumnBreakAfter = 1207,
CSSPropertyWebkitColumnBreakBefore = 1208,
CSSPropertyWebkitColumnBreakInside = 1209,
CSSPropertyWebkitColumnCount = 1210,
CSSPropertyWebkitColumnGap = 1211,
CSSPropertyWebkitColumnRule = 1212,
CSSPropertyWebkitColumnRuleColor = 1213,
CSSPropertyWebkitColumnRuleStyle = 1214,
CSSPropertyWebkitColumnRuleWidth = 1215,
CSSPropertyWebkitColumnSpan = 1216,
CSSPropertyWebkitColumnWidth = 1217,
CSSPropertyWebkitColumns = 1218,
CSSPropertyWebkitFilter = 1219,
CSSPropertyWebkitFlexAlign = 1220,
CSSPropertyWebkitFlexDirection = 1221,
CSSPropertyWebkitFlexFlow = 1222,
CSSPropertyWebkitFlexItemAlign = 1223,
CSSPropertyWebkitFlexOrder = 1224,
CSSPropertyWebkitFlexPack = 1225,
CSSPropertyWebkitFlexWrap = 1226,
CSSPropertyWebkitFontSizeDelta = 1227,
CSSPropertyWebkitHighlight = 1228,
CSSPropertyWebkitHyphenateCharacter = 1229,
CSSPropertyWebkitHyphenateLimitAfter = 1230,
CSSPropertyWebkitHyphenateLimitBefore = 1231,
CSSPropertyWebkitHyphenateLimitLines = 1232,
CSSPropertyWebkitHyphens = 1233,
CSSPropertyWebkitLineBoxContain = 1234,
CSSPropertyWebkitLineBreak = 1235,
CSSPropertyWebkitLineClamp = 1236,
CSSPropertyWebkitLineGrid = 1237,
CSSPropertyWebkitLineGridSnap = 1238,
CSSPropertyWebkitLogicalWidth = 1239,
CSSPropertyWebkitLogicalHeight = 1240,
CSSPropertyWebkitMarginAfterCollapse = 1241,
CSSPropertyWebkitMarginBeforeCollapse = 1242,
CSSPropertyWebkitMarginBottomCollapse = 1243,
CSSPropertyWebkitMarginTopCollapse = 1244,
CSSPropertyWebkitMarginCollapse = 1245,
CSSPropertyWebkitMarginAfter = 1246,
CSSPropertyWebkitMarginBefore = 1247,
CSSPropertyWebkitMarginEnd = 1248,
CSSPropertyWebkitMarginStart = 1249,
CSSPropertyWebkitMarquee = 1250,
CSSPropertyWebkitMarqueeDirection = 1251,
CSSPropertyWebkitMarqueeIncrement = 1252,
CSSPropertyWebkitMarqueeRepetition = 1253,
CSSPropertyWebkitMarqueeSpeed = 1254,
CSSPropertyWebkitMarqueeStyle = 1255,
CSSPropertyWebkitMask = 1256,
CSSPropertyWebkitMaskAttachment = 1257,
CSSPropertyWebkitMaskBoxImage = 1258,
CSSPropertyWebkitMaskBoxImageOutset = 1259,
CSSPropertyWebkitMaskBoxImageRepeat = 1260,
CSSPropertyWebkitMaskBoxImageSlice = 1261,
CSSPropertyWebkitMaskBoxImageSource = 1262,
CSSPropertyWebkitMaskBoxImageWidth = 1263,
CSSPropertyWebkitMaskClip = 1264,
CSSPropertyWebkitMaskComposite = 1265,
CSSPropertyWebkitMaskImage = 1266,
CSSPropertyWebkitMaskOrigin = 1267,
CSSPropertyWebkitMaskPosition = 1268,
CSSPropertyWebkitMaskPositionX = 1269,
CSSPropertyWebkitMaskPositionY = 1270,
CSSPropertyWebkitMaskRepeat = 1271,
CSSPropertyWebkitMaskRepeatX = 1272,
CSSPropertyWebkitMaskRepeatY = 1273,
CSSPropertyWebkitMaskSize = 1274,
CSSPropertyWebkitMatchNearestMailBlockquoteColor = 1275,
CSSPropertyWebkitMaxLogicalWidth = 1276,
CSSPropertyWebkitMaxLogicalHeight = 1277,
CSSPropertyWebkitMinLogicalWidth = 1278,
CSSPropertyWebkitMinLogicalHeight = 1279,
CSSPropertyWebkitNbspMode = 1280,
CSSPropertyWebkitPaddingAfter = 1281,
CSSPropertyWebkitPaddingBefore = 1282,
CSSPropertyWebkitPaddingEnd = 1283,
CSSPropertyWebkitPaddingStart = 1284,
CSSPropertyWebkitPerspective = 1285,
CSSPropertyWebkitPerspectiveOrigin = 1286,
CSSPropertyWebkitPerspectiveOriginX = 1287,
CSSPropertyWebkitPerspectiveOriginY = 1288,
CSSPropertyWebkitPrintColorAdjust = 1289,
CSSPropertyWebkitRtlOrdering = 1290,
CSSPropertyWebkitTextCombine = 1291,
CSSPropertyWebkitTextDecorationsInEffect = 1292,
CSSPropertyWebkitTextEmphasis = 1293,
CSSPropertyWebkitTextEmphasisColor = 1294,
CSSPropertyWebkitTextEmphasisPosition = 1295,
CSSPropertyWebkitTextEmphasisStyle = 1296,
CSSPropertyWebkitTextFillColor = 1297,
CSSPropertyWebkitTextSecurity = 1298,
CSSPropertyWebkitTextStroke = 1299,
CSSPropertyWebkitTextStrokeColor = 1300,
CSSPropertyWebkitTextStrokeWidth = 1301,
CSSPropertyWebkitTransform = 1302,
CSSPropertyWebkitTransformOrigin = 1303,
CSSPropertyWebkitTransformOriginX = 1304,
CSSPropertyWebkitTransformOriginY = 1305,
CSSPropertyWebkitTransformOriginZ = 1306,
CSSPropertyWebkitTransformStyle = 1307,
CSSPropertyWebkitTransition = 1308,
CSSPropertyWebkitTransitionDelay = 1309,
CSSPropertyWebkitTransitionDuration = 1310,
CSSPropertyWebkitTransitionProperty = 1311,
CSSPropertyWebkitTransitionTimingFunction = 1312,
CSSPropertyWebkitUserDrag = 1313,
CSSPropertyWebkitUserModify = 1314,
CSSPropertyWebkitUserSelect = 1315,
CSSPropertyWebkitFlowInto = 1316,
CSSPropertyWebkitFlowFrom = 1317,
CSSPropertyWebkitRegionOverflow = 1318,
CSSPropertyWebkitWrapShapeInside = 1319,
CSSPropertyWebkitWrapShapeOutside = 1320,
CSSPropertyWebkitWrapMargin = 1321,
CSSPropertyWebkitWrapPadding = 1322,
CSSPropertyWebkitRegionBreakAfter = 1323,
CSSPropertyWebkitRegionBreakBefore = 1324,
CSSPropertyWebkitRegionBreakInside = 1325,
CSSPropertyWebkitWrapFlow = 1326,
CSSPropertyWebkitWrapThrough = 1327,
CSSPropertyWebkitWrap = 1328,
CSSPropertyWebkitGridColumns = 1329,
CSSPropertyWebkitGridRows = 1330,
CSSPropertyClipPath = 1331,
CSSPropertyClipRule = 1332,
CSSPropertyMask = 1333,
CSSPropertyEnableBackground = 1334,
CSSPropertyFilter = 1335,
CSSPropertyFloodColor = 1336,
CSSPropertyFloodOpacity = 1337,
CSSPropertyLightingColor = 1338,
CSSPropertyStopColor = 1339,
CSSPropertyStopOpacity = 1340,
CSSPropertyColorInterpolation = 1341,
CSSPropertyColorInterpolationFilters = 1342,
CSSPropertyColorProfile = 1343,
CSSPropertyColorRendering = 1344,
CSSPropertyFill = 1345,
CSSPropertyFillOpacity = 1346,
CSSPropertyFillRule = 1347,
CSSPropertyMarker = 1348,
CSSPropertyMarkerEnd = 1349,
CSSPropertyMarkerMid = 1350,
CSSPropertyMarkerStart = 1351,
CSSPropertyShapeRendering = 1352,
CSSPropertyStroke = 1353,
CSSPropertyStrokeDasharray = 1354,
CSSPropertyStrokeDashoffset = 1355,
CSSPropertyStrokeLinecap = 1356,
CSSPropertyStrokeLinejoin = 1357,
CSSPropertyStrokeMiterlimit = 1358,
CSSPropertyStrokeOpacity = 1359,
CSSPropertyStrokeWidth = 1360,
CSSPropertyAlignmentBaseline = 1361,
CSSPropertyBaselineShift = 1362,
CSSPropertyDominantBaseline = 1363,
CSSPropertyGlyphOrientationHorizontal = 1364,
CSSPropertyGlyphOrientationVertical = 1365,
CSSPropertyKerning = 1366,
CSSPropertyTextAnchor = 1367,
CSSPropertyVectorEffect = 1368,
CSSPropertyWritingMode = 1369,
CSSPropertyWebkitSvgShadow = 1370,
CSSPropertyWebkitDashboardRegion = 1371,
};
const int firstCSSProperty = 1001;
const int numCSSProperties = 371;
const size_t maxCSSPropertyNameLength = 43;
const char* const propertyNameStrings[371] = {
"color",
"direction",
"display",
"font",
"font-family",
"font-size",
"font-style",
"font-variant",
"font-weight",
"text-rendering",
"-webkit-font-feature-settings",
"-webkit-font-kerning",
"-webkit-font-smoothing",
"-webkit-font-variant-ligatures",
"-webkit-locale",
"-webkit-text-orientation",
"-webkit-text-size-adjust",
"-webkit-writing-mode",
"zoom",
"line-height",
"background",
"background-attachment",
"background-clip",
"background-color",
"background-image",
"background-origin",
"background-position",
"background-position-x",
"background-position-y",
"background-repeat",
"background-repeat-x",
"background-repeat-y",
"background-size",
"border",
"border-bottom",
"border-bottom-color",
"border-bottom-left-radius",
"border-bottom-right-radius",
"border-bottom-style",
"border-bottom-width",
"border-collapse",
"border-color",
"border-image",
"border-image-outset",
"border-image-repeat",
"border-image-slice",
"border-image-source",
"border-image-width",
"border-left",
"border-left-color",
"border-left-style",
"border-left-width",
"border-radius",
"border-right",
"border-right-color",
"border-right-style",
"border-right-width",
"border-spacing",
"border-style",
"border-top",
"border-top-color",
"border-top-left-radius",
"border-top-right-radius",
"border-top-style",
"border-top-width",
"border-width",
"bottom",
"box-shadow",
"box-sizing",
"caption-side",
"clear",
"clip",
"content",
"counter-increment",
"counter-reset",
"cursor",
"empty-cells",
"float",
"font-stretch",
"height",
"image-rendering",
"left",
"letter-spacing",
"list-style",
"list-style-image",
"list-style-position",
"list-style-type",
"margin",
"margin-bottom",
"margin-left",
"margin-right",
"margin-top",
"max-height",
"max-width",
"min-height",
"min-width",
"opacity",
"orphans",
"outline",
"outline-color",
"outline-offset",
"outline-style",
"outline-width",
"overflow",
"overflow-x",
"overflow-y",
"padding",
"padding-bottom",
"padding-left",
"padding-right",
"padding-top",
"page",
"page-break-after",
"page-break-before",
"page-break-inside",
"pointer-events",
"position",
"quotes",
"resize",
"right",
"size",
"src",
"speak",
"table-layout",
"text-align",
"text-decoration",
"text-indent",
"text-line-through",
"text-line-through-color",
"text-line-through-mode",
"text-line-through-style",
"text-line-through-width",
"text-overflow",
"text-overline",
"text-overline-color",
"text-overline-mode",
"text-overline-style",
"text-overline-width",
"text-shadow",
"text-transform",
"text-underline",
"text-underline-color",
"text-underline-mode",
"text-underline-style",
"text-underline-width",
"top",
"unicode-bidi",
"unicode-range",
"vertical-align",
"visibility",
"white-space",
"widows",
"width",
"word-break",
"word-spacing",
"word-wrap",
"z-index",
"-webkit-animation",
"-webkit-animation-delay",
"-webkit-animation-direction",
"-webkit-animation-duration",
"-webkit-animation-fill-mode",
"-webkit-animation-iteration-count",
"-webkit-animation-name",
"-webkit-animation-play-state",
"-webkit-animation-timing-function",
"-webkit-appearance",
"-webkit-aspect-ratio",
"-webkit-backface-visibility",
"-webkit-background-clip",
"-webkit-background-composite",
"-webkit-background-origin",
"-webkit-background-size",
"-webkit-border-after",
"-webkit-border-after-color",
"-webkit-border-after-style",
"-webkit-border-after-width",
"-webkit-border-before",
"-webkit-border-before-color",
"-webkit-border-before-style",
"-webkit-border-before-width",
"-webkit-border-end",
"-webkit-border-end-color",
"-webkit-border-end-style",
"-webkit-border-end-width",
"-webkit-border-fit",
"-webkit-border-horizontal-spacing",
"-webkit-border-image",
"-webkit-border-radius",
"-webkit-border-start",
"-webkit-border-start-color",
"-webkit-border-start-style",
"-webkit-border-start-width",
"-webkit-border-vertical-spacing",
"-webkit-box-align",
"-webkit-box-direction",
"-webkit-box-flex",
"-webkit-box-flex-group",
"-webkit-box-lines",
"-webkit-box-ordinal-group",
"-webkit-box-orient",
"-webkit-box-pack",
"-webkit-box-reflect",
"-webkit-box-shadow",
"-webkit-color-correction",
"-webkit-column-axis",
"-webkit-column-break-after",
"-webkit-column-break-before",
"-webkit-column-break-inside",
"-webkit-column-count",
"-webkit-column-gap",
"-webkit-column-rule",
"-webkit-column-rule-color",
"-webkit-column-rule-style",
"-webkit-column-rule-width",
"-webkit-column-span",
"-webkit-column-width",
"-webkit-columns",
"-webkit-filter",
"-webkit-flex-align",
"-webkit-flex-direction",
"-webkit-flex-flow",
"-webkit-flex-item-align",
"-webkit-flex-order",
"-webkit-flex-pack",
"-webkit-flex-wrap",
"-webkit-font-size-delta",
"-webkit-highlight",
"-webkit-hyphenate-character",
"-webkit-hyphenate-limit-after",
"-webkit-hyphenate-limit-before",
"-webkit-hyphenate-limit-lines",
"-webkit-hyphens",
"-webkit-line-box-contain",
"-webkit-line-break",
"-webkit-line-clamp",
"-webkit-line-grid",
"-webkit-line-grid-snap",
"-webkit-logical-width",
"-webkit-logical-height",
"-webkit-margin-after-collapse",
"-webkit-margin-before-collapse",
"-webkit-margin-bottom-collapse",
"-webkit-margin-top-collapse",
"-webkit-margin-collapse",
"-webkit-margin-after",
"-webkit-margin-before",
"-webkit-margin-end",
"-webkit-margin-start",
"-webkit-marquee",
"-webkit-marquee-direction",
"-webkit-marquee-increment",
"-webkit-marquee-repetition",
"-webkit-marquee-speed",
"-webkit-marquee-style",
"-webkit-mask",
"-webkit-mask-attachment",
"-webkit-mask-box-image",
"-webkit-mask-box-image-outset",
"-webkit-mask-box-image-repeat",
"-webkit-mask-box-image-slice",
"-webkit-mask-box-image-source",
"-webkit-mask-box-image-width",
"-webkit-mask-clip",
"-webkit-mask-composite",
"-webkit-mask-image",
"-webkit-mask-origin",
"-webkit-mask-position",
"-webkit-mask-position-x",
"-webkit-mask-position-y",
"-webkit-mask-repeat",
"-webkit-mask-repeat-x",
"-webkit-mask-repeat-y",
"-webkit-mask-size",
"-webkit-match-nearest-mail-blockquote-color",
"-webkit-max-logical-width",
"-webkit-max-logical-height",
"-webkit-min-logical-width",
"-webkit-min-logical-height",
"-webkit-nbsp-mode",
"-webkit-padding-after",
"-webkit-padding-before",
"-webkit-padding-end",
"-webkit-padding-start",
"-webkit-perspective",
"-webkit-perspective-origin",
"-webkit-perspective-origin-x",
"-webkit-perspective-origin-y",
"-webkit-print-color-adjust",
"-webkit-rtl-ordering",
"-webkit-text-combine",
"-webkit-text-decorations-in-effect",
"-webkit-text-emphasis",
"-webkit-text-emphasis-color",
"-webkit-text-emphasis-position",
"-webkit-text-emphasis-style",
"-webkit-text-fill-color",
"-webkit-text-security",
"-webkit-text-stroke",
"-webkit-text-stroke-color",
"-webkit-text-stroke-width",
"-webkit-transform",
"-webkit-transform-origin",
"-webkit-transform-origin-x",
"-webkit-transform-origin-y",
"-webkit-transform-origin-z",
"-webkit-transform-style",
"-webkit-transition",
"-webkit-transition-delay",
"-webkit-transition-duration",
"-webkit-transition-property",
"-webkit-transition-timing-function",
"-webkit-user-drag",
"-webkit-user-modify",
"-webkit-user-select",
"-webkit-flow-into",
"-webkit-flow-from",
"-webkit-region-overflow",
"-webkit-wrap-shape-inside",
"-webkit-wrap-shape-outside",
"-webkit-wrap-margin",
"-webkit-wrap-padding",
"-webkit-region-break-after",
"-webkit-region-break-before",
"-webkit-region-break-inside",
"-webkit-wrap-flow",
"-webkit-wrap-through",
"-webkit-wrap",
"-webkit-grid-columns",
"-webkit-grid-rows",
"clip-path",
"clip-rule",
"mask",
"enable-background",
"filter",
"flood-color",
"flood-opacity",
"lighting-color",
"stop-color",
"stop-opacity",
"color-interpolation",
"color-interpolation-filters",
"color-profile",
"color-rendering",
"fill",
"fill-opacity",
"fill-rule",
"marker",
"marker-end",
"marker-mid",
"marker-start",
"shape-rendering",
"stroke",
"stroke-dasharray",
"stroke-dashoffset",
"stroke-linecap",
"stroke-linejoin",
"stroke-miterlimit",
"stroke-opacity",
"stroke-width",
"alignment-baseline",
"baseline-shift",
"dominant-baseline",
"glyph-orientation-horizontal",
"glyph-orientation-vertical",
"kerning",
"text-anchor",
"vector-effect",
"writing-mode",
"-webkit-svg-shadow",
"-webkit-dashboard-region",
};
const char* getPropertyName(CSSPropertyID);
WTF::String getJSPropertyName(CSSPropertyID);
} // namespace WebCore
#endif // CSSPropertyNames_h

View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CSSPropertySourceData_h
#define CSSPropertySourceData_h
#include "PlatformString.h"
#include <utility>
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
namespace WebCore {
class CSSStyleRule;
struct SourceRange {
SourceRange();
SourceRange(unsigned start, unsigned end);
unsigned length() const;
unsigned start;
unsigned end;
};
struct CSSPropertySourceData {
static void init();
CSSPropertySourceData(const String& name, const String& value, bool important, bool parsedOk, const SourceRange& range);
CSSPropertySourceData(const CSSPropertySourceData& other);
CSSPropertySourceData();
String toString() const;
unsigned hash() const;
String name;
String value;
bool important;
bool parsedOk;
SourceRange range;
};
#ifndef CSSPROPERTYSOURCEDATA_HIDE_GLOBALS
extern const CSSPropertySourceData emptyCSSPropertySourceData;
#endif
struct CSSStyleSourceData : public RefCounted<CSSStyleSourceData> {
static PassRefPtr<CSSStyleSourceData> create()
{
return adoptRef(new CSSStyleSourceData());
}
// Range of the style text in the enclosing source.
SourceRange styleBodyRange;
Vector<CSSPropertySourceData> propertyData;
};
struct CSSRuleSourceData : public RefCounted<CSSRuleSourceData> {
static PassRefPtr<CSSRuleSourceData> create()
{
return adoptRef(new CSSRuleSourceData());
}
// Range of the selector list in the enclosing source.
SourceRange selectorListRange;
RefPtr<CSSStyleSourceData> styleSourceData;
};
typedef HashMap<CSSStyleRule*, RefPtr<CSSRuleSourceData> > StyleRuleRangeMap;
} // namespace WebCore
#endif // CSSPropertySourceData_h

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CSSReflectValue_h
#define CSSReflectValue_h
#include "CSSReflectionDirection.h"
#include "CSSValue.h"
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CSSPrimitiveValue;
class CSSReflectValue : public CSSValue {
public:
static PassRefPtr<CSSReflectValue> create(CSSReflectionDirection direction,
PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
{
return adoptRef(new CSSReflectValue(direction, offset, mask));
}
CSSReflectionDirection direction() const { return m_direction; }
CSSPrimitiveValue* offset() const { return m_offset.get(); }
CSSValue* mask() const { return m_mask.get(); }
String customCssText() const;
void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
private:
CSSReflectValue(CSSReflectionDirection direction, PassRefPtr<CSSPrimitiveValue> offset, PassRefPtr<CSSValue> mask)
: CSSValue(ReflectClass)
, m_direction(direction)
, m_offset(offset)
, m_mask(mask)
{
}
CSSReflectionDirection m_direction;
RefPtr<CSSPrimitiveValue> m_offset;
RefPtr<CSSValue> m_mask;
};
} // namespace WebCore
#endif // CSSReflectValue_h

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CSSReflectionDirection_h
#define CSSReflectionDirection_h
namespace WebCore {
enum CSSReflectionDirection { ReflectionBelow, ReflectionAbove, ReflectionLeft, ReflectionRight };
} // namespace WebCore
#endif // CSSReflectionDirection_h

View File

@@ -0,0 +1,146 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2002, 2006, 2007 Apple Inc. All rights reserved.
* Copyright (C) 2011 Andreas Kling (kling@webkit.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSRule_h
#define CSSRule_h
#include "CSSStyleSheet.h"
#include "KURLHash.h"
#include <wtf/ListHashSet.h>
namespace WebCore {
typedef int ExceptionCode;
class CSSRule : public RefCounted<CSSRule> {
public:
// Override RefCounted's deref() to ensure operator delete is called on
// the appropriate subclass type.
void deref()
{
if (derefBase())
destroy();
}
enum Type {
UNKNOWN_RULE,
STYLE_RULE,
CHARSET_RULE,
IMPORT_RULE,
MEDIA_RULE,
FONT_FACE_RULE,
PAGE_RULE,
// 7 used to be VARIABLES_RULE
WEBKIT_KEYFRAMES_RULE = 8,
WEBKIT_KEYFRAME_RULE,
WEBKIT_REGION_RULE
};
Type type() const { return static_cast<Type>(m_type); }
bool isCharsetRule() const { return type() == CHARSET_RULE; }
bool isFontFaceRule() const { return type() == FONT_FACE_RULE; }
bool isKeyframeRule() const { return type() == WEBKIT_KEYFRAME_RULE; }
bool isKeyframesRule() const { return type() == WEBKIT_KEYFRAMES_RULE; }
bool isMediaRule() const { return type() == MEDIA_RULE; }
bool isPageRule() const { return type() == PAGE_RULE; }
bool isStyleRule() const { return type() == STYLE_RULE; }
bool isRegionRule() const { return type() == WEBKIT_REGION_RULE; }
bool isImportRule() const { return type() == IMPORT_RULE; }
bool useStrictParsing() const
{
if (parentRule())
return parentRule()->useStrictParsing();
if (parentStyleSheet())
return parentStyleSheet()->useStrictParsing();
return true;
}
void setParentStyleSheet(CSSStyleSheet* styleSheet)
{
m_parentIsRule = false;
m_parentStyleSheet = styleSheet;
}
void setParentRule(CSSRule* rule)
{
m_parentIsRule = true;
m_parentRule = rule;
}
CSSStyleSheet* parentStyleSheet() const
{
if (m_parentIsRule)
return m_parentRule ? m_parentRule->parentStyleSheet() : 0;
return m_parentStyleSheet;
}
CSSRule* parentRule() const { return m_parentIsRule ? m_parentRule : 0; }
String cssText() const;
void setCssText(const String&, ExceptionCode&);
KURL baseURL() const
{
if (CSSStyleSheet* parentSheet = parentStyleSheet())
return parentSheet->baseURL();
return KURL();
}
protected:
CSSRule(CSSStyleSheet* parent, Type type)
: m_sourceLine(0)
, m_hasCachedSelectorText(false)
, m_parentIsRule(false)
, m_type(type)
, m_parentStyleSheet(parent)
{
}
// NOTE: This class is non-virtual for memory and performance reasons.
// Don't go making it virtual again unless you know exactly what you're doing!
~CSSRule() { }
int sourceLine() const { return m_sourceLine; }
void setSourceLine(int sourceLine) { m_sourceLine = sourceLine; }
bool hasCachedSelectorText() const { return m_hasCachedSelectorText; }
void setHasCachedSelectorText(bool hasCachedSelectorText) const { m_hasCachedSelectorText = hasCachedSelectorText; }
private:
// Only used by CSSStyleRule but kept here to maximize struct packing.
signed m_sourceLine : 26;
mutable unsigned m_hasCachedSelectorText : 1;
unsigned m_parentIsRule : 1;
unsigned m_type : 4;
union {
CSSRule* m_parentRule;
CSSStyleSheet* m_parentStyleSheet;
};
void destroy();
};
} // namespace WebCore
#endif // CSSRule_h

View File

@@ -0,0 +1,71 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* (C) 2002-2003 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2002, 2006 Apple Computer, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSRuleList_h
#define CSSRuleList_h
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class CSSRule;
class CSSStyleSheet;
class CSSRuleList : public RefCounted<CSSRuleList> {
public:
static PassRefPtr<CSSRuleList> create(CSSStyleSheet* styleSheet, bool omitCharsetRules = false)
{
return adoptRef(new CSSRuleList(styleSheet, omitCharsetRules));
}
static PassRefPtr<CSSRuleList> create()
{
return adoptRef(new CSSRuleList);
}
~CSSRuleList();
unsigned length() const;
CSSRule* item(unsigned index) const;
// FIXME: Not part of the CSSOM. Only used by @media and @-webkit-keyframes rules.
unsigned insertRule(CSSRule*, unsigned index);
void deleteRule(unsigned index);
void append(CSSRule*);
CSSStyleSheet* styleSheet() { return m_styleSheet.get(); }
String rulesText() const;
private:
CSSRuleList();
CSSRuleList(CSSStyleSheet*, bool omitCharsetRules);
RefPtr<CSSStyleSheet> m_styleSheet;
Vector<RefPtr<CSSRule> > m_lstCSSRules; // FIXME: Want to eliminate, but used by IE rules() extension and still used by media rules.
};
} // namespace WebCore
#endif // CSSRuleList_h

View File

@@ -0,0 +1,374 @@
/*
* Copyright (C) 1999-2003 Lars Knoll (knoll@kde.org)
* 1999 Waldo Bastian (bastian@kde.org)
* Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSSelector_h
#define CSSSelector_h
#include "QualifiedName.h"
#include "RenderStyleConstants.h"
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class CSSSelectorList;
// this class represents a selector for a StyleRule
class CSSSelector {
WTF_MAKE_NONCOPYABLE(CSSSelector); WTF_MAKE_FAST_ALLOCATED;
public:
CSSSelector()
: m_relation(Descendant)
, m_match(None)
, m_pseudoType(PseudoNotParsed)
, m_parsedNth(false)
, m_isLastInSelectorList(false)
, m_isLastInTagHistory(true)
, m_hasRareData(false)
, m_isForPage(false)
, m_tag(anyQName())
{
}
CSSSelector(const QualifiedName& qName)
: m_relation(Descendant)
, m_match(None)
, m_pseudoType(PseudoNotParsed)
, m_parsedNth(false)
, m_isLastInSelectorList(false)
, m_isLastInTagHistory(true)
, m_hasRareData(false)
, m_isForPage(false)
, m_tag(qName)
{
}
~CSSSelector()
{
if (m_hasRareData)
delete m_data.m_rareData;
else if (m_data.m_value)
m_data.m_value->deref();
}
/**
* Re-create selector text from selector's data
*/
String selectorText() const;
// checks if the 2 selectors (including sub selectors) agree.
bool operator==(const CSSSelector&);
// tag == -1 means apply to all elements (Selector = *)
unsigned specificity() const;
/* how the attribute value has to match.... Default is Exact */
enum Match {
None = 0,
Id,
Class,
Exact,
Set,
List,
Hyphen,
PseudoClass,
PseudoElement,
Contain, // css3: E[foo*="bar"]
Begin, // css3: E[foo^="bar"]
End, // css3: E[foo$="bar"]
PagePseudoClass
};
enum Relation {
Descendant = 0,
Child,
DirectAdjacent,
IndirectAdjacent,
SubSelector,
ShadowDescendant
};
enum PseudoType {
PseudoNotParsed = 0,
PseudoUnknown,
PseudoEmpty,
PseudoFirstChild,
PseudoFirstOfType,
PseudoLastChild,
PseudoLastOfType,
PseudoOnlyChild,
PseudoOnlyOfType,
PseudoFirstLine,
PseudoFirstLetter,
PseudoNthChild,
PseudoNthOfType,
PseudoNthLastChild,
PseudoNthLastOfType,
PseudoLink,
PseudoVisited,
PseudoAny,
PseudoAnyLink,
PseudoAutofill,
PseudoHover,
PseudoDrag,
PseudoFocus,
PseudoActive,
PseudoChecked,
PseudoEnabled,
PseudoFullPageMedia,
PseudoDefault,
PseudoDisabled,
PseudoOptional,
PseudoRequired,
PseudoReadOnly,
PseudoReadWrite,
PseudoValid,
PseudoInvalid,
PseudoIndeterminate,
PseudoTarget,
PseudoBefore,
PseudoAfter,
PseudoLang,
PseudoNot,
PseudoResizer,
PseudoRoot,
PseudoScrollbar,
PseudoScrollbarBack,
PseudoScrollbarButton,
PseudoScrollbarCorner,
PseudoScrollbarForward,
PseudoScrollbarThumb,
PseudoScrollbarTrack,
PseudoScrollbarTrackPiece,
PseudoWindowInactive,
PseudoCornerPresent,
PseudoDecrement,
PseudoIncrement,
PseudoHorizontal,
PseudoVertical,
PseudoStart,
PseudoEnd,
PseudoDoubleButton,
PseudoSingleButton,
PseudoNoButton,
PseudoSelection,
PseudoInputListButton,
PseudoLeftPage,
PseudoRightPage,
PseudoFirstPage,
#if ENABLE(FULLSCREEN_API)
PseudoFullScreen,
PseudoFullScreenDocument,
PseudoFullScreenAncestor,
PseudoAnimatingFullScreenTransition,
#endif
PseudoInRange,
PseudoOutOfRange,
};
enum MarginBoxType {
TopLeftCornerMarginBox,
TopLeftMarginBox,
TopCenterMarginBox,
TopRightMarginBox,
TopRightCornerMarginBox,
BottomLeftCornerMarginBox,
BottomLeftMarginBox,
BottomCenterMarginBox,
BottomRightMarginBox,
BottomRightCornerMarginBox,
LeftTopMarginBox,
LeftMiddleMarginBox,
LeftBottomMarginBox,
RightTopMarginBox,
RightMiddleMarginBox,
RightBottomMarginBox,
};
PseudoType pseudoType() const
{
if (m_pseudoType == PseudoNotParsed)
extractPseudoType();
return static_cast<PseudoType>(m_pseudoType);
}
static PseudoType parsePseudoType(const AtomicString&);
static bool isUnknownPseudoType(const AtomicString&);
static PseudoId pseudoId(PseudoType);
// Selectors are kept in an array by CSSSelectorList. The next component of the selector is
// the next item in the array.
CSSSelector* tagHistory() const { return m_isLastInTagHistory ? 0 : const_cast<CSSSelector*>(this + 1); }
bool hasTag() const { return m_tag != anyQName(); }
const QualifiedName& tag() const { return m_tag; }
// AtomicString is really just an AtomicStringImpl* so the cast below is safe.
// FIXME: Perhaps call sites could be changed to accept AtomicStringImpl?
const AtomicString& value() const { return *reinterpret_cast<const AtomicString*>(m_hasRareData ? &m_data.m_rareData->m_value : &m_data.m_value); }
const QualifiedName& attribute() const;
const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareData->m_argument : nullAtom; }
CSSSelectorList* selectorList() const { return m_hasRareData ? m_data.m_rareData->m_selectorList.get() : 0; }
void setTag(const QualifiedName& value) { m_tag = value; }
void setValue(const AtomicString&);
void setAttribute(const QualifiedName&);
void setArgument(const AtomicString&);
void setSelectorList(PassOwnPtr<CSSSelectorList>);
bool parseNth();
bool matchNth(int count);
bool matchesPseudoElement() const;
bool isUnknownPseudoElement() const;
bool isSiblingSelector() const;
bool isAttributeSelector() const;
Relation relation() const { return static_cast<Relation>(m_relation); }
bool isLastInSelectorList() const { return m_isLastInSelectorList; }
void setLastInSelectorList() { m_isLastInSelectorList = true; }
bool isLastInTagHistory() const { return m_isLastInTagHistory; }
void setNotLastInTagHistory() { m_isLastInTagHistory = false; }
bool isSimple() const;
bool isForPage() const { return m_isForPage; }
void setForPage() { m_isForPage = true; }
unsigned m_relation : 3; // enum Relation
mutable unsigned m_match : 4; // enum Match
mutable unsigned m_pseudoType : 8; // PseudoType
private:
bool m_parsedNth : 1; // Used for :nth-*
bool m_isLastInSelectorList : 1;
bool m_isLastInTagHistory : 1;
bool m_hasRareData : 1;
bool m_isForPage : 1;
unsigned specificityForOneSelector() const;
unsigned specificityForPage() const;
void extractPseudoType() const;
struct RareData {
WTF_MAKE_NONCOPYABLE(RareData); WTF_MAKE_FAST_ALLOCATED;
public:
RareData(PassRefPtr<AtomicStringImpl> value);
~RareData();
bool parseNth();
bool matchNth(int count);
AtomicStringImpl* m_value; // Plain pointer to keep things uniform with the union.
int m_a; // Used for :nth-*
int m_b; // Used for :nth-*
QualifiedName m_attribute; // used for attribute selector
AtomicString m_argument; // Used for :contains, :lang and :nth-*
OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any and :not
};
void createRareData();
union DataUnion {
DataUnion() : m_value(0) { }
AtomicStringImpl* m_value;
RareData* m_rareData;
} m_data;
QualifiedName m_tag;
};
inline const QualifiedName& CSSSelector::attribute() const
{
ASSERT(isAttributeSelector());
ASSERT(m_hasRareData);
return m_data.m_rareData->m_attribute;
}
inline bool CSSSelector::matchesPseudoElement() const
{
if (m_pseudoType == PseudoUnknown)
extractPseudoType();
return m_match == PseudoElement;
}
inline bool CSSSelector::isUnknownPseudoElement() const
{
return m_match == PseudoElement && m_pseudoType == PseudoUnknown;
}
inline bool CSSSelector::isSiblingSelector() const
{
PseudoType type = pseudoType();
return m_relation == DirectAdjacent
|| m_relation == IndirectAdjacent
|| type == PseudoEmpty
|| type == PseudoFirstChild
|| type == PseudoFirstOfType
|| type == PseudoLastChild
|| type == PseudoLastOfType
|| type == PseudoOnlyChild
|| type == PseudoOnlyOfType
|| type == PseudoNthChild
|| type == PseudoNthOfType
|| type == PseudoNthLastChild
|| type == PseudoNthLastOfType;
}
inline bool CSSSelector::isAttributeSelector() const
{
return m_match == CSSSelector::Exact
|| m_match == CSSSelector::Set
|| m_match == CSSSelector::List
|| m_match == CSSSelector::Hyphen
|| m_match == CSSSelector::Contain
|| m_match == CSSSelector::Begin
|| m_match == CSSSelector::End;
}
inline void CSSSelector::setValue(const AtomicString& value)
{
// Need to do ref counting manually for the union.
if (m_hasRareData) {
if (m_data.m_rareData->m_value)
m_data.m_rareData->m_value->deref();
m_data.m_rareData->m_value = value.impl();
m_data.m_rareData->m_value->ref();
return;
}
if (m_data.m_value)
m_data.m_value->deref();
m_data.m_value = value.impl();
m_data.m_value->ref();
}
inline void move(PassOwnPtr<CSSSelector> from, CSSSelector* to)
{
memcpy(to, from.get(), sizeof(CSSSelector));
// We want to free the memory (which was allocated with fastNew), but we
// don't want the destructor to run since it will affect the copy we've just made.
fastDeleteSkippingDestructor(from.leakPtr());
}
} // namespace WebCore
#endif // CSSSelector_h

View File

@@ -0,0 +1,119 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSStyleDeclaration_h
#define CSSStyleDeclaration_h
#include "CSSRule.h"
#include <wtf/Forward.h>
namespace WebCore {
class CSSMutableStyleDeclaration;
class CSSProperty;
class CSSStyleSheet;
class CSSValue;
class StyledElement;
typedef int ExceptionCode;
class CSSStyleDeclaration : public RefCounted<CSSStyleDeclaration> {
WTF_MAKE_NONCOPYABLE(CSSStyleDeclaration);
public:
virtual ~CSSStyleDeclaration() { }
static bool isPropertyName(const String&);
CSSRule* parentRule() const { return m_isElementStyleDeclaration ? 0 : m_parent.rule; }
void clearParentRule() { ASSERT(!m_isElementStyleDeclaration); m_parent.rule = 0; }
StyledElement* parentElement() const { ASSERT(m_isElementStyleDeclaration); return m_parent.element; }
void clearParentElement() { ASSERT(m_isElementStyleDeclaration); m_parent.element = 0; }
CSSStyleSheet* parentStyleSheet() const;
virtual String cssText() const = 0;
virtual void setCssText(const String&, ExceptionCode&) = 0;
unsigned length() const { return virtualLength(); }
virtual unsigned virtualLength() const = 0;
bool isEmpty() const { return !length(); }
virtual String item(unsigned index) const = 0;
PassRefPtr<CSSValue> getPropertyCSSValue(const String& propertyName);
String getPropertyValue(const String& propertyName);
String getPropertyPriority(const String& propertyName);
String getPropertyShorthand(const String& propertyName);
bool isPropertyImplicit(const String& propertyName);
virtual PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID) const = 0;
virtual String getPropertyValue(int propertyID) const = 0;
virtual bool getPropertyPriority(int propertyID) const = 0;
virtual int getPropertyShorthand(int propertyID) const = 0;
virtual bool isPropertyImplicit(int propertyID) const = 0;
void setProperty(const String& propertyName, const String& value, const String& priority, ExceptionCode&);
String removeProperty(const String& propertyName, ExceptionCode&);
virtual void setProperty(int propertyId, const String& value, bool important, ExceptionCode&) = 0;
virtual String removeProperty(int propertyID, ExceptionCode&) = 0;
virtual PassRefPtr<CSSMutableStyleDeclaration> copy() const = 0;
virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable() = 0;
void diff(CSSMutableStyleDeclaration*) const;
PassRefPtr<CSSMutableStyleDeclaration> copyPropertiesInSet(const int* set, unsigned length) const;
#ifndef NDEBUG
void showStyle();
#endif
bool isElementStyleDeclaration() const { return m_isElementStyleDeclaration; }
bool isInlineStyleDeclaration() const { return m_isInlineStyleDeclaration; }
protected:
CSSStyleDeclaration(CSSRule* parentRule = 0);
CSSStyleDeclaration(StyledElement* parentElement, bool isInline);
virtual bool cssPropertyMatches(const CSSProperty*) const;
// The bits in this section are only used by specific subclasses but kept here
// to maximize struct packing.
// CSSMutableStyleDeclaration bits:
bool m_strictParsing : 1;
#ifndef NDEBUG
unsigned m_iteratorCount : 4;
#endif
bool m_isElementStyleDeclaration : 1;
bool m_isInlineStyleDeclaration : 1;
private:
union Parent {
Parent(CSSRule* rule) : rule(rule) { }
Parent(StyledElement* element) : element(element) { }
CSSRule* rule;
StyledElement* element;
} m_parent;
};
} // namespace WebCore
#endif // CSSStyleDeclaration_h

View File

@@ -0,0 +1,135 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSStyleSheet_h
#define CSSStyleSheet_h
#include "CSSRuleList.h"
#include "StyleSheet.h"
namespace WebCore {
struct CSSNamespace;
class CSSParser;
class CSSRule;
class CachedResourceLoader;
class Document;
typedef int ExceptionCode;
class CSSStyleSheet : public StyleSheet {
public:
static PassRefPtr<CSSStyleSheet> create()
{
return adoptRef(new CSSStyleSheet(static_cast<CSSImportRule*>(0), String(), KURL(), String()));
}
static PassRefPtr<CSSStyleSheet> create(Node* ownerNode)
{
return adoptRef(new CSSStyleSheet(ownerNode, String(), KURL(), String()));
}
static PassRefPtr<CSSStyleSheet> create(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset)
{
return adoptRef(new CSSStyleSheet(ownerNode, originalURL, finalURL, charset));
}
static PassRefPtr<CSSStyleSheet> create(CSSImportRule* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset)
{
return adoptRef(new CSSStyleSheet(ownerRule, originalURL, finalURL, charset));
}
static PassRefPtr<CSSStyleSheet> createInline(Node* ownerNode, const KURL& finalURL)
{
return adoptRef(new CSSStyleSheet(ownerNode, finalURL.string(), finalURL, String()));
}
virtual ~CSSStyleSheet();
CSSStyleSheet* parentStyleSheet() const
{
StyleSheet* parentSheet = StyleSheet::parentStyleSheet();
ASSERT(!parentSheet || parentSheet->isCSSStyleSheet());
return static_cast<CSSStyleSheet*>(parentSheet);
}
PassRefPtr<CSSRuleList> cssRules(bool omitCharsetRules = false);
unsigned insertRule(const String& rule, unsigned index, ExceptionCode&);
void deleteRule(unsigned index, ExceptionCode&);
// IE Extensions
PassRefPtr<CSSRuleList> rules() { return cssRules(true); }
int addRule(const String& selector, const String& style, int index, ExceptionCode&);
int addRule(const String& selector, const String& style, ExceptionCode&);
void removeRule(unsigned index, ExceptionCode& ec) { deleteRule(index, ec); }
void addNamespace(CSSParser*, const AtomicString& prefix, const AtomicString& uri);
const AtomicString& determineNamespace(const AtomicString& prefix);
void styleSheetChanged();
virtual bool parseString(const String&, bool strict = true);
bool parseStringAtLine(const String&, bool strict, int startLineNumber);
virtual bool isLoading();
void checkLoaded();
void startLoadingDynamicSheet();
Node* findStyleSheetOwnerNode() const;
Document* findDocument();
const String& charset() const { return m_charset; }
bool loadCompleted() const { return m_loadCompleted; }
KURL completeURL(const String& url) const;
void addSubresourceStyleURLs(ListHashSet<KURL>&);
void setStrictParsing(bool b) { m_strictParsing = b; }
bool useStrictParsing() const { return m_strictParsing; }
void setIsUserStyleSheet(bool b) { m_isUserStyleSheet = b; }
bool isUserStyleSheet() const { return m_isUserStyleSheet; }
void setHasSyntacticallyValidCSSHeader(bool b) { m_hasSyntacticallyValidCSSHeader = b; }
bool hasSyntacticallyValidCSSHeader() const { return m_hasSyntacticallyValidCSSHeader; }
void append(PassRefPtr<CSSRule>);
void remove(unsigned index);
unsigned length() const { return m_children.size(); }
CSSRule* item(unsigned index) { return index < length() ? m_children.at(index).get() : 0; }
private:
CSSStyleSheet(Node* ownerNode, const String& originalURL, const KURL& finalURL, const String& charset);
CSSStyleSheet(CSSImportRule* ownerRule, const String& originalURL, const KURL& finalURL, const String& charset);
virtual bool isCSSStyleSheet() const { return true; }
virtual String type() const { return "text/css"; }
Vector<RefPtr<CSSRule> > m_children;
OwnPtr<CSSNamespace> m_namespaces;
String m_charset;
bool m_loadCompleted : 1;
bool m_strictParsing : 1;
bool m_isUserStyleSheet : 1;
bool m_hasSyntacticallyValidCSSHeader : 1;
};
} // namespace
#endif

View File

@@ -0,0 +1,189 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSValue_h
#define CSSValue_h
#include "KURLHash.h"
#include <wtf/ListHashSet.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CSSStyleSheet;
typedef int ExceptionCode;
class CSSValue : public RefCounted<CSSValue> {
public:
enum Type {
CSS_INHERIT = 0,
CSS_PRIMITIVE_VALUE = 1,
CSS_VALUE_LIST = 2,
CSS_CUSTOM = 3,
CSS_INITIAL = 4
};
// Override RefCounted's deref() to ensure operator delete is called on
// the appropriate subclass type.
void deref()
{
if (derefBase())
destroy();
}
Type cssValueType() const;
String cssText() const;
void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented.
bool isPrimitiveValue() const { return m_classType <= PrimitiveClass; }
bool isValueList() const { return m_classType >= ValueListClass; }
bool isAspectRatioValue() const { return m_classType == AspectRatioClass; }
bool isBorderImageSliceValue() const { return m_classType == BorderImageSliceClass; }
bool isCursorImageValue() const { return m_classType == CursorImageClass; }
bool isFontFamilyValue() const { return m_classType == FontFamilyClass; }
bool isFontFeatureValue() const { return m_classType == FontFeatureClass; }
bool isFontValue() const { return m_classType == FontClass; }
bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_classType <= RadialGradientClass; }
bool isImageValue() const { return m_classType == ImageClass || m_classType == CursorImageClass; }
bool isImplicitInitialValue() const;
bool isInheritedValue() const { return m_classType == InheritedClass; }
bool isInitialValue() const { return m_classType == InitialClass; }
bool isReflectValue() const { return m_classType == ReflectClass; }
bool isShadowValue() const { return m_classType == ShadowClass; }
bool isTimingFunctionValue() const { return m_classType >= CubicBezierTimingFunctionClass && m_classType <= StepsTimingFunctionClass; }
bool isWebKitCSSTransformValue() const { return m_classType == WebKitCSSTransformClass; }
bool isCSSLineBoxContainValue() const { return m_classType == LineBoxContainClass; }
bool isFlexValue() const { return m_classType == FlexClass; }
#if ENABLE(CSS_FILTERS)
bool isWebKitCSSFilterValue() const { return m_classType == WebKitCSSFilterClass; }
#if ENABLE(CSS_SHADERS)
bool isWebKitCSSShaderValue() const { return m_classType == WebKitCSSShaderClass; }
#endif
#endif // ENABLE(CSS_FILTERS)
#if ENABLE(SVG)
bool isSVGColor() const { return m_classType == SVGColorClass || m_classType == SVGPaintClass; }
bool isSVGPaint() const { return m_classType == SVGPaintClass; }
#endif
void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
protected:
static const size_t ClassTypeBits = 5;
enum ClassType {
// Primitive class types must appear before PrimitiveClass.
ImageClass,
CursorImageClass,
FontFamilyClass,
PrimitiveClass,
// Image generator classes.
CanvasClass,
CrossfadeClass,
LinearGradientClass,
RadialGradientClass,
// Timing function classes.
CubicBezierTimingFunctionClass,
LinearTimingFunctionClass,
StepsTimingFunctionClass,
// Other class types.
AspectRatioClass,
BorderImageSliceClass,
FontFeatureClass,
FontClass,
FontFaceSrcClass,
FunctionClass,
InheritedClass,
InitialClass,
ReflectClass,
ShadowClass,
UnicodeRangeClass,
LineBoxContainClass,
FlexClass,
#if ENABLE(CSS_FILTERS) && ENABLE(CSS_SHADERS)
WebKitCSSShaderClass,
#endif
#if ENABLE(SVG)
SVGColorClass,
SVGPaintClass,
#endif
// List class types must appear after ValueListClass.
ValueListClass,
#if ENABLE(CSS_FILTERS)
WebKitCSSFilterClass,
#endif
WebKitCSSTransformClass,
// Do not append non-list class types here.
};
static const size_t ValueListSeparatorBits = 2;
enum ValueListSeparator {
SpaceSeparator,
CommaSeparator,
SlashSeparator
};
ClassType classType() const { return static_cast<ClassType>(m_classType); }
explicit CSSValue(ClassType classType)
: m_primitiveUnitType(0)
, m_hasCachedCSSText(false)
, m_isQuirkValue(false)
, m_valueListSeparator(SpaceSeparator)
, m_classType(classType)
{
}
// NOTE: This class is non-virtual for memory and performance reasons.
// Don't go making it virtual again unless you know exactly what you're doing!
~CSSValue() { }
private:
void destroy();
protected:
// The bits in this section are only used by specific subclasses but kept here
// to maximize struct packing.
// CSSPrimitiveValue bits:
unsigned char m_primitiveUnitType : 7; // CSSPrimitiveValue::UnitTypes
mutable bool m_hasCachedCSSText : 1;
bool m_isQuirkValue : 1;
unsigned char m_valueListSeparator : ValueListSeparatorBits;
private:
unsigned char m_classType : ClassTypeBits; // ClassType
};
} // namespace WebCore
#endif // CSSValue_h

View File

@@ -0,0 +1,105 @@
/*
* (C) 1999-2003 Lars Knoll (knoll@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef CSSValueList_h
#define CSSValueList_h
#include "CSSValue.h"
#include <wtf/PassRefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class CSSParserValueList;
class CSSValueList : public CSSValue {
public:
static PassRefPtr<CSSValueList> createCommaSeparated()
{
return adoptRef(new CSSValueList(CommaSeparator));
}
static PassRefPtr<CSSValueList> createSpaceSeparated()
{
return adoptRef(new CSSValueList(SpaceSeparator));
}
static PassRefPtr<CSSValueList> createSlashSeparated()
{
return adoptRef(new CSSValueList(SlashSeparator));
}
static PassRefPtr<CSSValueList> createFromParserValueList(CSSParserValueList* list)
{
return adoptRef(new CSSValueList(list));
}
size_t length() const { return m_values.size(); }
CSSValue* item(size_t index) { return index < m_values.size() ? m_values[index].get() : 0; }
CSSValue* itemWithoutBoundsCheck(size_t index) { return m_values[index].get(); }
void append(PassRefPtr<CSSValue>);
void prepend(PassRefPtr<CSSValue>);
bool removeAll(CSSValue*);
bool hasValue(CSSValue*) const;
PassRefPtr<CSSValueList> copy();
String customCssText() const;
void addSubresourceStyleURLs(ListHashSet<KURL>&, const CSSStyleSheet*);
protected:
CSSValueList(ClassType, ValueListSeparator);
private:
explicit CSSValueList(ValueListSeparator);
explicit CSSValueList(CSSParserValueList*);
Vector<RefPtr<CSSValue> > m_values;
};
// Objects of this class are intended to be stack-allocated and scoped to a single function.
// Please take care not to pass these around as they do hold onto a raw pointer.
class CSSValueListInspector {
public:
CSSValueListInspector(CSSValue* value) : m_list((value && value->isValueList()) ? static_cast<CSSValueList*>(value) : 0) { }
CSSValue* item(size_t index) const { ASSERT(index < length()); return m_list->itemWithoutBoundsCheck(index); }
CSSValue* first() const { return item(0); }
CSSValue* second() const { return item(1); }
size_t length() const { return m_list ? m_list->length() : 0; }
private:
CSSValueList* m_list;
};
// Wrapper that can be used to iterate over any CSSValue. Non-list values and 0 behave as zero-length lists.
// Objects of this class are intended to be stack-allocated and scoped to a single function.
// Please take care not to pass these around as they do hold onto a raw pointer.
class CSSValueListIterator {
public:
CSSValueListIterator(CSSValue* value) : m_inspector(value), m_position(0) { }
bool hasMore() const { return m_position < m_inspector.length(); }
CSSValue* value() const { return m_inspector.item(m_position); }
bool isPrimitiveValue() const { return value()->isPrimitiveValue(); }
void advance() { m_position++; ASSERT(m_position <= m_inspector.length());}
size_t index() const { return m_position; }
private:
CSSValueListInspector m_inspector;
size_t m_position;
};
} // namespace WebCore
#endif // CSSValueList_h

View File

@@ -0,0 +1,173 @@
/*
* Copyright 2011 Adobe Systems Incorporated. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef CSSWrapShapes_h
#define CSSWrapShapes_h
#include "CSSPrimitiveValue.h"
#include "PlatformString.h"
#include "WindRule.h"
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class CSSWrapShape : public RefCounted<CSSWrapShape> {
public:
enum Type {
CSS_WRAP_SHAPE_RECT = 1,
CSS_WRAP_SHAPE_CIRCLE = 2,
CSS_WRAP_SHAPE_ELLIPSE = 3,
CSS_WRAP_SHAPE_POLYGON = 4,
CSS_WRAP_SHAPE_PATH = 5
};
virtual Type type() = 0;
virtual String cssText() const = 0;
public:
virtual ~CSSWrapShape() { }
protected:
CSSWrapShape() { }
};
class CSSWrapShapeRect : public CSSWrapShape {
public:
static PassRefPtr<CSSWrapShapeRect> create() { return adoptRef(new CSSWrapShapeRect); }
CSSPrimitiveValue* left() const { return m_left.get(); }
CSSPrimitiveValue* top() const { return m_top.get(); }
CSSPrimitiveValue* width() const { return m_width.get(); }
CSSPrimitiveValue* height() const { return m_height.get(); }
CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
void setWidth(PassRefPtr<CSSPrimitiveValue> width) { m_width = width; }
void setHeight(PassRefPtr<CSSPrimitiveValue> height) { m_height = height; }
void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
virtual Type type() { return CSS_WRAP_SHAPE_RECT; }
virtual String cssText() const;
private:
CSSWrapShapeRect() { }
RefPtr<CSSPrimitiveValue> m_top;
RefPtr<CSSPrimitiveValue> m_left;
RefPtr<CSSPrimitiveValue> m_width;
RefPtr<CSSPrimitiveValue> m_height;
RefPtr<CSSPrimitiveValue> m_radiusX;
RefPtr<CSSPrimitiveValue> m_radiusY;
};
class CSSWrapShapeCircle : public CSSWrapShape {
public:
static PassRefPtr<CSSWrapShapeCircle> create() { return adoptRef(new CSSWrapShapeCircle); }
CSSPrimitiveValue* left() const { return m_left.get(); }
CSSPrimitiveValue* top() const { return m_top.get(); }
CSSPrimitiveValue* radius() const { return m_radius.get(); }
void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; }
virtual Type type() { return CSS_WRAP_SHAPE_CIRCLE; }
virtual String cssText() const;
private:
CSSWrapShapeCircle() { }
RefPtr<CSSPrimitiveValue> m_top;
RefPtr<CSSPrimitiveValue> m_left;
RefPtr<CSSPrimitiveValue> m_radius;
};
class CSSWrapShapeEllipse : public CSSWrapShape {
public:
static PassRefPtr<CSSWrapShapeEllipse> create() { return adoptRef(new CSSWrapShapeEllipse); }
CSSPrimitiveValue* left() const { return m_left.get(); }
CSSPrimitiveValue* top() const { return m_top.get(); }
CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); }
CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); }
void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; }
void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; }
void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX; }
void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY; }
virtual Type type() { return CSS_WRAP_SHAPE_ELLIPSE; }
virtual String cssText() const;
private:
CSSWrapShapeEllipse() { }
RefPtr<CSSPrimitiveValue> m_top;
RefPtr<CSSPrimitiveValue> m_left;
RefPtr<CSSPrimitiveValue> m_radiusX;
RefPtr<CSSPrimitiveValue> m_radiusY;
};
class CSSWrapShapePolygon : public CSSWrapShape {
public:
static PassRefPtr<CSSWrapShapePolygon> create() { return adoptRef(new CSSWrapShapePolygon); }
void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveValue> y)
{
m_values.append(x);
m_values.append(y);
}
PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) { return m_values.at(i * 2); }
PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) { return m_values.at(i * 2 + 1); }
void setWindRule(WindRule w) { m_windRule = w; }
WindRule windRule() const { return m_windRule; }
virtual Type type() { return CSS_WRAP_SHAPE_POLYGON; }
virtual String cssText() const;
private:
CSSWrapShapePolygon()
: m_windRule(RULE_NONZERO)
{
}
Vector<RefPtr<CSSPrimitiveValue> > m_values;
WindRule m_windRule;
};
} // namespace WebCore
#endif // CSSWrapShapes_h

View File

@@ -0,0 +1,41 @@
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CachePolicy_h
#define CachePolicy_h
namespace WebCore {
enum CachePolicy {
CachePolicyCache,
CachePolicyVerify,
CachePolicyRevalidate,
CachePolicyReload,
CachePolicyHistoryBuffer
};
}
#endif

View File

@@ -0,0 +1,100 @@
/*
* Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CachedFrame_h
#define CachedFrame_h
#include "KURL.h"
#include "ScriptCachedFrameData.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class CachedFrame;
class CachedFramePlatformData;
class Document;
class DocumentLoader;
class FrameView;
class Node;
typedef Vector<RefPtr<CachedFrame> > CachedFrameVector;
class CachedFrameBase {
public:
void restore();
Document* document() const { return m_document.get(); }
FrameView* view() const { return m_view.get(); }
const KURL& url() const { return m_url; }
DOMWindow* domWindow() const { return m_cachedFrameScriptData->domWindow(); }
bool isMainFrame() { return m_isMainFrame; }
protected:
CachedFrameBase(Frame*);
~CachedFrameBase();
RefPtr<Document> m_document;
RefPtr<DocumentLoader> m_documentLoader;
RefPtr<FrameView> m_view;
RefPtr<Node> m_mousePressNode;
KURL m_url;
OwnPtr<ScriptCachedFrameData> m_cachedFrameScriptData;
OwnPtr<CachedFramePlatformData> m_cachedFramePlatformData;
bool m_isMainFrame;
#if USE(ACCELERATED_COMPOSITING)
bool m_isComposited;
#endif
CachedFrameVector m_childFrames;
};
class CachedFrame : public RefCounted<CachedFrame>, private CachedFrameBase {
public:
static PassRefPtr<CachedFrame> create(Frame* frame) { return adoptRef(new CachedFrame(frame)); }
void open();
void clear();
void destroy();
void setCachedFramePlatformData(PassOwnPtr<CachedFramePlatformData>);
CachedFramePlatformData* cachedFramePlatformData();
using CachedFrameBase::document;
using CachedFrameBase::view;
using CachedFrameBase::url;
DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
Node* mousePressNode() const { return m_mousePressNode.get(); }
int descendantFrameCount() const;
private:
CachedFrame(Frame*);
};
} // namespace WebCore
#endif // CachedFrame_h

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CachedFramePlatformData_h
#define CachedFramePlatformData_h
namespace WebCore {
// The purpose of this class is to give each platform a vessel to store platform data when a page
// goes into the Back/Forward page cache, and perform some action with that data when the page comes out.
// Each platform should subclass this class as neccessary
class CachedFramePlatformData {
public:
virtual ~CachedFramePlatformData() { }
virtual void clear() { }
};
} // namespace WebCore
#endif // CachedFramePlatformData_h

View File

@@ -0,0 +1,135 @@
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CachedImage_h
#define CachedImage_h
#include "CachedResource.h"
#include "CachedResourceClient.h"
#include "SVGImageCache.h"
#include "ImageObserver.h"
#include "IntRect.h"
#include "Timer.h"
#include <wtf/Vector.h>
namespace WebCore {
class CachedResourceLoader;
class FloatSize;
class MemoryCache;
class RenderObject;
struct Length;
class CachedImage : public CachedResource, public ImageObserver {
friend class MemoryCache;
public:
CachedImage(const ResourceRequest&);
CachedImage(Image*);
virtual ~CachedImage();
virtual void load(CachedResourceLoader*, const ResourceLoaderOptions&);
Image* image(); // Returns the nullImage() if the image is not available yet.
Image* imageForRenderer(const RenderObject*); // Returns the nullImage() if the image is not available yet.
bool hasImage() const { return m_image.get(); }
std::pair<Image*, float> brokenImage(float deviceScaleFactor) const; // Returns an image and the image's resolution scale factor.
bool willPaintBrokenImage() const;
bool canRender(const RenderObject* renderer, float multiplier) { return !errorOccurred() && !imageSizeForRenderer(renderer, multiplier).isEmpty(); }
void setContainerSizeForRenderer(const RenderObject*, const IntSize&, float);
bool usesImageContainerSize() const;
bool imageHasRelativeWidth() const;
bool imageHasRelativeHeight() const;
// This method takes a zoom multiplier that can be used to increase the natural size of the image by the zoom.
IntSize imageSizeForRenderer(const RenderObject*, float multiplier); // returns the size of the complete image.
void computeIntrinsicDimensions(Length& intrinsicWidth, Length& intrinsicHeight, FloatSize& intrinsicRatio);
void removeClientForRenderer(RenderObject*);
virtual void didAddClient(CachedResourceClient*);
virtual void allClientsRemoved();
virtual void destroyDecodedData();
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
virtual void error(CachedResource::Status);
virtual void setResponse(const ResourceResponse&);
// For compatibility, images keep loading even if there are HTTP errors.
virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
virtual bool isImage() const { return true; }
bool stillNeedsLoad() const { return !errorOccurred() && status() == Unknown && !isLoading(); }
void load();
// ImageObserver
virtual void decodedSizeChanged(const Image* image, int delta);
virtual void didDraw(const Image*);
virtual bool shouldPauseAnimation(const Image*);
virtual void animationAdvanced(const Image*);
virtual void changedInRect(const Image*, const IntRect&);
private:
Image* lookupOrCreateImageForRenderer(const RenderObject*);
void clear();
void createImage();
size_t maximumDecodedImageSize();
// If not null, changeRect is the changed part of the image.
void notifyObservers(const IntRect* changeRect = 0);
void decodedDataDeletionTimerFired(Timer<CachedImage>*);
virtual PurgePriority purgePriority() const { return PurgeFirst; }
void checkShouldPaintBrokenImage();
RefPtr<Image> m_image;
#if ENABLE(SVG)
OwnPtr<SVGImageCache> m_svgImageCache;
#endif
Timer<CachedImage> m_decodedDataDeletionTimer;
bool m_shouldPaintBrokenImage;
};
class CachedImageClient : public CachedResourceClient {
public:
virtual ~CachedImageClient() { }
static CachedResourceClientType expectedType() { return ImageType; }
virtual CachedResourceClientType resourceClientType() { return expectedType(); }
// Called whenever a frame of an image changes, either because we got more data from the network or
// because we are animating. If not null, the IntRect is the changed rect of the image.
virtual void imageChanged(CachedImage*, const IntRect* = 0) { }
// Called to find out if this client wants to actually display the image. Used to tell when we
// can halt animation. Content nodes that hold image refs for example would not render the image,
// but RenderImages would (assuming they have visibility: visible and their render tree isn't hidden
// e.g., in the b/f cache or in a background tab).
virtual bool willRenderImage(CachedImage*) { return false; }
};
}
#endif

View File

@@ -0,0 +1,69 @@
/*
* Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CachedPage_h
#define CachedPage_h
#include "CachedFrame.h"
#include <wtf/RefCounted.h>
namespace WebCore {
class Document;
class DocumentLoader;
class Page;
class CachedPage : public RefCounted<CachedPage> {
public:
static PassRefPtr<CachedPage> create(Page*);
~CachedPage();
void restore(Page*);
void clear();
void destroy();
Document* document() const { return m_cachedMainFrame->document(); }
DocumentLoader* documentLoader() const { return m_cachedMainFrame->documentLoader(); }
double timeStamp() const { return m_timeStamp; }
CachedFrame* cachedMainFrame() { return m_cachedMainFrame.get(); }
void markForVistedLinkStyleRecalc() { m_needStyleRecalcForVisitedLinks = true; }
void markForFullStyleRecalc() { m_needsFullStyleRecalc = true; }
private:
CachedPage(Page*);
double m_timeStamp;
RefPtr<CachedFrame> m_cachedMainFrame;
bool m_needStyleRecalcForVisitedLinks;
bool m_needsFullStyleRecalc;
};
} // namespace WebCore
#endif // CachedPage_h

View File

@@ -0,0 +1,329 @@
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CachedResource_h
#define CachedResource_h
#include "CachePolicy.h"
#include "FrameLoaderTypes.h"
#include "PlatformString.h"
#include "PurgePriority.h"
#include "ResourceLoaderOptions.h"
#include "ResourceLoadPriority.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/Vector.h>
#include <time.h>
namespace WebCore {
class MemoryCache;
class CachedMetadata;
class CachedResourceClient;
class CachedResourceHandleBase;
class CachedResourceLoader;
class Frame;
class InspectorResource;
class PurgeableBuffer;
class SecurityOrigin;
class SubresourceLoader;
// A resource that is held in the cache. Classes who want to use this object should derive
// from CachedResourceClient, to get the function calls in case the requested data has arrived.
// This class also does the actual communication with the loader to obtain the resource from the network.
class CachedResource {
WTF_MAKE_NONCOPYABLE(CachedResource); WTF_MAKE_FAST_ALLOCATED;
friend class MemoryCache;
friend class InspectorResource;
public:
enum Type {
ImageResource,
CSSStyleSheet,
Script,
FontResource,
RawResource
#if ENABLE(XSLT)
, XSLStyleSheet
#endif
#if ENABLE(LINK_PREFETCH)
, LinkPrefetch
, LinkPrerender
, LinkSubresource
#endif
#if ENABLE(VIDEO_TRACK)
, TextTrackResource
#endif
#if ENABLE(CSS_SHADERS)
, ShaderResource
#endif
};
enum Status {
Unknown, // let cache decide what to do with it
Pending, // only partially loaded
Cached, // regular case
Canceled,
LoadError,
DecodeError
};
CachedResource(const ResourceRequest&, Type);
virtual ~CachedResource();
virtual void load(CachedResourceLoader*, const ResourceLoaderOptions&);
virtual void setEncoding(const String&) { }
virtual String encoding() const { return String(); }
virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived);
virtual void error(CachedResource::Status);
virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; }
ResourceRequest& resourceRequest() { return m_resourceRequest; }
const KURL& url() const { return m_resourceRequest.url();}
Type type() const { return static_cast<Type>(m_type); }
ResourceLoadPriority loadPriority() const { return m_loadPriority; }
void setLoadPriority(ResourceLoadPriority);
void addClient(CachedResourceClient*);
void removeClient(CachedResourceClient*);
bool hasClients() const { return !m_clients.isEmpty(); }
void deleteIfPossible();
enum PreloadResult {
PreloadNotReferenced,
PreloadReferenced,
PreloadReferencedWhileLoading,
PreloadReferencedWhileComplete
};
PreloadResult preloadResult() const { return static_cast<PreloadResult>(m_preloadResult); }
virtual void didAddClient(CachedResourceClient*);
virtual void allClientsRemoved() { }
unsigned count() const { return m_clients.size(); }
Status status() const { return static_cast<Status>(m_status); }
void setStatus(Status status) { m_status = status; }
unsigned size() const { return encodedSize() + decodedSize() + overheadSize(); }
unsigned encodedSize() const { return m_encodedSize; }
unsigned decodedSize() const { return m_decodedSize; }
unsigned overheadSize() const;
bool isLoaded() const { return !m_loading; } // FIXME. Method name is inaccurate. Loading might not have started yet.
bool isLoading() const { return m_loading; }
void setLoading(bool b) { m_loading = b; }
virtual bool isImage() const { return false; }
bool ignoreForRequestCount() const
{
return false
#if ENABLE(LINK_PREFETCH)
|| type() == LinkPrefetch
|| type() == LinkPrerender
|| type() == LinkSubresource
#endif
|| type() == RawResource;
}
unsigned accessCount() const { return m_accessCount; }
void increaseAccessCount() { m_accessCount++; }
// Computes the status of an object after loading.
// Updates the expire date on the cache entry file
void finish();
bool passesAccessControlCheck(SecurityOrigin*);
// Called by the cache if the object has been removed from the cache
// while still being referenced. This means the object should delete itself
// if the number of clients observing it ever drops to 0.
// The resource can be brought back to cache after successful revalidation.
void setInCache(bool inCache) { m_inCache = inCache; }
bool inCache() const { return m_inCache; }
void setInLiveDecodedResourcesList(bool b) { m_inLiveDecodedResourcesList = b; }
bool inLiveDecodedResourcesList() { return m_inLiveDecodedResourcesList; }
void stopLoading();
SharedBuffer* data() const { ASSERT(!m_purgeableData); return m_data.get(); }
virtual void willSendRequest(ResourceRequest&, const ResourceResponse&) { m_requestedFromNetworkingLayer = true; }
virtual void setResponse(const ResourceResponse&);
const ResourceResponse& response() const { return m_response; }
// Sets the serialized metadata retrieved from the platform's cache.
void setSerializedCachedMetadata(const char*, size_t);
// Caches the given metadata in association with this resource and suggests
// that the platform persist it. The dataTypeID is a pseudo-randomly chosen
// identifier that is used to distinguish data generated by the caller.
void setCachedMetadata(unsigned dataTypeID, const char*, size_t);
// Returns cached metadata of the given type associated with this resource.
CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
bool canDelete() const { return !hasClients() && !m_loader && !m_preloadCount && !m_handleCount && !m_resourceToRevalidate && !m_proxyResource; }
bool hasOneHandle() const { return m_handleCount == 1; }
bool isExpired() const;
// List of acceptable MIME types separated by ",".
// A MIME type may contain a wildcard, e.g. "text/*".
String accept() const { return m_accept; }
void setAccept(const String& accept) { m_accept = accept; }
bool wasCanceled() const { return m_status == Canceled; }
bool errorOccurred() const { return (m_status == LoadError || m_status == DecodeError); }
bool sendResourceLoadCallbacks() const { return m_options.sendLoadCallbacks == SendCallbacks; }
virtual void destroyDecodedData() { }
void setOwningCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_owningCachedResourceLoader = cachedResourceLoader; }
bool isPreloaded() const { return m_preloadCount; }
void increasePreloadCount() { ++m_preloadCount; }
void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; }
void registerHandle(CachedResourceHandleBase* h);
void unregisterHandle(CachedResourceHandleBase* h);
bool canUseCacheValidator() const;
bool mustRevalidateDueToCacheHeaders(CachePolicy) const;
bool isCacheValidator() const { return m_resourceToRevalidate; }
CachedResource* resourceToRevalidate() const { return m_resourceToRevalidate; }
bool isPurgeable() const;
bool wasPurged() const;
// This is used by the archive machinery to get at a purged resource without
// triggering a load. We should make it protected again if we can find a
// better way to handle the archive case.
bool makePurgeable(bool purgeable);
// HTTP revalidation support methods for CachedResourceLoader.
void setResourceToRevalidate(CachedResource*);
void switchClientsToRevalidatedResource();
void clearResourceToRevalidate();
void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse);
virtual void didSendData(unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
#if PLATFORM(CHROMIUM)
virtual void didDownloadData(int) { }
#endif
void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; }
double loadFinishTime() const { return m_loadFinishTime; }
protected:
void checkNotify();
void setEncodedSize(unsigned);
void setDecodedSize(unsigned);
void didAccessDecodedData(double timeStamp);
bool isSafeToMakePurgeable() const;
HashCountedSet<CachedResourceClient*> m_clients;
ResourceRequest m_resourceRequest;
String m_accept;
RefPtr<SubresourceLoader> m_loader;
ResourceLoaderOptions m_options;
ResourceLoadPriority m_loadPriority;
ResourceResponse m_response;
double m_responseTimestamp;
RefPtr<SharedBuffer> m_data;
OwnPtr<PurgeableBuffer> m_purgeableData;
private:
void addClientToSet(CachedResourceClient*);
virtual PurgePriority purgePriority() const { return PurgeDefault; }
double currentAge() const;
double freshnessLifetime() const;
RefPtr<CachedMetadata> m_cachedMetadata;
double m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache
double m_loadFinishTime;
unsigned m_encodedSize;
unsigned m_decodedSize;
unsigned m_accessCount;
unsigned m_handleCount;
unsigned m_preloadCount;
unsigned m_preloadResult : 2; // PreloadResult
bool m_inLiveDecodedResourcesList : 1;
bool m_requestedFromNetworkingLayer : 1;
bool m_inCache : 1;
bool m_loading : 1;
bool m_switchingClientsToRevalidatedResource : 1;
unsigned m_type : 4; // Type
unsigned m_status : 3; // Status
#ifndef NDEBUG
bool m_deleted;
unsigned m_lruIndex;
#endif
CachedResource* m_nextInAllResourcesList;
CachedResource* m_prevInAllResourcesList;
CachedResource* m_nextInLiveResourcesList;
CachedResource* m_prevInLiveResourcesList;
CachedResourceLoader* m_owningCachedResourceLoader; // only non-0 for resources that are not in the cache
// If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
// using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
// to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
// resources becomes normal resource load.
CachedResource* m_resourceToRevalidate;
// If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
CachedResource* m_proxyResource;
// These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
HashSet<CachedResourceHandleBase*> m_handlesToRevalidate;
};
}
#endif

View File

@@ -0,0 +1,57 @@
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#ifndef CachedResourceClient_h
#define CachedResourceClient_h
#include <wtf/FastAllocBase.h>
#include <wtf/Forward.h>
namespace WebCore {
class CachedResource;
class CachedResourceClient {
WTF_MAKE_FAST_ALLOCATED;
public:
enum CachedResourceClientType {
BaseResourceType,
ImageType,
FontType,
StyleSheetType,
RawResourceType
};
virtual ~CachedResourceClient() { }
virtual void notifyFinished(CachedResource*) { }
virtual void didReceiveData(CachedResource*) { };
static CachedResourceClientType expectedType() { return BaseResourceType; }
virtual CachedResourceClientType resourceClientType() { return expectedType(); }
protected:
CachedResourceClient() { }
};
}
#endif

View File

@@ -0,0 +1,92 @@
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CachedResourceHandle_h
#define CachedResourceHandle_h
#include "CachedResource.h"
namespace WebCore {
class CachedResourceHandleBase {
public:
~CachedResourceHandleBase() { if (m_resource) m_resource->unregisterHandle(this); }
CachedResource* get() const { return m_resource; }
bool operator!() const { return !m_resource; }
// This conversion operator allows implicit conversion to bool but not to other integer types.
typedef CachedResource* CachedResourceHandleBase::*UnspecifiedBoolType;
operator UnspecifiedBoolType() const { return m_resource ? &CachedResourceHandleBase::m_resource : 0; }
protected:
CachedResourceHandleBase() : m_resource(0) {}
CachedResourceHandleBase(CachedResource* res) { m_resource = res; if (m_resource) m_resource->registerHandle(this); }
CachedResourceHandleBase(const CachedResourceHandleBase& o) : m_resource(o.m_resource) { if (m_resource) m_resource->registerHandle(this); }
void setResource(CachedResource*);
private:
CachedResourceHandleBase& operator=(const CachedResourceHandleBase&) { return *this; }
friend class CachedResource;
CachedResource* m_resource;
};
template <class R> class CachedResourceHandle : public CachedResourceHandleBase {
public:
CachedResourceHandle() { }
CachedResourceHandle(R* res) : CachedResourceHandleBase(res) { }
CachedResourceHandle(const CachedResourceHandle<R>& o) : CachedResourceHandleBase(o) { }
R* get() const { return reinterpret_cast<R*>(CachedResourceHandleBase::get()); }
R* operator->() const { return get(); }
CachedResourceHandle& operator=(R* res) { setResource(res); return *this; }
CachedResourceHandle& operator=(const CachedResourceHandle& o) { setResource(o.get()); return *this; }
bool operator==(const CachedResourceHandleBase& o) const { return get() == o.get(); }
bool operator!=(const CachedResourceHandleBase& o) const { return get() != o.get(); }
};
template <class R, class RR> bool operator==(const CachedResourceHandle<R>& h, const RR* res)
{
return h.get() == res;
}
template <class R, class RR> bool operator==(const RR* res, const CachedResourceHandle<R>& h)
{
return h.get() == res;
}
template <class R, class RR> bool operator!=(const CachedResourceHandle<R>& h, const RR* res)
{
return h.get() != res;
}
template <class R, class RR> bool operator!=(const RR* res, const CachedResourceHandle<R>& h)
{
return h.get() != res;
}
}
#endif

View File

@@ -0,0 +1,181 @@
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#ifndef CachedResourceLoader_h
#define CachedResourceLoader_h
#include "CachedResource.h"
#include "CachedResourceHandle.h"
#include "CachePolicy.h"
#include "ResourceLoadPriority.h"
#include "Timer.h"
#include <wtf/Deque.h>
#include <wtf/HashMap.h>
#include <wtf/HashSet.h>
#include <wtf/ListHashSet.h>
#include <wtf/text/StringHash.h>
namespace WebCore {
class CachedCSSStyleSheet;
class CachedFont;
class CachedImage;
class CachedRawResource;
class CachedScript;
class CachedShader;
class CachedTextTrack;
class CachedXSLStyleSheet;
class Document;
class Frame;
class ImageLoader;
class KURL;
// The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document.
class CachedResourceLoader {
WTF_MAKE_NONCOPYABLE(CachedResourceLoader); WTF_MAKE_FAST_ALLOCATED;
friend class ImageLoader;
friend class ResourceCacheValidationSuppressor;
public:
CachedResourceLoader(Document*);
~CachedResourceLoader();
CachedImage* requestImage(ResourceRequest&);
CachedCSSStyleSheet* requestCSSStyleSheet(ResourceRequest&, const String& charset, ResourceLoadPriority = ResourceLoadPriorityUnresolved);
CachedCSSStyleSheet* requestUserCSSStyleSheet(ResourceRequest&, const String& charset);
CachedScript* requestScript(ResourceRequest&, const String& charset);
CachedFont* requestFont(ResourceRequest&);
CachedRawResource* requestRawResource(ResourceRequest&, const ResourceLoaderOptions&);
#if ENABLE(XSLT)
CachedXSLStyleSheet* requestXSLStyleSheet(ResourceRequest&);
#endif
#if ENABLE(LINK_PREFETCH)
CachedResource* requestLinkResource(CachedResource::Type, ResourceRequest&, ResourceLoadPriority = ResourceLoadPriorityUnresolved);
#endif
#if ENABLE(VIDEO_TRACK)
CachedTextTrack* requestTextTrack(ResourceRequest&);
#endif
#if ENABLE(CSS_SHADERS)
CachedShader* requestShader(ResourceRequest&);
#endif
// Logs an access denied message to the console for the specified URL.
void printAccessDeniedMessage(const KURL& url) const;
CachedResource* cachedResource(const String& url) const;
CachedResource* cachedResource(const KURL& url) const;
typedef HashMap<String, CachedResourceHandle<CachedResource> > DocumentResourceMap;
const DocumentResourceMap& allCachedResources() const { return m_documentResources; }
bool autoLoadImages() const { return m_autoLoadImages; }
void setAutoLoadImages(bool);
CachePolicy cachePolicy() const;
Frame* frame() const; // Can be NULL
Document* document() const { return m_document; }
void removeCachedResource(CachedResource*) const;
void loadFinishing() { m_loadFinishing = true; }
void loadDone();
void incrementRequestCount(const CachedResource*);
void decrementRequestCount(const CachedResource*);
int requestCount();
bool isPreloaded(const String& urlString) const;
void clearPreloads();
void clearPendingPreloads();
void preload(CachedResource::Type, ResourceRequest&, const String& charset, bool referencedFromBody);
void checkForPendingPreloads();
void printPreloadStats();
bool canRequest(CachedResource::Type, const KURL&, bool forPreload = false);
private:
CachedResource* requestResource(CachedResource::Type, ResourceRequest&, const String& charset, const ResourceLoaderOptions&, ResourceLoadPriority = ResourceLoadPriorityUnresolved, bool isPreload = false);
CachedResource* revalidateResource(CachedResource*, ResourceLoadPriority, const ResourceLoaderOptions&);
CachedResource* loadResource(CachedResource::Type, ResourceRequest&, const String& charset, ResourceLoadPriority, const ResourceLoaderOptions&);
void requestPreload(CachedResource::Type, ResourceRequest&, const String& charset);
enum RevalidationPolicy { Use, Revalidate, Reload, Load };
RevalidationPolicy determineRevalidationPolicy(CachedResource::Type, ResourceRequest&, bool forPreload, CachedResource* existingResource) const;
void notifyLoadedFromMemoryCache(CachedResource*);
bool checkInsecureContent(CachedResource::Type, const KURL&) const;
void garbageCollectDocumentResourcesTimerFired(Timer<CachedResourceLoader>*);
void performPostLoadActions();
HashSet<String> m_validatedURLs;
mutable DocumentResourceMap m_documentResources;
Document* m_document;
int m_requestCount;
OwnPtr<ListHashSet<CachedResource*> > m_preloads;
struct PendingPreload {
CachedResource::Type m_type;
ResourceRequest m_request;
String m_charset;
};
Deque<PendingPreload> m_pendingPreloads;
Timer<CachedResourceLoader> m_garbageCollectDocumentResourcesTimer;
//29 bits left
bool m_autoLoadImages : 1;
bool m_loadFinishing : 1;
bool m_allowStaleResources : 1;
};
class ResourceCacheValidationSuppressor {
WTF_MAKE_NONCOPYABLE(ResourceCacheValidationSuppressor);
WTF_MAKE_FAST_ALLOCATED;
public:
ResourceCacheValidationSuppressor(CachedResourceLoader* loader)
: m_loader(loader)
, m_previousState(false)
{
if (m_loader) {
m_previousState = m_loader->m_allowStaleResources;
m_loader->m_allowStaleResources = true;
}
}
~ResourceCacheValidationSuppressor()
{
if (m_loader)
m_loader->m_allowStaleResources = m_previousState;
}
private:
CachedResourceLoader* m_loader;
bool m_previousState;
};
} // namespace WebCore
#endif

View File

@@ -0,0 +1,45 @@
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
Copyright (C) 2011 Google Inc. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
This class provides all functionality needed for loading images, style sheets and html
pages from the web. It has a memory cache for these objects.
*/
#ifndef CachedStyleSheetClient_h
#define CachedStyleSheetClient_h
#include "CachedResourceClient.h"
#include <wtf/Forward.h>
namespace WebCore {
class CachedCSSStyleSheet;
class CachedStyleSheetClient : public CachedResourceClient {
public:
virtual ~CachedStyleSheetClient() { }
static CachedResourceClientType expectedType() { return StyleSheetType; }
virtual CachedResourceClientType resourceClientType() { return expectedType(); }
virtual void setCSSStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* charset */, const CachedCSSStyleSheet*) { }
virtual void setXSLStyleSheet(const String& /* href */, const KURL& /* baseURL */, const String& /* sheet */) { }
};
}
#endif // CachedStyleSheetClient_h

View File

@@ -0,0 +1,82 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CharacterData_h
#define CharacterData_h
#include "Node.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
class CharacterData : public Node {
public:
String data() const { return m_data; }
void setData(const String&, ExceptionCode&);
unsigned length() const { return m_data.length(); }
String substringData(unsigned offset, unsigned count, ExceptionCode&);
void appendData(const String&, ExceptionCode&);
void insertData(unsigned offset, const String&, ExceptionCode&);
void deleteData(unsigned offset, unsigned count, ExceptionCode&);
void replaceData(unsigned offset, unsigned count, const String&, ExceptionCode&);
bool containsOnlyWhitespace() const;
StringImpl* dataImpl() { return m_data.impl(); }
// Like appendData, but optimized for the parser (e.g., no mutation events).
// Returns how much could be added before length limit was met.
unsigned parserAppendData(const UChar*, unsigned dataLength, unsigned lengthLimit);
protected:
CharacterData(Document* document, const String& text, ConstructionType type)
: Node(document, type)
, m_data(!text.isNull() ? text : emptyString())
{
ASSERT(type == CreateComment || type == CreateText);
}
virtual bool rendererIsNeeded(const NodeRenderingContext&);
void setDataWithoutUpdate(const String& data)
{
ASSERT(!data.isNull());
m_data = data;
}
void dispatchModifiedEvent(const String& oldValue);
private:
virtual String nodeValue() const;
virtual void setNodeValue(const String&, ExceptionCode&);
virtual bool isCharacterDataNode() const { return true; }
virtual int maxCharacterOffset() const;
virtual bool offsetInCharacters() const;
void setDataAndUpdate(const String&, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength);
void updateRenderer(unsigned offsetOfReplacedData, unsigned lengthOfReplacedData);
void checkCharDataOperation(unsigned offset, ExceptionCode&);
String m_data;
};
} // namespace WebCore
#endif // CharacterData_h

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace WebCore {
#define kTextEncodingISOLatinThai kCFStringEncodingISOLatinThai
struct CharsetEntry {
const char* name;
::TextEncoding encoding;
};
extern const CharsetEntry CharsetTable[];
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CheckedRadioButtons_h
#define CheckedRadioButtons_h
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
namespace WebCore {
class HTMLInputElement;
class RadioButtonGroup;
// FIXME: Rename the class. The class was a simple map from a name to a checked
// radio button. It manages RadioButtonGroup objects now.
class CheckedRadioButtons {
public:
CheckedRadioButtons();
~CheckedRadioButtons();
void addButton(HTMLInputElement*);
void updateCheckedState(HTMLInputElement*);
void requiredAttributeChanged(HTMLInputElement*);
void removeButton(HTMLInputElement*);
HTMLInputElement* checkedButtonForGroup(const AtomicString& groupName) const;
bool isInRequiredGroup(HTMLInputElement*) const;
private:
typedef HashMap<AtomicStringImpl*, OwnPtr<RadioButtonGroup> > NameToGroupMap;
OwnPtr<NameToGroupMap> m_nameToGroupMap;
};
} // namespace WebCore
#endif // CheckedRadioButtons_h

View File

@@ -0,0 +1,193 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef Chrome_h
#define Chrome_h
#include "Cursor.h"
#include "FocusDirection.h"
#include "HostWindow.h"
#include <wtf/Forward.h>
#include <wtf/RefPtr.h>
#if PLATFORM(MAC)
#ifndef __OBJC__
class NSView;
#endif
#endif
namespace WebCore {
class ChromeClient;
#if ENABLE(INPUT_COLOR)
class ColorChooser;
class ColorChooserClient;
#endif
class FileChooser;
class FileIconLoader;
class FloatRect;
class Frame;
class Geolocation;
class HitTestResult;
class IntRect;
class NavigationAction;
class Node;
class Page;
class PopupMenu;
class PopupMenuClient;
class SearchPopupMenu;
struct FrameLoadRequest;
struct ViewportArguments;
struct WindowFeatures;
class Chrome : public HostWindow {
public:
~Chrome();
static PassOwnPtr<Chrome> create(Page*, ChromeClient*);
ChromeClient* client() { return m_client; }
// HostWindow methods.
virtual void invalidateRootView(const IntRect&, bool) OVERRIDE;
virtual void invalidateContentsAndRootView(const IntRect&, bool) OVERRIDE;
virtual void invalidateContentsForSlowScroll(const IntRect&, bool);
virtual void scroll(const IntSize&, const IntRect&, const IntRect&);
#if USE(TILED_BACKING_STORE)
virtual void delegatedScrollRequested(const IntPoint& scrollPoint);
#endif
virtual IntPoint screenToRootView(const IntPoint&) const OVERRIDE;
virtual IntRect rootViewToScreen(const IntRect&) const OVERRIDE;
virtual PlatformPageClient platformPageClient() const;
virtual void scrollbarsModeDidChange() const;
virtual void setCursor(const Cursor&);
virtual void setCursorHiddenUntilMouseMoves(bool);
#if ENABLE(REQUEST_ANIMATION_FRAME)
virtual void scheduleAnimation();
#endif
void scrollRectIntoView(const IntRect&) const;
void contentsSizeChanged(Frame*, const IntSize&) const;
void layoutUpdated(Frame*) const;
void setWindowRect(const FloatRect&) const;
FloatRect windowRect() const;
FloatRect pageRect() const;
void focus() const;
void unfocus() const;
bool canTakeFocus(FocusDirection) const;
void takeFocus(FocusDirection) const;
void focusedNodeChanged(Node*) const;
void focusedFrameChanged(Frame*) const;
Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) const;
void show() const;
bool canRunModal() const;
bool canRunModalNow() const;
void runModal() const;
void setToolbarsVisible(bool) const;
bool toolbarsVisible() const;
void setStatusbarVisible(bool) const;
bool statusbarVisible() const;
void setScrollbarsVisible(bool) const;
bool scrollbarsVisible() const;
void setMenubarVisible(bool) const;
bool menubarVisible() const;
void setResizable(bool) const;
bool canRunBeforeUnloadConfirmPanel();
bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame);
void closeWindowSoon();
void runJavaScriptAlert(Frame*, const String&);
bool runJavaScriptConfirm(Frame*, const String&);
bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result);
void setStatusbarText(Frame*, const String&);
bool shouldInterruptJavaScript();
#if ENABLE(REGISTER_PROTOCOL_HANDLER)
void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title);
#endif
IntRect windowResizerRect() const;
void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
void setToolTip(const HitTestResult&);
void print(Frame*);
// FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
// For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
void requestGeolocationPermissionForFrame(Frame*, Geolocation*);
void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*);
#if ENABLE(INPUT_COLOR)
PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color& initialColor);
#endif
void runOpenPanel(Frame*, PassRefPtr<FileChooser>);
void loadIconForFiles(const Vector<String>&, FileIconLoader*);
#if ENABLE(DIRECTORY_UPLOAD)
void enumerateChosenDirectory(FileChooser*);
#endif
void dispatchViewportPropertiesDidChange(const ViewportArguments&) const;
bool requiresFullscreenForVideoPlayback();
#if PLATFORM(MAC)
void focusNSView(NSView*);
#endif
bool selectItemWritingDirectionIsNatural();
bool selectItemAlignmentFollowsMenuWritingDirection();
bool hasOpenedPopup() const;
PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const;
PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const;
#if ENABLE(CONTEXT_MENUS)
void showContextMenu();
#endif
private:
Chrome(Page*, ChromeClient*);
Page* m_page;
ChromeClient* m_client;
};
}
#endif // Chrome_h

View File

@@ -0,0 +1,337 @@
/*
* Copyright (C) 2006, 2007, 2008, 2009 Apple, Inc. All rights reserved.
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef ChromeClient_h
#define ChromeClient_h
#include "AXObjectCache.h"
#include "ConsoleTypes.h"
#include "Cursor.h"
#include "FocusDirection.h"
#include "FrameLoader.h"
#include "GraphicsContext.h"
#include "HostWindow.h"
#include "PopupMenu.h"
#include "PopupMenuClient.h"
#include "ScrollTypes.h"
#include "SearchPopupMenu.h"
#include "WebCoreKeyboardUIMode.h"
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/UnusedParam.h>
#include <wtf/Vector.h>
#ifndef __OBJC__
class NSMenu;
class NSResponder;
#endif
namespace WebCore {
class AccessibilityObject;
class Element;
class FileChooser;
class FileIconLoader;
class FloatRect;
class Frame;
class Geolocation;
class GraphicsLayer;
class HitTestResult;
class IntRect;
class NavigationAction;
class Node;
class Page;
class PopupMenuClient;
class SecurityOrigin;
class GraphicsContext3D;
class Widget;
struct FrameLoadRequest;
struct ViewportArguments;
struct WindowFeatures;
#if USE(ACCELERATED_COMPOSITING)
class GraphicsLayer;
#endif
#if ENABLE(INPUT_COLOR)
class ColorChooser;
class ColorChooserClient;
#endif
class ChromeClient {
public:
virtual void chromeDestroyed() = 0;
virtual void setWindowRect(const FloatRect&) = 0;
virtual FloatRect windowRect() = 0;
virtual FloatRect pageRect() = 0;
virtual void focus() = 0;
virtual void unfocus() = 0;
virtual bool canTakeFocus(FocusDirection) = 0;
virtual void takeFocus(FocusDirection) = 0;
virtual void focusedNodeChanged(Node*) = 0;
virtual void focusedFrameChanged(Frame*) = 0;
// The Frame pointer provides the ChromeClient with context about which
// Frame wants to create the new Page. Also, the newly created window
// should not be shown to the user until the ChromeClient of the newly
// created Page has its show method called.
// The FrameLoadRequest parameter is only for ChromeClient to check if the
// request could be fulfilled. The ChromeClient should not load the request.
virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) = 0;
virtual void show() = 0;
virtual bool canRunModal() = 0;
virtual void runModal() = 0;
virtual void setToolbarsVisible(bool) = 0;
virtual bool toolbarsVisible() = 0;
virtual void setStatusbarVisible(bool) = 0;
virtual bool statusbarVisible() = 0;
virtual void setScrollbarsVisible(bool) = 0;
virtual bool scrollbarsVisible() = 0;
virtual void setMenubarVisible(bool) = 0;
virtual bool menubarVisible() = 0;
virtual void setResizable(bool) = 0;
virtual void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, unsigned int lineNumber, const String& sourceID) = 0;
virtual bool canRunBeforeUnloadConfirmPanel() = 0;
virtual bool runBeforeUnloadConfirmPanel(const String& message, Frame* frame) = 0;
virtual void closeWindowSoon() = 0;
virtual void runJavaScriptAlert(Frame*, const String&) = 0;
virtual bool runJavaScriptConfirm(Frame*, const String&) = 0;
virtual bool runJavaScriptPrompt(Frame*, const String& message, const String& defaultValue, String& result) = 0;
virtual void setStatusbarText(const String&) = 0;
virtual bool shouldInterruptJavaScript() = 0;
virtual KeyboardUIMode keyboardUIMode() = 0;
virtual void* webView() const = 0;
#if ENABLE(REGISTER_PROTOCOL_HANDLER)
virtual void registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) = 0;
#endif
virtual IntRect windowResizerRect() const = 0;
// Methods used by HostWindow.
virtual void invalidateRootView(const IntRect&, bool) = 0;
virtual void invalidateContentsAndRootView(const IntRect&, bool) = 0;
virtual void invalidateContentsForSlowScroll(const IntRect&, bool) = 0;
virtual void scroll(const IntSize&, const IntRect&, const IntRect&) = 0;
#if USE(TILED_BACKING_STORE)
virtual void delegatedScrollRequested(const IntPoint&) = 0;
#endif
virtual IntPoint screenToRootView(const IntPoint&) const = 0;
virtual IntRect rootViewToScreen(const IntRect&) const = 0;
virtual PlatformPageClient platformPageClient() const = 0;
virtual void scrollbarsModeDidChange() const = 0;
virtual void setCursor(const Cursor&) = 0;
virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
#if ENABLE(REQUEST_ANIMATION_FRAME) && !USE(REQUEST_ANIMATION_FRAME_TIMER)
virtual void scheduleAnimation() = 0;
#endif
// End methods used by HostWindow.
virtual void dispatchViewportPropertiesDidChange(const ViewportArguments&) const { }
virtual void contentsSizeChanged(Frame*, const IntSize&) const = 0;
virtual void layoutUpdated(Frame*) const { }
virtual void scrollRectIntoView(const IntRect&) const { }; // Currently only Mac has a non empty implementation.
virtual bool shouldMissingPluginMessageBeButton() const { return false; }
virtual void missingPluginButtonClicked(Element*) const { }
virtual void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags) = 0;
virtual void setToolTip(const String&, TextDirection) = 0;
virtual void print(Frame*) = 0;
virtual bool shouldRubberBandInDirection(ScrollDirection) const = 0;
#if ENABLE(SQL_DATABASE)
virtual void exceededDatabaseQuota(Frame*, const String& databaseName) = 0;
#endif
// Callback invoked when the application cache fails to save a cache object
// because storing it would grow the database file past its defined maximum
// size or past the amount of free space on the device.
// The chrome client would need to take some action such as evicting some
// old caches.
virtual void reachedMaxAppCacheSize(int64_t spaceNeeded) = 0;
// Callback invoked when the application cache origin quota is reached. This
// means that the resources attempting to be cached via the manifest are
// more than allowed on this origin. This callback allows the chrome client
// to take action, such as prompting the user to ask to increase the quota
// for this origin. The totalSpaceNeeded parameter is the total amount of
// storage, in bytes, needed to store the new cache along with all of the
// other existing caches for the origin that would not be replaced by
// the new cache.
virtual void reachedApplicationCacheOriginQuota(SecurityOrigin*, int64_t totalSpaceNeeded) = 0;
#if ENABLE(DASHBOARD_SUPPORT)
virtual void dashboardRegionsChanged();
#endif
virtual void populateVisitedLinks();
virtual FloatRect customHighlightRect(Node*, const AtomicString& type, const FloatRect& lineRect);
virtual void paintCustomHighlight(Node*, const AtomicString& type, const FloatRect& boxRect, const FloatRect& lineRect,
bool behindText, bool entireLine);
virtual bool shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename);
virtual String generateReplacementFile(const String& path);
virtual bool paintCustomOverhangArea(GraphicsContext*, const IntRect&, const IntRect&, const IntRect&);
// FIXME: Remove once all ports are using client-based geolocation. https://bugs.webkit.org/show_bug.cgi?id=40373
// For client-based geolocation, these two methods have moved to GeolocationClient. https://bugs.webkit.org/show_bug.cgi?id=50061
// This can be either a synchronous or asynchronous call. The ChromeClient can display UI asking the user for permission
// to use Geolocation.
virtual void requestGeolocationPermissionForFrame(Frame*, Geolocation*) = 0;
virtual void cancelGeolocationPermissionRequestForFrame(Frame*, Geolocation*) = 0;
#if ENABLE(INPUT_COLOR)
virtual PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color&) = 0;
#endif
virtual void runOpenPanel(Frame*, PassRefPtr<FileChooser>) = 0;
// Asynchronous request to load an icon for specified filenames.
virtual void loadIconForFiles(const Vector<String>&, FileIconLoader*) = 0;
#if ENABLE(DIRECTORY_UPLOAD)
// Asychronous request to enumerate all files in a directory chosen by the user.
virtual void enumerateChosenDirectory(FileChooser*) = 0;
#endif
// Notification that the given form element has changed. This function
// will be called frequently, so handling should be very fast.
virtual void formStateDidChange(const Node*) = 0;
virtual void elementDidFocus(const Node*) { };
virtual void elementDidBlur(const Node*) { };
#if USE(ACCELERATED_COMPOSITING)
// Pass 0 as the GraphicsLayer to detatch the root layer.
virtual void attachRootGraphicsLayer(Frame*, GraphicsLayer*) = 0;
// Sets a flag to specify that the next time content is drawn to the window,
// the changes appear on the screen in synchrony with updates to GraphicsLayers.
virtual void setNeedsOneShotDrawingSynchronization() = 0;
// Sets a flag to specify that the view needs to be updated, so we need
// to do an eager layout before the drawing.
virtual void scheduleCompositingLayerSync() = 0;
// Returns whether or not the client can render the composited layer,
// regardless of the settings.
virtual bool allowsAcceleratedCompositing() const { return true; }
enum CompositingTrigger {
ThreeDTransformTrigger = 1 << 0,
VideoTrigger = 1 << 1,
PluginTrigger = 1 << 2,
CanvasTrigger = 1 << 3,
AnimationTrigger = 1 << 4,
FilterTrigger = 1 << 5,
AllTriggers = 0xFFFFFFFF
};
typedef unsigned CompositingTriggerFlags;
// Returns a bitfield indicating conditions that can trigger the compositor.
virtual CompositingTriggerFlags allowedCompositingTriggers() const { return static_cast<CompositingTriggerFlags>(AllTriggers); }
#endif
virtual bool supportsFullscreenForNode(const Node*) { return false; }
virtual void enterFullscreenForNode(Node*) { }
virtual void exitFullscreenForNode(Node*) { }
virtual bool requiresFullscreenForVideoPlayback() { return false; }
#if ENABLE(FULLSCREEN_API)
virtual bool supportsFullScreenForElement(const Element*, bool) { return false; }
virtual void enterFullScreenForElement(Element*) { }
virtual void exitFullScreenForElement(Element*) { }
virtual void fullScreenRendererChanged(RenderBox*) { }
virtual void setRootFullScreenLayer(GraphicsLayer*) { }
#endif
#if USE(TILED_BACKING_STORE)
virtual IntRect visibleRectForTiledBackingStore() const { return IntRect(); }
#endif
#if PLATFORM(MAC)
virtual NSResponder *firstResponder() { return 0; }
virtual void makeFirstResponder(NSResponder *) { }
// Focuses on the containing view associated with this page.
virtual void makeFirstResponder() { }
virtual void willPopUpMenu(NSMenu *) { }
#endif
#if PLATFORM(WIN)
virtual void setLastSetCursorToCurrentCursor() = 0;
#endif
#if ENABLE(TOUCH_EVENTS)
virtual void needTouchEvents(bool) = 0;
#endif
virtual bool selectItemWritingDirectionIsNatural() = 0;
virtual bool selectItemAlignmentFollowsMenuWritingDirection() = 0;
// Checks if there is an opened popup, called by RenderMenuList::showPopup().
virtual bool hasOpenedPopup() const = 0;
virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const = 0;
virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const = 0;
#if ENABLE(CONTEXT_MENUS)
virtual void showContextMenu() = 0;
#endif
virtual void postAccessibilityNotification(AccessibilityObject*, AXObjectCache::AXNotification) { }
virtual void notifyScrollerThumbIsVisibleInRect(const IntRect&) { }
virtual void recommendedScrollbarStyleDidChange(int /*newStyle*/) { }
enum DialogType {
AlertDialog = 0,
ConfirmDialog = 1,
PromptDialog = 2,
HTMLDialog = 3
};
virtual bool shouldRunModalDialogDuringPageDismissal(const DialogType&, const String& dialogMessage, FrameLoader::PageDismissalType) const { UNUSED_PARAM(dialogMessage); return true; }
virtual void numWheelEventHandlersChanged(unsigned) = 0;
virtual bool isSVGImageChromeClient() const { return false; }
protected:
virtual ~ChromeClient() { }
};
}
#endif // ChromeClient_h

View File

@@ -0,0 +1,130 @@
/*
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
* Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
* Copyright (C) 2003, 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef Clipboard_h
#define Clipboard_h
#include "CachedResourceHandle.h"
#include "ClipboardAccessPolicy.h"
#include "DragActions.h"
#include "DragImage.h"
#include "IntPoint.h"
#include "Node.h"
namespace WebCore {
class DataTransferItemList;
class DragData;
class FileList;
class Frame;
// State available during IE's events for drag and drop and copy/paste
class Clipboard : public RefCounted<Clipboard> {
public:
// Whether this clipboard is serving a drag-drop or copy-paste request.
enum ClipboardType {
CopyAndPaste,
DragAndDrop,
};
static PassRefPtr<Clipboard> create(ClipboardAccessPolicy, DragData*, Frame*);
virtual ~Clipboard() { }
bool isForCopyAndPaste() const { return m_clipboardType == CopyAndPaste; }
bool isForDragAndDrop() const { return m_clipboardType == DragAndDrop; }
String dropEffect() const { return dropEffectIsUninitialized() ? "none" : m_dropEffect; }
void setDropEffect(const String&);
bool dropEffectIsUninitialized() const { return m_dropEffect == "uninitialized"; }
String effectAllowed() const { return m_effectAllowed; }
void setEffectAllowed(const String&);
virtual void clearData(const String& type) = 0;
virtual void clearAllData() = 0;
virtual String getData(const String& type, bool& success) const = 0;
virtual bool setData(const String& type, const String& data) = 0;
// extensions beyond IE's API
virtual HashSet<String> types() const = 0;
virtual PassRefPtr<FileList> files() const = 0;
LayoutPoint dragLocation() const { return m_dragLoc; }
CachedImage* dragImage() const { return m_dragImage.get(); }
virtual void setDragImage(CachedImage*, const LayoutPoint&) = 0;
Node* dragImageElement() const { return m_dragImageElement.get(); }
virtual void setDragImageElement(Node*, const LayoutPoint&) = 0;
virtual DragImageRef createDragImage(LayoutPoint& dragLocation) const = 0;
#if ENABLE(DRAG_SUPPORT)
virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*) = 0;
#endif
virtual void writeURL(const KURL&, const String&, Frame*) = 0;
virtual void writeRange(Range*, Frame*) = 0;
virtual void writePlainText(const String&) = 0;
virtual bool hasData() = 0;
void setAccessPolicy(ClipboardAccessPolicy);
ClipboardAccessPolicy policy() const { return m_policy; }
DragOperation sourceOperation() const;
DragOperation destinationOperation() const;
void setSourceOperation(DragOperation);
void setDestinationOperation(DragOperation);
bool hasDropZoneType(const String&);
void setDragHasStarted() { m_dragStarted = true; }
#if ENABLE(DATA_TRANSFER_ITEMS)
virtual PassRefPtr<DataTransferItemList> items() = 0;
#endif
protected:
Clipboard(ClipboardAccessPolicy, ClipboardType);
bool dragStarted() const { return m_dragStarted; }
private:
bool hasFileOfType(const String&) const;
bool hasStringOfType(const String&) const;
ClipboardAccessPolicy m_policy;
String m_dropEffect;
String m_effectAllowed;
bool m_dragStarted;
ClipboardType m_clipboardType;
protected:
LayoutPoint m_dragLoc;
CachedResourceHandle<CachedImage> m_dragImage;
RefPtr<Node> m_dragImageElement;
};
DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation);
String convertDragOperationToDropZoneOperation(DragOperation);
} // namespace WebCore
#endif // Clipboard_h

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ClipboardAccessPolicy_h
#define ClipboardAccessPolicy_h
namespace WebCore {
enum ClipboardAccessPolicy {
ClipboardNumb, ClipboardImageWritable, ClipboardWritable, ClipboardTypesReadable, ClipboardReadable
};
} // namespace
#endif

View File

@@ -0,0 +1,89 @@
/*
* Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ClipboardMac_h
#define ClipboardMac_h
#include "CachedImage.h"
#include "Clipboard.h"
#include <wtf/RetainPtr.h>
OBJC_CLASS NSImage;
OBJC_CLASS NSPasteboard;
namespace WebCore {
class Frame;
class FileList;
class ClipboardMac : public Clipboard, public CachedImageClient {
WTF_MAKE_FAST_ALLOCATED;
public:
static PassRefPtr<ClipboardMac> create(ClipboardType clipboardType, NSPasteboard *pasteboard, ClipboardAccessPolicy policy, Frame* frame)
{
return adoptRef(new ClipboardMac(clipboardType, pasteboard, policy, frame));
}
virtual ~ClipboardMac();
void clearData(const String& type);
void clearAllData();
String getData(const String& type, bool& success) const;
bool setData(const String& type, const String& data);
virtual bool hasData();
// extensions beyond IE's API
virtual HashSet<String> types() const;
virtual PassRefPtr<FileList> files() const;
void setDragImage(CachedImage*, const IntPoint&);
void setDragImageElement(Node *, const IntPoint&);
virtual DragImageRef createDragImage(IntPoint& dragLoc) const;
#if ENABLE(DRAG_SUPPORT)
virtual void declareAndWriteDragImage(Element*, const KURL&, const String& title, Frame*);
#endif
virtual void writeRange(Range*, Frame* frame);
virtual void writeURL(const KURL&, const String&, Frame* frame);
virtual void writePlainText(const String&);
// Methods for getting info in Cocoa's type system
NSImage *dragNSImage(NSPoint&) const; // loc converted from dragLoc, based on whole image size
NSPasteboard *pasteboard() { return m_pasteboard.get(); }
private:
ClipboardMac(ClipboardType, NSPasteboard *, ClipboardAccessPolicy, Frame*);
void setDragImage(CachedImage*, Node*, const IntPoint&);
RetainPtr<NSPasteboard> m_pasteboard;
int m_changeCount;
Frame* m_frame; // used on the source side to generate dragging images
};
}
#endif

View File

@@ -0,0 +1,645 @@
#
# WebKit IDL parser
#
# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
# Copyright (C) Research In Motion Limited 2010. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with this library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
package CodeGenerator;
use strict;
use File::Find;
my $useDocument = "";
my $useGenerator = "";
my $useOutputDir = "";
my $useOutputHeadersDir = "";
my $useDirectories = "";
my $useLayerOnTop = 0;
my $preprocessor;
my $writeDependencies = 0;
my $defines = "";
my $codeGenerator = 0;
my $verbose = 0;
my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,
"unsigned int" => 1, "unsigned short" => 1,
"unsigned long" => 1, "unsigned long long" => 1,
"float" => 1, "double" => 1);
my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1);
my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1);
my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1);
my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1,
"SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1,
"SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1,
"SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1,
"SVGAnimatedPreserveAspectRatio" => 1,
"SVGAnimatedRect" => 1, "SVGAnimatedString" => 1,
"SVGAnimatedTransformList" => 1);
my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick" => 1,
"onerror" => 1, "onload" => 1, "onmousedown" => 1,
"onmousemove" => 1, "onmouseout" => 1, "onmouseover" => 1,
"onmouseup" => 1, "onresize" => 1, "onscroll" => 1,
"onunload" => 1);
my %svgTypeNeedingTearOff = (
"SVGAngle" => "SVGPropertyTearOff<SVGAngle>",
"SVGLength" => "SVGPropertyTearOff<SVGLength>",
"SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>",
"SVGMatrix" => "SVGPropertyTearOff<SVGMatrix>",
"SVGNumber" => "SVGPropertyTearOff<float>",
"SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>",
"SVGPathSegList" => "SVGPathSegListPropertyTearOff",
"SVGPoint" => "SVGPropertyTearOff<FloatPoint>",
"SVGPointList" => "SVGListPropertyTearOff<SVGPointList>",
"SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>",
"SVGRect" => "SVGPropertyTearOff<FloatRect>",
"SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>",
"SVGTransform" => "SVGPropertyTearOff<SVGTransform>",
"SVGTransformList" => "SVGTransformListPropertyTearOff"
);
my %svgTypeWithWritablePropertiesNeedingTearOff = (
"SVGPoint" => 1,
"SVGMatrix" => 1
);
# Cache of IDL file pathnames.
my $idlFiles;
# Default constructor
sub new
{
my $object = shift;
my $reference = { };
$useDirectories = shift;
$useGenerator = shift;
$useOutputDir = shift;
$useOutputHeadersDir = shift;
$useLayerOnTop = shift;
$preprocessor = shift;
$writeDependencies = shift;
$verbose = shift;
bless($reference, $object);
return $reference;
}
sub StripModule($)
{
my $object = shift;
my $name = shift;
$name =~ s/[a-zA-Z0-9]*:://;
return $name;
}
sub ProcessDocument
{
my $object = shift;
$useDocument = shift;
$defines = shift;
my $ifaceName = "CodeGenerator" . $useGenerator;
require $ifaceName . ".pm";
# Dynamically load external code generation perl module
$codeGenerator = $ifaceName->new($object, $useOutputDir, $useOutputHeadersDir, $useLayerOnTop, $preprocessor, $writeDependencies, $verbose);
unless (defined($codeGenerator)) {
my $classes = $useDocument->classes;
foreach my $class (@$classes) {
print "Skipping $useGenerator code generation for IDL interface \"" . $class->name . "\".\n" if $verbose;
}
return;
}
# Start the actual code generation!
$codeGenerator->GenerateModule($useDocument, $defines);
my $classes = $useDocument->classes;
foreach my $class (@$classes) {
print "Generating $useGenerator bindings code for IDL interface \"" . $class->name . "\"...\n" if $verbose;
$codeGenerator->GenerateInterface($class, $defines);
}
}
sub FileNamePrefix
{
my $object = shift;
my $ifaceName = "CodeGenerator" . $useGenerator;
require $ifaceName . ".pm";
# Dynamically load external code generation perl module
$codeGenerator = $ifaceName->new($object, $useOutputDir, $useOutputHeadersDir, $useLayerOnTop, $preprocessor, $writeDependencies, $verbose);
return $codeGenerator->FileNamePrefix();
}
sub UpdateFile
{
my $object = shift;
my $fileName = shift;
my $contents = shift;
open FH, "> $fileName" or die "Couldn't open $fileName: $!\n";
print FH $contents;
close FH;
}
sub ForAllParents
{
my $object = shift;
my $dataNode = shift;
my $beforeRecursion = shift;
my $afterRecursion = shift;
my $parentsOnly = shift;
my $recurse;
$recurse = sub {
my $interface = shift;
for (@{$interface->parents}) {
my $interfaceName = $object->StripModule($_);
my $parentInterface = $object->ParseInterface($interfaceName, $parentsOnly);
if ($beforeRecursion) {
&$beforeRecursion($parentInterface) eq 'prune' and next;
}
&$recurse($parentInterface);
&$afterRecursion($parentInterface) if $afterRecursion;
}
};
&$recurse($dataNode);
}
sub AddMethodsConstantsAndAttributesFromParentClasses
{
# Add to $dataNode all of its inherited interface members, except for those
# inherited through $dataNode's first listed parent. If an array reference
# is passed in as $parents, the names of all ancestor interfaces visited
# will be appended to the array. If $collectDirectParents is true, then
# even the names of $dataNode's first listed parent and its ancestors will
# be appended to $parents.
my $object = shift;
my $dataNode = shift;
my $parents = shift;
my $collectDirectParents = shift;
my $first = 1;
$object->ForAllParents($dataNode, sub {
my $interface = shift;
if ($first) {
# Ignore first parent class, already handled by the generation itself.
$first = 0;
if ($collectDirectParents) {
# Just collect the names of the direct ancestor interfaces,
# if necessary.
push(@$parents, $interface->name);
$object->ForAllParents($interface, sub {
my $interface = shift;
push(@$parents, $interface->name);
}, undef, 1);
}
# Prune the recursion here.
return 'prune';
}
# Collect the name of this additional parent.
push(@$parents, $interface->name) if $parents;
print " | |> -> Inheriting "
. @{$interface->constants} . " constants, "
. @{$interface->functions} . " functions, "
. @{$interface->attributes} . " attributes...\n | |>\n" if $verbose;
# Add this parent's members to $dataNode.
push(@{$dataNode->constants}, @{$interface->constants});
push(@{$dataNode->functions}, @{$interface->functions});
push(@{$dataNode->attributes}, @{$interface->attributes});
});
}
sub GetMethodsAndAttributesFromParentClasses
{
# For the passed interface, recursively parse all parent
# IDLs in order to find out all inherited properties/methods.
my $object = shift;
my $dataNode = shift;
my @parentList = ();
$object->ForAllParents($dataNode, undef, sub {
my $interface = shift;
my $hash = {
"name" => $interface->name,
"functions" => $interface->functions,
"attributes" => $interface->attributes
};
unshift(@parentList, $hash);
});
return @parentList;
}
sub FindSuperMethod
{
my ($object, $dataNode, $functionName) = @_;
my $indexer;
$object->ForAllParents($dataNode, undef, sub {
my $interface = shift;
foreach my $function (@{$interface->functions}) {
if ($function->signature->name eq $functionName) {
$indexer = $function->signature;
return 'prune';
}
}
});
return $indexer;
}
sub IDLFileForInterface
{
my $object = shift;
my $interfaceName = shift;
unless ($idlFiles) {
my $sourceRoot = $ENV{SOURCE_ROOT};
my @directories = map { $_ = "$sourceRoot/$_" if $sourceRoot && -d "$sourceRoot/$_"; $_ } @$useDirectories;
$idlFiles = { };
my $wanted = sub {
$idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/;
$File::Find::prune = 1 if /^\../;
};
find($wanted, @directories);
}
return $idlFiles->{$interfaceName};
}
sub ParseInterface
{
my $object = shift;
my $interfaceName = shift;
my $parentsOnly = shift;
return undef if $interfaceName eq 'Object';
# Step #1: Find the IDL file associated with 'interface'
my $filename = $object->IDLFileForInterface($interfaceName)
or die("Could NOT find IDL file for interface \"$interfaceName\"!\n");
print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceName\"\n" if $verbose;
# Step #2: Parse the found IDL file (in quiet mode).
my $parser = IDLParser->new(1);
my $document = $parser->Parse($filename, $defines, $preprocessor, $parentsOnly);
foreach my $interface (@{$document->classes}) {
return $interface if $interface->name eq $interfaceName;
}
die("Could NOT find interface definition for $interfaceName in $filename");
}
# Helpers for all CodeGenerator***.pm modules
sub AvoidInclusionOfType
{
my $object = shift;
my $type = shift;
# Special case: SVGPoint.h / SVGNumber.h do not exist.
return 1 if $type eq "SVGPoint" or $type eq "SVGNumber";
return 0;
}
sub IsNumericType
{
my $object = shift;
my $type = shift;
return 1 if $numericTypeHash{$type};
return 0;
}
sub IsPrimitiveType
{
my $object = shift;
my $type = shift;
return 1 if $primitiveTypeHash{$type};
return 1 if $numericTypeHash{$type};
return 0;
}
sub IsStringType
{
my $object = shift;
my $type = shift;
return 1 if $stringTypeHash{$type};
return 0;
}
sub IsNonPointerType
{
my $object = shift;
my $type = shift;
return 1 if $nonPointerTypeHash{$type} or $primitiveTypeHash{$type} or $numericTypeHash{$type};
return 0;
}
sub IsSVGTypeNeedingTearOff
{
my $object = shift;
my $type = shift;
return 1 if exists $svgTypeNeedingTearOff{$type};
return 0;
}
sub IsSVGTypeWithWritablePropertiesNeedingTearOff
{
my $object = shift;
my $type = shift;
return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type};
return 0;
}
sub GetSVGTypeNeedingTearOff
{
my $object = shift;
my $type = shift;
return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type};
return undef;
}
sub GetSVGWrappedTypeNeedingTearOff
{
my $object = shift;
my $type = shift;
my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type);
return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff;
if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) {
$svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//;
} elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) {
$svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//;
} elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) {
$svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//;
} elsif ($svgTypeNeedingTearOff =~ /SVGTransformListPropertyTearOff/) {
$svgTypeNeedingTearOff =~ s/SVGTransformListPropertyTearOff<//;
}
$svgTypeNeedingTearOff =~ s/>//;
return $svgTypeNeedingTearOff;
}
sub IsSVGAnimatedType
{
my $object = shift;
my $type = shift;
return 1 if $svgAnimatedTypeHash{$type};
return 0;
}
# Uppercase the first letter while respecting WebKit style guidelines.
# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
sub WK_ucfirst
{
my ($object, $param) = @_;
my $ret = ucfirst($param);
$ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
return $ret;
}
# Lowercase the first letter while respecting WebKit style guidelines.
# URL becomes url, but SetURL becomes setURL.
sub WK_lcfirst
{
my ($object, $param) = @_;
my $ret = lcfirst($param);
$ret =~ s/hTML/html/ if $ret =~ /^hTML/;
$ret =~ s/uRL/url/ if $ret =~ /^uRL/;
$ret =~ s/jS/js/ if $ret =~ /^jS/;
$ret =~ s/xML/xml/ if $ret =~ /^xML/;
$ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/;
# For HTML5 FileSystem API Flags attributes.
# (create is widely used to instantiate an object and must be avoided.)
$ret =~ s/^create/isCreate/ if $ret =~ /^create$/;
$ret =~ s/^exclusive/isExclusive/ if $ret =~ /^exclusive$/;
return $ret;
}
# Return the C++ namespace that a given attribute name string is defined in.
sub NamespaceForAttributeName
{
my ($object, $interfaceName, $attributeName) = @_;
return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName};
return "HTMLNames";
}
# Identifies overloaded functions and for each function adds an array with
# links to its respective overloads (including itself).
sub LinkOverloadedFunctions
{
my ($object, $dataNode) = @_;
my %nameToFunctionsMap = ();
foreach my $function (@{$dataNode->functions}) {
my $name = $function->signature->name;
$nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name};
push(@{$nameToFunctionsMap{$name}}, $function);
$function->{overloads} = $nameToFunctionsMap{$name};
$function->{overloadIndex} = @{$nameToFunctionsMap{$name}};
}
}
sub AttributeNameForGetterAndSetter
{
my ($generator, $attribute) = @_;
my $attributeName = $attribute->signature->name;
my $attributeType = $generator->StripModule($attribute->signature->type);
# Avoid clash with C++ keyword.
$attributeName = "_operator" if $attributeName eq "operator";
# SVGAElement defines a non-virtual "String& target() const" method which clashes with "virtual String target() const" in Element.
# To solve this issue the SVGAElement method was renamed to "svgTarget", take care of that when calling this method.
$attributeName = "svgTarget" if $attributeName eq "target" and $attributeType eq "SVGAnimatedString";
# SVG animated types need to use a special attribute name.
# The rest of the special casing for SVG animated types is handled in the language-specific code generators.
$attributeName .= "Animated" if $generator->IsSVGAnimatedType($attributeType);
return $attributeName;
}
sub ContentAttributeName
{
my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
my $contentAttributeName = $attribute->signature->extendedAttributes->{"Reflect"};
return undef if !$contentAttributeName;
$contentAttributeName = lc $generator->AttributeNameForGetterAndSetter($attribute) if $contentAttributeName eq "1";
my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
$implIncludes->{"${namespace}.h"} = 1;
return "WebCore::${namespace}::${contentAttributeName}Attr";
}
sub GetterExpression
{
my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
if (!$contentAttributeName) {
return ($generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)));
}
my $functionName;
if ($attribute->signature->extendedAttributes->{"URL"}) {
if ($attribute->signature->extendedAttributes->{"NonEmpty"}) {
$functionName = "getNonEmptyURLAttribute";
} else {
$functionName = "getURLAttribute";
}
} elsif ($attribute->signature->type eq "boolean") {
$functionName = "hasAttribute";
} elsif ($attribute->signature->type eq "long") {
$functionName = "getIntegralAttribute";
} elsif ($attribute->signature->type eq "unsigned long") {
$functionName = "getUnsignedIntegralAttribute";
} else {
$functionName = "getAttribute";
}
return ($functionName, $contentAttributeName);
}
sub SetterExpression
{
my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
if (!$contentAttributeName) {
return ("set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)));
}
my $functionName;
if ($attribute->signature->type eq "boolean") {
$functionName = "setBooleanAttribute";
} elsif ($attribute->signature->type eq "long") {
$functionName = "setIntegralAttribute";
} elsif ($attribute->signature->type eq "unsigned long") {
$functionName = "setUnsignedIntegralAttribute";
} else {
$functionName = "setAttribute";
}
return ($functionName, $contentAttributeName);
}
sub ShouldCheckEnums
{
my $dataNode = shift;
return not $dataNode->extendedAttributes->{"DontCheckEnums"};
}
sub GenerateConditionalStringFromAttributeValue
{
my $generator = shift;
my $conditional = shift;
my $operator = ($conditional =~ /&/ ? '&' : ($conditional =~ /\|/ ? '|' : ''));
if ($operator) {
# Avoid duplicated conditions.
my %conditions;
map { $conditions{$_} = 1 } split('\\' . $operator, $conditional);
return "ENABLE(" . join(") $operator$operator ENABLE(", sort keys %conditions) . ")";
} else {
return "ENABLE(" . $conditional . ")";
}
}
sub GenerateCompileTimeCheckForEnumsIfNeeded
{
my ($generator, $dataNode) = @_;
my $interfaceName = $dataNode->name;
my @checks = ();
# If necessary, check that all constants are available as enums with the same value.
if (ShouldCheckEnums($dataNode) && @{$dataNode->constants}) {
push(@checks, "\n");
foreach my $constant (@{$dataNode->constants}) {
my $reflect = $constant->extendedAttributes->{"Reflect"};
my $name = $reflect ? $reflect : $constant->name;
my $value = $constant->value;
my $conditional = $constant->extendedAttributes->{"Conditional"};
if ($conditional) {
my $conditionalString = $generator->GenerateConditionalStringFromAttributeValue($conditional);
push(@checks, "#if ${conditionalString}\n");
}
push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name, ${interfaceName}Enum${name}IsWrongUseDontCheckEnums);\n");
if ($conditional) {
push(@checks, "#endif\n");
}
}
push(@checks, "\n");
}
return @checks;
}
1;

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CollapsedBorderValue_h
#define CollapsedBorderValue_h
#include "BorderValue.h"
namespace WebCore {
class CollapsedBorderValue {
public:
CollapsedBorderValue()
: m_precedence(BOFF)
{
}
CollapsedBorderValue(const BorderValue& b, Color c, EBorderPrecedence p)
: m_border(b)
, m_borderColor(c)
, m_precedence(p)
{
}
int width() const { return m_border.nonZero() ? m_border.width() : 0; }
EBorderStyle style() const { return m_border.style(); }
bool exists() const { return m_precedence != BOFF; }
const Color& color() const { return m_borderColor; }
bool isTransparent() const { return m_border.isTransparent(); }
EBorderPrecedence precedence() const { return m_precedence; }
bool isSameIgnoringColor(const CollapsedBorderValue& o) const
{
return m_border.width() == o.m_border.width() && m_border.style() == o.m_border.style() && m_precedence == o.m_precedence;
}
private:
BorderValue m_border;
Color m_borderColor;
EBorderPrecedence m_precedence;
};
} // namespace WebCore
#endif // CollapsedBorderValue_h

View File

@@ -0,0 +1,72 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef CollectionType_h
#define CollectionType_h
namespace WebCore {
enum CollectionType {
// unnamed collection types cached in the document
DocImages, // all <img> elements in the document
DocApplets, // all <object> and <applet> elements
DocEmbeds, // all <embed> elements
DocObjects, // all <object> elements
DocForms, // all <form> elements
DocLinks, // all <a> _and_ <area> elements with a value for href
DocAnchors, // all <a> elements with a value for name
DocScripts, // all <script> elements
DocAll, // "all" elements (IE)
// named collection types cached in the document
WindowNamedItems,
DocumentNamedItems,
// types not cached in the document; these are types that can't be used on a document
NodeChildren, // first-level children (IE)
TableTBodies, // all <tbody> elements in this table
TSectionRows, // all row elements in this table section
TRCells, // all cells in this row
SelectOptions,
DataListOptions,
MapAreas,
#if ENABLE(MICRODATA)
ItemProperties, // Microdata item properties in the document
#endif
OtherCollection
};
static const CollectionType FirstUnnamedDocumentCachedType = DocImages;
static const unsigned NumUnnamedDocumentCachedTypes = WindowNamedItems - DocImages + 1;
static const CollectionType FirstNodeCollectionType = NodeChildren;
static const unsigned NumNodeCollectionTypes = OtherCollection - NodeChildren + 1;
} // namespace
#endif

View File

@@ -0,0 +1,208 @@
/*
* Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Color_h
#define Color_h
#include "AnimationUtilities.h"
#include <wtf/FastAllocBase.h>
#include <wtf/Forward.h>
#include <wtf/unicode/Unicode.h>
#if USE(CG)
#include "ColorSpace.h"
typedef struct CGColor* CGColorRef;
#endif
#if PLATFORM(QT)
#include <qglobal.h>
QT_BEGIN_NAMESPACE
class QColor;
QT_END_NAMESPACE
#endif
#if PLATFORM(GTK)
typedef struct _GdkColor GdkColor;
#ifndef GTK_API_VERSION_2
typedef struct _GdkRGBA GdkRGBA;
#endif
#endif
#if PLATFORM(WX)
class wxColour;
#endif
namespace WebCore {
class Color;
typedef unsigned RGBA32; // RGBA quadruplet
RGBA32 makeRGB(int r, int g, int b);
RGBA32 makeRGBA(int r, int g, int b, int a);
RGBA32 colorWithOverrideAlpha(RGBA32 color, float overrideAlpha);
RGBA32 makeRGBA32FromFloats(float r, float g, float b, float a);
RGBA32 makeRGBAFromHSLA(double h, double s, double l, double a);
RGBA32 makeRGBAFromCMYKA(float c, float m, float y, float k, float a);
int differenceSquared(const Color&, const Color&);
inline int redChannel(RGBA32 color) { return (color >> 16) & 0xFF; }
inline int greenChannel(RGBA32 color) { return (color >> 8) & 0xFF; }
inline int blueChannel(RGBA32 color) { return color & 0xFF; }
inline int alphaChannel(RGBA32 color) { return (color >> 24) & 0xFF; }
class Color {
WTF_MAKE_FAST_ALLOCATED;
public:
Color() : m_color(0), m_valid(false) { }
Color(RGBA32 col) : m_color(col), m_valid(true) { }
Color(int r, int g, int b) : m_color(makeRGB(r, g, b)), m_valid(true) { }
Color(int r, int g, int b, int a) : m_color(makeRGBA(r, g, b, a)), m_valid(true) { }
// Color is currently limited to 32bit RGBA, perhaps some day we'll support better colors
Color(float r, float g, float b, float a) : m_color(makeRGBA32FromFloats(r, g, b, a)), m_valid(true) { }
// Creates a new color from the specific CMYK and alpha values.
Color(float c, float m, float y, float k, float a) : m_color(makeRGBAFromCMYKA(c, m, y, k, a)), m_valid(true) { }
explicit Color(const String&);
explicit Color(const char*);
// Returns the color serialized according to HTML5
// - http://www.whatwg.org/specs/web-apps/current-work/#serialization-of-a-color
String serialized() const;
// Returns the color serialized as either #RRGGBB or #RRGGBBAA
// The latter format is not a valid CSS color, and should only be seen in DRT dumps.
String nameForRenderTreeAsText() const;
void setNamedColor(const String&);
bool isValid() const { return m_valid; }
bool hasAlpha() const { return alpha() < 255; }
int red() const { return redChannel(m_color); }
int green() const { return greenChannel(m_color); }
int blue() const { return blueChannel(m_color); }
int alpha() const { return alphaChannel(m_color); }
RGBA32 rgb() const { return m_color; } // Preserve the alpha.
void setRGB(int r, int g, int b) { m_color = makeRGB(r, g, b); m_valid = true; }
void setRGB(RGBA32 rgb) { m_color = rgb; m_valid = true; }
void getRGBA(float& r, float& g, float& b, float& a) const;
void getRGBA(double& r, double& g, double& b, double& a) const;
void getHSL(double& h, double& s, double& l) const;
Color light() const;
Color dark() const;
// This is an implementation of Porter-Duff's "source-over" equation
Color blend(const Color&) const;
Color blendWithWhite() const;
#if PLATFORM(QT)
Color(const QColor&);
operator QColor() const;
#endif
#if PLATFORM(GTK)
Color(const GdkColor&);
// We can't sensibly go back to GdkColor without losing the alpha value
#ifndef GTK_API_VERSION_2
Color(const GdkRGBA&);
operator GdkRGBA() const;
#endif
#endif
#if PLATFORM(WX)
Color(const wxColour&);
operator wxColour() const;
#endif
#if USE(CG)
Color(CGColorRef);
#endif
static bool parseHexColor(const String& name, RGBA32& rgb);
static bool parseHexColor(const UChar* name, unsigned length, RGBA32& rgb);
static const RGBA32 black = 0xFF000000;
static const RGBA32 white = 0xFFFFFFFF;
static const RGBA32 darkGray = 0xFF808080;
static const RGBA32 gray = 0xFFA0A0A0;
static const RGBA32 lightGray = 0xFFC0C0C0;
static const RGBA32 transparent = 0x00000000;
private:
RGBA32 m_color;
bool m_valid;
};
inline bool operator==(const Color& a, const Color& b)
{
return a.rgb() == b.rgb() && a.isValid() == b.isValid();
}
inline bool operator!=(const Color& a, const Color& b)
{
return !(a == b);
}
Color colorFromPremultipliedARGB(unsigned);
unsigned premultipliedARGBFromColor(const Color&);
inline Color blend(const Color& from, const Color& to, double progress, bool blendPremultiplied = true)
{
// We need to preserve the state of the valid flag at the end of the animation
if (progress == 1 && !to.isValid())
return Color();
if (blendPremultiplied) {
// Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor().
// Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that.
Color premultFrom = from.alpha() ? premultipliedARGBFromColor(from) : 0;
Color premultTo = to.alpha() ? premultipliedARGBFromColor(to) : 0;
Color premultBlended(blend(premultFrom.red(), premultTo.red(), progress),
blend(premultFrom.green(), premultTo.green(), progress),
blend(premultFrom.blue(), premultTo.blue(), progress),
blend(premultFrom.alpha(), premultTo.alpha(), progress));
return Color(colorFromPremultipliedARGB(premultBlended.rgb()));
}
return Color(blend(from.red(), to.red(), progress),
blend(from.green(), to.green(), progress),
blend(from.blue(), to.blue(), progress),
blend(from.alpha(), to.alpha(), progress));
}
#if USE(CG)
CGColorRef cachedCGColor(const Color&, ColorSpace);
#endif
} // namespace WebCore
#endif // Color_h

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef ColorChooser_h
#define ColorChooser_h
#if ENABLE(INPUT_COLOR)
namespace WebCore {
class Color;
class ColorChooser {
public:
virtual ~ColorChooser() { }
virtual void setSelectedColor(const Color&) { }
virtual void endChooser() { }
};
} // namespace WebCore
#endif // ENABLE(INPUT_COLOR)
#endif // ColorChooser_h

View File

@@ -0,0 +1,24 @@
#ifndef ColorChooserClient_h
#define ColorChooserClient_h
#if ENABLE(INPUT_COLOR)
#include "ColorChooser.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class Color;
class ColorChooserClient {
public:
virtual void didChooseColor(const Color&) = 0;
virtual void didEndChooser() = 0;
};
} // namespace WebCore
#endif // ENABLE(INPUT_COLOR)
#endif // ColorChooserClient_h

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ColorMac_h
#define ColorMac_h
#include "Color.h"
OBJC_CLASS NSColor;
namespace WebCore {
// These functions assume NSColors are in DeviceRGB colorspace
Color colorFromNSColor(NSColor *);
NSColor *nsColor(const Color&);
bool usesTestModeFocusRingColor();
void setUsesTestModeFocusRingColor(bool);
// Focus ring color used for testing purposes.
RGBA32 oldAquaFocusRingColor();
}
#endif

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2009 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ColorSpace_h
#define ColorSpace_h
namespace WebCore {
enum ColorSpace {
ColorSpaceDeviceRGB,
ColorSpaceSRGB,
ColorSpaceLinearRGB
};
} // namespace WebCore
#endif // ColorSpace_h

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ColumnInfo_h
#define ColumnInfo_h
#include "LayoutTypes.h"
#include <wtf/Vector.h>
namespace WebCore {
class ColumnInfo {
WTF_MAKE_NONCOPYABLE(ColumnInfo); WTF_MAKE_FAST_ALLOCATED;
public:
ColumnInfo()
: m_desiredColumnWidth(0)
, m_desiredColumnCount(1)
, m_progressionAxis(InlineAxis)
, m_columnCount(1)
, m_columnHeight(0)
, m_minimumColumnHeight(0)
, m_forcedBreaks(0)
, m_maximumDistanceBetweenForcedBreaks(0)
, m_forcedBreakOffset(0)
{
}
LayoutUnit desiredColumnWidth() const { return m_desiredColumnWidth; }
void setDesiredColumnWidth(LayoutUnit width) { m_desiredColumnWidth = width; }
unsigned desiredColumnCount() const { return m_desiredColumnCount; }
void setDesiredColumnCount(unsigned count) { m_desiredColumnCount = count; }
enum Axis { InlineAxis, BlockAxis };
Axis progressionAxis() const { return m_progressionAxis; }
void setProgressionAxis(Axis progressionAxis) { m_progressionAxis = progressionAxis; }
unsigned columnCount() const { return m_columnCount; }
LayoutUnit columnHeight() const { return m_columnHeight; }
// Set our count and height. This is enough info for a RenderBlock to compute page rects
// dynamically.
void setColumnCountAndHeight(int count, LayoutUnit height)
{
m_columnCount = count;
m_columnHeight = height;
}
void setColumnHeight(LayoutUnit height) { m_columnHeight = height; }
void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
int forcedBreaks() const { return m_forcedBreaks; }
int forcedBreakOffset() const { return m_forcedBreakOffset; }
int maximumDistanceBetweenForcedBreaks() const { return m_maximumDistanceBetweenForcedBreaks; }
void clearForcedBreaks()
{
m_forcedBreaks = 0;
m_maximumDistanceBetweenForcedBreaks = 0;
m_forcedBreakOffset = 0;
}
void addForcedBreak(int offsetFromFirstPage)
{
ASSERT(!m_columnHeight);
int distanceFromLastBreak = offsetFromFirstPage - m_forcedBreakOffset;
if (!distanceFromLastBreak)
return;
m_forcedBreaks++;
m_maximumDistanceBetweenForcedBreaks = std::max(m_maximumDistanceBetweenForcedBreaks, distanceFromLastBreak);
m_forcedBreakOffset = offsetFromFirstPage;
}
private:
LayoutUnit m_desiredColumnWidth;
unsigned m_desiredColumnCount;
Axis m_progressionAxis;
unsigned m_columnCount;
LayoutUnit m_columnHeight;
LayoutUnit m_minimumColumnHeight;
int m_forcedBreaks; // FIXME: We will ultimately need to cache more information to balance around forced breaks properly.
int m_maximumDistanceBetweenForcedBreaks;
int m_forcedBreakOffset;
};
}
#endif

View File

@@ -0,0 +1,186 @@
/*
* Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CompositeEditCommand_h
#define CompositeEditCommand_h
#include "EditCommand.h"
#include "CSSPropertyNames.h"
#include "UndoStep.h"
#include <wtf/Vector.h>
namespace WebCore {
class EditingStyle;
class HTMLElement;
class StyledElement;
class Text;
class EditCommandComposition : public UndoStep {
public:
static PassRefPtr<EditCommandComposition> create(Document*, const VisibleSelection&, const VisibleSelection&, EditAction);
virtual void unapply() OVERRIDE;
virtual void reapply() OVERRIDE;
EditAction editingAction() const OVERRIDE { return m_editAction; }
void append(SimpleEditCommand*);
bool wasCreateLinkCommand() const { return m_editAction == EditActionCreateLink; }
const VisibleSelection& startingSelection() const { return m_startingSelection; }
const VisibleSelection& endingSelection() const { return m_endingSelection; }
void setStartingSelection(const VisibleSelection&);
void setEndingSelection(const VisibleSelection&);
Element* startingRootEditableElement() const { return m_startingRootEditableElement.get(); }
Element* endingRootEditableElement() const { return m_endingRootEditableElement.get(); }
#ifndef NDEBUG
virtual void getNodesInCommand(HashSet<Node*>&);
#endif
private:
EditCommandComposition(Document*, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction);
RefPtr<Document> m_document;
VisibleSelection m_startingSelection;
VisibleSelection m_endingSelection;
Vector<RefPtr<SimpleEditCommand> > m_commands;
RefPtr<Element> m_startingRootEditableElement;
RefPtr<Element> m_endingRootEditableElement;
EditAction m_editAction;
};
class CompositeEditCommand : public EditCommand {
public:
virtual ~CompositeEditCommand();
void apply();
bool isFirstCommand(EditCommand* command) { return !m_commands.isEmpty() && m_commands.first() == command; }
EditCommandComposition* composition() { return m_composition.get(); }
EditCommandComposition* ensureComposition();
virtual bool isCreateLinkCommand() const;
virtual bool isTypingCommand() const;
virtual bool preservesTypingStyle() const;
virtual bool shouldRetainAutocorrectionIndicator() const;
virtual void setShouldRetainAutocorrectionIndicator(bool);
virtual bool shouldStopCaretBlinking() const { return false; }
protected:
explicit CompositeEditCommand(Document*);
//
// sugary-sweet convenience functions to help create and apply edit commands in composite commands
//
void appendNode(PassRefPtr<Node>, PassRefPtr<ContainerNode> parent);
void applyCommandToComposite(PassRefPtr<EditCommand>);
void applyCommandToComposite(PassRefPtr<CompositeEditCommand>, const VisibleSelection&);
void applyStyle(const EditingStyle*, EditAction = EditActionChangeAttributes);
void applyStyle(const EditingStyle*, const Position& start, const Position& end, EditAction = EditActionChangeAttributes);
void applyStyledElement(PassRefPtr<Element>);
void removeStyledElement(PassRefPtr<Element>);
void deleteSelection(bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
void deleteSelection(const VisibleSelection&, bool smartDelete = false, bool mergeBlocksAfterDelete = true, bool replace = false, bool expandForSpecialElements = true);
virtual void deleteTextFromNode(PassRefPtr<Text>, unsigned offset, unsigned count);
bool isRemovableBlock(const Node*);
void insertNodeAfter(PassRefPtr<Node>, PassRefPtr<Node> refChild);
void insertNodeAt(PassRefPtr<Node>, const Position&);
void insertNodeAtTabSpanPosition(PassRefPtr<Node>, const Position&);
void insertNodeBefore(PassRefPtr<Node>, PassRefPtr<Node> refChild);
void insertParagraphSeparator(bool useDefaultParagraphElement = false);
void insertLineBreak();
void insertTextIntoNode(PassRefPtr<Text>, unsigned offset, const String& text);
void mergeIdenticalElements(PassRefPtr<Element>, PassRefPtr<Element>);
void rebalanceWhitespace();
void rebalanceWhitespaceAt(const Position&);
void rebalanceWhitespaceOnTextSubstring(PassRefPtr<Text>, int startOffset, int endOffset);
void prepareWhitespaceAtPositionForSplit(Position&);
bool canRebalance(const Position&) const;
bool shouldRebalanceLeadingWhitespaceFor(const String&) const;
void removeCSSProperty(PassRefPtr<StyledElement>, CSSPropertyID);
void removeNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute);
void removeChildrenInRange(PassRefPtr<Node>, unsigned from, unsigned to);
virtual void removeNode(PassRefPtr<Node>);
HTMLElement* replaceElementWithSpanPreservingChildrenAndAttributes(PassRefPtr<HTMLElement>);
void removeNodePreservingChildren(PassRefPtr<Node>);
void removeNodeAndPruneAncestors(PassRefPtr<Node>);
void prune(PassRefPtr<Node>);
void replaceTextInNode(PassRefPtr<Text>, unsigned offset, unsigned count, const String& replacementText);
Position replaceSelectedTextInNode(const String&);
void replaceTextInNodePreservingMarkers(PassRefPtr<Text>, unsigned offset, unsigned count, const String& replacementText);
Position positionOutsideTabSpan(const Position&);
void setNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute, const AtomicString& value);
void splitElement(PassRefPtr<Element>, PassRefPtr<Node> atChild);
void splitTextNode(PassRefPtr<Text>, unsigned offset);
void splitTextNodeContainingElement(PassRefPtr<Text>, unsigned offset);
void wrapContentsInDummySpan(PassRefPtr<Element>);
void deleteInsignificantText(PassRefPtr<Text>, unsigned start, unsigned end);
void deleteInsignificantText(const Position& start, const Position& end);
void deleteInsignificantTextDownstream(const Position&);
PassRefPtr<Node> appendBlockPlaceholder(PassRefPtr<Element>);
PassRefPtr<Node> insertBlockPlaceholder(const Position&);
PassRefPtr<Node> addBlockPlaceholderIfNeeded(Element*);
void removePlaceholderAt(const Position&);
PassRefPtr<Node> insertNewDefaultParagraphElementAt(const Position&);
PassRefPtr<Node> moveParagraphContentsToNewBlockIfNecessary(const Position&);
void pushAnchorElementDown(Node*);
void moveParagraph(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true);
void moveParagraphs(const VisiblePosition&, const VisiblePosition&, const VisiblePosition&, bool preserveSelection = false, bool preserveStyle = true);
void moveParagraphWithClones(const VisiblePosition& startOfParagraphToMove, const VisiblePosition& endOfParagraphToMove, Element* blockElement, Node* outerNode);
void cloneParagraphUnderNewElement(Position& start, Position& end, Node* outerNode, Element* blockElement);
void cleanupAfterDeletion(VisiblePosition destination = VisiblePosition());
bool breakOutOfEmptyListItem();
bool breakOutOfEmptyMailBlockquotedParagraph();
Position positionAvoidingSpecialElementBoundary(const Position&);
PassRefPtr<Node> splitTreeToNode(Node*, Node*, bool splitAncestor = false);
Vector<RefPtr<EditCommand> > m_commands;
private:
bool isCompositeEditCommand() const OVERRIDE { return true; }
RefPtr<EditCommandComposition> m_composition;
};
void applyCommand(PassRefPtr<CompositeEditCommand>);
inline CompositeEditCommand* toCompositeEditCommand(EditCommand* command)
{
ASSERT(command);
ASSERT(command->isCompositeEditCommand());
return static_cast<CompositeEditCommand*>(command);
}
} // namespace WebCore
#endif // CompositeEditCommand_h

View File

@@ -0,0 +1,102 @@
/*
* Copyright (C) 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef Console_h
#define Console_h
#include "ConsoleTypes.h"
#include "DOMWindowProperty.h"
#include "ScriptCallStack.h"
#include "ScriptProfile.h"
#include "ScriptState.h"
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefCounted.h>
namespace WebCore {
class Frame;
class MemoryInfo;
class Page;
class ScriptArguments;
class ScriptCallStack;
#if ENABLE(JAVASCRIPT_DEBUGGER)
typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
#endif
class Console : public RefCounted<Console>, public DOMWindowProperty {
public:
static PassRefPtr<Console> create(Frame* frame) { return adoptRef(new Console(frame)); }
virtual ~Console();
void addMessage(MessageSource, MessageType, MessageLevel, const String& message, const String& sourceURL = String(), unsigned lineNumber = 0, PassRefPtr<ScriptCallStack> = 0);
void addMessage(MessageSource, MessageType, MessageLevel, const String& message, PassRefPtr<ScriptCallStack>);
void debug(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void error(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void info(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void log(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void warn(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void dir(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void dirxml(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void trace(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void assertCondition(bool condition, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void count(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void markTimeline(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
#if ENABLE(JAVASCRIPT_DEBUGGER)
const ProfilesArray& profiles() const { return m_profiles; }
void profile(const String&, ScriptState*, PassRefPtr<ScriptCallStack>);
void profileEnd(const String&, ScriptState*, PassRefPtr<ScriptCallStack>);
#endif
void time(const String&);
void timeEnd(const String&, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void timeStamp(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void group(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void groupCollapsed(PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>);
void groupEnd();
static bool shouldPrintExceptions();
static void setShouldPrintExceptions(bool);
PassRefPtr<MemoryInfo> memory() const;
private:
inline Page* page() const;
void addMessage(MessageType, MessageLevel, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>, bool acceptNoArguments = false);
explicit Console(Frame*);
#if ENABLE(JAVASCRIPT_DEBUGGER)
ProfilesArray m_profiles;
#endif
};
} // namespace WebCore
#endif // Console_h

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ConsoleTypes_h
#define ConsoleTypes_h
namespace WebCore {
enum MessageSource {
HTMLMessageSource,
XMLMessageSource,
JSMessageSource,
NetworkMessageSource,
ConsoleAPIMessageSource,
OtherMessageSource,
};
// FIXME: make this enum private to inspector, remove it from client callbacks.
// https://bugs.webkit.org/show_bug.cgi?id=66371
enum MessageType {
LogMessageType,
DirMessageType,
DirXMLMessageType,
TraceMessageType,
StartGroupMessageType,
StartGroupCollapsedMessageType,
EndGroupMessageType,
AssertMessageType
};
enum MessageLevel {
TipMessageLevel,
LogMessageLevel,
WarningMessageLevel,
ErrorMessageLevel,
DebugMessageLevel
};
} // namespace WebCore
#endif // ConsoleTypes_h

View File

@@ -0,0 +1,171 @@
/*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* (C) 2001 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef ContainerNode_h
#define ContainerNode_h
#include "ExceptionCodePlaceholder.h"
#include "Node.h"
namespace WebCore {
class FloatPoint;
typedef void (*NodeCallback)(Node*, unsigned);
namespace Private {
template<class GenericNode, class GenericNodeContainer>
void addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
};
class ContainerNode : public Node {
public:
virtual ~ContainerNode();
Node* firstChild() const { return m_firstChild; }
Node* lastChild() const { return m_lastChild; }
bool hasChildNodes() const { return m_firstChild; }
unsigned childNodeCount() const;
Node* childNode(unsigned index) const;
bool insertBefore(PassRefPtr<Node> newChild, Node* refChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
bool replaceChild(PassRefPtr<Node> newChild, Node* oldChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
bool removeChild(Node* child, ExceptionCode& = ASSERT_NO_EXCEPTION);
bool appendChild(PassRefPtr<Node> newChild, ExceptionCode& = ASSERT_NO_EXCEPTION, bool shouldLazyAttach = false);
// These methods are only used during parsing.
// They don't send DOM mutation events or handle reparenting.
// However, arbitrary code may be run by beforeload handlers.
void parserAddChild(PassRefPtr<Node>);
void parserRemoveChild(Node*);
void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild);
// FIXME: It's not good to have two functions with such similar names, especially public functions.
// How do removeChildren and removeAllChildren differ?
void removeChildren();
void removeAllChildren();
void takeAllChildrenFrom(ContainerNode*);
void cloneChildNodes(ContainerNode* clone);
bool dispatchBeforeLoadEvent(const String& sourceURL);
virtual void attach() OVERRIDE;
virtual void detach() OVERRIDE;
virtual void willRemove() OVERRIDE;
virtual LayoutRect getRect() const OVERRIDE;
virtual void setFocus(bool = true) OVERRIDE;
virtual void setActive(bool active = true, bool pause = false) OVERRIDE;
virtual void setHovered(bool = true) OVERRIDE;
virtual void insertedIntoDocument() OVERRIDE;
virtual void removedFromDocument() OVERRIDE;
virtual void insertedIntoTree(bool deep) OVERRIDE;
virtual void removedFromTree(bool deep) OVERRIDE;
virtual void childrenChanged(bool createdByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) OVERRIDE;
virtual void scheduleSetNeedsStyleRecalc(StyleChangeType = FullStyleChange) OVERRIDE;
protected:
ContainerNode(Document*, ConstructionType = CreateContainer);
static void queuePostAttachCallback(NodeCallback, Node*, unsigned = 0);
static bool postAttachCallbacksAreSuspended();
void suspendPostAttachCallbacks();
void resumePostAttachCallbacks();
template<class GenericNode, class GenericNodeContainer>
friend void appendChildToContainer(GenericNode* child, GenericNodeContainer*);
template<class GenericNode, class GenericNodeContainer>
friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
void setFirstChild(Node* child) { m_firstChild = child; }
void setLastChild(Node* child) { m_lastChild = child; }
private:
void removeBetween(Node* previousChild, Node* nextChild, Node* oldChild);
void insertBeforeCommon(Node* nextChild, Node* oldChild);
static void dispatchPostAttachCallbacks();
bool getUpperLeftCorner(FloatPoint&) const;
bool getLowerRightCorner(FloatPoint&) const;
Node* m_firstChild;
Node* m_lastChild;
};
inline ContainerNode* toContainerNode(Node* node)
{
ASSERT(!node || node->isContainerNode());
return static_cast<ContainerNode*>(node);
}
inline const ContainerNode* toContainerNode(const Node* node)
{
ASSERT(!node || node->isContainerNode());
return static_cast<const ContainerNode*>(node);
}
// This will catch anyone doing an unnecessary cast.
void toContainerNode(const ContainerNode*);
inline ContainerNode::ContainerNode(Document* document, ConstructionType type)
: Node(document, type)
, m_firstChild(0)
, m_lastChild(0)
{
}
inline unsigned Node::childNodeCount() const
{
if (!isContainerNode())
return 0;
return toContainerNode(this)->childNodeCount();
}
inline Node* Node::childNode(unsigned index) const
{
if (!isContainerNode())
return 0;
return toContainerNode(this)->childNode(index);
}
inline Node* Node::firstChild() const
{
if (!isContainerNode())
return 0;
return toContainerNode(this)->firstChild();
}
inline Node* Node::lastChild() const
{
if (!isContainerNode())
return 0;
return toContainerNode(this)->lastChild();
}
} // namespace WebCore
#endif // ContainerNode_h

View File

@@ -0,0 +1,154 @@
/*
* Copyright (C) 2000 Lars Knoll (knoll@kde.org)
* (C) 2000 Antti Koivisto (koivisto@kde.org)
* (C) 2000 Dirk Mueller (mueller@kde.org)
* Copyright (C) 2003, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2006 Graham Dennis (graham.dennis@gmail.com)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#ifndef ContentData_h
#define ContentData_h
#include "CounterContent.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class StyleImage;
class ContentData {
WTF_MAKE_FAST_ALLOCATED;
public:
static PassOwnPtr<ContentData> create(PassRefPtr<StyleImage>);
static PassOwnPtr<ContentData> create(const String&);
static PassOwnPtr<ContentData> create(PassOwnPtr<CounterContent>);
static PassOwnPtr<ContentData> create(QuoteType);
virtual ~ContentData() { }
virtual bool isCounter() const { return false; }
virtual bool isImage() const { return false; }
virtual bool isQuote() const { return false; }
virtual bool isText() const { return false; }
virtual StyleContentType type() const = 0;
friend bool operator==(const ContentData&, const ContentData&);
friend bool operator!=(const ContentData&, const ContentData&);
virtual PassOwnPtr<ContentData> clone() const;
ContentData* next() const { return m_next.get(); }
void setNext(PassOwnPtr<ContentData> next) { m_next = next; }
private:
virtual PassOwnPtr<ContentData> cloneInternal() const = 0;
OwnPtr<ContentData> m_next;
};
class ImageContentData : public ContentData {
friend class ContentData;
public:
const StyleImage* image() const { return m_image.get(); }
StyleImage* image() { return m_image.get(); }
void setImage(PassRefPtr<StyleImage> image) { m_image = image; }
private:
ImageContentData(PassRefPtr<StyleImage> image)
: m_image(image)
{
}
virtual StyleContentType type() const { return CONTENT_OBJECT; }
virtual bool isImage() const { return true; }
virtual PassOwnPtr<ContentData> cloneInternal() const
{
RefPtr<StyleImage> image = const_cast<StyleImage*>(this->image());
return create(image.release());
}
RefPtr<StyleImage> m_image;
};
class TextContentData : public ContentData {
friend class ContentData;
public:
const String& text() const { return m_text; }
void setText(const String& text) { m_text = text; }
private:
TextContentData(const String& text)
: m_text(text)
{
}
virtual StyleContentType type() const { return CONTENT_TEXT; }
virtual bool isText() const { return true; }
virtual PassOwnPtr<ContentData> cloneInternal() const { return create(text()); }
String m_text;
};
class CounterContentData : public ContentData {
friend class ContentData;
public:
const CounterContent* counter() const { return m_counter.get(); }
void setCounter(PassOwnPtr<CounterContent> counter) { m_counter = counter; }
private:
CounterContentData(PassOwnPtr<CounterContent> counter)
: m_counter(counter)
{
}
virtual StyleContentType type() const { return CONTENT_COUNTER; }
virtual bool isCounter() const { return true; }
virtual PassOwnPtr<ContentData> cloneInternal() const
{
OwnPtr<CounterContent> counterData = adoptPtr(new CounterContent(*counter()));
return create(counterData.release());
}
OwnPtr<CounterContent> m_counter;
};
class QuoteContentData : public ContentData {
friend class ContentData;
public:
QuoteType quote() const { return m_quote; }
void setQuote(QuoteType quote) { m_quote = quote; }
private:
QuoteContentData(QuoteType quote)
: m_quote(quote)
{
}
virtual StyleContentType type() const { return CONTENT_QUOTE; }
virtual bool isQuote() const { return true; }
virtual PassOwnPtr<ContentData> cloneInternal() const { return create(quote()); }
QuoteType m_quote;
};
} // namespace WebCore
#endif // ContentData_h

View File

@@ -0,0 +1,115 @@
/*
* Copyright (C) 2011 Google, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContentSecurityPolicy_h
#define ContentSecurityPolicy_h
#include <wtf/RefCounted.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class CSPDirective;
class ScriptExecutionContext;
class KURL;
class ContentSecurityPolicy : public RefCounted<ContentSecurityPolicy> {
public:
static PassRefPtr<ContentSecurityPolicy> create(ScriptExecutionContext* scriptExecutionContext)
{
return adoptRef(new ContentSecurityPolicy(scriptExecutionContext));
}
~ContentSecurityPolicy();
void copyStateFrom(const ContentSecurityPolicy*);
enum HeaderType {
ReportOnly,
EnforcePolicy
};
void didReceiveHeader(const String&, HeaderType);
String policy() { return m_header; }
HeaderType headerType() { return m_reportOnly ? ReportOnly : EnforcePolicy; }
bool allowJavaScriptURLs() const;
bool allowInlineEventHandlers() const;
bool allowInlineScript() const;
bool allowInlineStyle() const;
bool allowEval() const;
bool allowScriptFromSource(const KURL&) const;
bool allowObjectFromSource(const KURL&) const;
bool allowChildFrameFromSource(const KURL&) const;
bool allowImageFromSource(const KURL&) const;
bool allowStyleFromSource(const KURL&) const;
bool allowFontFromSource(const KURL&) const;
bool allowMediaFromSource(const KURL&) const;
bool allowConnectFromSource(const KURL&) const;
private:
explicit ContentSecurityPolicy(ScriptExecutionContext*);
void parse(const String&);
bool parseDirective(const UChar* begin, const UChar* end, String& name, String& value);
void parseReportURI(const String&);
void addDirective(const String& name, const String& value);
void applySandboxPolicy(const String& sandboxPolicy);
PassOwnPtr<CSPDirective> createCSPDirective(const String& name, const String& value);
CSPDirective* operativeDirective(CSPDirective*) const;
void reportViolation(const String& directiveText, const String& consoleMessage) const;
void logUnrecognizedDirective(const String& name) const;
bool checkEval(CSPDirective*) const;
bool checkInlineAndReportViolation(CSPDirective*, const String& consoleMessage) const;
bool checkEvalAndReportViolation(CSPDirective*, const String& consoleMessage) const;
bool checkSourceAndReportViolation(CSPDirective*, const KURL&, const String& type) const;
bool denyIfEnforcingPolicy() const { return m_reportOnly; }
bool m_havePolicy;
ScriptExecutionContext* m_scriptExecutionContext;
bool m_reportOnly;
String m_header;
OwnPtr<CSPDirective> m_defaultSrc;
OwnPtr<CSPDirective> m_scriptSrc;
OwnPtr<CSPDirective> m_objectSrc;
OwnPtr<CSPDirective> m_frameSrc;
OwnPtr<CSPDirective> m_imgSrc;
OwnPtr<CSPDirective> m_styleSrc;
OwnPtr<CSPDirective> m_fontSrc;
OwnPtr<CSPDirective> m_mediaSrc;
OwnPtr<CSPDirective> m_connectSrc;
bool m_haveSandboxPolicy;
Vector<KURL> m_reportURLs;
};
}
#endif

View File

@@ -0,0 +1,123 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContextMenu_h
#define ContextMenu_h
#include <wtf/Noncopyable.h>
#include "ContextMenuItem.h"
#include "PlatformMenuDescription.h"
#include "PlatformString.h"
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
#elif PLATFORM(QT)
#include <QMenu>
#elif PLATFORM(WIN)
#include <windows.h>
#endif
namespace WebCore {
class ContextMenuController;
class ContextMenu {
WTF_MAKE_NONCOPYABLE(ContextMenu); WTF_MAKE_FAST_ALLOCATED;
public:
ContextMenu();
ContextMenuItem* itemWithAction(unsigned);
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
#if PLATFORM(WIN)
typedef HMENU NativeMenu;
#elif PLATFORM(EFL)
typedef void* NativeMenu;
#endif
explicit ContextMenu(NativeMenu);
NativeMenu nativeMenu() const;
static NativeMenu createNativeMenuFromItems(const Vector<ContextMenuItem>&);
static void getContextMenuItems(NativeMenu, Vector<ContextMenuItem>&);
// FIXME: When more platforms switch over, this should return const ContextMenuItem*'s.
ContextMenuItem* itemAtIndex(unsigned index) { return &m_items[index]; }
void setItems(const Vector<ContextMenuItem>& items) { m_items = items; }
const Vector<ContextMenuItem>& items() const { return m_items; }
void appendItem(const ContextMenuItem& item) { m_items.append(item); }
#else
ContextMenu(const PlatformMenuDescription);
~ContextMenu();
void insertItem(unsigned position, ContextMenuItem&);
void appendItem(ContextMenuItem&);
ContextMenuItem* itemAtIndex(unsigned, const PlatformMenuDescription);
unsigned itemCount() const;
PlatformMenuDescription platformDescription() const;
void setPlatformDescription(PlatformMenuDescription);
PlatformMenuDescription releasePlatformDescription();
#if PLATFORM(WX)
static ContextMenuItem* itemWithId(int);
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
private:
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> m_items;
#else
#if PLATFORM(MAC)
// Keep this in sync with the PlatformMenuDescription typedef
RetainPtr<NSMutableArray> m_platformDescription;
#elif PLATFORM(QT)
QList<ContextMenuItem> m_items;
#elif PLATFORM(CHROMIUM) || PLATFORM(EFL)
Vector<ContextMenuItem> m_items;
#else
PlatformMenuDescription m_platformDescription;
#if OS(WINCE)
unsigned m_itemCount;
#endif
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
};
#if !USE(CROSS_PLATFORM_CONTEXT_MENUS)
Vector<ContextMenuItem> contextMenuItemVector(PlatformMenuDescription);
PlatformMenuDescription platformMenuDescription(Vector<ContextMenuItem>&);
#endif
}
#endif // ContextMenu_h

View File

@@ -0,0 +1,66 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContextMenuClient_h
#define ContextMenuClient_h
#include "ContextMenu.h"
#include "PlatformMenuDescription.h"
#include <wtf/Forward.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
class ContextMenuItem;
class Frame;
class HitTestResult;
class KURL;
class ContextMenuClient {
public:
virtual ~ContextMenuClient() { }
virtual void contextMenuDestroyed() = 0;
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
virtual PassOwnPtr<ContextMenu> customizeMenu(PassOwnPtr<ContextMenu>) = 0;
#else
virtual PlatformMenuDescription getCustomMenuFromDefaultItems(ContextMenu*) = 0;
#endif
virtual void contextMenuItemSelected(ContextMenuItem*, const ContextMenu*) = 0;
virtual void downloadURL(const KURL& url) = 0;
virtual void searchWithGoogle(const Frame*) = 0;
virtual void lookUpInDictionary(Frame*) = 0;
virtual bool isSpeaking() = 0;
virtual void speak(const String&) = 0;
virtual void stopSpeaking() = 0;
#if PLATFORM(MAC)
virtual void searchWithSpotlight() = 0;
#endif
};
}
#endif

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContextMenuController_h
#define ContextMenuController_h
#include "HitTestResult.h"
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class ContextMenu;
class ContextMenuClient;
class ContextMenuItem;
class ContextMenuProvider;
class Event;
class Page;
class ContextMenuController {
WTF_MAKE_NONCOPYABLE(ContextMenuController); WTF_MAKE_FAST_ALLOCATED;
public:
~ContextMenuController();
static PassOwnPtr<ContextMenuController> create(Page*, ContextMenuClient*);
ContextMenuClient* client() const { return m_client; }
ContextMenu* contextMenu() const { return m_contextMenu.get(); }
void clearContextMenu();
void handleContextMenuEvent(Event*);
void showContextMenu(Event*, PassRefPtr<ContextMenuProvider>);
void populate();
void contextMenuItemSelected(ContextMenuItem*);
void addInspectElementItem();
void checkOrEnableIfNeeded(ContextMenuItem&) const;
void setHitTestResult(const HitTestResult& result) { m_hitTestResult = result; }
const HitTestResult& hitTestResult() { return m_hitTestResult; }
private:
ContextMenuController(Page*, ContextMenuClient*);
PassOwnPtr<ContextMenu> createContextMenu(Event*);
void showContextMenu(Event*);
void appendItem(ContextMenuItem&, ContextMenu* parentMenu);
void createAndAppendFontSubMenu(ContextMenuItem&);
void createAndAppendSpellingAndGrammarSubMenu(ContextMenuItem&);
void createAndAppendSpellingSubMenu(ContextMenuItem&);
void createAndAppendSpeechSubMenu(ContextMenuItem& );
void createAndAppendWritingDirectionSubMenu(ContextMenuItem&);
void createAndAppendTextDirectionSubMenu(ContextMenuItem&);
void createAndAppendSubstitutionsSubMenu(ContextMenuItem&);
void createAndAppendTransformationsSubMenu(ContextMenuItem&);
Page* m_page;
ContextMenuClient* m_client;
OwnPtr<ContextMenu> m_contextMenu;
RefPtr<ContextMenuProvider> m_menuProvider;
HitTestResult m_hitTestResult;
};
}
#endif

View File

@@ -0,0 +1,298 @@
/*
* Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2010 Igalia S.L
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ContextMenuItem_h
#define ContextMenuItem_h
#include "PlatformMenuDescription.h"
#include "PlatformString.h"
#include <wtf/OwnPtr.h>
#if PLATFORM(MAC)
#include <wtf/RetainPtr.h>
OBJC_CLASS NSMenuItem;
#elif PLATFORM(WIN)
typedef struct tagMENUITEMINFOW MENUITEMINFO;
#elif PLATFORM(GTK)
typedef struct _GtkMenuItem GtkMenuItem;
typedef struct _GtkAction GtkAction;
#elif PLATFORM(QT)
#include <QAction>
#elif PLATFORM(WX)
class wxMenuItem;
#endif
namespace WebCore {
class ContextMenu;
// This enum needs to be in sync with the WebMenuItemTag enum in WebUIDelegate.h and the
// extra values in WebUIDelegatePrivate.h
enum ContextMenuAction {
ContextMenuItemTagNoAction=0, // This item is not actually in WebUIDelegate.h
ContextMenuItemTagOpenLinkInNewWindow=1,
ContextMenuItemTagDownloadLinkToDisk,
ContextMenuItemTagCopyLinkToClipboard,
ContextMenuItemTagOpenImageInNewWindow,
ContextMenuItemTagDownloadImageToDisk,
ContextMenuItemTagCopyImageToClipboard,
#if PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
ContextMenuItemTagCopyImageUrlToClipboard,
#endif
ContextMenuItemTagOpenFrameInNewWindow,
ContextMenuItemTagCopy,
ContextMenuItemTagGoBack,
ContextMenuItemTagGoForward,
ContextMenuItemTagStop,
ContextMenuItemTagReload,
ContextMenuItemTagCut,
ContextMenuItemTagPaste,
#if PLATFORM(GTK)
ContextMenuItemTagDelete,
#endif
#if PLATFORM(GTK) || PLATFORM(QT) || PLATFORM (EFL)
ContextMenuItemTagSelectAll,
#endif
#if PLATFORM(GTK)
ContextMenuItemTagInputMethods,
ContextMenuItemTagUnicode,
#endif
ContextMenuItemTagSpellingGuess,
ContextMenuItemTagNoGuessesFound,
ContextMenuItemTagIgnoreSpelling,
ContextMenuItemTagLearnSpelling,
ContextMenuItemTagOther,
ContextMenuItemTagSearchInSpotlight,
ContextMenuItemTagSearchWeb,
ContextMenuItemTagLookUpInDictionary,
ContextMenuItemTagOpenWithDefaultApplication,
ContextMenuItemPDFActualSize,
ContextMenuItemPDFZoomIn,
ContextMenuItemPDFZoomOut,
ContextMenuItemPDFAutoSize,
ContextMenuItemPDFSinglePage,
ContextMenuItemPDFFacingPages,
ContextMenuItemPDFContinuous,
ContextMenuItemPDFNextPage,
ContextMenuItemPDFPreviousPage,
// These are new tags! Not a part of API!!!!
ContextMenuItemTagOpenLink = 2000,
ContextMenuItemTagIgnoreGrammar,
ContextMenuItemTagSpellingMenu, // Spelling or Spelling/Grammar sub-menu
ContextMenuItemTagShowSpellingPanel,
ContextMenuItemTagCheckSpelling,
ContextMenuItemTagCheckSpellingWhileTyping,
ContextMenuItemTagCheckGrammarWithSpelling,
ContextMenuItemTagFontMenu, // Font sub-menu
ContextMenuItemTagShowFonts,
ContextMenuItemTagBold,
ContextMenuItemTagItalic,
ContextMenuItemTagUnderline,
ContextMenuItemTagOutline,
ContextMenuItemTagStyles,
ContextMenuItemTagShowColors,
ContextMenuItemTagSpeechMenu, // Speech sub-menu
ContextMenuItemTagStartSpeaking,
ContextMenuItemTagStopSpeaking,
ContextMenuItemTagWritingDirectionMenu, // Writing Direction sub-menu
ContextMenuItemTagDefaultDirection,
ContextMenuItemTagLeftToRight,
ContextMenuItemTagRightToLeft,
ContextMenuItemTagPDFSinglePageScrolling,
ContextMenuItemTagPDFFacingPagesScrolling,
#if ENABLE(INSPECTOR)
ContextMenuItemTagInspectElement,
#endif
ContextMenuItemTagTextDirectionMenu, // Text Direction sub-menu
ContextMenuItemTagTextDirectionDefault,
ContextMenuItemTagTextDirectionLeftToRight,
ContextMenuItemTagTextDirectionRightToLeft,
#if PLATFORM(MAC)
ContextMenuItemTagCorrectSpellingAutomatically,
ContextMenuItemTagSubstitutionsMenu,
ContextMenuItemTagShowSubstitutions,
ContextMenuItemTagSmartCopyPaste,
ContextMenuItemTagSmartQuotes,
ContextMenuItemTagSmartDashes,
ContextMenuItemTagSmartLinks,
ContextMenuItemTagTextReplacement,
ContextMenuItemTagTransformationsMenu,
ContextMenuItemTagMakeUpperCase,
ContextMenuItemTagMakeLowerCase,
ContextMenuItemTagCapitalize,
ContextMenuItemTagChangeBack,
#endif
ContextMenuItemTagOpenMediaInNewWindow,
ContextMenuItemTagCopyMediaLinkToClipboard,
ContextMenuItemTagToggleMediaControls,
ContextMenuItemTagToggleMediaLoop,
ContextMenuItemTagEnterVideoFullscreen,
ContextMenuItemTagMediaPlayPause,
ContextMenuItemTagMediaMute,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemCustomTagNoAction = 5998,
ContextMenuItemLastCustomTag = 5999,
ContextMenuItemBaseApplicationTag = 10000
};
enum ContextMenuItemType {
ActionType,
CheckableActionType,
SeparatorType,
SubmenuType
};
#if PLATFORM(MAC)
typedef NSMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(QT)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType),
action(ContextMenuItemTagNoAction),
checked(false),
enabled(true)
{}
ContextMenuItemType type;
ContextMenuAction action;
String title;
QList<ContextMenuItem> subMenuItems;
bool checked;
bool enabled;
};
#elif PLATFORM(GTK)
typedef GtkMenuItem* PlatformMenuItemDescription;
#elif PLATFORM(WX)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType),
action(ContextMenuItemTagNoAction),
checked(false),
enabled(true)
{}
ContextMenuItemType type;
ContextMenuAction action;
String title;
wxMenu * subMenu;
bool checked;
bool enabled;
};
#elif PLATFORM(CHROMIUM) || PLATFORM(EFL)
struct PlatformMenuItemDescription {
PlatformMenuItemDescription()
: type(ActionType)
, action(ContextMenuItemTagNoAction)
, checked(false)
, enabled(true) { }
ContextMenuItemType type;
ContextMenuAction action;
String title;
bool checked;
bool enabled;
};
#else
typedef void* PlatformMenuItemDescription;
#endif
class ContextMenuItem {
WTF_MAKE_FAST_ALLOCATED;
public:
ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, ContextMenu* subMenu = 0);
ContextMenuItem(ContextMenuItemType, ContextMenuAction, const String&, bool enabled, bool checked);
~ContextMenuItem();
void setType(ContextMenuItemType);
ContextMenuItemType type() const;
void setAction(ContextMenuAction);
ContextMenuAction action() const;
void setChecked(bool = true);
bool checked() const;
void setEnabled(bool = true);
bool enabled() const;
void setSubMenu(ContextMenu*);
#if PLATFORM(GTK)
GtkAction* gtkAction() const;
#endif
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
#if PLATFORM(WIN)
typedef MENUITEMINFO NativeItem;
#elif PLATFORM(EFL)
typedef void* NativeItem;
#endif
ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool checked, const Vector<ContextMenuItem>& subMenuItems);
explicit ContextMenuItem(const NativeItem&);
// On Windows, the title (dwTypeData of the MENUITEMINFO) is not set in this function. Callers can set the title themselves,
// and handle the lifetime of the title, if they need it.
NativeItem nativeMenuItem() const;
void setTitle(const String& title) { m_title = title; }
const String& title() const { return m_title; }
const Vector<ContextMenuItem>& subMenuItems() const { return m_subMenuItems; }
#else
public:
ContextMenuItem(PlatformMenuItemDescription);
ContextMenuItem(ContextMenu* subMenu = 0);
ContextMenuItem(ContextMenuAction, const String&, bool enabled, bool checked, Vector<ContextMenuItem>& submenuItems);
PlatformMenuItemDescription releasePlatformDescription();
String title() const;
void setTitle(const String&);
PlatformMenuDescription platformSubMenu() const;
void setSubMenu(Vector<ContextMenuItem>&);
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
private:
#if USE(CROSS_PLATFORM_CONTEXT_MENUS)
ContextMenuItemType m_type;
ContextMenuAction m_action;
String m_title;
bool m_enabled;
bool m_checked;
Vector<ContextMenuItem> m_subMenuItems;
#else
#if PLATFORM(MAC)
RetainPtr<NSMenuItem> m_platformDescription;
#else
PlatformMenuItemDescription m_platformDescription;
#endif
#endif // USE(CROSS_PLATFORM_CONTEXT_MENUS)
};
}
#endif // ContextMenuItem_h

Some files were not shown because too many files have changed in this diff Show More