Example #1
0
void CSSSelector::extractPseudoType() const
{
    if (m_match != PseudoClass && m_match != PseudoElement)
        return;

    AtomicString active("active");
    AtomicString after("after");
    AtomicString anyLink("-webkit-any-link");
    AtomicString autofill("-webkit-autofill");
    AtomicString before("before");
    AtomicString checked("checked");
    AtomicString fileUploadButton("-webkit-file-upload-button");
    AtomicString disabled("disabled");
    AtomicString drag("-webkit-drag");
    AtomicString dragAlias("-khtml-drag"); // was documented with this name in Apple documentation, so keep an alias
    AtomicString empty("empty");
    AtomicString enabled("enabled");
    AtomicString firstChild("first-child");
    AtomicString firstLetter("first-letter");
    AtomicString firstLine("first-line");
    AtomicString firstOfType("first-of-type");
    AtomicString nthChild("nth-child(");
    AtomicString nthOfType("nth-of-type(");
    AtomicString nthLastChild("nth-last-child(");
    AtomicString nthLastOfType("nth-last-of-type(");
    AtomicString focus("focus");
    AtomicString hover("hover");
    AtomicString indeterminate("indeterminate");
    AtomicString lastChild("last-child");
    AtomicString lastOfType("last-of-type");
    AtomicString link("link");
    AtomicString lang("lang(");
    AtomicString mediaControlsPanel("-webkit-media-controls-panel");
    AtomicString mediaControlsMuteButton("-webkit-media-controls-mute-button");
    AtomicString mediaControlsPlayButton("-webkit-media-controls-play-button");
    AtomicString mediaControlsTimeDisplay("-webkit-media-controls-time-display");
    AtomicString mediaControlsTimeline("-webkit-media-controls-timeline");
    AtomicString mediaControlsSeekBackButton("-webkit-media-controls-seek-back-button");
    AtomicString mediaControlsSeekForwardButton("-webkit-media-controls-seek-forward-button");
    AtomicString mediaControlsFullscreenButton("-webkit-media-controls-fullscreen-button");
    AtomicString notStr("not(");
    AtomicString onlyChild("only-child");
    AtomicString onlyOfType("only-of-type");
    AtomicString root("root");
    AtomicString searchCancelButton("-webkit-search-cancel-button");
    AtomicString searchDecoration("-webkit-search-decoration");
    AtomicString searchResultsDecoration("-webkit-search-results-decoration");
    AtomicString searchResultsButton("-webkit-search-results-button");
    AtomicString selection("selection");
    AtomicString sliderThumb("-webkit-slider-thumb");
    AtomicString target("target");
    AtomicString visited("visited");

    bool element = false; // pseudo-element
    bool compat = false; // single colon compatbility mode

    m_pseudoType = PseudoUnknown;
    if (m_value == active)
        m_pseudoType = PseudoActive;
    else if (m_value == after) {
        m_pseudoType = PseudoAfter;
        element = true;
        compat = true;
    } else if (m_value == anyLink)
        m_pseudoType = PseudoAnyLink;
    else if (m_value == autofill)
        m_pseudoType = PseudoAutofill;
    else if (m_value == before) {
        m_pseudoType = PseudoBefore;
        element = true;
        compat = true;
    } else if (m_value == checked)
        m_pseudoType = PseudoChecked;
    else if (m_value == fileUploadButton) {
        m_pseudoType = PseudoFileUploadButton;
        element = true;
    } else if (m_value == disabled)
        m_pseudoType = PseudoDisabled;
    else if (m_value == drag || m_value == dragAlias)
        m_pseudoType = PseudoDrag;
    else if (m_value == enabled)
        m_pseudoType = PseudoEnabled;
    else if (m_value == empty)
        m_pseudoType = PseudoEmpty;
    else if (m_value == firstChild)
        m_pseudoType = PseudoFirstChild;
    else if (m_value == lastChild)
        m_pseudoType = PseudoLastChild;
    else if (m_value == lastOfType)
        m_pseudoType = PseudoLastOfType;
    else if (m_value == onlyChild)
        m_pseudoType = PseudoOnlyChild;
    else if (m_value == onlyOfType)
        m_pseudoType = PseudoOnlyOfType;
    else if (m_value == firstLetter) {
        m_pseudoType = PseudoFirstLetter;
        element = true;
        compat = true;
    } else if (m_value == firstLine) {
        m_pseudoType = PseudoFirstLine;
        element = true;
        compat = true;
    } else if (m_value == firstOfType)
        m_pseudoType = PseudoFirstOfType;
    else if (m_value == focus)
        m_pseudoType = PseudoFocus;
    else if (m_value == hover)
        m_pseudoType = PseudoHover;
    else if (m_value == indeterminate)
        m_pseudoType = PseudoIndeterminate;
    else if (m_value == link)
        m_pseudoType = PseudoLink;
    else if (m_value == lang)
        m_pseudoType = PseudoLang;
    else if (m_value == mediaControlsPanel) {
        m_pseudoType = PseudoMediaControlsPanel;
        element = true;
    } else if (m_value == mediaControlsMuteButton) {
        m_pseudoType = PseudoMediaControlsMuteButton;
        element = true;
    } else if (m_value == mediaControlsPlayButton) {
        m_pseudoType = PseudoMediaControlsPlayButton;
        element = true;
    } else if (m_value == mediaControlsTimeDisplay) {
        m_pseudoType = PseudoMediaControlsTimeDisplay;
        element = true;
    } else if (m_value == mediaControlsTimeline) {
        m_pseudoType = PseudoMediaControlsTimeline;
        element = true;
    } else if (m_value == mediaControlsSeekBackButton) {
        m_pseudoType = PseudoMediaControlsSeekBackButton;
        element = true;
    } else if (m_value == mediaControlsSeekForwardButton) {
        m_pseudoType = PseudoMediaControlsSeekForwardButton;
        element = true;
    } else if (m_value == mediaControlsFullscreenButton) {
        m_pseudoType = PseudoMediaControlsFullscreenButton;
        element = true;
    } else if (m_value == notStr)
        m_pseudoType = PseudoNot;
    else if (m_value == nthChild)
        m_pseudoType = PseudoNthChild;
    else if (m_value == nthOfType)
        m_pseudoType = PseudoNthOfType;
    else if (m_value == nthLastChild)
        m_pseudoType = PseudoNthLastChild;
    else if (m_value == nthLastOfType)
        m_pseudoType = PseudoNthLastOfType;
    else if (m_value == root)
        m_pseudoType = PseudoRoot;
    else if (m_value == searchCancelButton) {
        m_pseudoType = PseudoSearchCancelButton;
        element = true;
    } else if (m_value == searchDecoration) {
        m_pseudoType = PseudoSearchDecoration;
        element = true;
    } else if (m_value == searchResultsDecoration) {
        m_pseudoType = PseudoSearchResultsDecoration;
        element = true;
    } else if (m_value == searchResultsButton) {
        m_pseudoType = PseudoSearchResultsButton;
        element = true;
    }  else if (m_value == selection) {
        m_pseudoType = PseudoSelection;
        element = true;
    } else if (m_value == sliderThumb) {
        m_pseudoType = PseudoSliderThumb;
        element = true;
    } else if (m_value == target)
        m_pseudoType = PseudoTarget;
    else if (m_value == visited)
        m_pseudoType = PseudoVisited;

    if (m_match == PseudoClass && element) {
        if (!compat)
            m_pseudoType = PseudoUnknown;
        else
            m_match = PseudoElement;
    } else if (m_match == PseudoElement && !element)
        m_pseudoType = PseudoUnknown;
}
Example #2
0
int Step::sizeit(
  int  rows[],         // accumulate sub-row heights here
  int  cols[],         // accumulate sub-col widths here
  int  marginRows[][2],// accumulate sub-row margin heights here
  int  marginCols[][2],
  int  x,
  int  y)// accumulate sub-col margin widths here
{

  // size up each callout
  
  int numCallouts = list.size();

  for (int i = 0; i < numCallouts; i++) {
    list[i]->sizeIt();
  }

  // size up the step number

  stepNumber.sizeit();

  /****************************************************/
  /* figure out who is placed in which row and column */
  /****************************************************/

  csiPlacement.tbl[XX] = TblCsi;
  csiPlacement.tbl[YY] = TblCsi;

  /* Lets start with the absolutes (those relative to the CSI) */

  PlacementData pliPlacement = pli.placement.value();
  
  // PLI relative to CSI

  if (pliPlacement.relativeTo == CsiType) {
    if (pliPlacement.preposition == Outside) {
      pli.tbl[XX] = pliPlace[pliPlacement.placement][XX];
      pli.tbl[YY] = pliPlace[pliPlacement.placement][YY];
    } else {
      pli.tbl[XX] = TblCsi;
      pli.tbl[YY] = TblCsi;
    }
  }

  PlacementData stepNumberPlacement = stepNumber.placement.value();
  
  // if Step Number relative to parts list, but no parts list,
  //    Step Number is relative to Assem

  if (stepNumberPlacement.relativeTo == PartsListType && ! pliPerStep) {
    stepNumberPlacement.relativeTo = CsiType;
  }

  if (stepNumberPlacement.relativeTo == CsiType) {
    if (stepNumberPlacement.preposition == Outside) {
      stepNumber.tbl[XX] = stepNumberPlace[stepNumberPlacement.placement][XX];
      stepNumber.tbl[YY] = stepNumberPlace[stepNumberPlacement.placement][YY];
    } else {
      stepNumber.tbl[XX] = TblCsi;
      stepNumber.tbl[YY] = TblCsi;
    }
  }

  /* Now lets place things relative to others row/columns */

  /* first the known entities */

  if (pliPlacement.relativeTo == StepNumberType) {
    if (pliPerStep && pli.tsize()) {
      pli.tbl[XX] = stepNumber.tbl[XX]+relativePlace[pliPlacement.placement][XX];
      pli.tbl[YY] = stepNumber.tbl[YY]+relativePlace[pliPlacement.placement][YY];
    } else {
      stepNumber.tbl[XX] = stepNumberPlace[stepNumberPlacement.placement][XX];
      stepNumber.tbl[YY] = stepNumberPlace[stepNumberPlacement.placement][YY];
    }
  }

  if (stepNumberPlacement.relativeTo == PartsListType) {
    stepNumber.tbl[XX] = pli.tbl[XX]+relativePlace[stepNumberPlacement.placement][XX];
    stepNumber.tbl[YY] = pli.tbl[YY]+relativePlace[stepNumberPlacement.placement][YY];
  }

  maxMargin(pli.margin,pli.tbl,marginRows,marginCols);
  maxMargin(stepNumber.margin,stepNumber.tbl,marginRows,marginCols);
  maxMargin(csiPlacement.margin,csiPlacement.tbl,marginRows,marginCols);

  /* now place the callouts relative to the known (CSI, PLI, SN) */
  
  int calloutSize[2] = { 0, 0 };
  bool shared = false;

  int square[NumPlaces][NumPlaces];
  
  for (int i = 0; i < NumPlaces; i++) {
    for (int j = 0; j < NumPlaces; j++) {
      square[i][j] = -1;
    }
  }
  
  square[TblCsi][TblCsi] = CsiType;
  square[pli.tbl[XX]][pli.tbl[YY]] = PartsListType;
  square[stepNumber.tbl[XX]][stepNumber.tbl[YY]] = StepNumberType;
  
  int pixmapSize[2] = { csiPixmap.width(), csiPixmap.height() };
  int max = pixmapSize[y];

  for (int i = 0; i < numCallouts; i++) {
    Callout *callout = list[i];
    
    PlacementData calloutPlacement = callout->placement.value();
    bool sharable = true;
    bool onSide = false;

    if (calloutPlacement.relativeTo == CsiType) {
      onSide = x == XX ? (calloutPlacement.placement == Left || 
                          calloutPlacement.placement == Right)
                       : (calloutPlacement.placement == Top || 
                          calloutPlacement.placement == Bottom);
    }
    
    if (onSide) {
      if (max < callout->size[y]) {
        max = callout->size[y];
      }
    }
    
    int rp = calloutPlacement.placement;
    switch (calloutPlacement.relativeTo) {
      case CsiType:
        callout->tbl[XX] = coPlace[rp][XX];
        callout->tbl[YY] = coPlace[rp][YY];
      break;
      case PartsListType:
        callout->tbl[XX] = pli.tbl[XX] + relativePlace[rp][XX];
        callout->tbl[YY] = pli.tbl[YY] + relativePlace[rp][YY];
      break;
      case StepNumberType:
        callout->tbl[XX] = stepNumber.tbl[XX] + relativePlace[rp][XX];
        callout->tbl[YY] = stepNumber.tbl[YY] + relativePlace[rp][YY];
      break;
      default:
        sharable = false;
      break;
    }
    
    square[callout->tbl[XX]][callout->tbl[YY]] = i + 1;
    int size = callout->submodelStack().size();
    if (sharable && size > 1) {
      if (callout->tbl[x] < TblCsi && callout->tbl[y] == TblCsi) {
        if (calloutSize[x] < callout->size[x]) {
          calloutSize[XX] = callout->size[XX];
          calloutSize[YY] = callout->size[YY];
        }
        callout->shared = true;
        shared = true;
      }
    } 
  }

  /************************************************/
  /*                                              */
  /* Determine the biggest in each column and row */
  /*                                              */
  /************************************************/
  
  if (pli.pliMeta.constrain.isDefault()) {
        
    int tsize = 0;
    
    switch (pliPlacement.placement) {
      case Top:
      case Bottom:
        tsize = csiPlacement.size[XX];
        pli.sizePli(ConstrainData::PliConstrainWidth,tsize);
        if (pli.size[YY] > gui->page.meta.LPub.page.size.valuePixels(YY)/3) {
          pli.sizePli(ConstrainData::PliConstrainArea,tsize);
        }
      break;
      case Left:
      case Right:
        tsize = csiPlacement.size[YY];
        pli.sizePli(ConstrainData::PliConstrainHeight,tsize);
        if (pli.size[XX] > gui->page.meta.LPub.page.size.valuePixels(XX)/3) {
          pli.sizePli(ConstrainData::PliConstrainArea,tsize);
        }
      break;
      default:
        pli.sizePli(ConstrainData::PliConstrainArea,tsize);
      break;
    }
  }
  
  // Allow PLI and CALLOUT to share one column
  
  if (shared && pli.tbl[y] == TblCsi) {
    int wX = 0, wY = 0;
    if (x == XX) {
      wX = pli.size[XX] + calloutSize[XX];
      wY = pli.size[YY];
    } else {
      wX = pli.size[XX];
      wY = pli.size[YY] + calloutSize[YY];
    }  
    if (cols[pli.tbl[XX]] < wX) {
      cols[pli.tbl[XX]] = wX;
    }
    if (rows[pli.tbl[YY]] < wY) {
      rows[pli.tbl[YY]] = wY;
    }
  } else {

    bool addOn = true;
    
    /* Drop the PLI down on top of the CSI, and reduce the pli's size */

    if (onlyChild()) {
      switch (pliPlacement.placement) {
        case Top:
        case Bottom:
          if (pliPlacement.relativeTo == CsiType) {
            if ( ! collide(square,pli.tbl,y, x)) {
              int height = (max - pixmapSize[y])/2;
              if (height > 0) {
                if (height >= pli.size[y]) {  // entire thing fits
                  rows[pli.tbl[y]] = 0;
                  addOn = false;
                } else {                      // fit what we can
                  rows[pli.tbl[y]] = pli.size[y] - height;
                  addOn = false;
                }
              }
            }
          }
        break;
        default:
        break;
      }
    }

    if (cols[pli.tbl[XX]] < pli.size[XX]) {
      cols[pli.tbl[XX]] = pli.size[XX];  // HINT 1
    }
    if (addOn) {
      if (rows[pli.tbl[YY]] < pli.size[YY]) {
        rows[pli.tbl[YY]] = pli.size[YY];
      }
    }
  }

  if (cols[stepNumber.tbl[XX]] < stepNumber.size[XX]) {
    cols[stepNumber.tbl[XX]] = stepNumber.size[XX];
  }
  if (rows[stepNumber.tbl[YY]] < stepNumber.size[YY]) {
    rows[stepNumber.tbl[YY]] = stepNumber.size[YY];
  }
  
  if (cols[TblCsi] < csiPlacement.size[XX]) {
    cols[TblCsi] = csiPlacement.size[XX];
  }
  if (rows[TblCsi] < csiPlacement.size[YY]) {
    rows[TblCsi] = csiPlacement.size[YY];
  }

  /******************************************************************/
  /* Determine col/row and margin for each callout that is relative */
  /* to step components (e.g. not page or multiStep)                */
  /******************************************************************/

  for (int i = 0; i < numCallouts; i++) {
    Callout *callout = list[i];

    switch (callout->placement.value().relativeTo) {
      case CsiType:
      case PartsListType:
      case StepNumberType:      
        if (callout->shared) {
          if (rows[TblCsi] < callout->size[y]) {
            rows[TblCsi] = callout->size[y];
          }
        } else {

          if (cols[callout->tbl[XX]] < callout->size[XX]) {
            cols[callout->tbl[XX]] = callout->size[XX];
          }
          if (rows[callout->tbl[YY]] < callout->size[YY]) {
            rows[callout->tbl[YY]] = callout->size[YY];
          }

          maxMargin(callout->margin,
                    callout->tbl,
                    marginRows,
                    marginCols);
        }
      break;
      default:
      break;
    }
  }

  return 0;
}