nsCOMPtr<nsIHTMLDocument> htmlDocument; if (mDocument) { htmlDocument = do_QueryInterface(mDocument); } else { nsCOMPtr<nsIDocument> doc; mNodeInfo->GetDocument(getter_AddRefs(doc)); htmlDocument = do_QueryInterface(doc); }
nsCOMPtr<nsIHTMLDocument> htmlDocument = do_QueryInterface(nsGenericHTMLContainerElement::GetOwnerDocument());
nsHTMLFrameSetElement::ParseRowColSpec(nsString&       aSpec,                                        PRInt32         aMaxNumValues,                                        nsFramesetSpec* aSpecs) {  static const PRUnichar sAster('*');  static const PRUnichar sPercent('%');  static const PRUnichar sComma(',');  // remove whitespace (Bug 33699)  // also remove leading/trailing commas (bug 31482)  aSpec.StripChars(" \n\r\t");  aSpec.Trim(",");    // Count the commas   PRInt32 commaX = aSpec.FindChar(sComma);  PRInt32 count = 1;  while (commaX >= 0) {    count++;    commaX = aSpec.FindChar(sComma, commaX + 1);  }  if (count > aMaxNumValues) {    NS_ASSERTION(0, "Not enough space for values");    count = aMaxNumValues;  }  // Parse each comma separated token  PRInt32 start = 0;  PRInt32 specLen = aSpec.Length();  for (PRInt32 i = 0; i < count; i++) {    // Find our comma    commaX = aSpec.FindChar(sComma, start);    PRInt32 end = (commaX < 0) ? specLen : commaX;    // Note: If end == start then it means that the token has no    // data in it other than a terminating comma (or the end of the spec)    aSpecs[i].mUnit = eFramesetUnit_Fixed;    if (end > start) {      PRInt32 numberEnd = end;      PRUnichar ch = aSpec.CharAt(numberEnd - 1);      if (sAster == ch) {        aSpecs[i].mUnit = eFramesetUnit_Relative;        numberEnd--;      } else if (sPercent == ch) {        aSpecs[i].mUnit = eFramesetUnit_Percent;        numberEnd--;        // check for "*%"        if (numberEnd > start) {          ch = aSpec.CharAt(numberEnd - 1);          if (sAster == ch) {            aSpecs[i].mUnit = eFramesetUnit_Relative;            numberEnd--;          }        }      }      // Translate value to an integer      nsString token;      aSpec.Mid(token, start, numberEnd - start);      // Treat * as 1*      if ((eFramesetUnit_Relative == aSpecs[i].mUnit) &&        (0 == token.Length())) {        aSpecs[i].mValue = 1;      }      else {        // Otherwise just convert to integer.        PRInt32 err;        aSpecs[i].mValue = token.ToInteger(&err);        if (err) {          aSpecs[i].mValue = 0;        }      }      // Treat 0* as 1* in quirks mode (bug 40383)      nsCompatibility mode = eCompatibility_FullStandards;      nsCOMPtr<nsIHTMLDocument> htmlDocument;      if (mDocument) {        htmlDocument = do_QueryInterface(mDocument);      } else {        nsCOMPtr<nsIDocument> doc;        mNodeInfo->GetDocument(getter_AddRefs(doc));        htmlDocument = do_QueryInterface(doc);      }      if (htmlDocument) {        htmlDocument->GetCompatibilityMode(mode);      }            if (eCompatibility_NavQuirks == mode) {        if ((eFramesetUnit_Relative == aSpecs[i].mUnit) &&          (0 == aSpecs[i].mValue)) {          aSpecs[i].mValue = 1;        }      }              // Catch zero and negative frame sizes for Nav compatability      // Nav resized absolute and relative frames to "1" and      // percent frames to an even percentage of the width      //      //if ((eCompatibility_NavQuirks == aMode) && (aSpecs[i].mValue <= 0)) {      //  if (eFramesetUnit_Percent == aSpecs[i].mUnit) {      //    aSpecs[i].mValue = 100 / count;      //  } else {      //    aSpecs[i].mValue = 1;      //  }      //} else {      // In standards mode, just set negative sizes to zero      if (aSpecs[i].mValue < 0) {        aSpecs[i].mValue = 0;      }      start = end + 1;    }  }  return count;}