Bug 1138065 - view elements as fragment identifiers should have normal target matching. r=dholbert
authorRobert Longson <longsonr@gmail.com>
Sun, 08 Mar 2015 17:34:47 +0000
changeset 232458 c3f8fae88426c58614e9d5aa1182f773ea897115
parent 232457 3d6cd86c1791e3eaed69d7b2b290b42080f99c3c
child 232459 58d2dbe695c43162703d882bf8c49b78c1cb7a71
push id56559
push userlongsonr@gmail.com
push dateSun, 08 Mar 2015 17:35:10 +0000
treeherdermozilla-inbound@c3f8fae88426 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1138065
milestone39.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 1138065 - view elements as fragment identifiers should have normal target matching. r=dholbert
dom/svg/SVGFragmentIdentifier.cpp
dom/svg/SVGFragmentIdentifier.h
layout/reftests/svg/fragmentIdentifier-01.xhtml
layout/reftests/svg/fragmentIdentifier-rect-01.svg
--- a/dom/svg/SVGFragmentIdentifier.cpp
+++ b/dom/svg/SVGFragmentIdentifier.cpp
@@ -254,17 +254,19 @@ SVGFragmentIdentifier::ProcessFragmentId
 
   if (viewElement) {
     if (!rootElement->mCurrentViewID) {
       rootElement->mCurrentViewID = new nsString();
     }
     *rootElement->mCurrentViewID = aAnchorName;
     rootElement->mUseCurrentView = true;
     rootElement->InvalidateTransformNotifyFrame();
-    return true;
+    // not an svgView()-style fragment identifier, return false so the caller
+    // continues processing to match any :target pseudo elements
+    return false;
   }
 
   bool wasOverridden = !!rootElement->mCurrentViewID;
   rootElement->mCurrentViewID = nullptr;
 
   rootElement->mUseCurrentView = ProcessSVGViewSpec(aAnchorName, rootElement);
   if (rootElement->mUseCurrentView) {
     return true;
--- a/dom/svg/SVGFragmentIdentifier.h
+++ b/dom/svg/SVGFragmentIdentifier.h
@@ -24,17 +24,19 @@ class SVGSVGElement;
 class SVGFragmentIdentifier
 {
   // To prevent the class being instantiated
   SVGFragmentIdentifier() = delete;
 
 public:
   /**
    * Process the SVG fragment identifier, if there is one.
-   * @return true if we found something we recognised
+   * @return true if we found a valid svgView()-style fragment identifier,
+   * in which case further processing by the caller can stop. Otherwise return
+   * false as we may have an ordinary anchor which needs to be :target matched.
    */
   static bool ProcessFragmentIdentifier(nsIDocument *aDocument,
                                         const nsAString &aAnchorName);
 
 private:
  /**
   * Parse an SVG ViewSpec and set applicable attributes on the root element.
   * @return true if there is a valid ViewSpec
--- a/layout/reftests/svg/fragmentIdentifier-01.xhtml
+++ b/layout/reftests/svg/fragmentIdentifier-01.xhtml
@@ -1,16 +1,17 @@
 <html xmlns="http://www.w3.org/1999/xhtml" class="reftest-wait">
   <head>
     <title>Testcases for SVG fragment identifiers</title>
   </head>
   <body style="background-color: lime;">
     <div>
       <object type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#limeView" />
       <object type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#svgView(viewBox(0,200,100,100))" />
+      <object type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#view" />
     </div>
     <div>
       <object type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#svgView(viewBox(0,0,100,100);transform(translate(0,200)))" />
       <object id="replace" type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#svgView(viewBox(0,0,100,100);transform(translate(0,0))" />
       <object id="remove" type="image/svg+xml" width="100" height="100" data="fragmentIdentifier-rect-01.svg#svgView(viewBox(0,200,100,100);transform(translate(0,200)))" />
     </div>
     <script type="text/javascript">
       window.onload = function() {
--- a/layout/reftests/svg/fragmentIdentifier-rect-01.svg
+++ b/layout/reftests/svg/fragmentIdentifier-rect-01.svg
@@ -1,9 +1,19 @@
 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
      xmlns:xlink="http://www.w3.org/1999/xlink">
 
+  <style>
+      view:target + a rect {
+          fill: lime;
+      }
+  </style>
+
   <view id="limeView" viewBox="0 200 100 100"/>
 
   <rect fill="red" height="100%" width="100%"/>
   <rect fill="lime" x="0" y="200" height="100" width="100"/>
 
+  <view id="view" viewBox="200 200 100 100"/>
+  <a xlink:href="#view">
+      <rect fill="red" x="200" y="200" height="100" width="100"/>
+  </a>
 </svg>