Commit a9232041 authored by darin@apple.com's avatar darin@apple.com

<https://webkit.org/b/119942> Remove unnecessary uses of Element::ownerDocument

Reviewed by Andreas Kling.

The Element::document is a simpler faster alternative to Element::ownerDocument.
The only behavior difference between the two is that ownerDocument returns 0 when
called on a Document.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::supportsFocus): Call document instead of ownerDocument.
(WebCore::HTMLMediaElement::mediaPlayerOwningDocument): Removed null checking of
document and call to ownerDocument, since ownerDocument will never return non-null
if document returns null.
(WebCore::HTMLMediaElement::mediaPlayerSawUnsupportedTracks): Call document instead
of ownerDocument.

* inspector/DOMEditor.cpp:
(WebCore::DOMEditor::SetOuterHTMLAction::perform): Call document instead of ownerDocument.

* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getMatchedStylesForNode): Call document instead of ownerDocument.
(WebCore::InspectorCSSAgent::forcePseudoState): Call document instead of ownerDocument.
(WebCore::InspectorCSSAgent::resetPseudoStates): Call document instead of ownerDocument.

* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::setOuterHTML): Call document instead of expression that
does the same thing in a roundabout way.
(WebCore::InspectorDOMAgent::focusNode): Call document instead of ownerDocument.
(WebCore::InspectorDOMAgent::resolveNode): Call document instead of expression that
does the same thing in a roundabout way.

* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Call document instead of ownerDocument.

* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::ownerDocument): Call document instead of ownerDocument.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154225 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5e48bb2
2013-08-17 Darin Adler <darin@apple.com>
<https://webkit.org/b/119942> Remove unnecessary uses of Element::ownerDocument
Reviewed by Andreas Kling.
The Element::document is a simpler faster alternative to Element::ownerDocument.
The only behavior difference between the two is that ownerDocument returns 0 when
called on a Document.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::supportsFocus): Call document instead of ownerDocument.
(WebCore::HTMLMediaElement::mediaPlayerOwningDocument): Removed null checking of
document and call to ownerDocument, since ownerDocument will never return non-null
if document returns null.
(WebCore::HTMLMediaElement::mediaPlayerSawUnsupportedTracks): Call document instead
of ownerDocument.
* inspector/DOMEditor.cpp:
(WebCore::DOMEditor::SetOuterHTMLAction::perform): Call document instead of ownerDocument.
* inspector/InspectorCSSAgent.cpp:
(WebCore::InspectorCSSAgent::getMatchedStylesForNode): Call document instead of ownerDocument.
(WebCore::InspectorCSSAgent::forcePseudoState): Call document instead of ownerDocument.
(WebCore::InspectorCSSAgent::resetPseudoStates): Call document instead of ownerDocument.
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::setOuterHTML): Call document instead of expression that
does the same thing in a roundabout way.
(WebCore::InspectorDOMAgent::focusNode): Call document instead of ownerDocument.
(WebCore::InspectorDOMAgent::resolveNode): Call document instead of expression that
does the same thing in a roundabout way.
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Call document instead of ownerDocument.
* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::ownerDocument): Call document instead of ownerDocument.
2013-08-17 Darin Adler <darin@apple.com>
<https://webkit.org/b/119941> Make Page::dragController return a reference
......@@ -424,7 +424,7 @@ bool HTMLMediaElement::hasCustomFocusLogic() const
bool HTMLMediaElement::supportsFocus() const
{
if (ownerDocument()->isMediaDocument())
if (document()->isMediaDocument())
return false;
// If no controls specified, we should still be able to focus the element if it has tabIndex.
......@@ -1667,12 +1667,7 @@ void HTMLMediaElement::cancelPendingEventsAndCallbacks()
Document* HTMLMediaElement::mediaPlayerOwningDocument()
{
Document* d = document();
if (!d)
d = ownerDocument();
return d;
return document();
}
void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*)
......@@ -3767,8 +3762,8 @@ void HTMLMediaElement::mediaPlayerSawUnsupportedTracks(MediaPlayer*)
// 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 (ownerDocument()->isMediaDocument()) {
MediaDocument* mediaDocument = toMediaDocument(ownerDocument());
if (document()->isMediaDocument()) {
MediaDocument* mediaDocument = toMediaDocument(document());
mediaDocument->mediaElementSawUnsupportedTracks();
}
}
......
......@@ -220,7 +220,7 @@ public:
virtual bool perform(ExceptionCode& ec)
{
m_oldHTML = createMarkup(m_node.get());
DOMPatchSupport domPatchSupport(m_domEditor.get(), m_node->ownerDocument());
DOMPatchSupport domPatchSupport(m_domEditor.get(), m_node->document());
m_newNode = domPatchSupport.patchNode(m_node.get(), m_html, ec);
return !ec;
}
......
......@@ -809,7 +809,7 @@ void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
return;
// Matched rules.
StyleResolver& styleResolver = element->ownerDocument()->ensureStyleResolver();
StyleResolver& styleResolver = element->document()->ensureStyleResolver();
Vector<RefPtr<StyleRuleBase> > matchedRules = styleResolver.styleRulesForElement(element, StyleResolver::AllCSSRules);
matchedCSSRules = buildArrayForMatchedRuleList(matchedRules, styleResolver, element);
......@@ -834,7 +834,7 @@ void InspectorCSSAgent::getMatchedStylesForNode(ErrorString* errorString, int no
RefPtr<TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry> > entries = TypeBuilder::Array<TypeBuilder::CSS::InheritedStyleEntry>::create();
Element* parentElement = element->parentElement();
while (parentElement) {
StyleResolver& parentStyleResolver = parentElement->ownerDocument()->ensureStyleResolver();
StyleResolver& parentStyleResolver = parentElement->document()->ensureStyleResolver();
Vector<RefPtr<StyleRuleBase> > parentMatchedRules = parentStyleResolver.styleRulesForElement(parentElement, StyleResolver::AllCSSRules);
RefPtr<TypeBuilder::CSS::InheritedStyleEntry> entry = TypeBuilder::CSS::InheritedStyleEntry::create()
.setMatchedCSSRules(buildArrayForMatchedRuleList(parentMatchedRules, styleResolver, parentElement));
......@@ -1053,7 +1053,7 @@ void InspectorCSSAgent::forcePseudoState(ErrorString* errorString, int nodeId, c
m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
else
m_nodeIdToForcedPseudoState.remove(nodeId);
element->ownerDocument()->styleResolverChanged(RecalcStyleImmediately);
element->document()->styleResolverChanged(RecalcStyleImmediately);
}
void InspectorCSSAgent::getNamedFlowCollection(ErrorString* errorString, int documentNodeId, RefPtr<TypeBuilder::Array<TypeBuilder::CSS::NamedFlow> >& result)
......@@ -1454,8 +1454,8 @@ void InspectorCSSAgent::resetPseudoStates()
HashSet<Document*> documentsToChange;
for (NodeIdToForcedPseudoState::iterator it = m_nodeIdToForcedPseudoState.begin(), end = m_nodeIdToForcedPseudoState.end(); it != end; ++it) {
Element* element = toElement(m_domAgent->nodeForId(it->key));
if (element && element->ownerDocument())
documentsToChange.add(element->ownerDocument());
if (element && element->document())
documentsToChange.add(element->document());
}
m_nodeIdToForcedPseudoState.clear();
......
......@@ -784,7 +784,7 @@ void InspectorDOMAgent::setOuterHTML(ErrorString* errorString, int nodeId, const
if (!node)
return;
Document* document = node->isDocumentNode() ? toDocument(node) : node->ownerDocument();
Document* document = node->document();
if (!document || (!document->isHTMLDocument() && !document->isXHTMLDocument()
#if ENABLE(SVG)
&& !document->isSVGDocument()
......@@ -1086,7 +1086,7 @@ void InspectorDOMAgent::focusNode()
RefPtr<Node> node = m_nodeToFocus.get();
m_nodeToFocus = 0;
Document* document = node->ownerDocument();
Document* document = node->document();
if (!document)
return;
Frame* frame = document->frame();
......@@ -1816,7 +1816,7 @@ void InspectorDOMAgent::pushNodeByBackendIdToFrontend(ErrorString* errorString,
PassRefPtr<TypeBuilder::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(Node* node, const String& objectGroup)
{
Document* document = node->isDocumentNode() ? node->document() : node->ownerDocument();
Document* document = node->document();
Frame* frame = document ? document->frame() : 0;
if (!frame)
return 0;
......
......@@ -462,7 +462,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
if (!element)
return false;
RefPtr<Frame> innerFrame = element->ownerDocument()->frame();
RefPtr<Frame> innerFrame = element->document()->frame();
ASSERT(innerFrame);
if (m_page->dragCaretController()->hasCaret() && !dispatchTextInputEventFor(innerFrame.get(), dragData))
......
......@@ -166,7 +166,7 @@ PassRefPtr<SVGElementInstanceList> SVGElementInstance::childNodes()
Document* SVGElementInstance::ownerDocument() const
{
return m_element ? m_element->ownerDocument() : 0;
return m_element ? m_element->document() : 0;
}
void SVGElementInstance::setShadowTreeElement(SVGElement* element)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment