Title: [154228] trunk/Source/WebCore
Revision
154228
Author
[email protected]
Date
2013-08-17 07:48:32 -0700 (Sat, 17 Aug 2013)

Log Message

<https://webkit.org/b/119943> Clean up the Document class a bit

Reviewed by Antti Koivisto.

* dom/Document.cpp:
(WebCore::Document::~Document): Fixed typo in comment.
(WebCore::Document::suggestedMIMEType): Use ASCIILiteral for literals.
Also name local variable just loader rather than documentLoader.
(WebCore::Document::updateTitle): Call loader rather than going indirectly
through frame to get to the loader.
(WebCore::Document::setTitleElement): Fixed formatting (add braces).
(WebCore::Document::removeTitle): Iterate elements instead of nodes.
(WebCore::Document::isPageBoxVisible): Use ensureStyleResolver to call
styleForPage to avoid the need for a simple forwarding function. Also
eliminated local variable to increase clarity.
(WebCore::Document::pageSizeAndMarginsInPixels): Use ensureStyleResolver
to call styleForPage to avoid the need for a simple forwarding function.
(WebCore::Document::setIsViewSource): Renamed a local variable.

* dom/Document.h: Removed unneeded childNeedsAndNotInStyleRecalc and
styleForPage functions.

* loader/FrameLoader.cpp: Removed unnneeded setTitle function.
* loader/FrameLoader.h: Ditto.

* page/PrintContext.cpp:
(WebCore::PrintContext::pageProperty): Use ensureStyleResolver to call
styleForPage to avoid the need for a simple forwarding function.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (154227 => 154228)


--- trunk/Source/WebCore/ChangeLog	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/ChangeLog	2013-08-17 14:48:32 UTC (rev 154228)
@@ -1,5 +1,36 @@
 2013-08-17  Darin Adler  <[email protected]>
 
+        <https://webkit.org/b/119943> Clean up the Document class a bit
+
+        Reviewed by Antti Koivisto.
+
+        * dom/Document.cpp:
+        (WebCore::Document::~Document): Fixed typo in comment.
+        (WebCore::Document::suggestedMIMEType): Use ASCIILiteral for literals.
+        Also name local variable just loader rather than documentLoader.
+        (WebCore::Document::updateTitle): Call loader rather than going indirectly
+        through frame to get to the loader.
+        (WebCore::Document::setTitleElement): Fixed formatting (add braces).
+        (WebCore::Document::removeTitle): Iterate elements instead of nodes.
+        (WebCore::Document::isPageBoxVisible): Use ensureStyleResolver to call
+        styleForPage to avoid the need for a simple forwarding function. Also
+        eliminated local variable to increase clarity.
+        (WebCore::Document::pageSizeAndMarginsInPixels): Use ensureStyleResolver
+        to call styleForPage to avoid the need for a simple forwarding function.
+        (WebCore::Document::setIsViewSource): Renamed a local variable.
+
+        * dom/Document.h: Removed unneeded childNeedsAndNotInStyleRecalc and
+        styleForPage functions.
+
+        * loader/FrameLoader.cpp: Removed unnneeded setTitle function.
+        * loader/FrameLoader.h: Ditto.
+
+        * page/PrintContext.cpp:
+        (WebCore::PrintContext::pageProperty): Use ensureStyleResolver to call
+        styleForPage to avoid the need for a simple forwarding function.
+
+2013-08-17  Darin Adler  <[email protected]>
+
         <https://webkit.org/b/119939> Remove some unused clipboard and pasteboard code
 
         Reviewed by Andreas Kling.

Modified: trunk/Source/WebCore/dom/Document.cpp (154227 => 154228)


--- trunk/Source/WebCore/dom/Document.cpp	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-08-17 14:48:32 UTC (rev 154228)
@@ -591,7 +591,7 @@
     if (m_elemSheet)
         m_elemSheet->clearOwnerNode();
 
-    clearStyleResolver(); // We need to destory CSSFontSelector before destroying m_cachedResourceLoader.
+    clearStyleResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
 
     // It's possible for multiple Documents to end up referencing the same CachedResourceLoader (e.g., SVGImages
     // load the initial empty document and the SVGDocument with the same DocumentLoader).
@@ -674,7 +674,7 @@
     ASSERT(scope);
     ContainerNode* rootNode = scope->rootNode();
     for (Element* element = ElementTraversal::firstWithin(rootNode); element; element = ElementTraversal::next(element, rootNode)) {
-        const AtomicString& accessKey = element->getAttribute(accesskeyAttr);
+        const AtomicString& accessKey = element->fastGetAttribute(accesskeyAttr);
         if (!accessKey.isEmpty())
             m_elementsByAccessKey.set(accessKey.impl(), element);
 
@@ -1386,16 +1386,15 @@
 String Document::suggestedMIMEType() const
 {
     if (isXHTMLDocument())
-        return "application/xhtml+xml";
+        return ASCIILiteral("application/xhtml+xml");
     if (isSVGDocument())
-        return "image/svg+xml";
+        return ASCIILiteral("image/svg+xml");
     if (xmlStandalone())
-        return "text/xml";
+        return ASCIILiteral("text/xml");
     if (isHTMLDocument())
-        return "text/html";
-
-    if (DocumentLoader* documentLoader = loader())
-        return documentLoader->responseMIMEType();
+        return ASCIILiteral("text/html");
+    if (DocumentLoader* loader = this->loader())
+        return loader->responseMIMEType();
     return String();
 }
 
@@ -1509,8 +1508,8 @@
         else
             m_title = canonicalizedTitle<UChar>(this, m_rawTitle);
     }
-    if (Frame* f = frame())
-        f->loader().setTitle(m_title);
+    if (DocumentLoader* loader = this->loader())
+        loader->setTitle(m_title);
 }
 
 void Document::setTitle(const String& title)
@@ -1539,9 +1538,10 @@
 void Document::setTitleElement(const StringWithDirection& title, Element* titleElement)
 {
     if (titleElement != m_titleElement) {
-        if (m_titleElement || m_titleSetExplicitly)
+        if (m_titleElement || m_titleSetExplicitly) {
             // Only allow the first title element to change the title -- others have no effect.
             return;
+        }
         m_titleElement = titleElement;
     }
 
@@ -1558,12 +1558,13 @@
 
     // Update title based on first title element in the head, if one exists.
     if (HTMLElement* headElement = head()) {
-        for (Node* e = headElement->firstChild(); e; e = e->nextSibling())
-            if (isHTMLTitleElement(e)) {
-                HTMLTitleElement* titleElement = toHTMLTitleElement(e);
+        for (Element* element = ElementTraversal::firstWithin(headElement); element; element = ElementTraversal::nextSibling(element)) {
+            if (isHTMLTitleElement(element)) {
+                HTMLTitleElement* titleElement = toHTMLTitleElement(element);
                 setTitleElement(titleElement->textWithDirection(), titleElement);
                 break;
             }
+        }
     }
 
     if (!m_titleElement)
@@ -1729,11 +1730,6 @@
     updateStyleIfNeeded();
 }
 
-bool Document::childNeedsAndNotInStyleRecalc()
-{
-    return childNeedsStyleRecalc() && !m_inStyleRecalc;
-}
-
 void Document::recalcStyle(Style::Change change)
 {
     // we should not enter style recalc while painting
@@ -1903,21 +1899,14 @@
     return style.release();
 }
 
-PassRefPtr<RenderStyle> Document::styleForPage(int pageIndex)
-{
-    RefPtr<RenderStyle> style = ensureStyleResolver().styleForPage(pageIndex);
-    return style.release();
-}
-
 bool Document::isPageBoxVisible(int pageIndex)
 {
-    RefPtr<RenderStyle> style = styleForPage(pageIndex);
-    return style->visibility() != HIDDEN; // display property doesn't apply to @page.
+    return ensureStyleResolver().styleForPage(pageIndex)->visibility() != HIDDEN; // display property doesn't apply to @page.
 }
 
 void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
 {
-    RefPtr<RenderStyle> style = styleForPage(pageIndex);
+    RefPtr<RenderStyle> style = ensureStyleResolver().styleForPage(pageIndex);
     RenderView* view = renderView();
 
     int width = pageSize.width();
@@ -1966,8 +1955,8 @@
 void Document::createStyleResolver()
 {
     bool matchAuthorAndUserStyles = true;
-    if (Settings* docSettings = settings())
-        matchAuthorAndUserStyles = docSettings->authorAndUserStylesEnabled();
+    if (Settings* settings = this->settings())
+        matchAuthorAndUserStyles = settings->authorAndUserStylesEnabled();
     m_styleResolver = adoptPtr(new StyleResolver(this, matchAuthorAndUserStyles));
     m_styleSheetCollection->combineCSSFeatureFlags();
 }

Modified: trunk/Source/WebCore/dom/Document.h (154227 => 154228)


--- trunk/Source/WebCore/dom/Document.h	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/dom/Document.h	2013-08-17 14:48:32 UTC (rev 154228)
@@ -509,12 +509,10 @@
     PassRefPtr<Text> createEditingTextNode(const String&);
 
     void recalcStyle(Style::Change = Style::NoChange);
-    bool childNeedsAndNotInStyleRecalc();
     void updateStyleIfNeeded();
     void updateLayout();
     void updateLayoutIgnorePendingStylesheets();
     PassRefPtr<RenderStyle> styleForElementIgnoringPendingStylesheets(Element*);
-    PassRefPtr<RenderStyle> styleForPage(int pageIndex);
 
     // Returns true if page box (margin boxes and page borders) is visible.
     bool isPageBoxVisible(int pageIndex);

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (154227 => 154228)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2013-08-17 14:48:32 UTC (rev 154228)
@@ -1862,7 +1862,6 @@
                     ASSERT(cachedDocumentLoader);
                     cachedDocumentLoader->setFrame(m_frame);
                     m_client->transitionToCommittedFromCachedFrame(cachedPage->cachedMainFrame());
-
                 } else
                     m_client->transitionToCommittedForNewPage();
             }
@@ -3245,11 +3244,6 @@
     return error;
 }
 
-void FrameLoader::setTitle(const StringWithDirection& title)
-{
-    documentLoader()->setTitle(title);
-}
-
 String FrameLoader::referrer() const
 {
     return m_documentLoader ? m_documentLoader->request().httpReferrer() : "";

Modified: trunk/Source/WebCore/loader/FrameLoader.h (154227 => 154228)


--- trunk/Source/WebCore/loader/FrameLoader.h	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/loader/FrameLoader.h	2013-08-17 14:48:32 UTC (rev 154228)
@@ -239,8 +239,6 @@
 
     bool isComplete() const;
 
-    void setTitle(const StringWithDirection&);
-
     void commitProvisionalLoad();
 
     FrameLoaderStateMachine* stateMachine() const { return &m_stateMachine; }

Modified: trunk/Source/WebCore/page/PrintContext.cpp (154227 => 154228)


--- trunk/Source/WebCore/page/PrintContext.cpp	2013-08-17 14:41:40 UTC (rev 154227)
+++ trunk/Source/WebCore/page/PrintContext.cpp	2013-08-17 14:48:32 UTC (rev 154228)
@@ -26,6 +26,7 @@
 #include "FrameView.h"
 #include "RenderView.h"
 #include "StyleInheritedData.h"
+#include "StyleResolver.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -266,7 +267,7 @@
     PrintContext printContext(frame);
     printContext.begin(800); // Any width is OK here.
     document->updateLayout();
-    RefPtr<RenderStyle> style = document->styleForPage(pageNumber);
+    RefPtr<RenderStyle> style = document->ensureStyleResolver().styleForPage(pageNumber);
 
     // Implement formatters for properties we care about.
     if (!strcmp(propertyName, "margin-left")) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to