+2013-09-24 Sam Weinig <sam@webkit.org>
+
+ CTTE: More Document references please
+ https://bugs.webkit.org/show_bug.cgi?id=121893
+
+ Reviewed by Anders Carlsson.
+
+ * Thread even more Document&s around. *
+
2013-09-25 Anders Carlsson <andersca@apple.com>
HasMemoryCostMemberFunction should work for final classes
__ZN7WebCore15visitedLinkHashERKN3WTF6StringE
__ZN7WebCore16ApplicationCache18diskUsageForOriginEPNS_14SecurityOriginE
__ZN7WebCore16ApplicationCache20deleteCacheForOriginEPNS_14SecurityOriginE
-__ZN7WebCore16CSSParserContextC1EPNS_8DocumentERKNS_4KURLERKN3WTF6StringE
+__ZN7WebCore16CSSParserContextC1ERNS_8DocumentERKNS_4KURLERKN3WTF6StringE
__ZN7WebCore16DatabaseStrategy17getDatabaseServerEv
__ZN7WebCore16DeviceMotionData12Acceleration6createEbdbdbd
__ZN7WebCore16DeviceMotionData12RotationRate6createEbdbdbd
namespace WebCore {
#if ENABLE(SVG)
-static inline SVGCursorElement* resourceReferencedByCursorElement(const String& url, Document* document)
+static inline SVGCursorElement* resourceReferencedByCursorElement(const String& url, Document& document)
{
Element* element = SVGURIReference::targetElementFromIRIString(url, document);
if (element && isSVGCursorElement(element))
for (; it != end; ++it) {
SVGElement* referencedElement = *it;
referencedElement->cursorImageValueRemoved();
- if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, &referencedElement->document()))
+ if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, referencedElement->document()))
cursorElement->removeClient(referencedElement);
}
#endif
return false;
String url = static_cast<CSSImageValue*>(m_imageValue.get())->url();
- if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, &element->document())) {
+ if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(url, element->document())) {
// FIXME: This will override hot spot specified in CSS, which is probably incorrect.
SVGLengthContext lengthContext(0);
m_hasHotSpot = true;
if (isSVGCursor() && loader && loader->document()) {
RefPtr<CSSImageValue> imageValue = static_cast<CSSImageValue*>(m_imageValue.get());
// FIXME: This will fail if the <cursor> element is in a shadow DOM (bug 59827)
- if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), loader->document())) {
+ if (SVGCursorElement* cursorElement = resourceReferencedByCursorElement(imageValue->url(), *loader->document())) {
RefPtr<CSSImageValue> svgImageValue = CSSImageValue::create(cursorElement->href());
StyleCachedImage* cachedImage = svgImageValue->cachedImage(loader);
m_image = cachedImage;
return 0;
}
-StyleImage* CSSCursorImageValue::cachedOrPendingImage(Document* document)
+StyleImage* CSSCursorImageValue::cachedOrPendingImage(Document& document)
{
#if ENABLE(CSS_IMAGE_SET)
// Need to delegate completely so that changes in device scale factor can be handled appropriately.
bool updateIfSVGCursorIsUsed(Element*);
StyleImage* cachedImage(CachedResourceLoader*);
- StyleImage* cachedOrPendingImage(Document*);
+ StyleImage* cachedOrPendingImage(Document&);
#if ENABLE(SVG)
void removeReferencedElement(SVGElement*);
return (m_imageSet && m_imageSet->isCachedImageSet()) ? static_cast<StyleCachedImageSet*>(m_imageSet.get()) : 0;
}
-StyleImage* CSSImageSetValue::cachedOrPendingImageSet(Document* document)
+StyleImage* CSSImageSetValue::cachedOrPendingImageSet(Document& document)
{
if (!m_imageSet)
m_imageSet = StylePendingImage::create(this);
- else if (document && !m_imageSet->isPendingImage()) {
+ else if (!m_imageSet->isPendingImage()) {
float deviceScaleFactor = 1;
- if (Page* page = document->page())
+ if (Page* page = document.page())
deviceScaleFactor = page->deviceScaleFactor();
// If the deviceScaleFactor has changed, we may not have the best image loaded, so we have to re-assess.
StyleCachedImageSet* cachedImageSet(CachedResourceLoader*);
// Returns a StyleCachedImageSet if the best fit image has been cached already, otherwise a StylePendingImage.
- StyleImage* cachedOrPendingImageSet(Document*);
+ StyleImage* cachedOrPendingImageSet(Document&);
String customCSSText() const;
{
}
-CSSParserContext::CSSParserContext(Document* document, const KURL& baseURL, const String& charset)
- : baseURL(baseURL.isNull() ? document->baseURL() : baseURL)
+CSSParserContext::CSSParserContext(Document& document, const KURL& baseURL, const String& charset)
+ : baseURL(baseURL.isNull() ? document.baseURL() : baseURL)
, charset(charset)
- , mode(document->inQuirksMode() ? CSSQuirksMode : CSSStrictMode)
- , isHTMLDocument(document->isHTMLDocument())
- , isCSSCustomFilterEnabled(document->settings() ? document->settings()->isCSSCustomFilterEnabled() : false)
- , isCSSStickyPositionEnabled(document->cssStickyPositionEnabled())
- , isCSSRegionsEnabled(document->cssRegionsEnabled())
- , isCSSCompositingEnabled(document->cssCompositingEnabled())
- , isCSSGridLayoutEnabled(document->cssGridLayoutEnabled())
+ , mode(document.inQuirksMode() ? CSSQuirksMode : CSSStrictMode)
+ , isHTMLDocument(document.isHTMLDocument())
+ , isCSSCustomFilterEnabled(document.settings() ? document.settings()->isCSSCustomFilterEnabled() : false)
+ , isCSSStickyPositionEnabled(document.cssStickyPositionEnabled())
+ , isCSSRegionsEnabled(document.cssRegionsEnabled())
+ , isCSSCompositingEnabled(document.cssCompositingEnabled())
+ , isCSSGridLayoutEnabled(document.cssGridLayoutEnabled())
#if ENABLE(CSS_VARIABLES)
- , isCSSVariablesEnabled(document->settings() ? document->settings()->cssVariablesEnabled() : false)
+ , isCSSVariablesEnabled(document.settings() ? document.settings()->cssVariablesEnabled() : false)
#endif
- , needsSiteSpecificQuirks(document->settings() ? document->settings()->needsSiteSpecificQuirks() : false)
- , enforcesCSSMIMETypeInNoQuirksMode(!document->settings() || document->settings()->enforceCSSMIMETypeInNoQuirksMode())
- , useLegacyBackgroundSizeShorthandBehavior(document->settings() ? document->settings()->useLegacyBackgroundSizeShorthandBehavior() : false)
+ , needsSiteSpecificQuirks(document.settings() ? document.settings()->needsSiteSpecificQuirks() : false)
+ , enforcesCSSMIMETypeInNoQuirksMode(!document.settings() || document.settings()->enforceCSSMIMETypeInNoQuirksMode())
+ , useLegacyBackgroundSizeShorthandBehavior(document.settings() ? document.settings()->useLegacyBackgroundSizeShorthandBehavior() : false)
{
}
}
#if ENABLE(CSS_VARIABLES)
-bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document* document)
+bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID propertyID, const String& string, bool important, Document& document)
{
ASSERT(!string.isEmpty());
bool parseQuotes(CSSPropertyID, bool important);
#if ENABLE(CSS_VARIABLES)
- static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, Document*);
+ static bool parseValue(MutableStylePropertySet*, CSSPropertyID, const String&, bool important, Document&);
bool cssVariablesEnabled() const;
void storeVariableDeclaration(const CSSParserString&, PassOwnPtr<CSSParserValueList>, bool important);
#endif
WTF_MAKE_FAST_ALLOCATED;
public:
CSSParserContext(CSSParserMode, const KURL& baseURL = KURL());
- CSSParserContext(Document*, const KURL& baseURL = KURL(), const String& charset = emptyString());
+ CSSParserContext(Document&, const KURL& baseURL = KURL(), const String& charset = emptyString());
KURL baseURL;
String charset;
return adoptRef(new CSSStyleSheet(sheet, ownerNode, false));
}
-PassRefPtr<CSSStyleSheet> CSSStyleSheet::createInline(Node* ownerNode, const KURL& baseURL, const String& encoding)
+PassRefPtr<CSSStyleSheet> CSSStyleSheet::createInline(Node& ownerNode, const KURL& baseURL, const String& encoding)
{
- CSSParserContext parserContext(&ownerNode->document(), baseURL, encoding);
+ CSSParserContext parserContext(ownerNode.document(), baseURL, encoding);
RefPtr<StyleSheetContents> sheet = StyleSheetContents::create(baseURL.string(), parserContext);
- return adoptRef(new CSSStyleSheet(sheet.release(), ownerNode, true));
+ return adoptRef(new CSSStyleSheet(sheet.release(), &ownerNode, true));
}
CSSStyleSheet::CSSStyleSheet(PassRefPtr<StyleSheetContents> contents, CSSImportRule* ownerRule)
public:
static PassRefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetContents>, CSSImportRule* ownerRule = 0);
static PassRefPtr<CSSStyleSheet> create(PassRefPtr<StyleSheetContents>, Node* ownerNode);
- static PassRefPtr<CSSStyleSheet> createInline(Node*, const KURL&, const String& encoding = String());
+ static PassRefPtr<CSSStyleSheet> createInline(Node&, const KURL&, const String& encoding = String());
virtual ~CSSStyleSheet();
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setMarkerStartResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyMarkerMid:
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setMarkerMidResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyMarkerEnd:
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setMarkerEndResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyStrokeLinecap:
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setFilterResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyMask:
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setMaskerResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyClipPath:
if (type == CSSPrimitiveValue::CSS_URI)
s = primitiveValue->getStringValue();
- svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, &state.document()));
+ svgstyle->setClipperResource(SVGURIReference::fragmentIdentifierFromIRIString(s, state.document()));
break;
}
case CSSPropertyTextAnchor:
// FIXME: It would be faster not to re-parse from strings, but for now CSS property validation lives inside the parser so we do it there.
RefPtr<MutableStylePropertySet> resultSet = MutableStylePropertySet::create();
- if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, &document()))
+ if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, document()))
return; // expression failed to parse.
for (unsigned i = 0; i < resultSet->propertyCount(); i++) {
#if ENABLE(CSS_IMAGE_SET)
PassRefPtr<StyleImage> StyleResolver::setOrPendingFromValue(CSSPropertyID property, CSSImageSetValue* value)
{
- RefPtr<StyleImage> image = value->cachedOrPendingImageSet(&document());
+ RefPtr<StyleImage> image = value->cachedOrPendingImageSet(document());
if (image && image->isPendingImage())
m_state.pendingImageProperties().set(property, value);
return image.release();
PassRefPtr<StyleImage> StyleResolver::cursorOrPendingFromValue(CSSPropertyID property, CSSCursorImageValue* value)
{
- RefPtr<StyleImage> image = value->cachedOrPendingImage(&document());
+ RefPtr<StyleImage> image = value->cachedOrPendingImage(document());
if (image && image->isPendingImage())
m_state.pendingImageProperties().set(property, value);
return image.release();
KURL url = m_state.document().completeURL(svgDocumentValue->url());
RefPtr<ReferenceFilterOperation> operation = ReferenceFilterOperation::create(svgDocumentValue->url(), url.fragmentIdentifier(), operationType);
- if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), &m_state.document())) {
+ if (SVGURIReference::isExternalURIReference(svgDocumentValue->url(), m_state.document())) {
if (!svgDocumentValue->loadRequested())
m_state.pendingSVGDocuments().set(operation.get(), svgDocumentValue);
else if (svgDocumentValue->cachedSVGDocument())
, m_domTreeVersion(++s_globalTreeVersion)
, m_listenerTypes(0)
, m_mutationObserverTypes(0)
- , m_styleSheetCollection(DocumentStyleSheetCollection::create(this))
+ , m_styleSheetCollection(DocumentStyleSheetCollection::create(*this))
, m_visitedLinkState(VisitedLinkState::create(this))
, m_visuallyOrdered(false)
, m_readyState(Complete)
// Element sheet is silly. It never contains anything.
ASSERT(!m_elementSheet->contents()->ruleCount());
bool usesRemUnits = m_elementSheet->contents()->usesRemUnits();
- m_elementSheet = CSSStyleSheet::createInline(this, m_baseURL);
+ m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL);
// FIXME: So we are not really the parser. The right fix is to eliminate the element sheet completely.
m_elementSheet->contents()->parserSetUsesRemUnits(usesRemUnits);
}
CSSStyleSheet& Document::elementSheet()
{
if (!m_elementSheet)
- m_elementSheet = CSSStyleSheet::createInline(this, m_baseURL);
+ m_elementSheet = CSSStyleSheet::createInline(*this, m_baseURL);
return *m_elementSheet;
}
}
if (m_fullScreenElement != documentElement())
- RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() : 0, this);
+ RenderFullScreen::wrapRenderer(renderer, renderer ? renderer->parent() : 0, *this);
m_fullScreenElement->setContainsFullScreenElementOnAncestorsCrossingFrameBoundaries(true);
using namespace HTMLNames;
-DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document* document)
+DocumentStyleSheetCollection::DocumentStyleSheetCollection(Document& document)
: m_document(document)
, m_pendingStylesheets(0)
, m_injectedStyleSheetCacheValid(false)
void DocumentStyleSheetCollection::combineCSSFeatureFlags()
{
// Delay resetting the flags until after next style recalc since unapplying the style may not work without these set (this is true at least with before/after).
- const StyleResolver& styleResolver = m_document->ensureStyleResolver();
+ const StyleResolver& styleResolver = m_document.ensureStyleResolver();
m_usesSiblingRules = m_usesSiblingRules || styleResolver.usesSiblingRules();
m_usesFirstLineRules = m_usesFirstLineRules || styleResolver.usesFirstLineRules();
m_usesBeforeAfterRules = m_usesBeforeAfterRules || styleResolver.usesBeforeAfterRules();
void DocumentStyleSheetCollection::resetCSSFeatureFlags()
{
- const StyleResolver& styleResolver = m_document->ensureStyleResolver();
+ const StyleResolver& styleResolver = m_document.ensureStyleResolver();
m_usesSiblingRules = styleResolver.usesSiblingRules();
m_usesFirstLineRules = styleResolver.usesFirstLineRules();
m_usesBeforeAfterRules = styleResolver.usesBeforeAfterRules();
if (m_pageUserSheet)
return m_pageUserSheet.get();
- Page* owningPage = m_document->page();
+ Page* owningPage = m_document.page();
if (!owningPage)
return 0;
return 0;
// Parse the sheet and cache it.
- m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document->settings()->userStyleSheetLocation());
+ m_pageUserSheet = CSSStyleSheet::createInline(m_document, m_document.settings()->userStyleSheetLocation());
m_pageUserSheet->contents()->setIsUserStyleSheet(true);
m_pageUserSheet->contents()->parseString(userSheetText);
return m_pageUserSheet.get();
{
if (m_pageUserSheet) {
m_pageUserSheet = 0;
- m_document->styleResolverChanged(DeferRecalcStyle);
+ m_document.styleResolverChanged(DeferRecalcStyle);
}
}
{
clearPageUserSheet();
if (pageUserSheet())
- m_document->styleResolverChanged(RecalcStyleImmediately);
+ m_document.styleResolverChanged(RecalcStyleImmediately);
}
const Vector<RefPtr<CSSStyleSheet> >& DocumentStyleSheetCollection::injectedUserStyleSheets() const
m_injectedUserStyleSheets.clear();
m_injectedAuthorStyleSheets.clear();
- Page* owningPage = m_document->page();
+ Page* owningPage = m_document.page();
if (!owningPage)
return;
const UserStyleSheetVector* sheets = it->value.get();
for (unsigned i = 0; i < sheets->size(); ++i) {
const UserStyleSheet* sheet = sheets->at(i).get();
- if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document->ownerElement())
+ if (sheet->injectedFrames() == InjectInTopFrameOnly && m_document.ownerElement())
continue;
- if (!UserContentURLPattern::matchesPatterns(m_document->url(), sheet->whitelist(), sheet->blacklist()))
+ if (!UserContentURLPattern::matchesPatterns(m_document.url(), sheet->whitelist(), sheet->blacklist()))
continue;
- RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document*>(m_document), sheet->url());
+ RefPtr<CSSStyleSheet> groupSheet = CSSStyleSheet::createInline(const_cast<Document&>(m_document), sheet->url());
bool isUserStyleSheet = sheet->level() == UserStyleUserLevel;
if (isUserStyleSheet)
m_injectedUserStyleSheets.append(groupSheet);
m_injectedStyleSheetCacheValid = false;
if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
return;
- m_document->styleResolverChanged(DeferRecalcStyle);
+ m_document.styleResolverChanged(DeferRecalcStyle);
}
void DocumentStyleSheetCollection::addAuthorSheet(PassRefPtr<StyleSheetContents> authorSheet)
{
ASSERT(!authorSheet->isUserStyleSheet());
- m_authorStyleSheets.append(CSSStyleSheet::create(authorSheet, m_document));
- m_document->styleResolverChanged(RecalcStyleImmediately);
+ m_authorStyleSheets.append(CSSStyleSheet::create(authorSheet, &m_document));
+ m_document.styleResolverChanged(RecalcStyleImmediately);
}
void DocumentStyleSheetCollection::addUserSheet(PassRefPtr<StyleSheetContents> userSheet)
{
ASSERT(userSheet->isUserStyleSheet());
- m_userStyleSheets.append(CSSStyleSheet::create(userSheet, m_document));
- m_document->styleResolverChanged(RecalcStyleImmediately);
+ m_userStyleSheets.append(CSSStyleSheet::create(userSheet, &m_document));
+ m_document.styleResolverChanged(RecalcStyleImmediately);
}
// This method is called whenever a top-level stylesheet has finished loading.
return;
if (notification == RemovePendingSheetNotifyLater) {
- m_document->setNeedsNotifyRemoveAllPendingStylesheet();
+ m_document.setNeedsNotifyRemoveAllPendingStylesheet();
return;
}
- m_document->didRemoveAllPendingStylesheet();
+ m_document.didRemoveAllPendingStylesheet();
}
-void DocumentStyleSheetCollection::addStyleSheetCandidateNode(Node* node, bool createdByParser)
+void DocumentStyleSheetCollection::addStyleSheetCandidateNode(Node& node, bool createdByParser)
{
- if (!node->inDocument())
+ if (!node.inDocument())
return;
// Until the <body> exists, we have no choice but to compare document positions,
// since styles outside of the body and head continue to be shunted into the head
// (and thus can shift to end up before dynamically added DOM content that is also
// outside the body).
- if ((createdByParser && m_document->body()) || m_styleSheetCandidateNodes.isEmpty()) {
- m_styleSheetCandidateNodes.add(node);
+ if ((createdByParser && m_document.body()) || m_styleSheetCandidateNodes.isEmpty()) {
+ m_styleSheetCandidateNodes.add(&node);
return;
}
do {
--it;
Node* n = *it;
- unsigned short position = n->compareDocumentPosition(node);
+ unsigned short position = n->compareDocumentPosition(&node);
if (position == Node::DOCUMENT_POSITION_FOLLOWING) {
- m_styleSheetCandidateNodes.insertBefore(followingNode, node);
+ m_styleSheetCandidateNodes.insertBefore(followingNode, &node);
return;
}
followingNode = n;
} while (it != begin);
- m_styleSheetCandidateNodes.insertBefore(followingNode, node);
+ m_styleSheetCandidateNodes.insertBefore(followingNode, &node);
}
-void DocumentStyleSheetCollection::removeStyleSheetCandidateNode(Node* node)
+void DocumentStyleSheetCollection::removeStyleSheetCandidateNode(Node& node)
{
- m_styleSheetCandidateNodes.remove(node);
+ m_styleSheetCandidateNodes.remove(&node);
}
void DocumentStyleSheetCollection::collectActiveStyleSheets(Vector<RefPtr<StyleSheet> >& sheets)
{
- if (m_document->settings() && !m_document->settings()->authorAndUserStylesEnabled())
+ if (m_document.settings() && !m_document.settings()->authorAndUserStylesEnabled())
return;
StyleSheetCandidateListHashSet::iterator begin = m_styleSheetCandidateNodes.begin();
sheet = pi->sheet();
#if ENABLE(XSLT)
// Don't apply XSL transforms to already transformed documents -- <rdar://problem/4132806>
- if (pi->isXSL() && !m_document->transformSourceDocument()) {
+ if (pi->isXSL() && !m_document.transformSourceDocument()) {
// Don't apply XSL transforms until loading is finished.
- if (!m_document->parsing())
- m_document->applyXSLTransform(pi);
+ if (!m_document.parsing())
+ m_document.applyXSLTransform(pi);
return;
}
#endif
if (updateFlag != OptimizedUpdate)
return;
- if (!m_document->styleResolverIfExists())
+ if (!m_document.styleResolverIfExists())
return;
// Find out which stylesheets are new.
styleResolverUpdateType = hasInsertions ? Reset : Additive;
// If we are already parsing the body and so may have significant amount of elements, put some effort into trying to avoid style recalcs.
- if (!m_document->body() || m_document->hasNodesWithPlaceholderStyle())
+ if (!m_document.body() || m_document.hasNodesWithPlaceholderStyle())
return;
StyleInvalidationAnalysis invalidationAnalysis(addedSheets);
if (invalidationAnalysis.dirtiesAllStyle())
return;
- invalidationAnalysis.invalidateStyle(m_document);
+ invalidationAnalysis.invalidateStyle(&m_document);
requiresFullStyleRecalc = false;
}
}
}
-static void collectActiveCSSStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document* document)
+static void collectActiveCSSStyleSheetsFromSeamlessParents(Vector<RefPtr<CSSStyleSheet> >& sheets, Document& document)
{
- HTMLIFrameElement* seamlessParentIFrame = document->seamlessParentIFrame();
+ HTMLIFrameElement* seamlessParentIFrame = document.seamlessParentIFrame();
if (!seamlessParentIFrame)
return;
sheets.appendVector(seamlessParentIFrame->document().styleSheetCollection()->activeAuthorStyleSheets());
bool DocumentStyleSheetCollection::updateActiveStyleSheets(UpdateFlag updateFlag)
{
- if (m_document->inStyleRecalc()) {
+ if (m_document.inStyleRecalc()) {
// SVG <use> element may manage to invalidate style selector in the middle of a style recalc.
// https://bugs.webkit.org/show_bug.cgi?id=54344
// FIXME: This should be fixed in SVG and the call site replaced by ASSERT(!m_inStyleRecalc).
m_pendingUpdateType = FullUpdate;
- m_document->scheduleForcedStyleRecalc();
+ m_document.scheduleForcedStyleRecalc();
return false;
}
- if (!m_document->renderView() || !m_document->attached())
+ if (!m_document.renderView() || !m_document.attached())
return false;
Vector<RefPtr<StyleSheet> > activeStyleSheets;
analyzeStyleSheetChange(updateFlag, activeCSSStyleSheets, styleResolverUpdateType, requiresFullStyleRecalc);
if (styleResolverUpdateType == Reconstruct)
- m_document->clearStyleResolver();
+ m_document.clearStyleResolver();
else {
- StyleResolver& styleResolver = m_document->ensureStyleResolver();
+ StyleResolver& styleResolver = m_document.ensureStyleResolver();
if (styleResolverUpdateType == Reset) {
styleResolver.ruleSets().resetAuthorStyle();
styleResolver.appendAuthorStyleSheets(0, activeCSSStyleSheets);
m_usesRemUnits = styleSheetsUseRemUnits(m_activeAuthorStyleSheets);
m_pendingUpdateType = NoUpdate;
- m_document->notifySeamlessChildDocumentsOfStylesheetUpdate();
+ m_document.notifySeamlessChildDocumentsOfStylesheetUpdate();
return requiresFullStyleRecalc;
}
class DocumentStyleSheetCollection {
WTF_MAKE_FAST_ALLOCATED;
public:
- static PassOwnPtr<DocumentStyleSheetCollection> create(Document* document) { return adoptPtr(new DocumentStyleSheetCollection(document)); }
+ static PassOwnPtr<DocumentStyleSheetCollection> create(Document& document) { return adoptPtr(new DocumentStyleSheetCollection(document)); }
~DocumentStyleSheetCollection();
- const Vector<RefPtr<StyleSheet> >& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
+ const Vector<RefPtr<StyleSheet>>& styleSheetsForStyleSheetList() const { return m_styleSheetsForStyleSheetList; }
- const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
+ const Vector<RefPtr<CSSStyleSheet>>& activeAuthorStyleSheets() const { return m_activeAuthorStyleSheets; }
CSSStyleSheet* pageUserSheet();
- const Vector<RefPtr<CSSStyleSheet> >& documentUserStyleSheets() const { return m_userStyleSheets; }
- const Vector<RefPtr<CSSStyleSheet> >& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
- const Vector<RefPtr<CSSStyleSheet> >& injectedUserStyleSheets() const;
- const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const;
+ const Vector<RefPtr<CSSStyleSheet>>& documentUserStyleSheets() const { return m_userStyleSheets; }
+ const Vector<RefPtr<CSSStyleSheet>>& documentAuthorStyleSheets() const { return m_authorStyleSheets; }
+ const Vector<RefPtr<CSSStyleSheet>>& injectedUserStyleSheets() const;
+ const Vector<RefPtr<CSSStyleSheet>>& injectedAuthorStyleSheets() const;
- void addStyleSheetCandidateNode(Node*, bool createdByParser);
- void removeStyleSheetCandidateNode(Node*);
+ void addStyleSheetCandidateNode(Node&, bool createdByParser);
+ void removeStyleSheetCandidateNode(Node&);
void clearPageUserSheet();
void updatePageUserSheet();
bool activeStyleSheetsContains(const CSSStyleSheet*) const;
private:
- explicit DocumentStyleSheetCollection(Document*);
+ explicit DocumentStyleSheetCollection(Document&);
void collectActiveStyleSheets(Vector<RefPtr<StyleSheet> >&);
enum StyleResolverUpdateType {
};
void analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet> >& newStylesheets, StyleResolverUpdateType&, bool& requiresFullStyleRecalc);
- Document* m_document;
+ Document& m_document;
Vector<RefPtr<StyleSheet> > m_styleSheetsForStyleSheetList;
Vector<RefPtr<CSSStyleSheet> > m_activeAuthorStyleSheets;
RefPtr<CSSStyleSheet> m_pageUserSheet;
- mutable Vector<RefPtr<CSSStyleSheet> > m_injectedUserStyleSheets;
- mutable Vector<RefPtr<CSSStyleSheet> > m_injectedAuthorStyleSheets;
+ mutable Vector<RefPtr<CSSStyleSheet>> m_injectedUserStyleSheets;
+ mutable Vector<RefPtr<CSSStyleSheet>> m_injectedAuthorStyleSheets;
mutable bool m_injectedStyleSheetCacheValid;
- Vector<RefPtr<CSSStyleSheet> > m_userStyleSheets;
- Vector<RefPtr<CSSStyleSheet> > m_authorStyleSheets;
+ Vector<RefPtr<CSSStyleSheet>> m_userStyleSheets;
+ Vector<RefPtr<CSSStyleSheet>> m_authorStyleSheets;
bool m_hadActiveLoadingStylesheet;
UpdateFlag m_pendingUpdateType;
if (newScope)
updateIdForTreeScope(newScope, nullAtom, idValue);
if (newDocument)
- updateIdForDocument(newDocument, nullAtom, idValue, AlwaysUpdateHTMLDocumentNamedItemMaps);
+ updateIdForDocument(*newDocument, nullAtom, idValue, AlwaysUpdateHTMLDocumentNamedItemMaps);
}
const AtomicString& nameValue = getNameAttribute();
if (newScope)
updateNameForTreeScope(newScope, nullAtom, nameValue);
if (newDocument)
- updateNameForDocument(newDocument, nullAtom, nameValue);
+ updateNameForDocument(*newDocument, nullAtom, nameValue);
}
if (newScope && hasTagName(labelTag)) {
if (oldScope)
updateIdForTreeScope(oldScope, idValue, nullAtom);
if (oldDocument)
- updateIdForDocument(oldDocument, idValue, nullAtom, AlwaysUpdateHTMLDocumentNamedItemMaps);
+ updateIdForDocument(*oldDocument, idValue, nullAtom, AlwaysUpdateHTMLDocumentNamedItemMaps);
}
const AtomicString& nameValue = getNameAttribute();
if (oldScope)
updateNameForTreeScope(oldScope, nameValue, nullAtom);
if (oldDocument)
- updateNameForDocument(oldDocument, nameValue, nullAtom);
+ updateNameForDocument(*oldDocument, nameValue, nullAtom);
}
if (oldScope && hasTagName(labelTag)) {
return false;
}
- SelectorQuery* selectorQuery = document().selectorQueryCache().add(selector, &document(), ec);
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(selector, document(), ec);
if (!selectorQuery)
return false;
return selectorQuery->matches(this);
return;
if (!document().isHTMLDocument())
return;
- updateNameForDocument(toHTMLDocument(&document()), oldName, newName);
+ updateNameForDocument(toHTMLDocument(document()), oldName, newName);
}
void Element::updateNameForTreeScope(TreeScope* scope, const AtomicString& oldName, const AtomicString& newName)
scope->addElementByName(newName, this);
}
-void Element::updateNameForDocument(HTMLDocument* document, const AtomicString& oldName, const AtomicString& newName)
+void Element::updateNameForDocument(HTMLDocument& document, const AtomicString& oldName, const AtomicString& newName)
{
ASSERT(inDocument());
ASSERT(oldName != newName);
if (WindowNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
const AtomicString& id = WindowNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
- document->removeWindowNamedItem(oldName, this);
+ document.removeWindowNamedItem(oldName, this);
if (!newName.isEmpty() && newName != id)
- document->addWindowNamedItem(newName, this);
+ document.addWindowNamedItem(newName, this);
}
if (DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this)) {
const AtomicString& id = DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this) ? getIdAttribute() : nullAtom;
if (!oldName.isEmpty() && oldName != id)
- document->removeDocumentNamedItem(oldName, this);
+ document.removeDocumentNamedItem(oldName, this);
if (!newName.isEmpty() && newName != id)
- document->addDocumentNamedItem(newName, this);
+ document.addDocumentNamedItem(newName, this);
}
}
return;
if (!document().isHTMLDocument())
return;
- updateIdForDocument(toHTMLDocument(&document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
+ updateIdForDocument(toHTMLDocument(document()), oldId, newId, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute);
}
void Element::updateIdForTreeScope(TreeScope* scope, const AtomicString& oldId, const AtomicString& newId)
scope->addElementById(newId, this);
}
-void Element::updateIdForDocument(HTMLDocument* document, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition condition)
+void Element::updateIdForDocument(HTMLDocument& document, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition condition)
{
ASSERT(inDocument());
ASSERT(oldId != newId);
if (WindowNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && WindowNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
- document->removeWindowNamedItem(oldId, this);
+ document.removeWindowNamedItem(oldId, this);
if (!newId.isEmpty() && newId != name)
- document->addWindowNamedItem(newId, this);
+ document.addWindowNamedItem(newId, this);
}
if (DocumentNameCollection::nodeMatchesIfIdAttributeMatch(this)) {
const AtomicString& name = condition == UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute && DocumentNameCollection::nodeMatchesIfNameAttributeMatch(this) ? getNameAttribute() : nullAtom;
if (!oldId.isEmpty() && oldId != name)
- document->removeDocumentNamedItem(oldId, this);
+ document.removeDocumentNamedItem(oldId, this);
if (!newId.isEmpty() && newId != name)
- document->addDocumentNamedItem(newId, this);
+ document.addDocumentNamedItem(newId, this);
}
}
void updateName(const AtomicString& oldName, const AtomicString& newName);
void updateNameForTreeScope(TreeScope*, const AtomicString& oldName, const AtomicString& newName);
- void updateNameForDocument(HTMLDocument*, const AtomicString& oldName, const AtomicString& newName);
+ void updateNameForDocument(HTMLDocument&, const AtomicString& oldName, const AtomicString& newName);
void updateId(const AtomicString& oldId, const AtomicString& newId);
void updateIdForTreeScope(TreeScope*, const AtomicString& oldId, const AtomicString& newId);
enum HTMLDocumentNamedItemMapsUpdatingCondition { AlwaysUpdateHTMLDocumentNamedItemMaps, UpdateHTMLDocumentNamedItemMapsOnlyIfDiffersFromNameAttribute };
- void updateIdForDocument(HTMLDocument*, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition);
+ void updateIdForDocument(HTMLDocument&, const AtomicString& oldId, const AtomicString& newId, HTMLDocumentNamedItemMapsUpdatingCondition);
void updateLabel(TreeScope*, const AtomicString& oldForAttributeValue, const AtomicString& newForAttributeValue);
void scrollByUnits(int units, ScrollGranularity);
{
}
-void InlineStyleSheetOwner::insertedIntoDocument(Document* document, Element* element)
+void InlineStyleSheetOwner::insertedIntoDocument(Document& document, Element& element)
{
- ASSERT(document);
- ASSERT(element);
- document->styleSheetCollection()->addStyleSheetCandidateNode(element, m_isParsingChildren);
+ document.styleSheetCollection()->addStyleSheetCandidateNode(element, m_isParsingChildren);
if (m_isParsingChildren)
return;
createSheetFromTextContents(element);
}
-void InlineStyleSheetOwner::removedFromDocument(Document* document, Element* element)
+void InlineStyleSheetOwner::removedFromDocument(Document& document, Element& element)
{
- ASSERT(document);
- ASSERT(element);
- document->styleSheetCollection()->removeStyleSheetCandidateNode(element);
+ document.styleSheetCollection()->removeStyleSheetCandidateNode(element);
if (m_sheet)
clearSheet();
// If we're in document teardown, then we don't need to do any notification of our sheet's removal.
- if (document->hasLivingRenderTree())
- document->styleResolverChanged(DeferRecalcStyle);
+ if (document.hasLivingRenderTree())
+ document.styleResolverChanged(DeferRecalcStyle);
}
-void InlineStyleSheetOwner::clearDocumentData(Document* document, Element* element)
+void InlineStyleSheetOwner::clearDocumentData(Document& document, Element& element)
{
if (m_sheet)
m_sheet->clearOwnerNode();
- if (!element->inDocument())
+ if (!element.inDocument())
return;
- document->styleSheetCollection()->removeStyleSheetCandidateNode(element);
+ document.styleSheetCollection()->removeStyleSheetCandidateNode(element);
}
-void InlineStyleSheetOwner::childrenChanged(Element* element)
+void InlineStyleSheetOwner::childrenChanged(Element& element)
{
- ASSERT(element);
if (m_isParsingChildren)
return;
- if (!element->inDocument())
+ if (!element.inDocument())
return;
createSheetFromTextContents(element);
}
-void InlineStyleSheetOwner::finishParsingChildren(Element* element)
+void InlineStyleSheetOwner::finishParsingChildren(Element& element)
{
- ASSERT(element);
- if (element->inDocument())
+ if (element.inDocument())
createSheetFromTextContents(element);
m_isParsingChildren = false;
}
-void InlineStyleSheetOwner::createSheetFromTextContents(Element* element)
+void InlineStyleSheetOwner::createSheetFromTextContents(Element& element)
{
- createSheet(element, TextNodeTraversal::contentsAsString(element));
+ createSheet(element, TextNodeTraversal::contentsAsString(&element));
}
void InlineStyleSheetOwner::clearSheet()
m_sheet.release()->clearOwnerNode();
}
-inline bool isValidCSSContentType(Element* element, const AtomicString& type)
+inline bool isValidCSSContentType(Element& element, const AtomicString& type)
{
DEFINE_STATIC_LOCAL(const AtomicString, cssContentType, ("text/css", AtomicString::ConstructFromLiteral));
if (type.isEmpty())
return true;
- return element->isHTMLElement() ? equalIgnoringCase(type, cssContentType) : type == cssContentType;
+ return element.isHTMLElement() ? equalIgnoringCase(type, cssContentType) : type == cssContentType;
}
-void InlineStyleSheetOwner::createSheet(Element* element, const String& text)
+void InlineStyleSheetOwner::createSheet(Element& element, const String& text)
{
- ASSERT(element);
- ASSERT(element->inDocument());
- Document& document = element->document();
+ ASSERT(element.inDocument());
+ Document& document = element.document();
if (m_sheet) {
if (m_sheet->isLoading())
document.styleSheetCollection()->removePendingSheet();
return;
RefPtr<MediaQuerySet> mediaQueries;
- if (element->isHTMLElement())
+ if (element.isHTMLElement())
mediaQueries = MediaQuerySet::createAllowingDescriptionSyntax(m_media);
else
mediaQueries = MediaQuerySet::create(m_media);
m_sheet = CSSStyleSheet::createInline(element, KURL(), document.inputEncoding());
m_sheet->setMediaQueries(mediaQueries.release());
- m_sheet->setTitle(element->title());
+ m_sheet->setTitle(element.title());
m_sheet->contents()->parseStringAtLine(text, m_startLineNumber.zeroBasedInt(), m_isParsingChildren);
m_loading = false;
return m_sheet && m_sheet->isLoading();
}
-bool InlineStyleSheetOwner::sheetLoaded(Document* document)
+bool InlineStyleSheetOwner::sheetLoaded(Document& document)
{
- ASSERT(document);
if (isLoading())
return false;
- document->styleSheetCollection()->removePendingSheet();
+ document.styleSheetCollection()->removePendingSheet();
return true;
}
-void InlineStyleSheetOwner::startLoadingDynamicSheet(Document* document)
+void InlineStyleSheetOwner::startLoadingDynamicSheet(Document& document)
{
- ASSERT(document);
- document->styleSheetCollection()->addPendingSheet();
+ document.styleSheetCollection()->addPendingSheet();
}
}
CSSStyleSheet* sheet() const { return m_sheet.get(); }
bool isLoading() const;
- bool sheetLoaded(Document*);
- void startLoadingDynamicSheet(Document*);
+ bool sheetLoaded(Document&);
+ void startLoadingDynamicSheet(Document&);
- void insertedIntoDocument(Document*, Element*);
- void removedFromDocument(Document*, Element*);
- void clearDocumentData(Document*, Element*);
- void childrenChanged(Element*);
- void finishParsingChildren(Element*);
+ void insertedIntoDocument(Document&, Element&);
+ void removedFromDocument(Document&, Element&);
+ void clearDocumentData(Document&, Element&);
+ void childrenChanged(Element&);
+ void finishParsingChildren(Element&);
private:
- void createSheet(Element*, const String& text);
- void createSheetFromTextContents(Element*);
+ void createSheet(Element&, const String& text);
+ void createSheetFromTextContents(Element&);
void clearSheet();
bool m_isParsingChildren;
return 0;
}
- SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, &document(), ec);
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, document(), ec);
if (!selectorQuery)
return 0;
return selectorQuery->queryFirst(this);
return 0;
}
- SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, &document(), ec);
+ SelectorQuery* selectorQuery = document().selectorQueryCache().add(selectors, document(), ec);
if (!selectorQuery)
return 0;
return selectorQuery->queryAll(this);
m_cachedSheet->removeClient(this);
if (inDocument())
- document().styleSheetCollection()->removeStyleSheetCandidateNode(this);
+ document().styleSheetCollection()->removeStyleSheetCandidateNode(*this);
}
String ProcessingInstruction::nodeName() const
}
ASSERT(m_isCSS);
- CSSParserContext parserContext(&document(), baseURL, charset);
+ CSSParserContext parserContext(document(), baseURL, charset);
RefPtr<StyleSheetContents> newSheet = StyleSheetContents::create(href, parserContext);
CharacterData::insertedInto(insertionPoint);
if (!insertionPoint->inDocument())
return InsertionDone;
- document().styleSheetCollection()->addStyleSheetCandidateNode(this, m_createdByParser);
+ document().styleSheetCollection()->addStyleSheetCandidateNode(*this, m_createdByParser);
checkStyleSheet();
return InsertionDone;
}
if (!insertionPoint->inDocument())
return;
- document().styleSheetCollection()->removeStyleSheetCandidateNode(this);
+ document().styleSheetCollection()->removeStyleSheetCandidateNode(*this);
if (m_sheet) {
ASSERT(m_sheet->ownerNode() == this);
m_selectors.initialize(m_selectorList);
}
-SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, Document* document, ExceptionCode& ec)
+SelectorQuery* SelectorQueryCache::add(const AtomicString& selectors, Document& document, ExceptionCode& ec)
{
HashMap<AtomicString, OwnPtr<SelectorQuery> >::iterator it = m_entries.find(selectors);
if (it != m_entries.end())
class SelectorQueryCache {
WTF_MAKE_FAST_ALLOCATED;
public:
- SelectorQuery* add(const AtomicString&, Document*, ExceptionCode&);
+ SelectorQuery* add(const AtomicString&, Document&, ExceptionCode&);
void invalidate();
private:
using namespace HTMLNames;
-PassRefPtr<EditCommandComposition> EditCommandComposition::create(Document* document,
+PassRefPtr<EditCommandComposition> EditCommandComposition::create(Document& document,
const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction editAction)
{
return adoptRef(new EditCommandComposition(document, startingSelection, endingSelection, editAction));
}
-EditCommandComposition::EditCommandComposition(Document* document, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction editAction)
- : m_document(document)
+EditCommandComposition::EditCommandComposition(Document& document, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction editAction)
+ : m_document(&document)
, m_startingSelection(startingSelection)
, m_endingSelection(endingSelection)
, m_startingRootEditableElement(startingSelection.rootEditableElement())
while (command && command->parent())
command = command->parent();
if (!command->m_composition)
- command->m_composition = EditCommandComposition::create(&document(), startingSelection(), endingSelection(), editingAction());
+ command->m_composition = EditCommandComposition::create(document(), startingSelection(), endingSelection(), editingAction());
return command->m_composition.get();
}
class EditCommandComposition : public UndoStep {
public:
- static PassRefPtr<EditCommandComposition> create(Document*, const VisibleSelection&, const VisibleSelection&, EditAction);
+ static PassRefPtr<EditCommandComposition> create(Document&, const VisibleSelection&, const VisibleSelection&, EditAction);
virtual void unapply() OVERRIDE;
virtual void reapply() OVERRIDE;
#endif
private:
- EditCommandComposition(Document*, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction);
+ EditCommandComposition(Document&, const VisibleSelection& startingSelection, const VisibleSelection& endingSelection, EditAction);
RefPtr<Document> m_document;
VisibleSelection m_startingSelection;
setAttribute(vlinkAttr, value);
}
-static int adjustForZoom(int value, Document* document)
+static int adjustForZoom(int value, Frame& frame)
{
- Frame* frame = document->frame();
- float zoomFactor = frame->pageZoomFactor() * frame->frameScaleFactor();
+ float zoomFactor = frame.pageZoomFactor() * frame.frameScaleFactor();
if (zoomFactor == 1)
return value;
// Needed because of truncation (rather than rounding) when scaling up.
if (!document().inQuirksMode())
return 0;
document().updateLayoutIgnorePendingStylesheets();
- FrameView* view = document().view();
- return view ? adjustForZoom(view->scrollX(), &document()) : 0;
+ Frame* frame = document().frame();
+ if (!frame)
+ return 0;
+ FrameView* view = frame->view();
+ if (!view)
+ return 0;
+ return adjustForZoom(view->scrollX(), *frame);
}
void HTMLBodyElement::setScrollLeft(int scrollLeft)
if (!document().inQuirksMode())
return 0;
document().updateLayoutIgnorePendingStylesheets();
- FrameView* view = document().view();
- return view ? adjustForZoom(view->scrollY(), &document()) : 0;
+ Frame* frame = document().frame();
+ if (!frame)
+ return 0;
+ FrameView* view = frame->view();
+ if (!view)
+ return 0;
+ return adjustForZoom(view->scrollY(), *frame);
}
void HTMLBodyElement::setScrollTop(int scrollTop)
{
// Update the document's layout.
document().updateLayoutIgnorePendingStylesheets();
- FrameView* view = document().view();
- return view ? adjustForZoom(view->contentsHeight(), &document()) : 0;
+ Frame* frame = document().frame();
+ if (!frame)
+ return 0;
+ FrameView* view = frame->view();
+ if (!view)
+ return 0;
+ return adjustForZoom(view->contentsHeight(), *frame);
}
int HTMLBodyElement::scrollWidth()
{
// Update the document's layout.
document().updateLayoutIgnorePendingStylesheets();
- FrameView* view = document().view();
- return view ? adjustForZoom(view->contentsWidth(), &document()) : 0;
+ Frame* frame = document().frame();
+ if (!frame)
+ return 0;
+ FrameView* view = frame->view();
+ if (!view)
+ return 0;
+ return adjustForZoom(view->contentsWidth(), *frame);
}
void HTMLBodyElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
return static_cast<const HTMLDocument*>(document);
}
+inline HTMLDocument& toHTMLDocument(Document& document)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(document.isHTMLDocument());
+ return static_cast<HTMLDocument&>(document);
+}
+
+inline const HTMLDocument& toHTMLDocument(const Document& document)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(document.isHTMLDocument());
+ return static_cast<const HTMLDocument&>(document);
+}
// This will catch anyone doing an unnecessary cast.
void toHTMLDocument(const HTMLDocument*);
+void toHTMLDocument(const HTMLDocument&);
} // namespace WebCore
m_cachedSheet->removeClient(this);
if (inDocument())
- document().styleSheetCollection()->removeStyleSheetCandidateNode(this);
+ document().styleSheetCollection()->removeStyleSheetCandidateNode(*this);
linkLoadEventSender().cancelEvent(this);
}
if (m_isInShadowTree)
return InsertionDone;
- document().styleSheetCollection()->addStyleSheetCandidateNode(this, m_createdByParser);
+ document().styleSheetCollection()->addStyleSheetCandidateNode(*this, m_createdByParser);
process();
return InsertionDone;
ASSERT(!m_sheet);
return;
}
- document().styleSheetCollection()->removeStyleSheetCandidateNode(this);
+ document().styleSheetCollection()->removeStyleSheetCandidateNode(*this);
if (m_sheet)
clearSheet();
// Completing the sheet load may cause scripts to execute.
Ref<HTMLLinkElement> protect(*this);
- CSSParserContext parserContext(&document(), baseURL, charset);
+ CSSParserContext parserContext(document(), baseURL, charset);
if (RefPtr<StyleSheetContents> restoredSheet = const_cast<CachedCSSStyleSheet*>(cachedStyleSheet)->restoreParsedStyleSheet(parserContext)) {
ASSERT(restoredSheet->isCacheable());
return map;
}
-static void addElementToDocumentMap(HTMLMediaElement* element, Document* document)
+static void addElementToDocumentMap(HTMLMediaElement& element, Document& document)
{
DocumentElementSetMap& map = documentToElementSetMap();
- HashSet<HTMLMediaElement*> set = map.take(document);
- set.add(element);
- map.add(document, set);
+ HashSet<HTMLMediaElement*> set = map.take(&document);
+ set.add(&element);
+ map.add(&document, set);
}
-static void removeElementFromDocumentMap(HTMLMediaElement* element, Document* document)
+static void removeElementFromDocumentMap(HTMLMediaElement& element, Document& document)
{
DocumentElementSetMap& map = documentToElementSetMap();
- HashSet<HTMLMediaElement*> set = map.take(document);
- set.remove(element);
+ HashSet<HTMLMediaElement*> set = map.take(&document);
+ set.remove(&element);
if (!set.isEmpty())
- map.add(document, set);
+ map.add(&document, set);
}
#if ENABLE(ENCRYPTED_MEDIA)
addBehaviorRestriction(RequireUserGestureForLoadRestriction);
}
- addElementToDocumentMap(this, &document);
+ addElementToDocumentMap(*this, document);
#if ENABLE(VIDEO_TRACK)
document.registerForCaptionPreferencesChangedCallbacks(this);
setMediaKeys(0);
#endif
- removeElementFromDocumentMap(this, &document());
+ removeElementFromDocumentMap(*this, document());
m_completelyLoaded = true;
if (m_player)
if (oldDocument) {
oldDocument->unregisterForMediaVolumeCallbacks(this);
- removeElementFromDocumentMap(this, oldDocument);
+ removeElementFromDocumentMap(*this, *oldDocument);
}
document().registerForMediaVolumeCallbacks(this);
- addElementToDocumentMap(this, &document());
+ addElementToDocumentMap(*this, document());
HTMLElement::didMoveToNewDocument(oldDocument);
}
// The MediaPlayer came across content it cannot completely handle.
// This is normally acceptable except when we are in a standalone
// MediaDocument. If so, tell the document what has happened.
- if (document().isMediaDocument()) {
- MediaDocument* mediaDocument = toMediaDocument(&document());
- mediaDocument->mediaElementSawUnsupportedTracks();
- }
+ if (document().isMediaDocument())
+ toMediaDocument(document()).mediaElementSawUnsupportedTracks();
}
void HTMLMediaElement::mediaPlayerResourceNotSupported(MediaPlayer*)
m_pendingClickEventFromSnapshot = nullptr;
}
-static bool documentHadRecentUserGesture(Document* document)
+static bool documentHadRecentUserGesture(Document& document)
{
- double lastKnownUserGestureTimestamp = document->lastHandledUserGestureTimestamp();
+ double lastKnownUserGestureTimestamp = document.lastHandledUserGestureTimestamp();
- if (document->frame() != &document->page()->mainFrame() && document->page()->mainFrame().document())
- lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document->page()->mainFrame().document()->lastHandledUserGestureTimestamp());
+ if (document.frame() != &document.page()->mainFrame() && document.page()->mainFrame().document())
+ lastKnownUserGestureTimestamp = std::max(lastKnownUserGestureTimestamp, document.page()->mainFrame().document()->lastHandledUserGestureTimestamp());
if (monotonicallyIncreasingTime() - lastKnownUserGestureTimestamp < autostartSoonAfterUserGestureThreshold)
return true;
void HTMLPlugInImageElement::checkSizeChangeForSnapshotting()
{
- if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(&document()))
+ if (!m_needsCheckForSizeChange || m_snapshotDecision != MaySnapshotWhenResized || documentHadRecentUserGesture(document()))
return;
m_needsCheckForSizeChange = false;
return;
}
- if (documentHadRecentUserGesture(&document())) {
+ if (documentHadRecentUserGesture(document())) {
LOG(Plugins, "%p Plug-in was created shortly after a user gesture, set to play", this);
m_snapshotDecision = NeverSnapshot;
return;
{
// During tear-down, willRemove isn't called, so m_scopedStyleRegistrationState may still be RegisteredAsScoped or RegisteredInShadowRoot here.
// Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered).
- m_styleSheetOwner.clearDocumentData(&document(), this);
+ m_styleSheetOwner.clearDocumentData(document(), *this);
styleLoadEventSender().cancelEvent(this);
}
void HTMLStyleElement::finishParsingChildren()
{
- m_styleSheetOwner.finishParsingChildren(this);
+ m_styleSheetOwner.finishParsingChildren(*this);
HTMLElement::finishParsingChildren();
}
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint->inDocument()) {
- m_styleSheetOwner.insertedIntoDocument(&document(), this);
+ m_styleSheetOwner.insertedIntoDocument(document(), *this);
#if ENABLE(STYLE_SCOPED)
if (m_scopedStyleRegistrationState == NotRegistered && (scoped() || isInShadowTree()))
registerWithScopingNode(scoped());
#endif
if (insertionPoint->inDocument())
- m_styleSheetOwner.removedFromDocument(&document(), this);
+ m_styleSheetOwner.removedFromDocument(document(), *this);
}
void HTMLStyleElement::childrenChanged(const ChildChange& change)
{
HTMLElement::childrenChanged(change);
- m_styleSheetOwner.childrenChanged(this);
+ m_styleSheetOwner.childrenChanged(*this);
}
void HTMLStyleElement::dispatchPendingLoadEvents()
virtual void finishParsingChildren();
virtual bool isLoading() const { return m_styleSheetOwner.isLoading(); }
- virtual bool sheetLoaded() { return m_styleSheetOwner.sheetLoaded(&document()); }
+ virtual bool sheetLoaded() { return m_styleSheetOwner.sheetLoaded(document()); }
virtual void notifyLoadedSheetAndAllCriticalSubresources(bool errorOccurred);
- virtual void startLoadingDynamicSheet() { m_styleSheetOwner.startLoadingDynamicSheet(&document()); }
+ virtual void startLoadingDynamicSheet() { m_styleSheetOwner.startLoadingDynamicSheet(document()); }
virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const;
return static_cast<const MediaDocument*>(document);
}
+inline MediaDocument& toMediaDocument(Document& document)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(document.isMediaDocument());
+ return static_cast<MediaDocument&>(document);
+}
+
+inline const MediaDocument& toMediaDocument(const Document& document)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(document.isMediaDocument());
+ return static_cast<const MediaDocument&>(document);
+}
+
// This will catch anyone doing an unnecessary cast.
void toMediaDocument(const MediaDocument*);
+void toMediaDocument(const MediaDocument&);
}
static PassOwnPtr<CSSParser> createCSSParser(Document* document)
{
- return adoptPtr(new CSSParser(document ? CSSParserContext(document) : strictCSSParserContext()));
+ return adoptPtr(new CSSParser(document ? CSSParserContext(*document) : strictCSSParserContext()));
}
PassRefPtr<InspectorStyle> InspectorStyle::create(const InspectorCSSId& styleId, PassRefPtr<CSSStyleDeclaration> style, InspectorStyleSheet* parentStyleSheet)
}
}
- TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), &document);
+ TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document);
RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding.encodingForFormSubmission());
Vector<pair<String, String> > formValues;
}
}
-TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptCharset, Document* document)
+TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptCharset, Document& document)
{
String normalizedAcceptCharset = acceptCharset;
normalizedAcceptCharset.replace(',', ' ');
return encoding;
}
- return document->inputEncoding();
+ return document.inputEncoding();
}
Vector<char> FormDataBuilder::generateUniqueBoundaryString()
class FormDataBuilder {
WTF_MAKE_NONCOPYABLE(FormDataBuilder);
public:
- static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document* document);
+ static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document&);
// Helper functions used by HTMLFormElement for multi-part form data
static Vector<char> generateUniqueBoundaryString();
return fullscreenStyle.release();
}
-RenderFullScreen* RenderFullScreen::wrapRenderer(RenderObject* object, RenderElement* parent, Document* document)
+RenderFullScreen* RenderFullScreen::wrapRenderer(RenderObject* object, RenderElement* parent, Document& document)
{
- RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(*document);
+ RenderFullScreen* fullscreenRenderer = RenderFullScreen::createAnonymous(document);
fullscreenRenderer->setStyle(createFullScreenStyle());
if (parent && !parent->isChildAllowed(fullscreenRenderer, fullscreenRenderer->style())) {
fullscreenRenderer->destroy();
fullscreenRenderer->addChild(object);
fullscreenRenderer->setNeedsLayoutAndPrefWidthsRecalc();
}
- document->setFullScreenRenderer(fullscreenRenderer);
+ document.setFullScreenRenderer(fullscreenRenderer);
return fullscreenRenderer;
}
void createPlaceholder(PassRefPtr<RenderStyle>, const LayoutRect& frameRect);
- static RenderFullScreen* wrapRenderer(RenderObject*, RenderElement*, Document*);
+ static RenderFullScreen* wrapRenderer(RenderObject*, RenderElement*, Document&);
void unwrapRenderer();
private:
HashSet<RenderLayer*> m_clientLayers;
};
-inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(Document* document, const AtomicString& id)
+inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(Document& document, const AtomicString& id)
{
if (id.isEmpty())
return 0;
- if (RenderSVGResourceContainer* renderResource = document->accessSVGExtensions()->resourceById(id))
+ if (RenderSVGResourceContainer* renderResource = document.accessSVGExtensions()->resourceById(id))
return renderResource;
return 0;
}
template<typename Renderer>
-Renderer* getRenderSVGResourceById(Document* document, const AtomicString& id)
+Renderer* getRenderSVGResourceById(Document& document, const AtomicString& id)
{
if (RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(document, id))
return container->cast<Renderer>();
Path RenderSVGTextPath::layoutPath() const
{
- Element* targetElement = SVGURIReference::targetElementFromIRIString(textPathElement().href(), &document());
+ Element* targetElement = SVGURIReference::targetElementFromIRIString(textPathElement().href(), document());
if (!targetElement || !targetElement->hasTagName(SVGNames::pathTag))
return Path();
// For now leave the DRT output as is, but later on we should change this so cycles are properly ignored in the DRT output.
RenderObject& renderer = const_cast<RenderObject&>(object);
if (!svgStyle->maskerResource().isEmpty()) {
- if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(&object.document(), svgStyle->maskerResource())) {
+ if (RenderSVGResourceMasker* masker = getRenderSVGResourceById<RenderSVGResourceMasker>(object.document(), svgStyle->maskerResource())) {
writeIndent(ts, indent);
ts << " ";
writeNameAndQuotedValue(ts, "masker", svgStyle->maskerResource());
}
}
if (!svgStyle->clipperResource().isEmpty()) {
- if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(&object.document(), svgStyle->clipperResource())) {
+ if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById<RenderSVGResourceClipper>(object.document(), svgStyle->clipperResource())) {
writeIndent(ts, indent);
ts << " ";
writeNameAndQuotedValue(ts, "clipPath", svgStyle->clipperResource());
}
#if ENABLE(FILTERS)
if (!svgStyle->filterResource().isEmpty()) {
- if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(&object.document(), svgStyle->filterResource())) {
+ if (RenderSVGResourceFilter* filter = getRenderSVGResourceById<RenderSVGResourceFilter>(object.document(), svgStyle->filterResource())) {
writeIndent(ts, indent);
ts << " ";
writeNameAndQuotedValue(ts, "filter", svgStyle->filterResource());
else
ASSERT_NOT_REACHED();
- return SVGURIReference::fragmentIdentifierFromIRIString(target, &element->document());
+ return SVGURIReference::fragmentIdentifierFromIRIString(target, element->document());
}
-static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, AtomicString& id, bool& hasPendingResource)
+static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document& document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, AtomicString& id, bool& hasPendingResource)
{
if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR)
return 0;
if (clipperFilterMaskerTags().contains(tagName)) {
if (style->hasClipper()) {
AtomicString id(style->clipperResource());
- if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(&document, id)))
+ if (setClipper(getRenderSVGResourceById<RenderSVGResourceClipper>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
#if ENABLE(FILTERS)
if (style->hasFilter()) {
AtomicString id(style->filterResource());
- if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(&document, id)))
+ if (setFilter(getRenderSVGResourceById<RenderSVGResourceFilter>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
if (style->hasMasker()) {
AtomicString id(style->maskerResource());
- if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(&document, id)))
+ if (setMasker(getRenderSVGResourceById<RenderSVGResourceMasker>(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
if (markerTags().contains(tagName) && style->hasMarkers()) {
AtomicString markerStartId(style->markerStartResource());
- if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(&document, markerStartId)))
+ if (setMarkerStart(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerStartId)))
foundResources = true;
else
registerPendingResource(extensions, markerStartId, element);
AtomicString markerMidId(style->markerMidResource());
- if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(&document, markerMidId)))
+ if (setMarkerMid(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerMidId)))
foundResources = true;
else
registerPendingResource(extensions, markerMidId, element);
AtomicString markerEndId(style->markerEndResource());
- if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(&document, markerEndId)))
+ if (setMarkerEnd(getRenderSVGResourceById<RenderSVGResourceMarker>(document, markerEndId)))
foundResources = true;
else
registerPendingResource(extensions, markerEndId, element);
if (style->hasFill()) {
bool hasPendingResource = false;
AtomicString id;
- if (setFill(paintingResourceFromSVGPaint(&document, style->fillPaintType(), style->fillPaintUri(), id, hasPendingResource)))
+ if (setFill(paintingResourceFromSVGPaint(document, style->fillPaintType(), style->fillPaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
if (style->hasStroke()) {
bool hasPendingResource = false;
AtomicString id;
- if (setStroke(paintingResourceFromSVGPaint(&document, style->strokePaintType(), style->strokePaintUri(), id, hasPendingResource)))
+ if (setStroke(paintingResourceFromSVGPaint(document, style->strokePaintType(), style->strokePaintUri(), id, hasPendingResource)))
foundResources = true;
else if (hasPendingResource)
registerPendingResource(extensions, id, element);
if (chainableResourceTags().contains(tagName)) {
AtomicString id(targetReferenceFromResource(element));
- if (setLinkedResource(getRenderSVGResourceContainerById(&document, id)))
+ if (setLinkedResource(getRenderSVGResourceContainerById(document, id)))
foundResources = true;
else
registerPendingResource(extensions, id, element);
#if ENABLE(FULLSCREEN_API)
if (document.webkitIsFullScreen() && document.webkitCurrentFullScreenElement() == &element) {
- newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, &document);
+ newRenderer = RenderFullScreen::wrapRenderer(newRenderer, parentRenderer, document);
if (!newRenderer)
return;
}
bool SVGAltGlyphElement::hasValidGlyphElements(Vector<String>& glyphNames) const
{
String target;
- Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), &document(), &target);
+ Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &target);
if (!element)
return false;
return;
String id;
- Element* target = SVGURIReference::targetElementFromIRIString(href(), &document(), &id);
+ Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id);
if (!target) {
if (id.isEmpty())
requestImageResource();
{
if (m_cachedImage)
return FEImage::createWithImage(filter, m_cachedImage->imageForRenderer(renderer()), preserveAspectRatio());
- return FEImage::createWithIRIReference(filter, &document(), href(), preserveAspectRatio());
+ return FEImage::createWithIRIReference(filter, document(), href(), preserveAspectRatio());
}
void SVGFEImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
// FIXME: We only support xlink:href so far.
// https://bugs.webkit.org/show_bug.cgi?id=64787
- Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), &document(), &glyphName);
+ Element* element = targetElementFromIRIString(getAttribute(XLinkNames::hrefAttr), document(), &glyphName);
if (!element || !element->hasTagName(SVGNames::glyphTag))
return false;
return true;
processedGradients.add(current);
// Respect xlink:href, take attributes from referenced element
- Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), &document());
+ Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refNode && (refNode->hasTagName(SVGNames::linearGradientTag) || refNode->hasTagName(SVGNames::radialGradientTag))) {
current = toSVGGradientElement(refNode);
return;
String id;
- Element* target = SVGURIReference::targetElementFromIRIString(href(), &document(), &id);
+ Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id);
if (!target) {
// Do not register as pending if we are already pending this resource.
if (document().accessSVGExtensions()->isElementPendingResource(this, id))
SVGPathElement* SVGMPathElement::pathElement()
{
- Element* target = targetElementFromIRIString(href(), &document());
+ Element* target = targetElementFromIRIString(href(), document());
if (target && target->hasTagName(SVGNames::pathTag))
return toSVGPathElement(target);
return 0;
processedPatterns.add(current);
// Respect xlink:href, take attributes from referenced element
- Element* refElement = SVGURIReference::targetElementFromIRIString(current->href(), &document());
+ Element* refElement = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refElement && isSVGPatternElement(refElement)) {
current = toSVGPatternElement(refElement);
processedGradients.add(current);
// Respect xlink:href, take attributes from referenced element
- Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), &document());
+ Node* refNode = SVGURIReference::targetElementFromIRIString(current->href(), document());
if (refNode && (refNode->hasTagName(SVGNames::radialGradientTag) || refNode->hasTagName(SVGNames::linearGradientTag))) {
current = toSVGGradientElement(refNode);
SVGStyleElement::~SVGStyleElement()
{
- m_styleSheetOwner.clearDocumentData(&document(), this);
+ m_styleSheetOwner.clearDocumentData(document(), *this);
}
PassRefPtr<SVGStyleElement> SVGStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser)
void SVGStyleElement::finishParsingChildren()
{
- m_styleSheetOwner.finishParsingChildren(this);
+ m_styleSheetOwner.finishParsingChildren(*this);
SVGElement::finishParsingChildren();
}
{
SVGElement::insertedInto(rootParent);
if (rootParent->inDocument())
- m_styleSheetOwner.insertedIntoDocument(&document(), this);
+ m_styleSheetOwner.insertedIntoDocument(document(), *this);
return InsertionDone;
}
{
SVGElement::removedFrom(rootParent);
if (rootParent->inDocument())
- m_styleSheetOwner.removedFromDocument(&document(), this);
+ m_styleSheetOwner.removedFromDocument(document(), *this);
}
void SVGStyleElement::childrenChanged(const ChildChange& change)
{
SVGElement::childrenChanged(change);
- m_styleSheetOwner.childrenChanged(this);
+ m_styleSheetOwner.childrenChanged(*this);
}
}
virtual void finishParsingChildren();
virtual bool isLoading() const { return m_styleSheetOwner.isLoading(); }
- virtual bool sheetLoaded() OVERRIDE { return m_styleSheetOwner.sheetLoaded(&document()); }
- virtual void startLoadingDynamicSheet() OVERRIDE { m_styleSheetOwner.startLoadingDynamicSheet(&document()); }
+ virtual bool sheetLoaded() OVERRIDE { return m_styleSheetOwner.sheetLoaded(document()); }
+ virtual void startLoadingDynamicSheet() OVERRIDE { m_styleSheetOwner.startLoadingDynamicSheet(document()); }
virtual Timer<SVGElement>* svgLoadEventTimer() OVERRIDE { return &m_svgLoadEventTimer; }
InlineStyleSheetOwner m_styleSheetOwner;
// Mark the referenced ID as pending.
String id;
- SVGURIReference::targetElementFromIRIString(href(), &document(), &id);
+ SVGURIReference::targetElementFromIRIString(href(), document(), &id);
if (!id.isEmpty())
document().accessSVGExtensions()->addPendingResource(id, this);
}
return;
String id;
- RefPtr<Element> target = SVGURIReference::targetElementFromIRIString(href(), &document(), &id);
+ RefPtr<Element> target = SVGURIReference::targetElementFromIRIString(href(), document(), &id);
if (!target.get()) {
if (id.isEmpty())
return;
return;
String id;
- Element* target = SVGURIReference::targetElementFromIRIString(href(), &document(), &id);
+ Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id);
if (!target) {
// Do not register as pending if we are already pending this resource.
if (document().accessSVGExtensions()->isElementPendingResource(this, id))
return attrName.matches(XLinkNames::hrefAttr);
}
-String SVGURIReference::fragmentIdentifierFromIRIString(const String& url, Document* document)
+String SVGURIReference::fragmentIdentifierFromIRIString(const String& url, Document& document)
{
- ASSERT(document);
size_t start = url.find('#');
if (start == notFound)
return emptyString();
- KURL base = start ? KURL(document->baseURI(), url.substring(0, start)) : document->baseURI();
+ KURL base = start ? KURL(document.baseURI(), url.substring(0, start)) : document.baseURI();
String fragmentIdentifier = url.substring(start);
KURL kurl(base, fragmentIdentifier);
- if (equalIgnoringFragmentIdentifier(kurl, document->url()))
+ if (equalIgnoringFragmentIdentifier(kurl, document.url()))
return fragmentIdentifier.substring(1);
// The url doesn't have any fragment identifier.
return emptyString();
}
-static inline KURL urlFromIRIStringWithFragmentIdentifier(const String& url, Document* document, String& fragmentIdentifier)
+static inline KURL urlFromIRIStringWithFragmentIdentifier(const String& url, Document& document, String& fragmentIdentifier)
{
- ASSERT(document);
size_t startOfFragmentIdentifier = url.find('#');
if (startOfFragmentIdentifier == notFound)
return KURL();
// Exclude the '#' character when determining the fragmentIdentifier.
fragmentIdentifier = url.substring(startOfFragmentIdentifier + 1);
if (startOfFragmentIdentifier) {
- KURL base(document->baseURI(), url.substring(0, startOfFragmentIdentifier));
+ KURL base(document.baseURI(), url.substring(0, startOfFragmentIdentifier));
return KURL(base, url.substring(startOfFragmentIdentifier));
}
- return KURL(document->baseURI(), url.substring(startOfFragmentIdentifier));
+ return KURL(document.baseURI(), url.substring(startOfFragmentIdentifier));
}
-Element* SVGURIReference::targetElementFromIRIString(const String& iri, Document* document, String* fragmentIdentifier, Document* externalDocument)
+Element* SVGURIReference::targetElementFromIRIString(const String& iri, Document& document, String* fragmentIdentifier, Document* externalDocument)
{
// If there's no fragment identifier contained within the IRI string, we can't lookup an element.
String id;
if (isExternalURIReference(iri, document))
return 0;
- return document->getElementById(id);
+ return document.getElementById(id);
}
void SVGURIReference::addSupportedAttributes(HashSet<QualifiedName>& supportedAttributes)
bool isKnownAttribute(const QualifiedName&);
void addSupportedAttributes(HashSet<QualifiedName>&);
- static String fragmentIdentifierFromIRIString(const String&, Document*);
- static Element* targetElementFromIRIString(const String&, Document*, String* = 0, Document* = 0);
+ static String fragmentIdentifierFromIRIString(const String&, Document&);
+ static Element* targetElementFromIRIString(const String&, Document&, String* = 0, Document* = 0);
- static inline bool isExternalURIReference(const String& uri, Document* document)
+ static inline bool isExternalURIReference(const String& uri, Document& document)
{
// Fragment-only URIs are always internal
if (uri.startsWith('#'))
return false;
// If the URI matches our documents URL, we're dealing with a local reference.
- ASSERT(document);
- KURL url = document->completeURL(uri);
- return !equalIgnoringFragmentIdentifier(url, document->url());
+ KURL url = document.completeURL(uri);
+ return !equalIgnoringFragmentIdentifier(url, document.url());
}
protected:
Document* SVGUseElement::referencedDocument() const
{
- if (!isExternalURIReference(href(), &document()))
+ if (!isExternalURIReference(href(), document()))
return &document();
return externalDocument();
}
return;
if (SVGURIReference::isKnownAttribute(attrName)) {
- bool isExternalReference = isExternalURIReference(href(), &document());
+ bool isExternalReference = isExternalURIReference(href(), document());
if (isExternalReference) {
KURL url = document().completeURL(href());
if (url.hasFragmentIdentifier()) {
return;
String id;
- Element* target = SVGURIReference::targetElementFromIRIString(href(), &document(), &id, externalDocument());
+ Element* target = SVGURIReference::targetElementFromIRIString(href(), document(), &id, externalDocument());
if (!target || !target->inDocument()) {
// If we can't find the target of an external element, just give up.
// We can't observe if the target somewhen enters the external document, nor should we do it.
bool SVGUseElement::hasCycleUseReferencing(SVGUseElement* use, SVGElementInstance* targetInstance, SVGElement*& newTarget)
{
- Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), referencedDocument());
+ ASSERT(referencedDocument());
+ Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), *referencedDocument());
newTarget = 0;
if (targetElement && targetElement->isSVGElement())
newTarget = toSVGElement(targetElement);
SVGUseElement* use = toSVGUseElement(element);
ASSERT(!use->cachedDocumentIsStillLoading());
- Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), referencedDocument());
+ ASSERT(referencedDocument());
+ Element* targetElement = SVGURIReference::targetElementFromIRIString(use->href(), *referencedDocument());
SVGElement* target = 0;
if (targetElement && targetElement->isSVGElement())
target = toSVGElement(targetElement);
if (href.isEmpty())
target = parentNode() && parentNode()->isElementNode() ? toElement(parentNode()) : 0;
else
- target = SVGURIReference::targetElementFromIRIString(href, &document(), &id);
+ target = SVGURIReference::targetElementFromIRIString(href, document(), &id);
SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(target) : 0;
if (svgTarget && !svgTarget->inDocument())
{
}
-FEImage::FEImage(Filter* filter, Document* document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+FEImage::FEImage(Filter* filter, Document& document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
: FilterEffect(filter)
- , m_document(document)
+ , m_document(&document)
, m_href(href)
, m_preserveAspectRatio(preserveAspectRatio)
{
return adoptRef(new FEImage(filter, image, preserveAspectRatio));
}
-PassRefPtr<FEImage> FEImage::createWithIRIReference(Filter* filter, Document* document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
+PassRefPtr<FEImage> FEImage::createWithIRIReference(Filter* filter, Document& document, const String& href, const SVGPreserveAspectRatio& preserveAspectRatio)
{
return adoptRef(new FEImage(filter, document, href, preserveAspectRatio));
}
{
if (!m_document)
return 0;
- Element* hrefElement = SVGURIReference::targetElementFromIRIString(m_href, m_document);
+ Element* hrefElement = SVGURIReference::targetElementFromIRIString(m_href, *m_document);
if (!hrefElement || !hrefElement->isSVGElement())
return 0;
return hrefElement->renderer();
class FEImage : public FilterEffect {
public:
static PassRefPtr<FEImage> createWithImage(Filter*, PassRefPtr<Image>, const SVGPreserveAspectRatio&);
- static PassRefPtr<FEImage> createWithIRIReference(Filter*, Document*, const String&, const SVGPreserveAspectRatio&);
+ static PassRefPtr<FEImage> createWithIRIReference(Filter*, Document&, const String&, const SVGPreserveAspectRatio&);
virtual void platformApplySoftware();
#if ENABLE(OPENCL)
private:
virtual ~FEImage() { }
FEImage(Filter*, PassRefPtr<Image>, const SVGPreserveAspectRatio&);
- FEImage(Filter*, Document*, const String&, const SVGPreserveAspectRatio&);
+ FEImage(Filter*, Document&, const String&, const SVGPreserveAspectRatio&);
RenderElement* referencedRenderer() const;
RefPtr<Image> m_image;
TextRun::setAllowsRoundingHacks(true);
}
-void Internals::insertAuthorCSS(Document* document, const String& css) const
+void Internals::insertAuthorCSS(Document* document, const String& css, ExceptionCode& ec) const
{
- RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(document);
+ if (!document) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(*document);
parsedSheet->setIsUserStyleSheet(false);
parsedSheet->parseString(css);
document->styleSheetCollection()->addAuthorSheet(parsedSheet);
}
-void Internals::insertUserCSS(Document* document, const String& css) const
+void Internals::insertUserCSS(Document* document, const String& css, ExceptionCode& ec) const
{
- RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(document);
+ if (!document) {
+ ec = INVALID_ACCESS_ERR;
+ return;
+ }
+
+ RefPtr<StyleSheetContents> parsedSheet = StyleSheetContents::create(*document);
parsedSheet->setIsUserStyleSheet(true);
parsedSheet->parseString(css);
document->styleSheetCollection()->addUserSheet(parsedSheet);
void allowRoundingHacks() const;
- void insertAuthorCSS(Document*, const String&) const;
- void insertUserCSS(Document*, const String&) const;
+ void insertAuthorCSS(Document*, const String&, ExceptionCode&) const;
+ void insertUserCSS(Document*, const String&, ExceptionCode&) const;
#if ENABLE(INSPECTOR)
unsigned numberOfLiveNodes() const;
void allowRoundingHacks();
- void insertAuthorCSS(Document document, DOMString css);
- void insertUserCSS(Document document, DOMString css);
+ [RaisesException] void insertAuthorCSS(Document document, DOMString css);
+ [RaisesException] void insertUserCSS(Document document, DOMString css);
#if defined(ENABLE_BATTERY_STATUS) && ENABLE_BATTERY_STATUS
[RaisesException] void setBatteryStatus(Document document, DOMString eventType, boolean charging, double chargingTime, double dischargingTime, double level);