Bug 862117 - Move CSS rule classes relevant to image documents for cursor appearance (zoom in / zoom out) into layout/style/ImageDocument.css. r=roc, r=jaws
authorBrandon Waterloo <brandon.waterloo@gmail.com>
Sun, 21 Apr 2013 18:29:14 -0400
changeset 140559 2e822e8396c2dbeab342b1d5ce36fc7a3ae1bde0
parent 140558 40a9300f1200628ef558bbf7a69cc91bd49e561c
child 140560 e5320348d5d75eddf827b3370405c22babcc4c7d
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, jaws
bugs862117
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 862117 - Move CSS rule classes relevant to image documents for cursor appearance (zoom in / zoom out) into layout/style/ImageDocument.css. r=roc, r=jaws This stylesheet applies to all ImageDocuments, including those in frames. In old location for CSS rules, some full themes would not show cursors correctly, nor would ImageDocuments in frames. Image rotation CSS rule classes moved to layout/style/TopLevelImageDocument.css.
content/html/document/src/ImageDocument.cpp
layout/style/ImageDocument.css
layout/style/Makefile.in
layout/style/TopLevelImageDocument.css
toolkit/themes/osx/global/media/TopLevelImageDocument.css
toolkit/themes/windows/global/media/TopLevelImageDocument.css
--- a/content/html/document/src/ImageDocument.cpp
+++ b/content/html/document/src/ImageDocument.cpp
@@ -372,20 +372,22 @@ ImageDocument::SetScriptGlobalObject(nsI
       target = do_QueryInterface(mImageContent);
       target->AddEventListener(NS_LITERAL_STRING("click"), this, false);
     }
 
     target = do_QueryInterface(aScriptGlobalObject);
     target->AddEventListener(NS_LITERAL_STRING("resize"), this, false);
     target->AddEventListener(NS_LITERAL_STRING("keypress"), this, false);
 
-    if (!nsContentUtils::IsChildOfSameType(this) &&
-        GetReadyStateEnum() != nsIDocument::READYSTATE_COMPLETE) {
-      LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelImageDocument.css"));
-      LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelImageDocument.css"));
+    if (GetReadyStateEnum() != nsIDocument::READYSTATE_COMPLETE) {
+      LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/ImageDocument.css"));
+      if (!nsContentUtils::IsChildOfSameType(this)) {
+        LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelImageDocument.css"));
+        LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelImageDocument.css"));
+      }
     }
     BecomeInteractive();
   }
 }
 
 void
 ImageDocument::OnPageShow(bool aPersisted,
                           EventTarget* aDispatchStartTarget)
@@ -805,46 +807,24 @@ ImageDocument::HandleEvent(nsIDOMEvent* 
 
 nsresult
 ImageDocument::CreateSyntheticDocument()
 {
   // Synthesize an html document that refers to the image
   nsresult rv = MediaDocument::CreateSyntheticDocument();
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // We must declare the image as a block element. If we stay as
-  // an inline element, our parent LineBox will be inline too and
-  // ignore the available height during reflow.
-  // This is bad during printing, it means tall image frames won't know
-  // the size of the paper and cannot break into continuations along
-  // multiple pages.
-  Element* head = GetHeadElement();
-  NS_ENSURE_TRUE(head, NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsINodeInfo> nodeInfo;
-  if (nsContentUtils::IsChildOfSameType(this)) {
-    nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::style, nullptr,
-                                             kNameSpaceID_XHTML,
-                                             nsIDOMNode::ELEMENT_NODE);
-    nsRefPtr<nsGenericHTMLElement> styleContent = NS_NewHTMLStyleElement(nodeInfo.forget());
-    NS_ENSURE_TRUE(styleContent, NS_ERROR_OUT_OF_MEMORY);
-
-    ErrorResult error;
-    styleContent->SetTextContent(NS_LITERAL_STRING("img { display: block; }"),
-                                 error);
-    head->AppendChildTo(styleContent, false);
-  }
-
   // Add the image element
   Element* body = GetBodyElement();
   if (!body) {
     NS_WARNING("no body on image document!");
     return NS_ERROR_FAILURE;
   }
 
+  nsCOMPtr<nsINodeInfo> nodeInfo;
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::img, nullptr,
                                            kNameSpaceID_XHTML,
                                            nsIDOMNode::ELEMENT_NODE);
 
   mImageContent = NS_NewHTMLImageElement(nodeInfo.forget());
   if (!mImageContent) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
new file mode 100644
--- /dev/null
+++ b/layout/style/ImageDocument.css
@@ -0,0 +1,32 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * This CSS stylesheet defines the rules to be applied to any ImageDocuments,
+ * including those in frames.
+*/
+
+@media not print {
+  .overflowing {
+    cursor: -moz-zoom-out;
+  }
+
+  .shrinkToFit,
+  .scaleToDevicePixels {
+    cursor: -moz-zoom-in;
+  }
+}
+
+@media print {
+  /* We must declare the image as a block element. If we stay as
+  an inline element, our parent LineBox will be inline too and
+  ignore the available height during reflow.
+  This is bad during printing, it means tall image frames won't know
+  the size of the paper and cannot break into continuations along
+  multiple pages. */
+  img {
+    display: block;
+  }
+}
--- a/layout/style/Makefile.in
+++ b/layout/style/Makefile.in
@@ -82,16 +82,17 @@ LOCAL_INCLUDES	+= \
 		-I$(srcdir)/../../content/html/content/src \
 		-I$(srcdir)/../../content/xbl/src \
 		-I$(srcdir)/../../content/xul/document/src \
 		$(NULL)
 
 _FILES	= \
 	contenteditable.css \
 	designmode.css \
+	ImageDocument.css \
 	TopLevelImageDocument.css \
 	TopLevelVideoDocument.css \
 	$(NULL)
 
 GARBAGE		+= $(addprefix $(DIST)/bin/res/,$(_FILES))
 
 libs:: $(_FILES)
 	$(INSTALL) $^ $(DIST)/bin/res
--- a/layout/style/TopLevelImageDocument.css
+++ b/layout/style/TopLevelImageDocument.css
@@ -17,21 +17,13 @@
     text-align: center;
     position: absolute;
     margin: auto;
     top: 0;
     right: 0;
     bottom: 0;
     left: 0;
   }
-}
 
-@media print {
-  /* We must declare the image as a block element. If we stay as
-  an inline element, our parent LineBox will be inline too and
-  ignore the available height during reflow.
-  This is bad during printing, it means tall image frames won't know
-  the size of the paper and cannot break into continuations along
-  multiple pages. */
-  img {
-    display: block;
+  .completeRotation {
+    transition: transform 0.3s ease 0s;
   }
 }
--- a/toolkit/themes/osx/global/media/TopLevelImageDocument.css
+++ b/toolkit/themes/osx/global/media/TopLevelImageDocument.css
@@ -9,22 +9,9 @@
     color: #eee;
     background: #222 url("chrome://global/skin/media/imagedoc-darknoise.png");
   }
 
   img.decoded {
     background: hsl(0,0%,90%) url("chrome://global/skin/media/imagedoc-lightnoise.png");
     color: #222;
   }
-
-  .overflowing {
-    cursor: -moz-zoom-out;
-  }
-
-  .shrinkToFit,
-  .scaleToDevicePixels {
-    cursor: -moz-zoom-in;
-  }
-
-  .completeRotation {
-    transition: transform 0.3s ease 0s;
-  }
 }
--- a/toolkit/themes/windows/global/media/TopLevelImageDocument.css
+++ b/toolkit/themes/windows/global/media/TopLevelImageDocument.css
@@ -9,22 +9,9 @@
     color: #eee;
     background: #222 url("chrome://global/skin/media/imagedoc-darknoise.png");
   }
 
   img.decoded {
     background: hsl(0,0%,90%) url("chrome://global/skin/media/imagedoc-lightnoise.png");
     color: #222;
   }
-
-  .overflowing {
-    cursor: -moz-zoom-out;
-  }
-
-  .shrinkToFit,
-  .scaleTodevicePixels {
-    cursor: -moz-zoom-in;
-  }
-
-  .completeRotation {
-    transition: transform 0.3s ease 0s;
-  }
 }